aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/world/entity/Mob.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/entity/Mob.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/world/entity/Mob.java.patch1787
1 files changed, 1787 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/entity/Mob.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/entity/Mob.java.patch
new file mode 100644
index 0000000000..2ec43eca63
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/world/entity/Mob.java.patch
@@ -0,0 +1,1787 @@
+--- a/net/minecraft/world/entity/Mob.java
++++ b/net/minecraft/world/entity/Mob.java
+@@ -25,13 +25,14 @@
+ import net.minecraft.network.syncher.SynchedEntityData;
+ import net.minecraft.resources.ResourceLocation;
+ import net.minecraft.server.level.ServerLevel;
++import net.minecraft.server.level.ServerPlayer;
+ import net.minecraft.sounds.SoundEvent;
+ import net.minecraft.tags.TagKey;
+ import net.minecraft.util.Mth;
+ import net.minecraft.util.RandomSource;
+ import net.minecraft.world.Difficulty;
+ import net.minecraft.world.DifficultyInstance;
+-import net.minecraft.world.InteractionHand;
++import net.minecraft.world.EnumHand;
+ import net.minecraft.world.InteractionResult;
+ import net.minecraft.world.damagesource.DamageSource;
+ import net.minecraft.world.entity.ai.attributes.AttributeModifier;
+@@ -49,7 +50,7 @@
+ import net.minecraft.world.entity.decoration.HangingEntity;
+ import net.minecraft.world.entity.decoration.LeashFenceKnotEntity;
+ import net.minecraft.world.entity.item.ItemEntity;
+-import net.minecraft.world.entity.monster.Enemy;
++import net.minecraft.world.entity.monster.IMonster;
+ import net.minecraft.world.entity.player.Player;
+ import net.minecraft.world.entity.vehicle.Boat;
+ import net.minecraft.world.item.ArmorItem;
+@@ -66,7 +67,7 @@
+ import net.minecraft.world.item.SwordItem;
+ import net.minecraft.world.item.enchantment.EnchantmentHelper;
+ import net.minecraft.world.level.GameRules;
+-import net.minecraft.world.level.ItemLike;
++import net.minecraft.world.level.IMaterial;
+ import net.minecraft.world.level.Level;
+ import net.minecraft.world.level.LevelAccessor;
+ import net.minecraft.world.level.LevelReader;
+@@ -75,6 +76,16 @@
+ import net.minecraft.world.level.material.Fluid;
+ import net.minecraft.world.level.pathfinder.BlockPathTypes;
+ import net.minecraft.world.phys.AABB;
++import org.bukkit.craftbukkit.event.CraftEventFactory;
++import org.bukkit.craftbukkit.entity.CraftLivingEntity;
++import org.bukkit.event.entity.CreatureSpawnEvent;
++import org.bukkit.event.entity.EntityCombustByEntityEvent;
++import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
++import org.bukkit.event.entity.EntityTargetEvent;
++import org.bukkit.event.entity.EntityTransformEvent;
++import org.bukkit.event.entity.EntityUnleashEvent;
++import org.bukkit.event.entity.EntityUnleashEvent.UnleashReason;
++// CraftBukkit end
+
+ public abstract class Mob extends LivingEntity implements Targeting {
+
+@@ -100,21 +111,21 @@
+ protected JumpControl jumpControl;
+ private final BodyRotationControl bodyRotationControl;
+ protected PathNavigation navigation;
+- protected final GoalSelector goalSelector;
+- protected final GoalSelector targetSelector;
++ public GoalSelector goalSelector;
++ public GoalSelector targetSelector;
+ @Nullable
+ private LivingEntity target;
+ private final Sensing sensing;
+ private final NonNullList<ItemStack> handItems;
+- protected final float[] handDropChances;
++ public final float[] handDropChances;
+ private final NonNullList<ItemStack> armorItems;
+- protected final float[] armorDropChances;
++ public final float[] armorDropChances;
+ private boolean canPickUpLoot;
+ private boolean persistenceRequired;
+ private final Map<BlockPathTypes, Float> pathfindingMalus;
+ @Nullable
+- private ResourceLocation lootTable;
+- private long lootTableSeed;
++ public ResourceLocation lootTable;
++ public long lootTableSeed;
+ @Nullable
+ private Entity leashHolder;
+ private int delayedLeashHolderId;
+@@ -123,8 +134,10 @@
+ private BlockPos restrictCenter;
+ private float restrictRadius;
+
+- protected Mob(EntityType<? extends Mob> entitytype, Level level) {
+- super(entitytype, level);
++ public boolean aware = true; // CraftBukkit
++
++ protected Mob(EntityType<? extends Mob> entityType, Level level) {
++ super(entityType, level);
+ this.handItems = NonNullList.withSize(2, ItemStack.EMPTY);
+ this.handDropChances = new float[2];
+ this.armorItems = NonNullList.withSize(4, ItemStack.EMPTY);
+@@ -148,6 +161,12 @@
+
+ }
+
++ // CraftBukkit start
++ public void setPersistenceRequired(boolean persistenceRequired) {
++ this.persistenceRequired = persistenceRequired;
++ }
++ // CraftBukkit end
++
+ protected void registerGoals() {}
+
+ public static AttributeSupplier.Builder createMobAttributes() {
+@@ -162,31 +181,31 @@
+ return false;
+ }
+
+- public float getPathfindingMalus(BlockPathTypes blockpathtypes) {
+- Mob mob;
++ public float getPathfindingMalus(BlockPathTypes nodeType) {
++ Mob entityinsentient;
+ label17:
+ {
+ Entity entity = this.getControlledVehicle();
+
+ if (entity instanceof Mob) {
+- Mob mob1 = (Mob) entity;
++ Mob entityinsentient1 = (Mob) entity;
+
+- if (mob1.shouldPassengersInheritMalus()) {
+- mob = mob1;
++ if (entityinsentient1.shouldPassengersInheritMalus()) {
++ entityinsentient = entityinsentient1;
+ break label17;
+ }
+ }
+
+- mob = this;
++ entityinsentient = this;
+ }
+
+- Float ofloat = (Float) mob.pathfindingMalus.get(blockpathtypes);
++ Float ofloat = (Float) entityinsentient.pathfindingMalus.get(nodeType);
+
+- return ofloat == null ? blockpathtypes.getMalus() : ofloat;
++ return ofloat == null ? nodeType.getMalus() : ofloat;
+ }
+
+- public void setPathfindingMalus(BlockPathTypes blockpathtypes, float f) {
+- this.pathfindingMalus.put(blockpathtypes, f);
++ public void setPathfindingMalus(BlockPathTypes nodeType, float malus) {
++ this.pathfindingMalus.put(nodeType, malus);
+ }
+
+ public void onPathfindingStart() {}
+@@ -205,9 +224,9 @@
+ Entity entity = this.getControlledVehicle();
+
+ if (entity instanceof Mob) {
+- Mob mob = (Mob) entity;
++ Mob entityinsentient = (Mob) entity;
+
+- return mob.getMoveControl();
++ return entityinsentient.getMoveControl();
+ } else {
+ return this.moveControl;
+ }
+@@ -221,9 +240,9 @@
+ Entity entity = this.getControlledVehicle();
+
+ if (entity instanceof Mob) {
+- Mob mob = (Mob) entity;
++ Mob entityinsentient = (Mob) entity;
+
+- return mob.getNavigation();
++ return entityinsentient.getNavigation();
+ } else {
+ return this.navigation;
+ }
+@@ -231,22 +250,21 @@
+
+ @Nullable
+ @Override
+- @Override
+ public LivingEntity getControllingPassenger() {
+ Entity entity = this.getFirstPassenger();
+- Mob mob;
++ Mob entityinsentient;
+
+ if (!this.isNoAi() && entity instanceof Mob) {
+- Mob mob1 = (Mob) entity;
++ Mob entityinsentient1 = (Mob) entity;
+
+ if (entity.canControlVehicle()) {
+- mob = mob1;
+- return mob;
++ entityinsentient = entityinsentient1;
++ return entityinsentient;
+ }
+ }
+
+- mob = null;
+- return mob;
++ entityinsentient = null;
++ return entityinsentient;
+ }
+
+ public Sensing getSensing() {
+@@ -255,22 +273,51 @@
+
+ @Nullable
+ @Override
+- @Override
+ public LivingEntity getTarget() {
+ return this.target;
+ }
+
+- public void setTarget(@Nullable LivingEntity livingentity) {
+- this.target = livingentity;
++ public void setTarget(@Nullable LivingEntity target) {
++ // CraftBukkit start - fire event
++ setTarget(target, EntityTargetEvent.TargetReason.UNKNOWN, true);
+ }
+
++ public boolean setTarget(LivingEntity entityliving, EntityTargetEvent.TargetReason reason, boolean fireEvent) {
++ if (getTarget() == entityliving) return false;
++ if (fireEvent) {
++ if (reason == EntityTargetEvent.TargetReason.UNKNOWN && getTarget() != null && entityliving == null) {
++ reason = getTarget().isAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED;
++ }
++ if (reason == EntityTargetEvent.TargetReason.UNKNOWN) {
++ this.level().getCraftServer().getLogger().log(java.util.logging.Level.WARNING, "Unknown target reason, please report on the issue tracker", new Exception());
++ }
++ CraftLivingEntity ctarget = null;
++ if (entityliving != null) {
++ ctarget = (CraftLivingEntity) entityliving.getBukkitEntity();
++ }
++ EntityTargetLivingEntityEvent event = new EntityTargetLivingEntityEvent(this.getBukkitEntity(), ctarget, reason);
++ this.level().getCraftServer().getPluginManager().callEvent(event);
++ if (event.isCancelled()) {
++ return false;
++ }
++
++ if (event.getTarget() != null) {
++ entityliving = ((CraftLivingEntity) event.getTarget()).getHandle();
++ } else {
++ entityliving = null;
++ }
++ }
++ this.target = entityliving;
++ return true;
++ // CraftBukkit end
++ }
++
+ @Override
+- @Override
+- public boolean canAttackType(EntityType<?> entitytype) {
+- return entitytype != EntityType.GHAST;
++ public boolean canAttackType(EntityType<?> type) {
++ return type != EntityType.GHAST;
+ }
+
+- public boolean canFireProjectileWeapon(ProjectileWeaponItem projectileweaponitem) {
++ public boolean canFireProjectileWeapon(ProjectileWeaponItem projectileWeapon) {
+ return false;
+ }
+
+@@ -279,7 +326,6 @@
+ }
+
+ @Override
+- @Override
+ protected void defineSynchedData() {
+ super.defineSynchedData();
+ this.entityData.define(Mob.DATA_MOB_FLAGS_ID, (byte) 0);
+@@ -290,16 +336,15 @@
+ }
+
+ public void playAmbientSound() {
+- SoundEvent soundevent = this.getAmbientSound();
++ SoundEvent soundeffect = this.getAmbientSound();
+
+- if (soundevent != null) {
+- this.playSound(soundevent, this.getSoundVolume(), this.getVoicePitch());
++ if (soundeffect != null) {
++ this.playSound(soundeffect, this.getSoundVolume(), this.getVoicePitch());
+ }
+
+ }
+
+ @Override
+- @Override
+ public void baseTick() {
+ super.baseTick();
+ this.level().getProfiler().push("mobBaseTick");
+@@ -312,10 +357,9 @@
+ }
+
+ @Override
+- @Override
+- protected void playHurtSound(DamageSource damagesource) {
++ protected void playHurtSound(DamageSource source) {
+ this.resetAmbientSoundTime();
+- super.playHurtSound(damagesource);
++ super.playHurtSound(source);
+ }
+
+ private void resetAmbientSoundTime() {
+@@ -323,7 +367,6 @@
+ }
+
+ @Override
+- @Override
+ public int getExperienceReward() {
+ if (this.xpReward > 0) {
+ int i = this.xpReward;
+@@ -365,18 +408,16 @@
+ }
+
+ @Override
+- @Override
+- public void handleEntityEvent(byte b0) {
+- if (b0 == 20) {
++ public void handleEntityEvent(byte id) {
++ if (id == 20) {
+ this.spawnAnim();
+ } else {
+- super.handleEntityEvent(b0);
++ super.handleEntityEvent(id);
+ }
+
+ }
+
+ @Override
+- @Override
+ public void tick() {
+ super.tick();
+ if (!this.level().isClientSide) {
+@@ -392,16 +433,15 @@
+ boolean flag = !(this.getControllingPassenger() instanceof Mob);
+ boolean flag1 = !(this.getVehicle() instanceof Boat);
+
+- this.goalSelector.setControlFlag(Goal.Flag.MOVE, flag);
+- this.goalSelector.setControlFlag(Goal.Flag.JUMP, flag && flag1);
+- this.goalSelector.setControlFlag(Goal.Flag.LOOK, flag);
++ this.goalSelector.setControlFlag(Goal.Type.MOVE, flag);
++ this.goalSelector.setControlFlag(Goal.Type.JUMP, flag && flag1);
++ this.goalSelector.setControlFlag(Goal.Type.LOOK, flag);
+ }
+
+ @Override
+- @Override
+- protected float tickHeadTurn(float f, float f1) {
++ protected float tickHeadTurn(float yRot, float animStep) {
+ this.bodyRotationControl.clientTick();
+- return f1;
++ return animStep;
+ }
+
+ @Nullable
+@@ -409,41 +449,46 @@
+ return null;
+ }
+
++ // CraftBukkit start - Add delegate method
++ public SoundEvent getAmbientSound0() {
++ return getAmbientSound();
++ }
++ // CraftBukkit end
++
+ @Override
+- @Override
+- public void addAdditionalSaveData(CompoundTag compoundtag) {
+- super.addAdditionalSaveData(compoundtag);
+- compoundtag.putBoolean("CanPickUpLoot", this.canPickUpLoot());
+- compoundtag.putBoolean("PersistenceRequired", this.persistenceRequired);
+- ListTag listtag = new ListTag();
++ public void addAdditionalSaveData(CompoundTag compound) {
++ super.addAdditionalSaveData(compound);
++ compound.putBoolean("CanPickUpLoot", this.canPickUpLoot());
++ compound.putBoolean("PersistenceRequired", this.persistenceRequired);
++ ListTag nbttaglist = new ListTag();
+
+- CompoundTag compoundtag1;
++ CompoundTag nbttagcompound1;
+
+- for (Iterator iterator = this.armorItems.iterator(); iterator.hasNext(); listtag.add(compoundtag1)) {
++ for (Iterator iterator = this.armorItems.iterator(); iterator.hasNext(); nbttaglist.add(nbttagcompound1)) {
+ ItemStack itemstack = (ItemStack) iterator.next();
+
+- compoundtag1 = new CompoundTag();
++ nbttagcompound1 = new CompoundTag();
+ if (!itemstack.isEmpty()) {
+- itemstack.save(compoundtag1);
++ itemstack.save(nbttagcompound1);
+ }
+ }
+
+- compoundtag.put("ArmorItems", listtag);
+- ListTag listtag1 = new ListTag();
++ compound.put("ArmorItems", nbttaglist);
++ ListTag nbttaglist1 = new ListTag();
+
+- CompoundTag compoundtag2;
++ CompoundTag nbttagcompound2;
+
+- for (Iterator iterator1 = this.handItems.iterator(); iterator1.hasNext(); listtag1.add(compoundtag2)) {
++ for (Iterator iterator1 = this.handItems.iterator(); iterator1.hasNext(); nbttaglist1.add(nbttagcompound2)) {
+ ItemStack itemstack1 = (ItemStack) iterator1.next();
+
+- compoundtag2 = new CompoundTag();
++ nbttagcompound2 = new CompoundTag();
+ if (!itemstack1.isEmpty()) {
+- itemstack1.save(compoundtag2);
++ itemstack1.save(nbttagcompound2);
+ }
+ }
+
+- compoundtag.put("HandItems", listtag1);
+- ListTag listtag2 = new ListTag();
++ compound.put("HandItems", nbttaglist1);
++ ListTag nbttaglist2 = new ListTag();
+ float[] afloat = this.armorDropChances;
+ int i = afloat.length;
+
+@@ -452,11 +497,11 @@
+ for (j = 0; j < i; ++j) {
+ float f = afloat[j];
+
+- listtag2.add(FloatTag.valueOf(f));
++ nbttaglist2.add(FloatTag.valueOf(f));
+ }
+
+- compoundtag.put("ArmorDropChances", listtag2);
+- ListTag listtag3 = new ListTag();
++ compound.put("ArmorDropChances", nbttaglist2);
++ ListTag nbttaglist3 = new ListTag();
+ float[] afloat1 = this.handDropChances;
+
+ j = afloat1.length;
+@@ -464,157 +509,166 @@
+ for (int k = 0; k < j; ++k) {
+ float f1 = afloat1[k];
+
+- listtag3.add(FloatTag.valueOf(f1));
++ nbttaglist3.add(FloatTag.valueOf(f1));
+ }
+
+- compoundtag.put("HandDropChances", listtag3);
+- if (this.leashHolder != null) {
+- compoundtag2 = new CompoundTag();
++ compound.put("HandDropChances", nbttaglist3);
++ if (this.leashHolder != null && !this.leashHolder.pluginRemoved) { // CraftBukkit - SPIGOT-7487: Don't save (and possible drop) leash, when the holder was removed by a plugin
++ nbttagcompound2 = new CompoundTag();
+ if (this.leashHolder instanceof LivingEntity) {
+ UUID uuid = this.leashHolder.getUUID();
+
+- compoundtag2.putUUID("UUID", uuid);
++ nbttagcompound2.putUUID("UUID", uuid);
+ } else if (this.leashHolder instanceof HangingEntity) {
+- BlockPos blockpos = ((HangingEntity) this.leashHolder).getPos();
++ BlockPos blockposition = ((HangingEntity) this.leashHolder).getPos();
+
+- compoundtag2.putInt("X", blockpos.getX());
+- compoundtag2.putInt("Y", blockpos.getY());
+- compoundtag2.putInt("Z", blockpos.getZ());
++ nbttagcompound2.putInt("X", blockposition.getX());
++ nbttagcompound2.putInt("Y", blockposition.getY());
++ nbttagcompound2.putInt("Z", blockposition.getZ());
+ }
+
+- compoundtag.put("Leash", compoundtag2);
++ compound.put("Leash", nbttagcompound2);
+ } else if (this.leashInfoTag != null) {
+- compoundtag.put("Leash", this.leashInfoTag.copy());
++ compound.put("Leash", this.leashInfoTag.copy());
+ }
+
+- compoundtag.putBoolean("LeftHanded", this.isLeftHanded());
++ compound.putBoolean("LeftHanded", this.isLeftHanded());
+ if (this.lootTable != null) {
+- compoundtag.putString("DeathLootTable", this.lootTable.toString());
++ compound.putString("DeathLootTable", this.lootTable.toString());
+ if (this.lootTableSeed != 0L) {
+- compoundtag.putLong("DeathLootTableSeed", this.lootTableSeed);
++ compound.putLong("DeathLootTableSeed", this.lootTableSeed);
+ }
+ }
+
+ if (this.isNoAi()) {
+- compoundtag.putBoolean("NoAI", this.isNoAi());
++ compound.putBoolean("NoAI", this.isNoAi());
+ }
+
++ compound.putBoolean("Bukkit.Aware", this.aware); // CraftBukkit
+ }
+
+ @Override
+- @Override
+- public void readAdditionalSaveData(CompoundTag compoundtag) {
+- super.readAdditionalSaveData(compoundtag);
+- if (compoundtag.contains("CanPickUpLoot", 1)) {
+- this.setCanPickUpLoot(compoundtag.getBoolean("CanPickUpLoot"));
++ public void readAdditionalSaveData(CompoundTag compound) {
++ super.readAdditionalSaveData(compound);
++
++ // CraftBukkit start - If looting or persistence is false only use it if it was set after we started using it
++ if (compound.contains("CanPickUpLoot", 1)) {
++ boolean data = compound.getBoolean("CanPickUpLoot");
++ if (isLevelAtLeast(compound, 1) || data) {
++ this.setCanPickUpLoot(data);
++ }
+ }
+
+- this.persistenceRequired = compoundtag.getBoolean("PersistenceRequired");
+- ListTag listtag;
++ boolean data = compound.getBoolean("PersistenceRequired");
++ if (isLevelAtLeast(compound, 1) || data) {
++ this.persistenceRequired = data;
++ }
++ // CraftBukkit end
++ ListTag nbttaglist;
+ int i;
+
+- if (compoundtag.contains("ArmorItems", 9)) {
+- listtag = compoundtag.getList("ArmorItems", 10);
++ if (compound.contains("ArmorItems", 9)) {
++ nbttaglist = compound.getList("ArmorItems", 10);
+
+ for (i = 0; i < this.armorItems.size(); ++i) {
+- this.armorItems.set(i, ItemStack.of(listtag.getCompound(i)));
++ this.armorItems.set(i, ItemStack.of(nbttaglist.getCompound(i)));
+ }
+ }
+
+- if (compoundtag.contains("HandItems", 9)) {
+- listtag = compoundtag.getList("HandItems", 10);
++ if (compound.contains("HandItems", 9)) {
++ nbttaglist = compound.getList("HandItems", 10);
+
+ for (i = 0; i < this.handItems.size(); ++i) {
+- this.handItems.set(i, ItemStack.of(listtag.getCompound(i)));
++ this.handItems.set(i, ItemStack.of(nbttaglist.getCompound(i)));
+ }
+ }
+
+- if (compoundtag.contains("ArmorDropChances", 9)) {
+- listtag = compoundtag.getList("ArmorDropChances", 5);
++ if (compound.contains("ArmorDropChances", 9)) {
++ nbttaglist = compound.getList("ArmorDropChances", 5);
+
+- for (i = 0; i < listtag.size(); ++i) {
+- this.armorDropChances[i] = listtag.getFloat(i);
++ for (i = 0; i < nbttaglist.size(); ++i) {
++ this.armorDropChances[i] = nbttaglist.getFloat(i);
+ }
+ }
+
+- if (compoundtag.contains("HandDropChances", 9)) {
+- listtag = compoundtag.getList("HandDropChances", 5);
++ if (compound.contains("HandDropChances", 9)) {
++ nbttaglist = compound.getList("HandDropChances", 5);
+
+- for (i = 0; i < listtag.size(); ++i) {
+- this.handDropChances[i] = listtag.getFloat(i);
++ for (i = 0; i < nbttaglist.size(); ++i) {
++ this.handDropChances[i] = nbttaglist.getFloat(i);
+ }
+ }
+
+- if (compoundtag.contains("Leash", 10)) {
+- this.leashInfoTag = compoundtag.getCompound("Leash");
++ if (compound.contains("Leash", 10)) {
++ this.leashInfoTag = compound.getCompound("Leash");
+ }
+
+- this.setLeftHanded(compoundtag.getBoolean("LeftHanded"));
+- if (compoundtag.contains("DeathLootTable", 8)) {
+- this.lootTable = new ResourceLocation(compoundtag.getString("DeathLootTable"));
+- this.lootTableSeed = compoundtag.getLong("DeathLootTableSeed");
++ this.setLeftHanded(compound.getBoolean("LeftHanded"));
++ if (compound.contains("DeathLootTable", 8)) {
++ this.lootTable = new ResourceLocation(compound.getString("DeathLootTable"));
++ this.lootTableSeed = compound.getLong("DeathLootTableSeed");
+ }
+
+- this.setNoAi(compoundtag.getBoolean("NoAI"));
++ this.setNoAi(compound.getBoolean("NoAI"));
++ // CraftBukkit start
++ if (compound.contains("Bukkit.Aware")) {
++ this.aware = compound.getBoolean("Bukkit.Aware");
++ }
++ // CraftBukkit end
+ }
+
+ @Override
+- @Override
+- protected void dropFromLootTable(DamageSource damagesource, boolean flag) {
+- super.dropFromLootTable(damagesource, flag);
++ protected void dropFromLootTable(DamageSource damageSource, boolean attackedRecently) {
++ super.dropFromLootTable(damageSource, attackedRecently);
+ this.lootTable = null;
+ }
+
+ @Override
+- @Override
+ public final ResourceLocation getLootTable() {
+ return this.lootTable == null ? this.getDefaultLootTable() : this.lootTable;
+ }
+
+- protected ResourceLocation getDefaultLootTable() {
++ public ResourceLocation getDefaultLootTable() {
+ return super.getLootTable();
+ }
+
+ @Override
+- @Override
+ public long getLootTableSeed() {
+ return this.lootTableSeed;
+ }
+
+- public void setZza(float f) {
+- this.zza = f;
++ public void setZza(float amount) {
++ this.zza = amount;
+ }
+
+- public void setYya(float f) {
+- this.yya = f;
++ public void setYya(float amount) {
++ this.yya = amount;
+ }
+
+- public void setXxa(float f) {
+- this.xxa = f;
++ public void setXxa(float amount) {
++ this.xxa = amount;
+ }
+
+ @Override
+- @Override
+- public void setSpeed(float f) {
+- super.setSpeed(f);
+- this.setZza(f);
++ public void setSpeed(float speed) {
++ super.setSpeed(speed);
++ this.setZza(speed);
+ }
+
+ @Override
+- @Override
+ public void aiStep() {
+ super.aiStep();
+ this.level().getProfiler().push("looting");
+ if (!this.level().isClientSide && this.canPickUpLoot() && this.isAlive() && !this.dead && this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
+- Vec3i vec3i = this.getPickupReach();
+- List<ItemEntity> list = this.level().getEntitiesOfClass(ItemEntity.class, this.getBoundingBox().inflate((double) vec3i.getX(), (double) vec3i.getY(), (double) vec3i.getZ()));
++ Vec3i baseblockposition = this.getPickupReach();
++ List<ItemEntity> list = this.level().getEntitiesOfClass(ItemEntity.class, this.getBoundingBox().inflate((double) baseblockposition.getX(), (double) baseblockposition.getY(), (double) baseblockposition.getZ()));
+ Iterator iterator = list.iterator();
+
+ while (iterator.hasNext()) {
+- ItemEntity itementity = (ItemEntity) iterator.next();
++ ItemEntity entityitem = (ItemEntity) iterator.next();
+
+- if (!itementity.isRemoved() && !itementity.getItem().isEmpty() && !itementity.hasPickUpDelay() && this.wantsToPickUp(itementity.getItem())) {
+- this.pickUpItem(itementity);
++ if (!entityitem.isRemoved() && !entityitem.getItem().isEmpty() && !entityitem.hasPickUpDelay() && this.wantsToPickUp(entityitem.getItem())) {
++ this.pickUpItem(entityitem);
+ }
+ }
+ }
+@@ -626,46 +680,60 @@
+ return Mob.ITEM_PICKUP_REACH;
+ }
+
+- protected void pickUpItem(ItemEntity itementity) {
+- ItemStack itemstack = itementity.getItem();
+- ItemStack itemstack1 = this.equipItemIfPossible(itemstack.copy());
++ protected void pickUpItem(ItemEntity itemEntity) {
++ ItemStack itemstack = itemEntity.getItem();
++ ItemStack itemstack1 = this.equipItemIfPossible(itemstack.copy(), itemEntity); // CraftBukkit - add item
+
+ if (!itemstack1.isEmpty()) {
+- this.onItemPickup(itementity);
+- this.take(itementity, itemstack1.getCount());
++ this.onItemPickup(itemEntity);
++ this.take(itemEntity, itemstack1.getCount());
+ itemstack.shrink(itemstack1.getCount());
+ if (itemstack.isEmpty()) {
+- itementity.discard();
++ itemEntity.discard();
+ }
+ }
+
+ }
+
+- public ItemStack equipItemIfPossible(ItemStack itemstack) {
+- EquipmentSlot equipmentslot = getEquipmentSlotForItem(itemstack);
+- ItemStack itemstack1 = this.getItemBySlot(equipmentslot);
++ public ItemStack equipItemIfPossible(ItemStack stack) {
++ // CraftBukkit start - add item
++ return this.equipItemIfPossible(stack, null);
++ }
++
++ public ItemStack equipItemIfPossible(ItemStack itemstack, ItemEntity entityitem) {
++ // CraftBukkit end
++ EquipmentSlot enumitemslot = getEquipmentSlotForItem(itemstack);
++ ItemStack itemstack1 = this.getItemBySlot(enumitemslot);
+ boolean flag = this.canReplaceCurrentItem(itemstack, itemstack1);
+
+- if (equipmentslot.isArmor() && !flag) {
+- equipmentslot = EquipmentSlot.MAINHAND;
+- itemstack1 = this.getItemBySlot(equipmentslot);
++ if (enumitemslot.isArmor() && !flag) {
++ enumitemslot = EquipmentSlot.MAINHAND;
++ itemstack1 = this.getItemBySlot(enumitemslot);
+ flag = itemstack1.isEmpty();
+ }
+
+- if (flag && this.canHoldItem(itemstack)) {
+- double d0 = (double) this.getEquipmentDropChance(equipmentslot);
++ // CraftBukkit start
++ boolean canPickup = flag && this.canHoldItem(itemstack);
++ if (entityitem != null) {
++ canPickup = !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !canPickup).isCancelled();
++ }
++ if (canPickup) {
++ // CraftBukkit end
++ double d0 = (double) this.getEquipmentDropChance(enumitemslot);
+
+ if (!itemstack1.isEmpty() && (double) Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d0) {
++ this.forceDrops = true; // CraftBukkit
+ this.spawnAtLocation(itemstack1);
++ this.forceDrops = false; // CraftBukkit
+ }
+
+- if (equipmentslot.isArmor() && itemstack.getCount() > 1) {
++ if (enumitemslot.isArmor() && itemstack.getCount() > 1) {
+ ItemStack itemstack2 = itemstack.copyWithCount(1);
+
+- this.setItemSlotAndDropWhenKilled(equipmentslot, itemstack2);
++ this.setItemSlotAndDropWhenKilled(enumitemslot, itemstack2);
+ return itemstack2;
+ } else {
+- this.setItemSlotAndDropWhenKilled(equipmentslot, itemstack);
++ this.setItemSlotAndDropWhenKilled(enumitemslot, itemstack);
+ return itemstack;
+ }
+ } else {
+@@ -673,71 +741,71 @@
+ }
+ }
+
+- protected void setItemSlotAndDropWhenKilled(EquipmentSlot equipmentslot, ItemStack itemstack) {
+- this.setItemSlot(equipmentslot, itemstack);
+- this.setGuaranteedDrop(equipmentslot);
++ protected void setItemSlotAndDropWhenKilled(EquipmentSlot slot, ItemStack stack) {
++ this.setItemSlot(slot, stack);
++ this.setGuaranteedDrop(slot);
+ this.persistenceRequired = true;
+ }
+
+- public void setGuaranteedDrop(EquipmentSlot equipmentslot) {
+- switch (equipmentslot.getType()) {
++ public void setGuaranteedDrop(EquipmentSlot slot) {
++ switch (slot.getType()) {
+ case HAND:
+- this.handDropChances[equipmentslot.getIndex()] = 2.0F;
++ this.handDropChances[slot.getIndex()] = 2.0F;
+ break;
+ case ARMOR:
+- this.armorDropChances[equipmentslot.getIndex()] = 2.0F;
++ this.armorDropChances[slot.getIndex()] = 2.0F;
+ }
+
+ }
+
+- protected boolean canReplaceCurrentItem(ItemStack itemstack, ItemStack itemstack1) {
+- if (itemstack1.isEmpty()) {
++ protected boolean canReplaceCurrentItem(ItemStack candidate, ItemStack existing) {
++ if (existing.isEmpty()) {
+ return true;
+- } else if (itemstack.getItem() instanceof SwordItem) {
+- if (!(itemstack1.getItem() instanceof SwordItem)) {
++ } else if (candidate.getItem() instanceof SwordItem) {
++ if (!(existing.getItem() instanceof SwordItem)) {
+ return true;
+ } else {
+- SwordItem sworditem = (SwordItem) itemstack.getItem();
+- SwordItem sworditem1 = (SwordItem) itemstack1.getItem();
++ SwordItem itemsword = (SwordItem) candidate.getItem();
++ SwordItem itemsword1 = (SwordItem) existing.getItem();
+
+- return sworditem.getDamage() != sworditem1.getDamage() ? sworditem.getDamage() > sworditem1.getDamage() : this.canReplaceEqualItem(itemstack, itemstack1);
++ return itemsword.getDamage() != itemsword1.getDamage() ? itemsword.getDamage() > itemsword1.getDamage() : this.canReplaceEqualItem(candidate, existing);
+ }
+- } else if (itemstack.getItem() instanceof BowItem && itemstack1.getItem() instanceof BowItem) {
+- return this.canReplaceEqualItem(itemstack, itemstack1);
+- } else if (itemstack.getItem() instanceof CrossbowItem && itemstack1.getItem() instanceof CrossbowItem) {
+- return this.canReplaceEqualItem(itemstack, itemstack1);
++ } else if (candidate.getItem() instanceof BowItem && existing.getItem() instanceof BowItem) {
++ return this.canReplaceEqualItem(candidate, existing);
++ } else if (candidate.getItem() instanceof CrossbowItem && existing.getItem() instanceof CrossbowItem) {
++ return this.canReplaceEqualItem(candidate, existing);
+ } else {
+- Item item = itemstack.getItem();
++ Item item = candidate.getItem();
+
+ if (item instanceof ArmorItem) {
+- ArmorItem armoritem = (ArmorItem) item;
++ ArmorItem itemarmor = (ArmorItem) item;
+
+- if (EnchantmentHelper.hasBindingCurse(itemstack1)) {
++ if (EnchantmentHelper.hasBindingCurse(existing)) {
+ return false;
+- } else if (!(itemstack1.getItem() instanceof ArmorItem)) {
++ } else if (!(existing.getItem() instanceof ArmorItem)) {
+ return true;
+ } else {
+- ArmorItem armoritem1 = (ArmorItem) itemstack1.getItem();
++ ArmorItem itemarmor1 = (ArmorItem) existing.getItem();
+
+- return armoritem.getDefense() != armoritem1.getDefense() ? armoritem.getDefense() > armoritem1.getDefense() : (armoritem.getToughness() != armoritem1.getToughness() ? armoritem.getToughness() > armoritem1.getToughness() : this.canReplaceEqualItem(itemstack, itemstack1));
++ return itemarmor.getDefense() != itemarmor1.getDefense() ? itemarmor.getDefense() > itemarmor1.getDefense() : (itemarmor.getToughness() != itemarmor1.getToughness() ? itemarmor.getToughness() > itemarmor1.getToughness() : this.canReplaceEqualItem(candidate, existing));
+ }
+ } else {
+- if (itemstack.getItem() instanceof DiggerItem) {
+- if (itemstack1.getItem() instanceof BlockItem) {
++ if (candidate.getItem() instanceof DiggerItem) {
++ if (existing.getItem() instanceof BlockItem) {
+ return true;
+ }
+
+- Item item1 = itemstack1.getItem();
++ Item item1 = existing.getItem();
+
+ if (item1 instanceof DiggerItem) {
+- DiggerItem diggeritem = (DiggerItem) item1;
+- DiggerItem diggeritem1 = (DiggerItem) itemstack.getItem();
++ DiggerItem itemtool = (DiggerItem) item1;
++ DiggerItem itemtool1 = (DiggerItem) candidate.getItem();
+
+- if (diggeritem1.getAttackDamage() != diggeritem.getAttackDamage()) {
+- return diggeritem1.getAttackDamage() > diggeritem.getAttackDamage();
++ if (itemtool1.getAttackDamage() != itemtool.getAttackDamage()) {
++ return itemtool1.getAttackDamage() > itemtool.getAttackDamage();
+ }
+
+- return this.canReplaceEqualItem(itemstack, itemstack1);
++ return this.canReplaceEqualItem(candidate, existing);
+ }
+ }
+
+@@ -746,23 +814,23 @@
+ }
+ }
+
+- public boolean canReplaceEqualItem(ItemStack itemstack, ItemStack itemstack1) {
+- return itemstack.getDamageValue() >= itemstack1.getDamageValue() && (!itemstack.hasTag() || itemstack1.hasTag()) ? (itemstack.hasTag() && itemstack1.hasTag() ? itemstack.getTag().getAllKeys().stream().anyMatch((s) -> {
++ public boolean canReplaceEqualItem(ItemStack candidate, ItemStack existing) {
++ return candidate.getDamageValue() >= existing.getDamageValue() && (!candidate.hasTag() || existing.hasTag()) ? (candidate.hasTag() && existing.hasTag() ? candidate.getTag().getAllKeys().stream().anyMatch((s) -> {
+ return !s.equals("Damage");
+- }) && !itemstack1.getTag().getAllKeys().stream().anyMatch((s) -> {
++ }) && !existing.getTag().getAllKeys().stream().anyMatch((s) -> {
+ return !s.equals("Damage");
+ }) : false) : true;
+ }
+
+- public boolean canHoldItem(ItemStack itemstack) {
++ public boolean canHoldItem(ItemStack stack) {
+ return true;
+ }
+
+- public boolean wantsToPickUp(ItemStack itemstack) {
+- return this.canHoldItem(itemstack);
++ public boolean wantsToPickUp(ItemStack stack) {
++ return this.canHoldItem(stack);
+ }
+
+- public boolean removeWhenFarAway(double d0) {
++ public boolean removeWhenFarAway(double distanceToClosestPlayer) {
+ return true;
+ }
+
+@@ -775,15 +843,14 @@
+ }
+
+ @Override
+- @Override
+ public void checkDespawn() {
+ if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.shouldDespawnInPeaceful()) {
+ this.discard();
+ } else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) {
+- Player player = this.level().getNearestPlayer(this, -1.0D);
++ Player entityhuman = this.level().getNearestPlayer(this, -1.0D);
+
+- if (player != null) {
+- double d0 = player.distanceToSqr((Entity) this);
++ if (entityhuman != null) {
++ double d0 = entityhuman.distanceToSqr((Entity) this);
+ int i = this.getType().getCategory().getDespawnDistance();
+ int j = i * i;
+
+@@ -807,9 +874,9 @@
+ }
+
+ @Override
+- @Override
+ protected final void serverAiStep() {
+ ++this.noActionTime;
++ if (!this.aware) return; // CraftBukkit
+ this.level().getProfiler().push("sensing");
+ this.sensing.tick();
+ this.level().getProfiler().pop();
+@@ -867,15 +934,15 @@
+ return 10;
+ }
+
+- public void lookAt(Entity entity, float f, float f1) {
++ public void lookAt(Entity entity, float maxYRotIncrease, float maxXRotIncrease) {
+ double d0 = entity.getX() - this.getX();
+ double d1 = entity.getZ() - this.getZ();
+ double d2;
+
+ if (entity instanceof LivingEntity) {
+- LivingEntity livingentity = (LivingEntity) entity;
++ LivingEntity entityliving = (LivingEntity) entity;
+
+- d2 = livingentity.getEyeY() - this.getEyeY();
++ d2 = entityliving.getEyeY() - this.getEyeY();
+ } else {
+ d2 = (entity.getBoundingBox().minY + entity.getBoundingBox().maxY) / 2.0D - this.getEyeY();
+ }
+@@ -884,48 +951,47 @@
+ float f2 = (float) (Mth.atan2(d1, d0) * 57.2957763671875D) - 90.0F;
+ float f3 = (float) (-(Mth.atan2(d2, d3) * 57.2957763671875D));
+
+- this.setXRot(this.rotlerp(this.getXRot(), f3, f1));
+- this.setYRot(this.rotlerp(this.getYRot(), f2, f));
++ this.setXRot(this.rotlerp(this.getXRot(), f3, maxXRotIncrease));
++ this.setYRot(this.rotlerp(this.getYRot(), f2, maxYRotIncrease));
+ }
+
+- private float rotlerp(float f, float f1, float f2) {
+- float f3 = Mth.wrapDegrees(f1 - f);
++ private float rotlerp(float angle, float targetAngle, float maxIncrease) {
++ float f3 = Mth.wrapDegrees(targetAngle - angle);
+
+- if (f3 > f2) {
+- f3 = f2;
++ if (f3 > maxIncrease) {
++ f3 = maxIncrease;
+ }
+
+- if (f3 < -f2) {
+- f3 = -f2;
++ if (f3 < -maxIncrease) {
++ f3 = -maxIncrease;
+ }
+
+- return f + f3;
++ return angle + f3;
+ }
+
+- public static boolean checkMobSpawnRules(EntityType<? extends Mob> entitytype, LevelAccessor levelaccessor, MobSpawnType mobspawntype, BlockPos blockpos, RandomSource randomsource) {
+- BlockPos blockpos1 = blockpos.below();
++ public static boolean checkMobSpawnRules(EntityType<? extends Mob> type, LevelAccessor level, EnumMobSpawn spawnType, BlockPos pos, RandomSource random) {
++ BlockPos blockposition1 = pos.below();
+
+- return mobspawntype == MobSpawnType.SPAWNER || levelaccessor.getBlockState(blockpos1).isValidSpawn(levelaccessor, blockpos1, entitytype);
++ return spawnType == EnumMobSpawn.SPAWNER || level.getBlockState(blockposition1).isValidSpawn(level, blockposition1, type);
+ }
+
+- public boolean checkSpawnRules(LevelAccessor levelaccessor, MobSpawnType mobspawntype) {
++ public boolean checkSpawnRules(LevelAccessor level, EnumMobSpawn reason) {
+ return true;
+ }
+
+- public boolean checkSpawnObstruction(LevelReader levelreader) {
+- return !levelreader.containsAnyLiquid(this.getBoundingBox()) && levelreader.isUnobstructed(this);
++ public boolean checkSpawnObstruction(LevelReader level) {
++ return !level.containsAnyLiquid(this.getBoundingBox()) && level.isUnobstructed(this);
+ }
+
+ public int getMaxSpawnClusterSize() {
+ return 4;
+ }
+
+- public boolean isMaxGroupSizeReached(int i) {
++ public boolean isMaxGroupSizeReached(int size) {
+ return false;
+ }
+
+ @Override
+- @Override
+ public int getMaxFallDistance() {
+ if (this.getTarget() == null) {
+ return 3;
+@@ -942,78 +1008,73 @@
+ }
+
+ @Override
+- @Override
+ public Iterable<ItemStack> getHandSlots() {
+ return this.handItems;
+ }
+
+ @Override
+- @Override
+ public Iterable<ItemStack> getArmorSlots() {
+ return this.armorItems;
+ }
+
+ @Override
+- @Override
+- public ItemStack getItemBySlot(EquipmentSlot equipmentslot) {
+- switch (equipmentslot.getType()) {
++ public ItemStack getItemBySlot(EquipmentSlot slot) {
++ switch (slot.getType()) {
+ case HAND:
+- return (ItemStack) this.handItems.get(equipmentslot.getIndex());
++ return (ItemStack) this.handItems.get(slot.getIndex());
+ case ARMOR:
+- return (ItemStack) this.armorItems.get(equipmentslot.getIndex());
++ return (ItemStack) this.armorItems.get(slot.getIndex());
+ default:
+ return ItemStack.EMPTY;
+ }
+ }
+
+ @Override
+- @Override
+- public void setItemSlot(EquipmentSlot equipmentslot, ItemStack itemstack) {
+- this.verifyEquippedItem(itemstack);
+- switch (equipmentslot.getType()) {
++ public void setItemSlot(EquipmentSlot slot, ItemStack stack) {
++ this.verifyEquippedItem(stack);
++ switch (slot.getType()) {
+ case HAND:
+- this.onEquipItem(equipmentslot, (ItemStack) this.handItems.set(equipmentslot.getIndex(), itemstack), itemstack);
++ this.onEquipItem(slot, (ItemStack) this.handItems.set(slot.getIndex(), stack), stack);
+ break;
+ case ARMOR:
+- this.onEquipItem(equipmentslot, (ItemStack) this.armorItems.set(equipmentslot.getIndex(), itemstack), itemstack);
++ this.onEquipItem(slot, (ItemStack) this.armorItems.set(slot.getIndex(), stack), stack);
+ }
+
+ }
+
+ @Override
+- @Override
+- protected void dropCustomDeathLoot(DamageSource damagesource, int i, boolean flag) {
+- super.dropCustomDeathLoot(damagesource, i, flag);
+- EquipmentSlot[] aequipmentslot = EquipmentSlot.values();
+- int j = aequipmentslot.length;
++ protected void dropCustomDeathLoot(DamageSource source, int looting, boolean recentlyHit) {
++ super.dropCustomDeathLoot(source, looting, recentlyHit);
++ EquipmentSlot[] aenumitemslot = EquipmentSlot.values();
++ int j = aenumitemslot.length;
+
+ for (int k = 0; k < j; ++k) {
+- EquipmentSlot equipmentslot = aequipmentslot[k];
+- ItemStack itemstack = this.getItemBySlot(equipmentslot);
+- float f = this.getEquipmentDropChance(equipmentslot);
++ EquipmentSlot enumitemslot = aenumitemslot[k];
++ ItemStack itemstack = this.getItemBySlot(enumitemslot);
++ float f = this.getEquipmentDropChance(enumitemslot);
+ boolean flag1 = f > 1.0F;
+
+- if (!itemstack.isEmpty() && !EnchantmentHelper.hasVanishingCurse(itemstack) && (flag || flag1) && Math.max(this.random.nextFloat() - (float) i * 0.01F, 0.0F) < f) {
++ if (!itemstack.isEmpty() && !EnchantmentHelper.hasVanishingCurse(itemstack) && (recentlyHit || flag1) && Math.max(this.random.nextFloat() - (float) looting * 0.01F, 0.0F) < f) {
+ if (!flag1 && itemstack.isDamageableItem()) {
+ itemstack.setDamageValue(itemstack.getMaxDamage() - this.random.nextInt(1 + this.random.nextInt(Math.max(itemstack.getMaxDamage() - 3, 1))));
+ }
+
+ this.spawnAtLocation(itemstack);
+- this.setItemSlot(equipmentslot, ItemStack.EMPTY);
++ this.setItemSlot(enumitemslot, ItemStack.EMPTY);
+ }
+ }
+
+ }
+
+- protected float getEquipmentDropChance(EquipmentSlot equipmentslot) {
++ protected float getEquipmentDropChance(EquipmentSlot slot) {
+ float f;
+
+- switch (equipmentslot.getType()) {
++ switch (slot.getType()) {
+ case HAND:
+- f = this.handDropChances[equipmentslot.getIndex()];
++ f = this.handDropChances[slot.getIndex()];
+ break;
+ case ARMOR:
+- f = this.armorDropChances[equipmentslot.getIndex()];
++ f = this.armorDropChances[slot.getIndex()];
+ break;
+ default:
+ f = 0.0F;
+@@ -1022,43 +1083,43 @@
+ return f;
+ }
+
+- protected void populateDefaultEquipmentSlots(RandomSource randomsource, DifficultyInstance difficultyinstance) {
+- if (randomsource.nextFloat() < 0.15F * difficultyinstance.getSpecialMultiplier()) {
+- int i = randomsource.nextInt(2);
++ protected void populateDefaultEquipmentSlots(RandomSource random, DifficultyInstance difficulty) {
++ if (random.nextFloat() < 0.15F * difficulty.getSpecialMultiplier()) {
++ int i = random.nextInt(2);
+ float f = this.level().getDifficulty() == Difficulty.HARD ? 0.1F : 0.25F;
+
+- if (randomsource.nextFloat() < 0.095F) {
++ if (random.nextFloat() < 0.095F) {
+ ++i;
+ }
+
+- if (randomsource.nextFloat() < 0.095F) {
++ if (random.nextFloat() < 0.095F) {
+ ++i;
+ }
+
+- if (randomsource.nextFloat() < 0.095F) {
++ if (random.nextFloat() < 0.095F) {
+ ++i;
+ }
+
+ boolean flag = true;
+- EquipmentSlot[] aequipmentslot = EquipmentSlot.values();
+- int j = aequipmentslot.length;
++ EquipmentSlot[] aenumitemslot = EquipmentSlot.values();
++ int j = aenumitemslot.length;
+
+ for (int k = 0; k < j; ++k) {
+- EquipmentSlot equipmentslot = aequipmentslot[k];
++ EquipmentSlot enumitemslot = aenumitemslot[k];
+
+- if (equipmentslot.getType() == EquipmentSlot.Type.ARMOR) {
+- ItemStack itemstack = this.getItemBySlot(equipmentslot);
++ if (enumitemslot.getType() == EquipmentSlot.Function.ARMOR) {
++ ItemStack itemstack = this.getItemBySlot(enumitemslot);
+
+- if (!flag && randomsource.nextFloat() < f) {
++ if (!flag && random.nextFloat() < f) {
+ break;
+ }
+
+ flag = false;
+ if (itemstack.isEmpty()) {
+- Item item = getEquipmentForSlot(equipmentslot, i);
++ Item item = getEquipmentForSlot(enumitemslot, i);
+
+ if (item != null) {
+- this.setItemSlot(equipmentslot, new ItemStack(item));
++ this.setItemSlot(enumitemslot, new ItemStack(item));
+ }
+ }
+ }
+@@ -1068,54 +1129,54 @@
+ }
+
+ @Nullable
+- public static Item getEquipmentForSlot(EquipmentSlot equipmentslot, int i) {
+- switch (equipmentslot) {
++ public static Item getEquipmentForSlot(EquipmentSlot slot, int chance) {
++ switch (slot) {
+ case HEAD:
+- if (i == 0) {
++ if (chance == 0) {
+ return Items.LEATHER_HELMET;
+- } else if (i == 1) {
++ } else if (chance == 1) {
+ return Items.GOLDEN_HELMET;
+- } else if (i == 2) {
++ } else if (chance == 2) {
+ return Items.CHAINMAIL_HELMET;
+- } else if (i == 3) {
++ } else if (chance == 3) {
+ return Items.IRON_HELMET;
+- } else if (i == 4) {
++ } else if (chance == 4) {
+ return Items.DIAMOND_HELMET;
+ }
+ case CHEST:
+- if (i == 0) {
++ if (chance == 0) {
+ return Items.LEATHER_CHESTPLATE;
+- } else if (i == 1) {
++ } else if (chance == 1) {
+ return Items.GOLDEN_CHESTPLATE;
+- } else if (i == 2) {
++ } else if (chance == 2) {
+ return Items.CHAINMAIL_CHESTPLATE;
+- } else if (i == 3) {
++ } else if (chance == 3) {
+ return Items.IRON_CHESTPLATE;
+- } else if (i == 4) {
++ } else if (chance == 4) {
+ return Items.DIAMOND_CHESTPLATE;
+ }
+ case LEGS:
+- if (i == 0) {
++ if (chance == 0) {
+ return Items.LEATHER_LEGGINGS;
+- } else if (i == 1) {
++ } else if (chance == 1) {
+ return Items.GOLDEN_LEGGINGS;
+- } else if (i == 2) {
++ } else if (chance == 2) {
+ return Items.CHAINMAIL_LEGGINGS;
+- } else if (i == 3) {
++ } else if (chance == 3) {
+ return Items.IRON_LEGGINGS;
+- } else if (i == 4) {
++ } else if (chance == 4) {
+ return Items.DIAMOND_LEGGINGS;
+ }
+ case FEET:
+- if (i == 0) {
++ if (chance == 0) {
+ return Items.LEATHER_BOOTS;
+- } else if (i == 1) {
++ } else if (chance == 1) {
+ return Items.GOLDEN_BOOTS;
+- } else if (i == 2) {
++ } else if (chance == 2) {
+ return Items.CHAINMAIL_BOOTS;
+- } else if (i == 3) {
++ } else if (chance == 3) {
+ return Items.IRON_BOOTS;
+- } else if (i == 4) {
++ } else if (chance == 4) {
+ return Items.DIAMOND_BOOTS;
+ }
+ default:
+@@ -1123,42 +1184,42 @@
+ }
+ }
+
+- protected void populateDefaultEquipmentEnchantments(RandomSource randomsource, DifficultyInstance difficultyinstance) {
+- float f = difficultyinstance.getSpecialMultiplier();
++ protected void populateDefaultEquipmentEnchantments(RandomSource random, DifficultyInstance difficulty) {
++ float f = difficulty.getSpecialMultiplier();
+
+- this.enchantSpawnedWeapon(randomsource, f);
+- EquipmentSlot[] aequipmentslot = EquipmentSlot.values();
+- int i = aequipmentslot.length;
++ this.enchantSpawnedWeapon(random, f);
++ EquipmentSlot[] aenumitemslot = EquipmentSlot.values();
++ int i = aenumitemslot.length;
+
+ for (int j = 0; j < i; ++j) {
+- EquipmentSlot equipmentslot = aequipmentslot[j];
++ EquipmentSlot enumitemslot = aenumitemslot[j];
+
+- if (equipmentslot.getType() == EquipmentSlot.Type.ARMOR) {
+- this.enchantSpawnedArmor(randomsource, f, equipmentslot);
++ if (enumitemslot.getType() == EquipmentSlot.Function.ARMOR) {
++ this.enchantSpawnedArmor(random, f, enumitemslot);
+ }
+ }
+
+ }
+
+- protected void enchantSpawnedWeapon(RandomSource randomsource, float f) {
+- if (!this.getMainHandItem().isEmpty() && randomsource.nextFloat() < 0.25F * f) {
+- this.setItemSlot(EquipmentSlot.MAINHAND, EnchantmentHelper.enchantItem(randomsource, this.getMainHandItem(), (int) (5.0F + f * (float) randomsource.nextInt(18)), false));
++ protected void enchantSpawnedWeapon(RandomSource random, float chanceMultiplier) {
++ if (!this.getMainHandItem().isEmpty() && random.nextFloat() < 0.25F * chanceMultiplier) {
++ this.setItemSlot(EquipmentSlot.MAINHAND, EnchantmentHelper.enchantItem(random, this.getMainHandItem(), (int) (5.0F + chanceMultiplier * (float) random.nextInt(18)), false));
+ }
+
+ }
+
+- protected void enchantSpawnedArmor(RandomSource randomsource, float f, EquipmentSlot equipmentslot) {
+- ItemStack itemstack = this.getItemBySlot(equipmentslot);
++ protected void enchantSpawnedArmor(RandomSource random, float chanceMultiplier, EquipmentSlot slot) {
++ ItemStack itemstack = this.getItemBySlot(slot);
+
+- if (!itemstack.isEmpty() && randomsource.nextFloat() < 0.5F * f) {
+- this.setItemSlot(equipmentslot, EnchantmentHelper.enchantItem(randomsource, itemstack, (int) (5.0F + f * (float) randomsource.nextInt(18)), false));
++ if (!itemstack.isEmpty() && random.nextFloat() < 0.5F * chanceMultiplier) {
++ this.setItemSlot(slot, EnchantmentHelper.enchantItem(random, itemstack, (int) (5.0F + chanceMultiplier * (float) random.nextInt(18)), false));
+ }
+
+ }
+
+ @Nullable
+- public SpawnGroupData finalizeSpawn(ServerLevelAccessor serverlevelaccessor, DifficultyInstance difficultyinstance, MobSpawnType mobspawntype, @Nullable SpawnGroupData spawngroupdata, @Nullable CompoundTag compoundtag) {
+- RandomSource randomsource = serverlevelaccessor.getRandom();
++ public GroupDataEntity finalizeSpawn(ServerLevelAccessor level, DifficultyInstance difficulty, EnumMobSpawn reason, @Nullable GroupDataEntity spawnData, @Nullable CompoundTag dataTag) {
++ RandomSource randomsource = level.getRandom();
+
+ this.getAttribute(Attributes.FOLLOW_RANGE).addPermanentModifier(new AttributeModifier("Random spawn bonus", randomsource.triangle(0.0D, 0.11485000000000001D), AttributeModifier.Operation.MULTIPLY_BASE));
+ if (randomsource.nextFloat() < 0.05F) {
+@@ -1167,20 +1228,20 @@
+ this.setLeftHanded(false);
+ }
+
+- return spawngroupdata;
++ return spawnData;
+ }
+
+ public void setPersistenceRequired() {
+ this.persistenceRequired = true;
+ }
+
+- public void setDropChance(EquipmentSlot equipmentslot, float f) {
+- switch (equipmentslot.getType()) {
++ public void setDropChance(EquipmentSlot slot, float chance) {
++ switch (slot.getType()) {
+ case HAND:
+- this.handDropChances[equipmentslot.getIndex()] = f;
++ this.handDropChances[slot.getIndex()] = chance;
+ break;
+ case ARMOR:
+- this.armorDropChances[equipmentslot.getIndex()] = f;
++ this.armorDropChances[slot.getIndex()] = chance;
+ }
+
+ }
+@@ -1189,16 +1250,15 @@
+ return this.canPickUpLoot;
+ }
+
+- public void setCanPickUpLoot(boolean flag) {
+- this.canPickUpLoot = flag;
++ public void setCanPickUpLoot(boolean canPickUpLoot) {
++ this.canPickUpLoot = canPickUpLoot;
+ }
+
+ @Override
+- @Override
+ public boolean canTakeItem(ItemStack itemstack) {
+- EquipmentSlot equipmentslot = getEquipmentSlotForItem(itemstack);
++ EquipmentSlot enumitemslot = getEquipmentSlotForItem(itemstack);
+
+- return this.getItemBySlot(equipmentslot).isEmpty() && this.canPickUpLoot();
++ return this.getItemBySlot(enumitemslot).isEmpty() && this.canPickUpLoot();
+ }
+
+ public boolean isPersistenceRequired() {
+@@ -1206,55 +1266,66 @@
+ }
+
+ @Override
+- @Override
+- public final InteractionResult interact(Player player, InteractionHand interactionhand) {
++ public final InteractionResult interact(Player player, EnumHand hand) {
+ if (!this.isAlive()) {
+ return InteractionResult.PASS;
+ } else if (this.getLeashHolder() == player) {
++ // CraftBukkit start - fire PlayerUnleashEntityEvent
++ if (CraftEventFactory.callPlayerUnleashEntityEvent(this, player, hand).isCancelled()) {
++ ((ServerPlayer) player).connection.send(new ClientboundSetEntityLinkPacket(this, this.getLeashHolder()));
++ return InteractionResult.PASS;
++ }
++ // CraftBukkit end
+ this.dropLeash(true, !player.getAbilities().instabuild);
+ this.gameEvent(GameEvent.ENTITY_INTERACT, player);
+ return InteractionResult.sidedSuccess(this.level().isClientSide);
+ } else {
+- InteractionResult interactionresult = this.checkAndHandleImportantInteractions(player, interactionhand);
++ InteractionResult enuminteractionresult = this.checkAndHandleImportantInteractions(player, hand);
+
+- if (interactionresult.consumesAction()) {
++ if (enuminteractionresult.consumesAction()) {
+ this.gameEvent(GameEvent.ENTITY_INTERACT, player);
+- return interactionresult;
++ return enuminteractionresult;
+ } else {
+- interactionresult = this.mobInteract(player, interactionhand);
+- if (interactionresult.consumesAction()) {
++ enuminteractionresult = this.mobInteract(player, hand);
++ if (enuminteractionresult.consumesAction()) {
+ this.gameEvent(GameEvent.ENTITY_INTERACT, player);
+- return interactionresult;
++ return enuminteractionresult;
+ } else {
+- return super.interact(player, interactionhand);
++ return super.interact(player, hand);
+ }
+ }
+ }
+ }
+
+- private InteractionResult checkAndHandleImportantInteractions(Player player, InteractionHand interactionhand) {
+- ItemStack itemstack = player.getItemInHand(interactionhand);
++ private InteractionResult checkAndHandleImportantInteractions(Player player, EnumHand hand) {
++ ItemStack itemstack = player.getItemInHand(hand);
+
+ if (itemstack.is(Items.LEAD) && this.canBeLeashed(player)) {
++ // CraftBukkit start - fire PlayerLeashEntityEvent
++ if (CraftEventFactory.callPlayerLeashEntityEvent(this, player, player, hand).isCancelled()) {
++ ((ServerPlayer) player).connection.send(new ClientboundSetEntityLinkPacket(this, this.getLeashHolder()));
++ return InteractionResult.PASS;
++ }
++ // CraftBukkit end
+ this.setLeashedTo(player, true);
+ itemstack.shrink(1);
+ return InteractionResult.sidedSuccess(this.level().isClientSide);
+ } else {
+ if (itemstack.is(Items.NAME_TAG)) {
+- InteractionResult interactionresult = itemstack.interactLivingEntity(player, this, interactionhand);
++ InteractionResult enuminteractionresult = itemstack.interactLivingEntity(player, this, hand);
+
+- if (interactionresult.consumesAction()) {
+- return interactionresult;
++ if (enuminteractionresult.consumesAction()) {
++ return enuminteractionresult;
+ }
+ }
+
+ if (itemstack.getItem() instanceof SpawnEggItem) {
+ if (this.level() instanceof ServerLevel) {
+- SpawnEggItem spawneggitem = (SpawnEggItem) itemstack.getItem();
+- Optional<Mob> optional = spawneggitem.spawnOffspringFromSpawnEgg(player, this, this.getType(), (ServerLevel) this.level(), this.position(), itemstack);
++ SpawnEggItem itemmonsteregg = (SpawnEggItem) itemstack.getItem();
++ Optional<Mob> optional = itemmonsteregg.spawnOffspringFromSpawnEgg(player, this, (EntityType<? extends Mob>) this.getType(), (ServerLevel) this.level(), this.position(), itemstack); // CraftBukkit - decompile error
+
+- optional.ifPresent((mob) -> {
+- this.onOffspringSpawnedFromEgg(player, mob);
++ optional.ifPresent((entityinsentient) -> {
++ this.onOffspringSpawnedFromEgg(player, entityinsentient);
+ });
+ return optional.isPresent() ? InteractionResult.SUCCESS : InteractionResult.PASS;
+ } else {
+@@ -1266,9 +1337,9 @@
+ }
+ }
+
+- protected void onOffspringSpawnedFromEgg(Player player, Mob mob) {}
++ protected void onOffspringSpawnedFromEgg(Player player, Mob child) {}
+
+- protected InteractionResult mobInteract(Player player, InteractionHand interactionhand) {
++ protected InteractionResult mobInteract(Player player, EnumHand hand) {
+ return InteractionResult.PASS;
+ }
+
+@@ -1276,13 +1347,13 @@
+ return this.isWithinRestriction(this.blockPosition());
+ }
+
+- public boolean isWithinRestriction(BlockPos blockpos) {
+- return this.restrictRadius == -1.0F ? true : this.restrictCenter.distSqr(blockpos) < (double) (this.restrictRadius * this.restrictRadius);
++ public boolean isWithinRestriction(BlockPos pos) {
++ return this.restrictRadius == -1.0F ? true : this.restrictCenter.distSqr(pos) < (double) (this.restrictRadius * this.restrictRadius);
+ }
+
+- public void restrictTo(BlockPos blockpos, int i) {
+- this.restrictCenter = blockpos;
+- this.restrictRadius = (float) i;
++ public void restrictTo(BlockPos pos, int distance) {
++ this.restrictCenter = pos;
++ this.restrictRadius = (float) distance;
+ }
+
+ public BlockPos getRestrictCenter() {
+@@ -1301,12 +1372,19 @@
+ return this.restrictRadius != -1.0F;
+ }
+
++ // CraftBukkit start
+ @Nullable
+- public <T extends Mob> T convertTo(EntityType<T> entitytype, boolean flag) {
++ public <T extends Mob> T convertTo(EntityType<T> entityType, boolean transferInventory) {
++ return this.convertTo(entityType, transferInventory, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT);
++ }
++
++ @Nullable
++ public <T extends Mob> T convertTo(EntityType<T> entitytypes, boolean flag, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) {
++ // CraftBukkit end
+ if (this.isRemoved()) {
+ return null;
+ } else {
+- T t0 = (Mob) entitytype.create(this.level());
++ T t0 = entitytypes.create(this.level()); // CraftBukkit - decompile error
+
+ if (t0 == null) {
+ return null;
+@@ -1326,21 +1404,26 @@
+ t0.setInvulnerable(this.isInvulnerable());
+ if (flag) {
+ t0.setCanPickUpLoot(this.canPickUpLoot());
+- EquipmentSlot[] aequipmentslot = EquipmentSlot.values();
+- int i = aequipmentslot.length;
++ EquipmentSlot[] aenumitemslot = EquipmentSlot.values();
++ int i = aenumitemslot.length;
+
+ for (int j = 0; j < i; ++j) {
+- EquipmentSlot equipmentslot = aequipmentslot[j];
+- ItemStack itemstack = this.getItemBySlot(equipmentslot);
++ EquipmentSlot enumitemslot = aenumitemslot[j];
++ ItemStack itemstack = this.getItemBySlot(enumitemslot);
+
+ if (!itemstack.isEmpty()) {
+- t0.setItemSlot(equipmentslot, itemstack.copyAndClear());
+- t0.setDropChance(equipmentslot, this.getEquipmentDropChance(equipmentslot));
++ t0.setItemSlot(enumitemslot, itemstack.copyAndClear());
++ t0.setDropChance(enumitemslot, this.getEquipmentDropChance(enumitemslot));
+ }
+ }
+ }
+
+- this.level().addFreshEntity(t0);
++ // CraftBukkit start
++ if (CraftEventFactory.callEntityTransformEvent(this, t0, transformReason).isCancelled()) {
++ return null;
++ }
++ this.level().addFreshEntity(t0, spawnReason);
++ // CraftBukkit end
+ if (this.isPassenger()) {
+ Entity entity = this.getVehicle();
+
+@@ -1361,21 +1444,24 @@
+
+ if (this.leashHolder != null) {
+ if (!this.isAlive() || !this.leashHolder.isAlive()) {
+- this.dropLeash(true, true);
++ this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), (!this.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit
++ this.dropLeash(true, !this.leashHolder.pluginRemoved);// CraftBukkit - SPIGOT-7487: Don't drop leash, when the holder was removed by a plugin
+ }
+
+ }
+ }
+
+- public void dropLeash(boolean flag, boolean flag1) {
++ public void dropLeash(boolean broadcastPacket, boolean dropLeash) {
+ if (this.leashHolder != null) {
+ this.leashHolder = null;
+ this.leashInfoTag = null;
+- if (!this.level().isClientSide && flag1) {
+- this.spawnAtLocation((ItemLike) Items.LEAD);
++ if (!this.level().isClientSide && dropLeash) {
++ this.forceDrops = true; // CraftBukkit
++ this.spawnAtLocation((IMaterial) Items.LEAD);
++ this.forceDrops = false; // CraftBukkit
+ }
+
+- if (!this.level().isClientSide && flag && this.level() instanceof ServerLevel) {
++ if (!this.level().isClientSide && broadcastPacket && this.level() instanceof ServerLevel) {
+ ((ServerLevel) this.level()).getChunkSource().broadcast(this, new ClientboundSetEntityLinkPacket(this, (Entity) null));
+ }
+ }
+@@ -1383,7 +1469,7 @@
+ }
+
+ public boolean canBeLeashed(Player player) {
+- return !this.isLeashed() && !(this instanceof Enemy);
++ return !this.isLeashed() && !(this instanceof IMonster);
+ }
+
+ public boolean isLeashed() {
+@@ -1399,10 +1485,10 @@
+ return this.leashHolder;
+ }
+
+- public void setLeashedTo(Entity entity, boolean flag) {
+- this.leashHolder = entity;
++ public void setLeashedTo(Entity leashHolder, boolean broadcastPacket) {
++ this.leashHolder = leashHolder;
+ this.leashInfoTag = null;
+- if (!this.level().isClientSide && flag && this.level() instanceof ServerLevel) {
++ if (!this.level().isClientSide && broadcastPacket && this.level() instanceof ServerLevel) {
+ ((ServerLevel) this.level()).getChunkSource().broadcast(this, new ClientboundSetEntityLinkPacket(this, this.leashHolder));
+ }
+
+@@ -1412,17 +1498,17 @@
+
+ }
+
+- public void setDelayedLeashHolderId(int i) {
+- this.delayedLeashHolderId = i;
++ public void setDelayedLeashHolderId(int leashHolderID) {
++ this.delayedLeashHolderId = leashHolderID;
+ this.dropLeash(false, false);
+ }
+
+ @Override
+- @Override
+- public boolean startRiding(Entity entity, boolean flag) {
+- boolean flag1 = super.startRiding(entity, flag);
++ public boolean startRiding(Entity entity, boolean force) {
++ boolean flag1 = super.startRiding(entity, force);
+
+ if (flag1 && this.isLeashed()) {
++ this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
+ this.dropLeash(true, true);
+ }
+
+@@ -1440,14 +1526,16 @@
+ return;
+ }
+ } else if (this.leashInfoTag.contains("X", 99) && this.leashInfoTag.contains("Y", 99) && this.leashInfoTag.contains("Z", 99)) {
+- BlockPos blockpos = NbtUtils.readBlockPos(this.leashInfoTag);
++ BlockPos blockposition = NbtUtils.readBlockPos(this.leashInfoTag);
+
+- this.setLeashedTo(LeashFenceKnotEntity.getOrCreateKnot(this.level(), blockpos), true);
++ this.setLeashedTo(LeashFenceKnotEntity.getOrCreateKnot(this.level(), blockposition), true);
+ return;
+ }
+
+ if (this.tickCount > 100) {
+- this.spawnAtLocation((ItemLike) Items.LEAD);
++ this.forceDrops = true; // CraftBukkit
++ this.spawnAtLocation((IMaterial) Items.LEAD);
++ this.forceDrops = false; // CraftBukkit
+ this.leashInfoTag = null;
+ }
+ }
+@@ -1455,27 +1543,26 @@
+ }
+
+ @Override
+- @Override
+ public boolean isEffectiveAi() {
+ return super.isEffectiveAi() && !this.isNoAi();
+ }
+
+- public void setNoAi(boolean flag) {
++ public void setNoAi(boolean noAi) {
+ byte b0 = (Byte) this.entityData.get(Mob.DATA_MOB_FLAGS_ID);
+
+- this.entityData.set(Mob.DATA_MOB_FLAGS_ID, flag ? (byte) (b0 | 1) : (byte) (b0 & -2));
++ this.entityData.set(Mob.DATA_MOB_FLAGS_ID, noAi ? (byte) (b0 | 1) : (byte) (b0 & -2));
+ }
+
+- public void setLeftHanded(boolean flag) {
++ public void setLeftHanded(boolean leftHanded) {
+ byte b0 = (Byte) this.entityData.get(Mob.DATA_MOB_FLAGS_ID);
+
+- this.entityData.set(Mob.DATA_MOB_FLAGS_ID, flag ? (byte) (b0 | 2) : (byte) (b0 & -3));
++ this.entityData.set(Mob.DATA_MOB_FLAGS_ID, leftHanded ? (byte) (b0 | 2) : (byte) (b0 & -3));
+ }
+
+- public void setAggressive(boolean flag) {
++ public void setAggressive(boolean aggressive) {
+ byte b0 = (Byte) this.entityData.get(Mob.DATA_MOB_FLAGS_ID);
+
+- this.entityData.set(Mob.DATA_MOB_FLAGS_ID, flag ? (byte) (b0 | 4) : (byte) (b0 & -5));
++ this.entityData.set(Mob.DATA_MOB_FLAGS_ID, aggressive ? (byte) (b0 | 4) : (byte) (b0 & -5));
+ }
+
+ public boolean isNoAi() {
+@@ -1490,36 +1577,34 @@
+ return ((Byte) this.entityData.get(Mob.DATA_MOB_FLAGS_ID) & 4) != 0;
+ }
+
+- public void setBaby(boolean flag) {}
++ public void setBaby(boolean baby) {}
+
+ @Override
+- @Override
+ public HumanoidArm getMainArm() {
+ return this.isLeftHanded() ? HumanoidArm.LEFT : HumanoidArm.RIGHT;
+ }
+
+- public boolean isWithinMeleeAttackRange(LivingEntity livingentity) {
+- return this.getAttackBoundingBox().intersects(livingentity.getHitbox());
++ public boolean isWithinMeleeAttackRange(LivingEntity entity) {
++ return this.getAttackBoundingBox().intersects(entity.getHitbox());
+ }
+
+ protected AABB getAttackBoundingBox() {
+ Entity entity = this.getVehicle();
+- AABB aabb;
++ AABB axisalignedbb;
+
+ if (entity != null) {
+- AABB aabb1 = entity.getBoundingBox();
+- AABB aabb2 = this.getBoundingBox();
++ AABB axisalignedbb1 = entity.getBoundingBox();
++ AABB axisalignedbb2 = this.getBoundingBox();
+
+- aabb = new AABB(Math.min(aabb2.minX, aabb1.minX), aabb2.minY, Math.min(aabb2.minZ, aabb1.minZ), Math.max(aabb2.maxX, aabb1.maxX), aabb2.maxY, Math.max(aabb2.maxZ, aabb1.maxZ));
++ axisalignedbb = new AABB(Math.min(axisalignedbb2.minX, axisalignedbb1.minX), axisalignedbb2.minY, Math.min(axisalignedbb2.minZ, axisalignedbb1.minZ), Math.max(axisalignedbb2.maxX, axisalignedbb1.maxX), axisalignedbb2.maxY, Math.max(axisalignedbb2.maxZ, axisalignedbb1.maxZ));
+ } else {
+- aabb = this.getBoundingBox();
++ axisalignedbb = this.getBoundingBox();
+ }
+
+- return aabb.inflate(Mob.DEFAULT_ATTACK_REACH, 0.0D, Mob.DEFAULT_ATTACK_REACH);
++ return axisalignedbb.inflate(Mob.DEFAULT_ATTACK_REACH, 0.0D, Mob.DEFAULT_ATTACK_REACH);
+ }
+
+ @Override
+- @Override
+ public boolean doHurtTarget(Entity entity) {
+ float f = (float) this.getAttributeValue(Attributes.ATTACK_DAMAGE);
+ float f1 = (float) this.getAttributeValue(Attributes.ATTACK_KNOCKBACK);
+@@ -1532,7 +1617,14 @@
+ int i = EnchantmentHelper.getFireAspect(this);
+
+ if (i > 0) {
+- entity.setSecondsOnFire(i * 4);
++ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item
++ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), i * 4);
++ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
++
++ if (!combustEvent.isCancelled()) {
++ entity.setSecondsOnFire(combustEvent.getDuration(), false);
++ }
++ // CraftBukkit end
+ }
+
+ boolean flag = entity.hurt(this.damageSources().mobAttack(this), f);
+@@ -1544,9 +1636,9 @@
+ }
+
+ if (entity instanceof Player) {
+- Player player = (Player) entity;
++ Player entityhuman = (Player) entity;
+
+- this.maybeDisableShield(player, this.getMainHandItem(), player.isUsingItem() ? player.getUseItem() : ItemStack.EMPTY);
++ this.maybeDisableShield(entityhuman, this.getMainHandItem(), entityhuman.isUsingItem() ? entityhuman.getUseItem() : ItemStack.EMPTY);
+ }
+
+ this.doEnchantDamageEffects(this, entity);
+@@ -1556,8 +1648,8 @@
+ return flag;
+ }
+
+- private void maybeDisableShield(Player player, ItemStack itemstack, ItemStack itemstack1) {
+- if (!itemstack.isEmpty() && !itemstack1.isEmpty() && itemstack.getItem() instanceof AxeItem && itemstack1.is(Items.SHIELD)) {
++ private void maybeDisableShield(Player player, ItemStack mobItemStack, ItemStack playerItemStack) {
++ if (!mobItemStack.isEmpty() && !playerItemStack.isEmpty() && mobItemStack.getItem() instanceof AxeItem && playerItemStack.is(Items.SHIELD)) {
+ float f = 0.25F + (float) EnchantmentHelper.getBlockEfficiency(this) * 0.05F;
+
+ if (this.random.nextFloat() < f) {
+@@ -1571,10 +1663,10 @@
+ protected boolean isSunBurnTick() {
+ if (this.level().isDay() && !this.level().isClientSide) {
+ float f = this.getLightLevelDependentMagicValue();
+- BlockPos blockpos = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ());
++ BlockPos blockposition = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ());
+ boolean flag = this.isInWaterRainOrBubble() || this.isInPowderSnow || this.wasInPowderSnow;
+
+- if (f > 0.5F && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && !flag && this.level().canSeeSky(blockpos)) {
++ if (f > 0.5F && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && !flag && this.level().canSeeSky(blockposition)) {
+ return true;
+ }
+ }
+@@ -1583,10 +1675,9 @@
+ }
+
+ @Override
+- @Override
+- protected void jumpInLiquid(TagKey<Fluid> tagkey) {
++ protected void jumpInLiquid(TagKey<Fluid> fluidTag) {
+ if (this.getNavigation().canFloat()) {
+- super.jumpInLiquid(tagkey);
++ super.jumpInLiquid(fluidTag);
+ } else {
+ this.setDeltaMovement(this.getDeltaMovement().add(0.0D, 0.3D, 0.0D));
+ }
+@@ -1595,20 +1686,20 @@
+
+ @VisibleForTesting
+ public void removeFreeWill() {
+- this.removeAllGoals((goal) -> {
++ this.removeAllGoals((pathfindergoal) -> {
+ return true;
+ });
+ this.getBrain().removeAllBehaviors();
+ }
+
+- public void removeAllGoals(Predicate<Goal> predicate) {
+- this.goalSelector.removeAllGoals(predicate);
++ public void removeAllGoals(Predicate<Goal> filter) {
++ this.goalSelector.removeAllGoals(filter);
+ }
+
+ @Override
+- @Override
+ protected void removeAfterChangingDimensions() {
+ super.removeAfterChangingDimensions();
++ this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
+ this.dropLeash(true, false);
+ this.getAllSlots().forEach((itemstack) -> {
+ if (!itemstack.isEmpty()) {
+@@ -1620,10 +1711,9 @@
+
+ @Nullable
+ @Override
+- @Override
+ public ItemStack getPickResult() {
+- SpawnEggItem spawneggitem = SpawnEggItem.byId(this.getType());
++ SpawnEggItem itemmonsteregg = SpawnEggItem.byId(this.getType());
+
+- return spawneggitem == null ? null : new ItemStack(spawneggitem);
++ return itemmonsteregg == null ? null : new ItemStack(itemmonsteregg);
+ }
+ }