SPIGOT-7732: Issue with the "hurt()" method of EntityLiving and invulnerable time
By: LoliColleen <76620594+LoliColleen@users.noreply.github.com>
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityAnimal.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityAnimal.java
|
||||
@@ -29,12 +29,19 @@
|
||||
@@ -29,12 +29,20 @@
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.pathfinder.PathType;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityBreedEvent;
|
||||
+import org.bukkit.event.entity.EntityDamageEvent;
|
||||
+import org.bukkit.event.entity.EntityEnterLoveModeEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
@@ -20,25 +21,25 @@
|
||||
|
||||
protected EntityAnimal(EntityTypes<? extends EntityAnimal> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -72,9 +79,15 @@
|
||||
@@ -72,9 +80,15 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected void actuallyHurt(DamageSource damagesource, float f) {
|
||||
+ // CraftBukkit start - void -> boolean
|
||||
+ public boolean actuallyHurt(DamageSource damagesource, float f) {
|
||||
+ boolean result = super.actuallyHurt(damagesource, f);
|
||||
+ if (!result) {
|
||||
+ return result;
|
||||
+ public boolean actuallyHurt(DamageSource damagesource, float f, EntityDamageEvent event) {
|
||||
+ boolean damageResult = super.actuallyHurt(damagesource, f, event);
|
||||
+ if (!damageResult) {
|
||||
+ return false;
|
||||
+ }
|
||||
this.resetLove();
|
||||
- super.actuallyHurt(damagesource, f);
|
||||
+ return result;
|
||||
+ return true;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -162,10 +175,17 @@
|
||||
@@ -162,10 +176,17 @@
|
||||
}
|
||||
|
||||
public void setInLove(@Nullable EntityHuman entityhuman) {
|
||||
@@ -57,7 +58,7 @@
|
||||
|
||||
this.level().broadcastEntityEvent(this, (byte) 18);
|
||||
}
|
||||
@@ -207,12 +227,29 @@
|
||||
@@ -207,12 +228,29 @@
|
||||
if (entityageable != null) {
|
||||
entityageable.setBaby(true);
|
||||
entityageable.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F);
|
||||
@@ -89,7 +90,7 @@
|
||||
Optional.ofNullable(this.getLoveCause()).or(() -> {
|
||||
return Optional.ofNullable(entityanimal.getLoveCause());
|
||||
}).ifPresent((entityplayer) -> {
|
||||
@@ -225,7 +262,11 @@
|
||||
@@ -225,7 +263,11 @@
|
||||
entityanimal.resetLove();
|
||||
worldserver.broadcastEntityEvent(this, (byte) 18);
|
||||
if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityWolf.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityWolf.java
|
||||
@@ -90,6 +90,12 @@
|
||||
@@ -90,6 +90,13 @@
|
||||
import net.minecraft.world.level.pathfinder.PathType;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityDamageEvent;
|
||||
+import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
+import org.bukkit.event.entity.EntityTargetEvent;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
@@ -13,7 +14,7 @@
|
||||
public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable, VariantHolder<Holder<WolfVariant>> {
|
||||
|
||||
private static final DataWatcherObject<Boolean> DATA_INTERESTED_ID = DataWatcher.defineId(EntityWolf.class, DataWatcherRegistry.BOOLEAN);
|
||||
@@ -360,11 +366,14 @@
|
||||
@@ -360,11 +367,14 @@
|
||||
if (this.isInvulnerableTo(damagesource)) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -30,19 +31,19 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,9 +383,9 @@
|
||||
@@ -374,9 +384,9 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected void actuallyHurt(DamageSource damagesource, float f) {
|
||||
+ public boolean actuallyHurt(DamageSource damagesource, float f) { // CraftBukkit - void -> boolean
|
||||
+ public boolean actuallyHurt(DamageSource damagesource, float f, EntityDamageEvent event) { // CraftBukkit - void -> boolean
|
||||
if (!this.canArmorAbsorb(damagesource)) {
|
||||
- super.actuallyHurt(damagesource, f);
|
||||
+ return super.actuallyHurt(damagesource, f); // CraftBukkit
|
||||
+ return super.actuallyHurt(damagesource, f, event); // CraftBukkit
|
||||
} else {
|
||||
ItemStack itemstack = this.getBodyArmorItem();
|
||||
int i = itemstack.getDamageValue();
|
||||
@@ -395,6 +404,7 @@
|
||||
@@ -395,6 +405,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -50,7 +51,7 @@
|
||||
}
|
||||
|
||||
private boolean canArmorAbsorb(DamageSource damagesource) {
|
||||
@@ -405,7 +415,7 @@
|
||||
@@ -405,7 +416,7 @@
|
||||
protected void applyTamingSideEffects() {
|
||||
if (this.isTame()) {
|
||||
this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(40.0D);
|
||||
@@ -59,7 +60,7 @@
|
||||
} else {
|
||||
this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(8.0D);
|
||||
}
|
||||
@@ -432,7 +442,7 @@
|
||||
@@ -432,7 +443,7 @@
|
||||
FoodInfo foodinfo = (FoodInfo) itemstack.get(DataComponents.FOOD);
|
||||
float f = foodinfo != null ? (float) foodinfo.nutrition() : 1.0F;
|
||||
|
||||
@@ -68,7 +69,7 @@
|
||||
return EnumInteractionResult.sidedSuccess(this.level().isClientSide());
|
||||
} else {
|
||||
if (item instanceof ItemDye) {
|
||||
@@ -480,7 +490,7 @@
|
||||
@@ -480,7 +491,7 @@
|
||||
this.setOrderedToSit(!this.isOrderedToSit());
|
||||
this.jumping = false;
|
||||
this.navigation.stop();
|
||||
@@ -77,7 +78,7 @@
|
||||
return EnumInteractionResult.SUCCESS_NO_ITEM_USED;
|
||||
} else {
|
||||
return enuminteractionresult;
|
||||
@@ -498,7 +508,8 @@
|
||||
@@ -498,7 +509,8 @@
|
||||
}
|
||||
|
||||
private void tryToTame(EntityHuman entityhuman) {
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
--- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java
|
||||
+++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java
|
||||
@@ -132,14 +132,16 @@
|
||||
@@ -47,6 +47,10 @@
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityDamageEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class Armadillo extends EntityAnimal {
|
||||
|
||||
public static final float BABY_SCALE = 0.6F;
|
||||
@@ -132,14 +136,16 @@
|
||||
@Override
|
||||
protected void customServerAiStep() {
|
||||
this.level().getProfiler().push("armadilloBrain");
|
||||
@@ -18,31 +29,31 @@
|
||||
this.gameEvent(GameEvent.ENTITY_PLACE);
|
||||
this.scuteTime = this.pickNextScuteDropTime();
|
||||
}
|
||||
@@ -286,8 +288,13 @@
|
||||
@@ -286,8 +292,13 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected void actuallyHurt(DamageSource damagesource, float f) {
|
||||
- super.actuallyHurt(damagesource, f);
|
||||
+ // CraftBukkit start - void -> boolean
|
||||
+ public boolean actuallyHurt(DamageSource damagesource, float f) {
|
||||
+ boolean hurt = super.actuallyHurt(damagesource, f);
|
||||
+ if (!hurt) {
|
||||
+ return hurt;
|
||||
+ public boolean actuallyHurt(DamageSource damagesource, float f, EntityDamageEvent event) {
|
||||
+ boolean damageResult = super.actuallyHurt(damagesource, f, event);
|
||||
+ if (!damageResult) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (!this.isNoAi() && !this.isDeadOrDying()) {
|
||||
if (damagesource.getEntity() instanceof EntityLiving) {
|
||||
this.getBrain().setMemoryWithExpiry(MemoryModuleType.DANGER_DETECTED_RECENTLY, true, 80L);
|
||||
@@ -299,6 +306,7 @@
|
||||
@@ -299,6 +310,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
+ return hurt; // CraftBukkit
|
||||
+ return true; // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -326,7 +334,9 @@
|
||||
@@ -326,7 +338,9 @@
|
||||
if (this.isBaby()) {
|
||||
return false;
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
--- a/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
+++ b/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
@@ -141,7 +141,7 @@
|
||||
@@ -50,6 +50,10 @@
|
||||
import net.minecraft.world.phys.Vec2F;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityDamageEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class Camel extends EntityHorseAbstract implements IJumpable, ISaddleable {
|
||||
|
||||
public static final float BABY_SCALE = 0.45F;
|
||||
@@ -141,7 +145,7 @@
|
||||
@Override
|
||||
protected void customServerAiStep() {
|
||||
this.level().getProfiler().push("camelBrain");
|
||||
@@ -9,21 +20,21 @@
|
||||
|
||||
behaviorcontroller.tick((WorldServer) this.level(), this);
|
||||
this.level().getProfiler().pop();
|
||||
@@ -452,9 +452,15 @@
|
||||
@@ -452,9 +456,15 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected void actuallyHurt(DamageSource damagesource, float f) {
|
||||
+ // CraftBukkit start - void -> boolean
|
||||
+ public boolean actuallyHurt(DamageSource damagesource, float f) {
|
||||
+ boolean hurt = super.actuallyHurt(damagesource, f);
|
||||
+ if (!hurt) {
|
||||
+ return hurt;
|
||||
+ public boolean actuallyHurt(DamageSource damagesource, float f, EntityDamageEvent event) {
|
||||
+ boolean damageResult = super.actuallyHurt(damagesource, f, event);
|
||||
+ if (!damageResult) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.standUpInstantly();
|
||||
- super.actuallyHurt(damagesource, f);
|
||||
+ return hurt; // CraftBukkit
|
||||
+ return true; // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user