mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
EntityRegainHealthEvent isFastRegen API
Don't even get me started
This commit is contained in:
parent
b414f3d993
commit
3532e55dab
2 changed files with 58 additions and 53 deletions
|
@ -487,7 +487,7 @@
|
|||
if (mobeffect != null) {
|
||||
this.onEffectsRemoved(List.of(mobeffect));
|
||||
return true;
|
||||
@@ -1142,20 +1344,59 @@
|
||||
@@ -1142,20 +1344,65 @@
|
||||
|
||||
}
|
||||
|
||||
|
@ -497,11 +497,17 @@
|
|||
+ }
|
||||
+
|
||||
+ public void heal(float f, EntityRegainHealthEvent.RegainReason regainReason) {
|
||||
+ // Paper start - Forward
|
||||
+ heal(f, regainReason, false);
|
||||
+ }
|
||||
+
|
||||
+ public void heal(float f, EntityRegainHealthEvent.RegainReason regainReason, boolean isFastRegen) {
|
||||
+ // Paper end
|
||||
float f1 = this.getHealth();
|
||||
|
||||
if (f1 > 0.0F) {
|
||||
- this.setHealth(f1 + amount);
|
||||
+ EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), f, regainReason);
|
||||
+ EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), f, regainReason, isFastRegen); // Paper
|
||||
+ // Suppress during worldgen
|
||||
+ if (this.valid) {
|
||||
+ this.level().getCraftServer().getPluginManager().callEvent(event);
|
||||
|
@ -548,7 +554,7 @@
|
|||
this.entityData.set(LivingEntity.DATA_HEALTH_ID, Mth.clamp(health, 0.0F, this.getMaxHealth()));
|
||||
}
|
||||
|
||||
@@ -1167,7 +1408,7 @@
|
||||
@@ -1167,7 +1414,7 @@
|
||||
public boolean hurtServer(ServerLevel world, DamageSource source, float amount) {
|
||||
if (this.isInvulnerableTo(world, source)) {
|
||||
return false;
|
||||
|
@ -557,7 +563,7 @@
|
|||
return false;
|
||||
} else if (source.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) {
|
||||
return false;
|
||||
@@ -1182,10 +1423,11 @@
|
||||
@@ -1182,10 +1429,11 @@
|
||||
}
|
||||
|
||||
float f1 = amount;
|
||||
|
@ -571,7 +577,7 @@
|
|||
this.hurtCurrentlyUsedShield(amount);
|
||||
f2 = amount;
|
||||
amount = 0.0F;
|
||||
@@ -1202,15 +1444,26 @@
|
||||
@@ -1202,15 +1450,26 @@
|
||||
flag = true;
|
||||
}
|
||||
|
||||
|
@ -600,7 +606,7 @@
|
|||
this.walkAnimation.setSpeed(1.5F);
|
||||
if (Float.isNaN(amount) || Float.isInfinite(amount)) {
|
||||
amount = Float.MAX_VALUE;
|
||||
@@ -1218,18 +1471,27 @@
|
||||
@@ -1218,18 +1477,27 @@
|
||||
|
||||
boolean flag1 = true;
|
||||
|
||||
|
@ -632,7 +638,7 @@
|
|||
this.hurtDuration = 10;
|
||||
this.hurtTime = this.hurtDuration;
|
||||
}
|
||||
@@ -1243,7 +1505,7 @@
|
||||
@@ -1243,7 +1511,7 @@
|
||||
world.broadcastDamageEvent(this, source);
|
||||
}
|
||||
|
||||
|
@ -641,7 +647,7 @@
|
|||
this.markHurt();
|
||||
}
|
||||
|
||||
@@ -1263,7 +1525,7 @@
|
||||
@@ -1263,7 +1531,7 @@
|
||||
d1 = source.getSourcePosition().z() - this.getZ();
|
||||
}
|
||||
|
||||
|
@ -650,7 +656,7 @@
|
|||
if (!flag) {
|
||||
this.indicateDamage(d0, d1);
|
||||
}
|
||||
@@ -1282,7 +1544,7 @@
|
||||
@@ -1282,7 +1550,7 @@
|
||||
this.playHurtSound(source);
|
||||
}
|
||||
|
||||
|
@ -659,7 +665,7 @@
|
|||
|
||||
if (flag2) {
|
||||
this.lastDamageSource = source;
|
||||
@@ -1329,10 +1591,10 @@
|
||||
@@ -1329,10 +1597,10 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -672,7 +678,7 @@
|
|||
this.lastHurtByPlayerTime = 100;
|
||||
this.lastHurtByPlayer = entityhuman;
|
||||
return entityhuman;
|
||||
@@ -1342,8 +1604,8 @@
|
||||
@@ -1342,8 +1610,8 @@
|
||||
this.lastHurtByPlayerTime = 100;
|
||||
LivingEntity entityliving = entitywolf.getOwner();
|
||||
|
||||
|
@ -683,7 +689,7 @@
|
|||
|
||||
this.lastHurtByPlayer = entityhuman1;
|
||||
} else {
|
||||
@@ -1363,7 +1625,7 @@
|
||||
@@ -1363,7 +1631,7 @@
|
||||
}
|
||||
|
||||
protected void blockedByShield(LivingEntity target) {
|
||||
|
@ -692,7 +698,7 @@
|
|||
}
|
||||
|
||||
private boolean checkTotemDeathProtection(DamageSource source) {
|
||||
@@ -1375,20 +1637,33 @@
|
||||
@@ -1375,20 +1643,33 @@
|
||||
InteractionHand[] aenumhand = InteractionHand.values();
|
||||
int i = aenumhand.length;
|
||||
|
||||
|
@ -730,7 +736,7 @@
|
|||
ServerPlayer entityplayer = (ServerPlayer) this;
|
||||
|
||||
entityplayer.awardStat(Stats.ITEM_USED.get(itemstack.getItem()));
|
||||
@@ -1477,7 +1752,7 @@
|
||||
@@ -1477,7 +1758,7 @@
|
||||
}
|
||||
|
||||
if (!this.level().isClientSide && this.hasCustomName()) {
|
||||
|
@ -739,7 +745,7 @@
|
|||
}
|
||||
|
||||
this.dead = true;
|
||||
@@ -1512,14 +1787,22 @@
|
||||
@@ -1512,14 +1793,22 @@
|
||||
BlockState iblockdata = Blocks.WITHER_ROSE.defaultBlockState();
|
||||
|
||||
if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) {
|
||||
|
@ -764,7 +770,7 @@
|
|||
this.level().addFreshEntity(entityitem);
|
||||
}
|
||||
}
|
||||
@@ -1530,24 +1813,39 @@
|
||||
@@ -1530,24 +1819,39 @@
|
||||
protected void dropAllDeathLoot(ServerLevel world, DamageSource damageSource) {
|
||||
boolean flag = this.lastHurtByPlayerTime > 0;
|
||||
|
||||
|
@ -808,7 +814,7 @@
|
|||
protected void dropCustomDeathLoot(ServerLevel world, DamageSource source, boolean causedByPlayer) {}
|
||||
|
||||
public long getLootTableSeed() {
|
||||
@@ -1612,19 +1910,31 @@
|
||||
@@ -1612,19 +1916,31 @@
|
||||
}
|
||||
|
||||
public void knockback(double strength, double x, double z) {
|
||||
|
@ -847,7 +853,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -1683,6 +1993,20 @@
|
||||
@@ -1683,6 +1999,20 @@
|
||||
return new LivingEntity.Fallsounds(SoundEvents.GENERIC_SMALL_FALL, SoundEvents.GENERIC_BIG_FALL);
|
||||
}
|
||||
|
||||
|
@ -868,7 +874,7 @@
|
|||
public Optional<BlockPos> getLastClimbablePos() {
|
||||
return this.lastClimbablePos;
|
||||
}
|
||||
@@ -1757,9 +2081,14 @@
|
||||
@@ -1757,9 +2087,14 @@
|
||||
int i = this.calculateFallDamage(fallDistance, damageMultiplier);
|
||||
|
||||
if (i > 0) {
|
||||
|
@ -884,7 +890,7 @@
|
|||
return true;
|
||||
} else {
|
||||
return flag;
|
||||
@@ -1830,7 +2159,7 @@
|
||||
@@ -1830,7 +2165,7 @@
|
||||
|
||||
protected float getDamageAfterArmorAbsorb(DamageSource source, float amount) {
|
||||
if (!source.is(DamageTypeTags.BYPASSES_ARMOR)) {
|
||||
|
@ -893,7 +899,7 @@
|
|||
amount = CombatRules.getDamageAfterAbsorb(this, amount, source, (float) this.getArmorValue(), (float) this.getAttributeValue(Attributes.ARMOR_TOUGHNESS));
|
||||
}
|
||||
|
||||
@@ -1841,7 +2170,8 @@
|
||||
@@ -1841,7 +2176,8 @@
|
||||
if (source.is(DamageTypeTags.BYPASSES_EFFECTS)) {
|
||||
return amount;
|
||||
} else {
|
||||
|
@ -903,7 +909,7 @@
|
|||
int i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5;
|
||||
int j = 25 - i;
|
||||
float f1 = amount * (float) j;
|
||||
@@ -1884,18 +2214,144 @@
|
||||
@@ -1884,18 +2220,144 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -930,7 +936,7 @@
|
|||
+ };
|
||||
+ float freezingModifier = freezing.apply((double) f).floatValue();
|
||||
+ f += freezingModifier;
|
||||
|
||||
+
|
||||
+ com.google.common.base.Function<Double, Double> hardHat = new com.google.common.base.Function<Double, Double>() {
|
||||
+ @Override
|
||||
+ public Double apply(Double f) {
|
||||
|
@ -951,7 +957,7 @@
|
|||
+ };
|
||||
+ float blockingModifier = blocking.apply((double) f).floatValue();
|
||||
+ f += blockingModifier;
|
||||
+
|
||||
|
||||
+ com.google.common.base.Function<Double, Double> armor = new com.google.common.base.Function<Double, Double>() {
|
||||
+ @Override
|
||||
+ public Double apply(Double f) {
|
||||
|
@ -1057,7 +1063,7 @@
|
|||
|
||||
if (entity instanceof ServerPlayer) {
|
||||
ServerPlayer entityplayer = (ServerPlayer) entity;
|
||||
@@ -1904,13 +2360,48 @@
|
||||
@@ -1904,13 +2366,48 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1110,28 +1116,27 @@
|
|||
}
|
||||
|
||||
public CombatTracker getCombatTracker() {
|
||||
@@ -1935,9 +2426,19 @@
|
||||
@@ -1935,8 +2432,18 @@
|
||||
}
|
||||
|
||||
public final void setArrowCount(int stuckArrowCount) {
|
||||
- this.entityData.set(LivingEntity.DATA_ARROW_COUNT_ID, stuckArrowCount);
|
||||
+ // CraftBukkit start
|
||||
+ this.setArrowCount(stuckArrowCount, false);
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ public final void setArrowCount(int i, boolean flag) {
|
||||
+ ArrowBodyCountChangeEvent event = CraftEventFactory.callArrowBodyCountChangeEvent(this, this.getArrowCount(), i, flag);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ this.entityData.set(LivingEntity.DATA_ARROW_COUNT_ID, event.getNewAmount());
|
||||
+ }
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
||||
public final int getStingerCount() {
|
||||
return (Integer) this.entityData.get(LivingEntity.DATA_STINGER_COUNT_ID);
|
||||
}
|
||||
@@ -1999,7 +2500,7 @@
|
||||
@@ -1999,7 +2506,7 @@
|
||||
this.playSound(soundeffect, this.getSoundVolume(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
|
||||
}
|
||||
|
||||
|
@ -1140,7 +1145,7 @@
|
|||
this.setHealth(0.0F);
|
||||
this.die(this.damageSources().generic());
|
||||
}
|
||||
@@ -2182,6 +2683,12 @@
|
||||
@@ -2182,6 +2689,12 @@
|
||||
|
||||
public abstract ItemStack getItemBySlot(EquipmentSlot slot);
|
||||
|
||||
|
@ -1153,7 +1158,7 @@
|
|||
public abstract void setItemSlot(EquipmentSlot slot, ItemStack stack);
|
||||
|
||||
public Iterable<ItemStack> getHandSlots() {
|
||||
@@ -2494,7 +3001,7 @@
|
||||
@@ -2494,7 +3007,7 @@
|
||||
|
||||
}
|
||||
|
||||
|
@ -1162,7 +1167,7 @@
|
|||
Vec3 vec3d1 = this.getRiddenInput(controllingPlayer, movementInput);
|
||||
|
||||
this.tickRidden(controllingPlayer, vec3d1);
|
||||
@@ -2507,13 +3014,13 @@
|
||||
@@ -2507,13 +3020,13 @@
|
||||
|
||||
}
|
||||
|
||||
|
@ -1179,7 +1184,7 @@
|
|||
return this.getSpeed();
|
||||
}
|
||||
|
||||
@@ -2571,7 +3078,7 @@
|
||||
@@ -2571,7 +3084,7 @@
|
||||
double d1 = Mth.clamp(motion.z, -0.15000000596046448D, 0.15000000596046448D);
|
||||
double d2 = Math.max(motion.y, -0.15000000596046448D);
|
||||
|
||||
|
@ -1188,7 +1193,7 @@
|
|||
d2 = 0.0D;
|
||||
}
|
||||
|
||||
@@ -2586,7 +3093,7 @@
|
||||
@@ -2586,7 +3099,7 @@
|
||||
}
|
||||
|
||||
protected float getFlyingSpeed() {
|
||||
|
@ -1197,7 +1202,7 @@
|
|||
}
|
||||
|
||||
public float getSpeed() {
|
||||
@@ -2634,7 +3141,7 @@
|
||||
@@ -2634,7 +3147,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1206,7 +1211,7 @@
|
|||
if (this.tickCount % 20 == 0) {
|
||||
this.getCombatTracker().recheckStatus();
|
||||
}
|
||||
@@ -2741,7 +3248,7 @@
|
||||
@@ -2741,7 +3254,7 @@
|
||||
this.elytraAnimationState.tick();
|
||||
}
|
||||
|
||||
|
@ -1215,7 +1220,7 @@
|
|||
Map<EquipmentSlot, ItemStack> map = this.collectEquipmentChanges();
|
||||
|
||||
if (map != null) {
|
||||
@@ -3000,7 +3507,7 @@
|
||||
@@ -3000,7 +3513,7 @@
|
||||
{
|
||||
LivingEntity entityliving = this.getControllingPassenger();
|
||||
|
||||
|
@ -1224,7 +1229,7 @@
|
|||
if (this.isAlive()) {
|
||||
this.travelRidden(entityhuman, vec3d1);
|
||||
break label112;
|
||||
@@ -3063,6 +3570,7 @@
|
||||
@@ -3063,6 +3576,7 @@
|
||||
this.checkSlowFallDistance();
|
||||
if (!this.level().isClientSide) {
|
||||
if (!this.canGlide()) {
|
||||
|
@ -1232,7 +1237,7 @@
|
|||
this.setSharedFlag(7, false);
|
||||
return;
|
||||
}
|
||||
@@ -3113,7 +3621,7 @@
|
||||
@@ -3113,7 +3627,7 @@
|
||||
Level world = this.level();
|
||||
|
||||
if (!(world instanceof ServerLevel worldserver)) {
|
||||
|
@ -1241,7 +1246,7 @@
|
|||
} else {
|
||||
List list = this.level().getEntities((Entity) this, this.getBoundingBox(), EntitySelector.pushableBy(this));
|
||||
|
||||
@@ -3305,15 +3813,22 @@
|
||||
@@ -3305,15 +3819,22 @@
|
||||
|
||||
@Override
|
||||
public boolean isPickable() {
|
||||
|
@ -1266,7 +1271,7 @@
|
|||
public float getYHeadRot() {
|
||||
return this.yHeadRot;
|
||||
}
|
||||
@@ -3342,7 +3857,7 @@
|
||||
@@ -3342,7 +3863,7 @@
|
||||
}
|
||||
|
||||
public final void setAbsorptionAmount(float absorptionAmount) {
|
||||
|
@ -1275,7 +1280,7 @@
|
|||
}
|
||||
|
||||
protected void internalSetAbsorptionAmount(float absorptionAmount) {
|
||||
@@ -3483,13 +3998,48 @@
|
||||
@@ -3483,13 +4004,48 @@
|
||||
this.releaseUsingItem();
|
||||
} else {
|
||||
if (!this.useItem.isEmpty() && this.isUsingItem()) {
|
||||
|
@ -1325,7 +1330,7 @@
|
|||
}
|
||||
|
||||
}
|
||||
@@ -3568,12 +4118,18 @@
|
||||
@@ -3568,12 +4124,18 @@
|
||||
}
|
||||
|
||||
public boolean randomTeleport(double x, double y, double z, boolean particleEffects) {
|
||||
|
@ -1346,7 +1351,7 @@
|
|||
Level world = this.level();
|
||||
|
||||
if (world.hasChunkAt(blockposition)) {
|
||||
@@ -3592,18 +4148,43 @@
|
||||
@@ -3592,18 +4154,43 @@
|
||||
}
|
||||
|
||||
if (flag2) {
|
||||
|
@ -1394,7 +1399,7 @@
|
|||
world.broadcastEntityEvent(this, (byte) 46);
|
||||
}
|
||||
|
||||
@@ -3613,7 +4194,7 @@
|
||||
@@ -3613,7 +4200,7 @@
|
||||
entitycreature.getNavigation().stop();
|
||||
}
|
||||
|
||||
|
@ -1403,7 +1408,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -3706,7 +4287,7 @@
|
||||
@@ -3706,7 +4293,7 @@
|
||||
}
|
||||
|
||||
public void stopSleeping() {
|
||||
|
@ -1412,7 +1417,7 @@
|
|||
Level world = this.level();
|
||||
|
||||
java.util.Objects.requireNonNull(world);
|
||||
@@ -3718,9 +4299,9 @@
|
||||
@@ -3718,9 +4305,9 @@
|
||||
|
||||
this.level().setBlock(blockposition, (BlockState) iblockdata.setValue(BedBlock.OCCUPIED, false), 3);
|
||||
Vec3 vec3d = (Vec3) BedBlock.findStandUpPosition(this.getType(), this.level(), blockposition, enumdirection, this.getYRot()).orElseGet(() -> {
|
||||
|
@ -1424,7 +1429,7 @@
|
|||
});
|
||||
Vec3 vec3d1 = Vec3.atBottomCenterOf(blockposition).subtract(vec3d).normalize();
|
||||
float f = (float) Mth.wrapDegrees(Mth.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
|
||||
@@ -3740,7 +4321,7 @@
|
||||
@@ -3740,7 +4327,7 @@
|
||||
|
||||
@Nullable
|
||||
public Direction getBedOrientation() {
|
||||
|
@ -1433,7 +1438,7 @@
|
|||
|
||||
return blockposition != null ? BedBlock.getBedOrientation(this.level(), blockposition) : null;
|
||||
}
|
||||
@@ -3905,7 +4486,7 @@
|
||||
@@ -3905,7 +4492,7 @@
|
||||
public float maxUpStep() {
|
||||
float f = (float) this.getAttributeValue(Attributes.STEP_HEIGHT);
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
|
||||
- player.heal(f / 6.0F);
|
||||
- this.addExhaustion(f);
|
||||
+ player.heal(f / 6.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED); // CraftBukkit - added RegainReason
|
||||
+ player.heal(f / 6.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED, true); // CraftBukkit - added RegainReason // Paper - This is fast regen
|
||||
+ // this.addExhaustion(f); CraftBukkit - EntityExhaustionEvent
|
||||
+ player.causeFoodExhaustion(f, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.REGEN); // CraftBukkit - EntityExhaustionEvent
|
||||
this.tickTimer = 0;
|
||||
|
|
Loading…
Reference in a new issue