diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Panda.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Panda.java.patch | 1169 |
1 files changed, 1169 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Panda.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Panda.java.patch new file mode 100644 index 0000000000..4fbfab1d22 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Panda.java.patch @@ -0,0 +1,1169 @@ +--- a/net/minecraft/world/entity/animal/Panda.java ++++ b/net/minecraft/world/entity/animal/Panda.java +@@ -1,7 +1,9 @@ + package net.minecraft.world.entity.animal; + + import java.util.EnumSet; ++import java.util.Iterator; + import java.util.List; ++import java.util.Objects; + import java.util.function.IntFunction; + import java.util.function.Predicate; + import javax.annotation.Nullable; +@@ -20,7 +22,7 @@ + import net.minecraft.util.RandomSource; + import net.minecraft.util.StringRepresentable; + 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.AgeableMob; +@@ -28,11 +30,11 @@ + import net.minecraft.world.entity.EntityDimensions; + import net.minecraft.world.entity.EntitySelector; + import net.minecraft.world.entity.EntityType; ++import net.minecraft.world.entity.EnumMobSpawn; + import net.minecraft.world.entity.EquipmentSlot; ++import net.minecraft.world.entity.GroupDataEntity; + import net.minecraft.world.entity.LivingEntity; + import net.minecraft.world.entity.Mob; +-import net.minecraft.world.entity.MobSpawnType; +-import net.minecraft.world.entity.SpawnGroupData; + import net.minecraft.world.entity.ai.attributes.AttributeSupplier; + import net.minecraft.world.entity.ai.attributes.Attributes; + import net.minecraft.world.entity.ai.control.MoveControl; +@@ -56,22 +58,29 @@ + import net.minecraft.world.item.Items; + import net.minecraft.world.item.crafting.Ingredient; + import net.minecraft.world.level.GameRules; ++import net.minecraft.world.level.IMaterial; + import net.minecraft.world.level.Level; + import net.minecraft.world.level.ServerLevelAccessor; + import net.minecraft.world.level.block.Blocks; +-import net.minecraft.world.level.block.state.BlockState; ++import net.minecraft.world.level.block.state.IBlockData; + import net.minecraft.world.level.gameevent.GameEvent; + import net.minecraft.world.phys.Vec3; + import org.joml.Vector3f; + ++// CraftBukkit start; ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++import org.bukkit.event.entity.EntityTargetEvent; ++// CraftBukkit end ++ + public class Panda extends Animal { ++ + private static final EntityDataAccessor<Integer> UNHAPPY_COUNTER = SynchedEntityData.defineId(Panda.class, EntityDataSerializers.INT); + private static final EntityDataAccessor<Integer> SNEEZE_COUNTER = SynchedEntityData.defineId(Panda.class, EntityDataSerializers.INT); + private static final EntityDataAccessor<Integer> EAT_COUNTER = SynchedEntityData.defineId(Panda.class, EntityDataSerializers.INT); + private static final EntityDataAccessor<Byte> MAIN_GENE_ID = SynchedEntityData.defineId(Panda.class, EntityDataSerializers.BYTE); + private static final EntityDataAccessor<Byte> HIDDEN_GENE_ID = SynchedEntityData.defineId(Panda.class, EntityDataSerializers.BYTE); + private static final EntityDataAccessor<Byte> DATA_ID_FLAGS = SynchedEntityData.defineId(Panda.class, EntityDataSerializers.BYTE); +- static final TargetingConditions BREED_TARGETING = TargetingConditions.forNonCombat().range(8.0); ++ static final TargetingConditions BREED_TARGETING = TargetingConditions.forNonCombat().range(8.0D); + private static final int FLAG_SNEEZE = 2; + private static final int FLAG_ROLL = 4; + private static final int FLAG_SIT = 8; +@@ -90,9 +99,10 @@ + private float rollAmount; + private float rollAmountO; + Panda.PandaLookAtPlayerGoal lookAtPlayerGoal; +- static final Predicate<ItemEntity> PANDA_ITEMS = itemEntity -> { +- ItemStack item = itemEntity.getItem(); +- return (item.is(Blocks.BAMBOO.asItem()) || item.is(Blocks.CAKE.asItem())) && itemEntity.isAlive() && !itemEntity.hasPickUpDelay(); ++ static final Predicate<ItemEntity> PANDA_ITEMS = (entityitem) -> { ++ ItemStack itemstack = entityitem.getItem(); ++ ++ return (itemstack.is(Blocks.BAMBOO.asItem()) || itemstack.is(Blocks.CAKE.asItem())) && entityitem.isAlive() && !entityitem.hasPickUpDelay(); + }; + + public Panda(EntityType<? extends Panda> entityType, Level level) { +@@ -101,20 +111,22 @@ + if (!this.isBaby()) { + this.setCanPickUpLoot(true); + } ++ + } + + @Override + public boolean canTakeItem(ItemStack itemstack) { +- EquipmentSlot equipmentSlotForItem = Mob.getEquipmentSlotForItem(itemstack); +- return this.getItemBySlot(equipmentSlotForItem).isEmpty() && equipmentSlotForItem == EquipmentSlot.MAINHAND && super.canTakeItem(itemstack); ++ EquipmentSlot enumitemslot = Mob.getEquipmentSlotForItem(itemstack); ++ ++ return !this.getItemBySlot(enumitemslot).isEmpty() ? false : enumitemslot == EquipmentSlot.MAINHAND && super.canTakeItem(itemstack); + } + + public int getUnhappyCounter() { +- return this.entityData.get(UNHAPPY_COUNTER); ++ return (Integer) this.entityData.get(Panda.UNHAPPY_COUNTER); + } + + public void setUnhappyCounter(int unhappyCounter) { +- this.entityData.set(UNHAPPY_COUNTER, unhappyCounter); ++ this.entityData.set(Panda.UNHAPPY_COUNTER, unhappyCounter); + } + + public boolean isSneezing() { +@@ -138,19 +150,19 @@ + } + + public boolean isEating() { +- return this.entityData.get(EAT_COUNTER) > 0; ++ return (Integer) this.entityData.get(Panda.EAT_COUNTER) > 0; + } + + public void eat(boolean eating) { +- this.entityData.set(EAT_COUNTER, eating ? 1 : 0); ++ this.entityData.set(Panda.EAT_COUNTER, eating ? 1 : 0); + } + + private int getEatCounter() { +- return this.entityData.get(EAT_COUNTER); ++ return (Integer) this.entityData.get(Panda.EAT_COUNTER); + } + + private void setEatCounter(int eatCounter) { +- this.entityData.set(EAT_COUNTER, eatCounter); ++ this.entityData.set(Panda.EAT_COUNTER, eatCounter); + } + + public void sneeze(boolean sneezing) { +@@ -158,18 +170,19 @@ + if (!sneezing) { + this.setSneezeCounter(0); + } ++ + } + + public int getSneezeCounter() { +- return this.entityData.get(SNEEZE_COUNTER); ++ return (Integer) this.entityData.get(Panda.SNEEZE_COUNTER); + } + + public void setSneezeCounter(int sneezeCounter) { +- this.entityData.set(SNEEZE_COUNTER, sneezeCounter); ++ this.entityData.set(Panda.SNEEZE_COUNTER, sneezeCounter); + } + + public Panda.Gene getMainGene() { +- return Panda.Gene.byId(this.entityData.get(MAIN_GENE_ID)); ++ return Panda.Gene.byId((Byte) this.entityData.get(Panda.MAIN_GENE_ID)); + } + + public void setMainGene(Panda.Gene pandaType) { +@@ -177,11 +190,11 @@ + pandaType = Panda.Gene.getRandom(this.random); + } + +- this.entityData.set(MAIN_GENE_ID, (byte)pandaType.getId()); ++ this.entityData.set(Panda.MAIN_GENE_ID, (byte) pandaType.getId()); + } + + public Panda.Gene getHiddenGene() { +- return Panda.Gene.byId(this.entityData.get(HIDDEN_GENE_ID)); ++ return Panda.Gene.byId((Byte) this.entityData.get(Panda.HIDDEN_GENE_ID)); + } + + public void setHiddenGene(Panda.Gene pandaType) { +@@ -189,7 +202,7 @@ + pandaType = Panda.Gene.getRandom(this.random); + } + +- this.entityData.set(HIDDEN_GENE_ID, (byte)pandaType.getId()); ++ this.entityData.set(Panda.HIDDEN_GENE_ID, (byte) pandaType.getId()); + } + + public boolean isRolling() { +@@ -203,25 +216,27 @@ + @Override + protected void defineSynchedData() { + super.defineSynchedData(); +- this.entityData.define(UNHAPPY_COUNTER, 0); +- this.entityData.define(SNEEZE_COUNTER, 0); +- this.entityData.define(MAIN_GENE_ID, (byte)0); +- this.entityData.define(HIDDEN_GENE_ID, (byte)0); +- this.entityData.define(DATA_ID_FLAGS, (byte)0); +- this.entityData.define(EAT_COUNTER, 0); ++ this.entityData.define(Panda.UNHAPPY_COUNTER, 0); ++ this.entityData.define(Panda.SNEEZE_COUNTER, 0); ++ this.entityData.define(Panda.MAIN_GENE_ID, (byte) 0); ++ this.entityData.define(Panda.HIDDEN_GENE_ID, (byte) 0); ++ this.entityData.define(Panda.DATA_ID_FLAGS, (byte) 0); ++ this.entityData.define(Panda.EAT_COUNTER, 0); + } + + private boolean getFlag(int flag) { +- return (this.entityData.get(DATA_ID_FLAGS) & flag) != 0; ++ return ((Byte) this.entityData.get(Panda.DATA_ID_FLAGS) & flag) != 0; + } + + private void setFlag(int flagId, boolean value) { +- byte b = this.entityData.get(DATA_ID_FLAGS); ++ byte b0 = (Byte) this.entityData.get(Panda.DATA_ID_FLAGS); ++ + if (value) { +- this.entityData.set(DATA_ID_FLAGS, (byte)(b | flagId)); ++ this.entityData.set(Panda.DATA_ID_FLAGS, (byte) (b0 | flagId)); + } else { +- this.entityData.set(DATA_ID_FLAGS, (byte)(b & ~flagId)); ++ this.entityData.set(Panda.DATA_ID_FLAGS, (byte) (b0 & ~flagId)); + } ++ + } + + @Override +@@ -241,27 +256,30 @@ + @Nullable + @Override + public AgeableMob getBreedOffspring(ServerLevel level, AgeableMob otherParent) { +- Panda panda = EntityType.PANDA.create(level); +- if (panda != null) { +- if (otherParent instanceof Panda panda1) { +- panda.setGeneFromParents(this, panda1); ++ Panda entitypanda = (Panda) EntityType.PANDA.create(level); ++ ++ if (entitypanda != null) { ++ if (otherParent instanceof Panda) { ++ Panda entitypanda1 = (Panda) otherParent; ++ ++ entitypanda.setGeneFromParents(this, entitypanda1); + } + +- panda.setAttributes(); ++ entitypanda.setAttributes(); + } + +- return panda; ++ return entitypanda; + } + + @Override + protected void registerGoals() { + this.goalSelector.addGoal(0, new FloatGoal(this)); +- this.goalSelector.addGoal(2, new Panda.PandaPanicGoal(this, 2.0)); +- this.goalSelector.addGoal(2, new Panda.PandaBreedGoal(this, 1.0)); +- this.goalSelector.addGoal(3, new Panda.PandaAttackGoal(this, 1.2F, true)); +- this.goalSelector.addGoal(4, new TemptGoal(this, 1.0, Ingredient.of(Blocks.BAMBOO.asItem()), false)); +- this.goalSelector.addGoal(6, new Panda.PandaAvoidGoal<>(this, Player.class, 8.0F, 2.0, 2.0)); +- this.goalSelector.addGoal(6, new Panda.PandaAvoidGoal<>(this, Monster.class, 4.0F, 2.0, 2.0)); ++ this.goalSelector.addGoal(2, new Panda.PandaPanicGoal(this, 2.0D)); ++ this.goalSelector.addGoal(2, new Panda.PandaBreedGoal(this, 1.0D)); ++ this.goalSelector.addGoal(3, new Panda.PandaAttackGoal(this, 1.2000000476837158D, true)); ++ this.goalSelector.addGoal(4, new TemptGoal(this, 1.0D, Ingredient.of(Blocks.BAMBOO.asItem()), false)); ++ this.goalSelector.addGoal(6, new Panda.PandaAvoidGoal<>(this, Player.class, 8.0F, 2.0D, 2.0D)); ++ this.goalSelector.addGoal(6, new Panda.PandaAvoidGoal<>(this, Monster.class, 4.0F, 2.0D, 2.0D)); + this.goalSelector.addGoal(7, new Panda.PandaSitGoal()); + this.goalSelector.addGoal(8, new Panda.PandaLieOnBackGoal(this)); + this.goalSelector.addGoal(8, new Panda.PandaSneezeGoal(this)); +@@ -269,13 +287,13 @@ + this.goalSelector.addGoal(9, this.lookAtPlayerGoal); + this.goalSelector.addGoal(10, new RandomLookAroundGoal(this)); + this.goalSelector.addGoal(12, new Panda.PandaRollGoal(this)); +- this.goalSelector.addGoal(13, new FollowParentGoal(this, 1.25)); +- this.goalSelector.addGoal(14, new WaterAvoidingRandomStrollGoal(this, 1.0)); +- this.targetSelector.addGoal(1, new Panda.PandaHurtByTargetGoal(this).setAlertOthers(new Class[0])); ++ this.goalSelector.addGoal(13, new FollowParentGoal(this, 1.25D)); ++ this.goalSelector.addGoal(14, new WaterAvoidingRandomStrollGoal(this, 1.0D)); ++ this.targetSelector.addGoal(1, (new Panda.PandaHurtByTargetGoal(this, new Class[0])).setAlertOthers(new Class[0])); + } + + public static AttributeSupplier.Builder createAttributes() { +- return Mob.createMobAttributes().add(Attributes.MOVEMENT_SPEED, 0.15F).add(Attributes.ATTACK_DAMAGE, 6.0); ++ return Mob.createMobAttributes().add(Attributes.MOVEMENT_SPEED, 0.15000000596046448D).add(Attributes.ATTACK_DAMAGE, 6.0D); + } + + public Panda.Gene getVariant() { +@@ -334,15 +352,16 @@ + } + } + +- LivingEntity target = this.getTarget(); +- if (target == null) { ++ LivingEntity entityliving = this.getTarget(); ++ ++ if (entityliving == null) { + this.gotBamboo = false; + this.didBite = false; + } + + if (this.getUnhappyCounter() > 0) { +- if (target != null) { +- this.lookAt(target, 90.0F, 90.0F); ++ if (entityliving != null) { ++ this.lookAt(entityliving, 90.0F, 90.0F); + } + + if (this.getUnhappyCounter() == 29 || this.getUnhappyCounter() == 14) { +@@ -407,34 +426,27 @@ + + this.setEatCounter(this.getEatCounter() + 1); + } ++ + } + + private void addEatingParticles() { + if (this.getEatCounter() % 5 == 0) { +- this.playSound( +- SoundEvents.PANDA_EAT, 0.5F + 0.5F * (float)this.random.nextInt(2), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F +- ); ++ this.playSound(SoundEvents.PANDA_EAT, 0.5F + 0.5F * (float) this.random.nextInt(2), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + +- for (int i = 0; i < 6; i++) { +- Vec3 vec3 = new Vec3(((double)this.random.nextFloat() - 0.5) * 0.1, Math.random() * 0.1 + 0.1, ((double)this.random.nextFloat() - 0.5) * 0.1); +- vec3 = vec3.xRot(-this.getXRot() * (float) (Math.PI / 180.0)); +- vec3 = vec3.yRot(-this.getYRot() * (float) (Math.PI / 180.0)); +- double d = (double)(-this.random.nextFloat()) * 0.6 - 0.3; +- Vec3 vec31 = new Vec3(((double)this.random.nextFloat() - 0.5) * 0.8, d, 1.0 + ((double)this.random.nextFloat() - 0.5) * 0.4); +- vec31 = vec31.yRot(-this.yBodyRot * (float) (Math.PI / 180.0)); +- vec31 = vec31.add(this.getX(), this.getEyeY() + 1.0, this.getZ()); +- this.level() +- .addParticle( +- new ItemParticleOption(ParticleTypes.ITEM, this.getItemBySlot(EquipmentSlot.MAINHAND)), +- vec31.x, +- vec31.y, +- vec31.z, +- vec3.x, +- vec3.y + 0.05, +- vec3.z +- ); ++ for (int i = 0; i < 6; ++i) { ++ Vec3 vec3d = new Vec3(((double) this.random.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, ((double) this.random.nextFloat() - 0.5D) * 0.1D); ++ ++ vec3d = vec3d.xRot(-this.getXRot() * 0.017453292F); ++ vec3d = vec3d.yRot(-this.getYRot() * 0.017453292F); ++ double d0 = (double) (-this.random.nextFloat()) * 0.6D - 0.3D; ++ Vec3 vec3d1 = new Vec3(((double) this.random.nextFloat() - 0.5D) * 0.8D, d0, 1.0D + ((double) this.random.nextFloat() - 0.5D) * 0.4D); ++ ++ vec3d1 = vec3d1.yRot(-this.yBodyRot * 0.017453292F); ++ vec3d1 = vec3d1.add(this.getX(), this.getEyeY() + 1.0D, this.getZ()); ++ this.level().addParticle(new ItemParticleOption(ParticleTypes.ITEM, this.getItemBySlot(EquipmentSlot.MAINHAND)), vec3d1.x, vec3d1.y, vec3d1.z, vec3d.x, vec3d.y + 0.05D, vec3d.z); + } + } ++ + } + + private void updateSitAmount() { +@@ -444,6 +456,7 @@ + } else { + this.sitAmount = Math.max(0.0F, this.sitAmount - 0.19F); + } ++ + } + + private void updateOnBackAnimation() { +@@ -453,6 +466,7 @@ + } else { + this.onBackAmount = Math.max(0.0F, this.onBackAmount - 0.19F); + } ++ + } + + private void updateRollAmount() { +@@ -462,6 +476,7 @@ + } else { + this.rollAmount = Math.max(0.0F, this.rollAmount - 0.19F); + } ++ + } + + public float getSitAmount(float partialTick) { +@@ -477,61 +492,63 @@ + } + + private void handleRoll() { +- this.rollCounter++; ++ ++this.rollCounter; + if (this.rollCounter > 32) { + this.roll(false); + } else { + if (!this.level().isClientSide) { +- Vec3 deltaMovement = this.getDeltaMovement(); ++ Vec3 vec3d = this.getDeltaMovement(); ++ + if (this.rollCounter == 1) { +- float f = this.getYRot() * (float) (Math.PI / 180.0); ++ float f = this.getYRot() * 0.017453292F; + float f1 = this.isBaby() ? 0.1F : 0.2F; +- this.rollDelta = new Vec3(deltaMovement.x + (double)(-Mth.sin(f) * f1), 0.0, deltaMovement.z + (double)(Mth.cos(f) * f1)); +- this.setDeltaMovement(this.rollDelta.add(0.0, 0.27, 0.0)); +- } else if ((float)this.rollCounter != 7.0F && (float)this.rollCounter != 15.0F && (float)this.rollCounter != 23.0F) { +- this.setDeltaMovement(this.rollDelta.x, deltaMovement.y, this.rollDelta.z); ++ ++ this.rollDelta = new Vec3(vec3d.x + (double) (-Mth.sin(f) * f1), 0.0D, vec3d.z + (double) (Mth.cos(f) * f1)); ++ this.setDeltaMovement(this.rollDelta.add(0.0D, 0.27D, 0.0D)); ++ } else if ((float) this.rollCounter != 7.0F && (float) this.rollCounter != 15.0F && (float) this.rollCounter != 23.0F) { ++ this.setDeltaMovement(this.rollDelta.x, vec3d.y, this.rollDelta.z); + } else { +- this.setDeltaMovement(0.0, this.onGround() ? 0.27 : deltaMovement.y, 0.0); ++ this.setDeltaMovement(0.0D, this.onGround() ? 0.27D : vec3d.y, 0.0D); + } + } ++ + } + } + + private void afterSneeze() { +- Vec3 deltaMovement = this.getDeltaMovement(); +- this.level() +- .addParticle( +- ParticleTypes.SNEEZE, +- this.getX() - (double)(this.getBbWidth() + 1.0F) * 0.5 * (double)Mth.sin(this.yBodyRot * (float) (Math.PI / 180.0)), +- this.getEyeY() - 0.1F, +- this.getZ() + (double)(this.getBbWidth() + 1.0F) * 0.5 * (double)Mth.cos(this.yBodyRot * (float) (Math.PI / 180.0)), +- deltaMovement.x, +- 0.0, +- deltaMovement.z +- ); ++ Vec3 vec3d = this.getDeltaMovement(); ++ ++ this.level().addParticle(ParticleTypes.SNEEZE, this.getX() - (double) (this.getBbWidth() + 1.0F) * 0.5D * (double) Mth.sin(this.yBodyRot * 0.017453292F), this.getEyeY() - 0.10000000149011612D, this.getZ() + (double) (this.getBbWidth() + 1.0F) * 0.5D * (double) Mth.cos(this.yBodyRot * 0.017453292F), vec3d.x, 0.0D, vec3d.z); + this.playSound(SoundEvents.PANDA_SNEEZE, 1.0F, 1.0F); ++ List<Panda> list = this.level().getEntitiesOfClass(Panda.class, this.getBoundingBox().inflate(10.0D)); ++ Iterator iterator = list.iterator(); + +- for (Panda panda : this.level().getEntitiesOfClass(Panda.class, this.getBoundingBox().inflate(10.0))) { +- if (!panda.isBaby() && panda.onGround() && !panda.isInWater() && panda.canPerformAction()) { +- panda.jumpFromGround(); ++ while (iterator.hasNext()) { ++ Panda entitypanda = (Panda) iterator.next(); ++ ++ if (!entitypanda.isBaby() && entitypanda.onGround() && !entitypanda.isInWater() && entitypanda.canPerformAction()) { ++ entitypanda.jumpFromGround(); + } + } + + if (!this.level().isClientSide() && this.random.nextInt(700) == 0 && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { +- this.spawnAtLocation(Items.SLIME_BALL); ++ this.spawnAtLocation((IMaterial) Items.SLIME_BALL); + } ++ + } + + @Override + protected void pickUpItem(ItemEntity itemEntity) { +- if (this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty() && PANDA_ITEMS.test(itemEntity)) { ++ if (!CraftEventFactory.callEntityPickupItemEvent(this, itemEntity, 0, !(this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty() && Panda.PANDA_ITEMS.test(itemEntity))).isCancelled()) { // CraftBukkit + this.onItemPickup(itemEntity); +- ItemStack item = itemEntity.getItem(); +- this.setItemSlot(EquipmentSlot.MAINHAND, item); ++ ItemStack itemstack = itemEntity.getItem(); ++ ++ this.setItemSlot(EquipmentSlot.MAINHAND, itemstack); + this.setGuaranteedDrop(EquipmentSlot.MAINHAND); +- this.take(itemEntity, item.getCount()); ++ this.take(itemEntity, itemstack.getCount()); + itemEntity.discard(); + } ++ + } + + @Override +@@ -545,18 +562,17 @@ + + @Nullable + @Override +- public SpawnGroupData finalizeSpawn( +- ServerLevelAccessor level, DifficultyInstance difficulty, MobSpawnType reason, @Nullable SpawnGroupData spawnData, @Nullable CompoundTag dataTag +- ) { +- RandomSource random = level.getRandom(); +- this.setMainGene(Panda.Gene.getRandom(random)); +- this.setHiddenGene(Panda.Gene.getRandom(random)); ++ public GroupDataEntity finalizeSpawn(ServerLevelAccessor level, DifficultyInstance difficulty, EnumMobSpawn reason, @Nullable GroupDataEntity spawnData, @Nullable CompoundTag dataTag) { ++ RandomSource randomsource = level.getRandom(); ++ ++ this.setMainGene(Panda.Gene.getRandom(randomsource)); ++ this.setHiddenGene(Panda.Gene.getRandom(randomsource)); + this.setAttributes(); + if (spawnData == null) { + spawnData = new AgeableMob.AgeableMobGroupData(0.2F); + } + +- return super.finalizeSpawn(level, difficulty, reason, spawnData, dataTag); ++ return super.finalizeSpawn(level, difficulty, reason, (GroupDataEntity) spawnData, dataTag); + } + + public void setGeneFromParents(Panda father, @Nullable Panda mother) { +@@ -583,6 +599,7 @@ + if (this.random.nextInt(32) == 0) { + this.setHiddenGene(Panda.Gene.getRandom(this.random)); + } ++ + } + + private Panda.Gene getOneOfGenesRandomly() { +@@ -591,12 +608,13 @@ + + public void setAttributes() { + if (this.isWeak()) { +- this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(10.0); ++ this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(10.0D); + } + + if (this.isLazy()) { +- this.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.07F); ++ this.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.07000000029802322D); + } ++ + } + + void tryToSit() { +@@ -605,26 +623,28 @@ + this.getNavigation().stop(); + this.sit(true); + } ++ + } + + @Override +- public InteractionResult mobInteract(Player player, InteractionHand hand) { +- ItemStack itemInHand = player.getItemInHand(hand); ++ public InteractionResult mobInteract(Player player, EnumHand hand) { ++ ItemStack itemstack = player.getItemInHand(hand); ++ + if (this.isScared()) { + return InteractionResult.PASS; + } else if (this.isOnBack()) { + this.setOnBack(false); + return InteractionResult.sidedSuccess(this.level().isClientSide); +- } else if (this.isFood(itemInHand)) { ++ } else if (this.isFood(itemstack)) { + if (this.getTarget() != null) { + this.gotBamboo = true; + } + + if (this.isBaby()) { +- this.usePlayerItem(player, hand, itemInHand); +- this.ageUp((int)((float)(-this.getAge() / 20) * 0.1F), true); ++ this.usePlayerItem(player, hand, itemstack); ++ this.ageUp((int) ((float) (-this.getAge() / 20) * 0.1F), true); + } else if (!this.level().isClientSide && this.getAge() == 0 && this.canFallInLove()) { +- this.usePlayerItem(player, hand, itemInHand); ++ this.usePlayerItem(player, hand, itemstack); + this.setInLove(player); + } else { + if (this.level().isClientSide || this.isSitting() || this.isInWater()) { +@@ -633,13 +653,14 @@ + + this.tryToSit(); + this.eat(true); +- ItemStack itemBySlot = this.getItemBySlot(EquipmentSlot.MAINHAND); +- if (!itemBySlot.isEmpty() && !player.getAbilities().instabuild) { +- this.spawnAtLocation(itemBySlot); ++ ItemStack itemstack1 = this.getItemBySlot(EquipmentSlot.MAINHAND); ++ ++ if (!itemstack1.isEmpty() && !player.getAbilities().instabuild) { ++ this.spawnAtLocation(itemstack1); + } + +- this.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(itemInHand.getItem(), 1)); +- this.usePlayerItem(player, hand, itemInHand); ++ this.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(itemstack.getItem(), 1)); ++ this.usePlayerItem(player, hand, itemstack); + } + + return InteractionResult.SUCCESS; +@@ -651,15 +672,11 @@ + @Nullable + @Override + protected SoundEvent getAmbientSound() { +- if (this.isAggressive()) { +- return SoundEvents.PANDA_AGGRESSIVE_AMBIENT; +- } else { +- return this.isWorried() ? SoundEvents.PANDA_WORRIED_AMBIENT : SoundEvents.PANDA_AMBIENT; +- } ++ return this.isAggressive() ? SoundEvents.PANDA_AGGRESSIVE_AMBIENT : (this.isWorried() ? SoundEvents.PANDA_WORRIED_AMBIENT : SoundEvents.PANDA_AMBIENT); + } + + @Override +- protected void playStepSound(BlockPos pos, BlockState block) { ++ protected void playStepSound(BlockPos pos, IBlockData block) { + this.playSound(SoundEvents.PANDA_STEP, 0.15F, 1.0F); + } + +@@ -689,30 +706,42 @@ + } + + @Override +- protected Vector3f getPassengerAttachmentPoint(Entity entity, EntityDimensions entityDimensions, float f) { +- return new Vector3f(0.0F, entityDimensions.height - (this.isBaby() ? 0.4375F : 0.0F) * f, 0.0F); ++ protected Vector3f getPassengerAttachmentPoint(Entity entity, EntityDimensions entitysize, float f) { ++ return new Vector3f(0.0F, entitysize.height - (this.isBaby() ? 0.4375F : 0.0F) * f, 0.0F); + } + ++ private static class PandaMoveControl extends MoveControl { ++ ++ private final Panda panda; ++ ++ public PandaMoveControl(Panda panda) { ++ super(panda); ++ this.panda = panda; ++ } ++ ++ @Override ++ public void tick() { ++ if (this.panda.canPerformAction()) { ++ super.tick(); ++ } ++ } ++ } ++ + public static enum Gene implements StringRepresentable { +- NORMAL(0, "normal", false), +- LAZY(1, "lazy", false), +- WORRIED(2, "worried", false), +- PLAYFUL(3, "playful", false), +- BROWN(4, "brown", true), +- WEAK(5, "weak", true), +- AGGRESSIVE(6, "aggressive", false); + ++ NORMAL(0, "normal", false), LAZY(1, "lazy", false), WORRIED(2, "worried", false), PLAYFUL(3, "playful", false), BROWN(4, "brown", true), WEAK(5, "weak", true), AGGRESSIVE(6, "aggressive", false); ++ + public static final StringRepresentable.EnumCodec<Panda.Gene> CODEC = StringRepresentable.fromEnum(Panda.Gene::values); +- private static final IntFunction<Panda.Gene> BY_ID = ByIdMap.continuous(Panda.Gene::getId, values(), ByIdMap.OutOfBoundsStrategy.ZERO); ++ private static final IntFunction<Panda.Gene> BY_ID = ByIdMap.continuous(Panda.Gene::getId, values(), ByIdMap.a.ZERO); + private static final int MAX_GENE = 6; + private final int id; + private final String name; + private final boolean isRecessive; + +- private Gene(int id, String name, boolean isRecessive) { +- this.id = id; +- this.name = name; +- this.isRecessive = isRecessive; ++ private Gene(int i, String s, boolean flag) { ++ this.id = i; ++ this.name = s; ++ this.isRecessive = flag; + } + + public int getId() { +@@ -729,68 +758,51 @@ + } + + static Panda.Gene getVariantFromGenes(Panda.Gene mainGene, Panda.Gene hiddenGene) { +- if (mainGene.isRecessive()) { +- return mainGene == hiddenGene ? mainGene : NORMAL; +- } else { +- return mainGene; +- } ++ return mainGene.isRecessive() ? (mainGene == hiddenGene ? mainGene : Panda.Gene.NORMAL) : mainGene; + } + + public static Panda.Gene byId(int index) { +- return BY_ID.apply(index); ++ return (Panda.Gene) Panda.Gene.BY_ID.apply(index); + } + + public static Panda.Gene byName(String name) { +- return CODEC.byName(name, NORMAL); ++ return (Panda.Gene) Panda.Gene.CODEC.byName(name, Panda.Gene.NORMAL); + } + + public static Panda.Gene getRandom(RandomSource random) { +- int randomInt = random.nextInt(16); +- if (randomInt == 0) { +- return LAZY; +- } else if (randomInt == 1) { +- return WORRIED; +- } else if (randomInt == 2) { +- return PLAYFUL; +- } else if (randomInt == 4) { +- return AGGRESSIVE; +- } else if (randomInt < 9) { +- return WEAK; +- } else { +- return randomInt < 11 ? BROWN : NORMAL; +- } ++ int i = random.nextInt(16); ++ ++ return i == 0 ? Panda.Gene.LAZY : (i == 1 ? Panda.Gene.WORRIED : (i == 2 ? Panda.Gene.PLAYFUL : (i == 4 ? Panda.Gene.AGGRESSIVE : (i < 9 ? Panda.Gene.WEAK : (i < 11 ? Panda.Gene.BROWN : Panda.Gene.NORMAL))))); + } + } + +- static class PandaAttackGoal extends MeleeAttackGoal { ++ private static class PandaPanicGoal extends PanicGoal { ++ + private final Panda panda; + +- public PandaAttackGoal(Panda panda, double speedModifier, boolean followingTargetEvenIfNotSeen) { +- super(panda, speedModifier, followingTargetEvenIfNotSeen); ++ public PandaPanicGoal(Panda panda, double speedModifier) { ++ super(panda, speedModifier); + this.panda = panda; + } + + @Override +- public boolean canUse() { +- return this.panda.canPerformAction() && super.canUse(); ++ protected boolean shouldPanic() { ++ return this.mob.isFreezing() || this.mob.isOnFire(); + } +- } + +- static class PandaAvoidGoal<T extends LivingEntity> extends AvoidEntityGoal<T> { +- private final Panda panda; +- +- public PandaAvoidGoal(Panda panda, Class<T> entityClassToAvoid, float maxDist, double walkSpeedModifier, double sprintSpeedModifier) { +- super(panda, entityClassToAvoid, maxDist, walkSpeedModifier, sprintSpeedModifier, EntitySelector.NO_SPECTATORS::test); +- this.panda = panda; +- } +- + @Override +- public boolean canUse() { +- return this.panda.isWorried() && this.panda.canPerformAction() && super.canUse(); ++ public boolean canContinueToUse() { ++ if (this.panda.isSitting()) { ++ this.panda.getNavigation().stop(); ++ return false; ++ } else { ++ return super.canContinueToUse(); ++ } + } + } + +- static class PandaBreedGoal extends BreedGoal { ++ private static class PandaBreedGoal extends BreedGoal { ++ + private final Panda panda; + private int unhappyCooldown; + +@@ -801,34 +813,37 @@ + + @Override + public boolean canUse() { +- if (!super.canUse() || this.panda.getUnhappyCounter() != 0) { +- return false; +- } else if (!this.canFindBamboo()) { +- if (this.unhappyCooldown <= this.panda.tickCount) { +- this.panda.setUnhappyCounter(32); +- this.unhappyCooldown = this.panda.tickCount + 600; +- if (this.panda.isEffectiveAi()) { +- Player nearestPlayer = this.level.getNearestPlayer(Panda.BREED_TARGETING, this.panda); +- this.panda.lookAtPlayerGoal.setTarget(nearestPlayer); ++ if (super.canUse() && this.panda.getUnhappyCounter() == 0) { ++ if (!this.canFindBamboo()) { ++ if (this.unhappyCooldown <= this.panda.tickCount) { ++ this.panda.setUnhappyCounter(32); ++ this.unhappyCooldown = this.panda.tickCount + 600; ++ if (this.panda.isEffectiveAi()) { ++ Player entityhuman = this.level.getNearestPlayer(Panda.BREED_TARGETING, this.panda); ++ ++ this.panda.lookAtPlayerGoal.setTarget(entityhuman); ++ } + } +- } + +- return false; ++ return false; ++ } else { ++ return true; ++ } + } else { +- return true; ++ return false; + } + } + + private boolean canFindBamboo() { +- BlockPos blockPos = this.panda.blockPosition(); +- BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); ++ BlockPos blockposition = this.panda.blockPosition(); ++ BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); + +- for (int i = 0; i < 3; i++) { +- for (int i1 = 0; i1 < 8; i1++) { +- for (int i2 = 0; i2 <= i1; i2 = i2 > 0 ? -i2 : 1 - i2) { +- for (int i3 = i2 < i1 && i2 > -i1 ? i1 : 0; i3 <= i1; i3 = i3 > 0 ? -i3 : 1 - i3) { +- mutableBlockPos.setWithOffset(blockPos, i2, i, i3); +- if (this.level.getBlockState(mutableBlockPos).is(Blocks.BAMBOO)) { ++ for (int i = 0; i < 3; ++i) { ++ for (int j = 0; j < 8; ++j) { ++ for (int k = 0; k <= j; k = k > 0 ? -k : 1 - k) { ++ for (int l = k < j && k > -j ? j : 0; l <= j; l = l > 0 ? -l : 1 - l) { ++ blockposition_mutableblockposition.setWithOffset(blockposition, k, i, l); ++ if (this.level.getBlockState(blockposition_mutableblockposition).is(Blocks.BAMBOO)) { + return true; + } + } +@@ -840,33 +855,102 @@ + } + } + +- static class PandaHurtByTargetGoal extends HurtByTargetGoal { ++ private static class PandaAttackGoal extends MeleeAttackGoal { ++ + private final Panda panda; + +- public PandaHurtByTargetGoal(Panda panda, Class<?>... entityClassToIgnoreDamage) { +- super(panda, entityClassToIgnoreDamage); ++ public PandaAttackGoal(Panda panda, double speedModifier, boolean flag) { ++ super(panda, speedModifier, flag); + this.panda = panda; + } + + @Override +- public boolean canContinueToUse() { +- if (!this.panda.gotBamboo && !this.panda.didBite) { +- return super.canContinueToUse(); ++ public boolean canUse() { ++ return this.panda.canPerformAction() && super.canUse(); ++ } ++ } ++ ++ private static class PandaAvoidGoal<T extends LivingEntity> extends AvoidEntityGoal<T> { ++ ++ private final Panda panda; ++ ++ public PandaAvoidGoal(Panda panda, Class<T> entityClassToAvoid, float maxDist, double walkSpeedModifier, double d1) { ++ // Predicate predicate = IEntitySelector.NO_SPECTATORS; ++ ++ // Objects.requireNonNull(predicate); ++ super(panda, entityClassToAvoid, maxDist, walkSpeedModifier, d1, EntitySelector.NO_SPECTATORS::test); ++ this.panda = panda; ++ } ++ ++ @Override ++ public boolean canUse() { ++ return this.panda.isWorried() && this.panda.canPerformAction() && super.canUse(); ++ } ++ } ++ ++ private class PandaSitGoal extends Goal { ++ ++ private int cooldown; ++ ++ public PandaSitGoal() { ++ this.setFlags(EnumSet.of(Goal.Type.MOVE)); ++ } ++ ++ @Override ++ public boolean canUse() { ++ if (this.cooldown <= Panda.this.tickCount && !Panda.this.isBaby() && !Panda.this.isInWater() && Panda.this.canPerformAction() && Panda.this.getUnhappyCounter() <= 0) { ++ List<ItemEntity> list = Panda.this.level().getEntitiesOfClass(ItemEntity.class, Panda.this.getBoundingBox().inflate(6.0D, 6.0D, 6.0D), Panda.PANDA_ITEMS); ++ ++ return !list.isEmpty() || !Panda.this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty(); + } else { +- this.panda.setTarget(null); + return false; + } + } + + @Override +- protected void alertOther(Mob mob, LivingEntity target) { +- if (mob instanceof Panda && mob.isAggressive()) { +- mob.setTarget(target); ++ public boolean canContinueToUse() { ++ return !Panda.this.isInWater() && (Panda.this.isLazy() || Panda.this.random.nextInt(reducedTickDelay(600)) != 1) ? Panda.this.random.nextInt(reducedTickDelay(2000)) != 1 : false; ++ } ++ ++ @Override ++ public void tick() { ++ if (!Panda.this.isSitting() && !Panda.this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty()) { ++ Panda.this.tryToSit(); + } ++ + } ++ ++ @Override ++ public void start() { ++ List<ItemEntity> list = Panda.this.level().getEntitiesOfClass(ItemEntity.class, Panda.this.getBoundingBox().inflate(8.0D, 8.0D, 8.0D), Panda.PANDA_ITEMS); ++ ++ if (!list.isEmpty() && Panda.this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty()) { ++ Panda.this.getNavigation().moveTo((Entity) list.get(0), 1.2000000476837158D); ++ } else if (!Panda.this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty()) { ++ Panda.this.tryToSit(); ++ } ++ ++ this.cooldown = 0; ++ } ++ ++ @Override ++ public void stop() { ++ ItemStack itemstack = Panda.this.getItemBySlot(EquipmentSlot.MAINHAND); ++ ++ if (!itemstack.isEmpty()) { ++ Panda.this.spawnAtLocation(itemstack); ++ Panda.this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY); ++ int i = Panda.this.isLazy() ? Panda.this.random.nextInt(50) + 10 : Panda.this.random.nextInt(150) + 10; ++ ++ this.cooldown = Panda.this.tickCount + i * 20; ++ } ++ ++ Panda.this.sit(false); ++ } + } + +- static class PandaLieOnBackGoal extends Goal { ++ private static class PandaLieOnBackGoal extends Goal { ++ + private final Panda panda; + private int cooldown; + +@@ -876,17 +960,12 @@ + + @Override + public boolean canUse() { +- return this.cooldown < this.panda.tickCount +- && this.panda.isLazy() +- && this.panda.canPerformAction() +- && this.panda.random.nextInt(reducedTickDelay(400)) == 1; ++ return this.cooldown < this.panda.tickCount && this.panda.isLazy() && this.panda.canPerformAction() && this.panda.random.nextInt(reducedTickDelay(400)) == 1; + } + + @Override + public boolean canContinueToUse() { +- return !this.panda.isInWater() +- && (this.panda.isLazy() || this.panda.random.nextInt(reducedTickDelay(600)) != 1) +- && this.panda.random.nextInt(reducedTickDelay(2000)) != 1; ++ return !this.panda.isInWater() && (this.panda.isLazy() || this.panda.random.nextInt(reducedTickDelay(600)) != 1) ? this.panda.random.nextInt(reducedTickDelay(2000)) != 1 : false; + } + + @Override +@@ -902,9 +981,34 @@ + } + } + +- static class PandaLookAtPlayerGoal extends LookAtPlayerGoal { ++ private static class PandaSneezeGoal extends Goal { ++ + private final Panda panda; + ++ public PandaSneezeGoal(Panda panda) { ++ this.panda = panda; ++ } ++ ++ @Override ++ public boolean canUse() { ++ return this.panda.isBaby() && this.panda.canPerformAction() ? (this.panda.isWeak() && this.panda.random.nextInt(reducedTickDelay(500)) == 1 ? true : this.panda.random.nextInt(reducedTickDelay(6000)) == 1) : false; ++ } ++ ++ @Override ++ public boolean canContinueToUse() { ++ return false; ++ } ++ ++ @Override ++ public void start() { ++ this.panda.sneeze(true); ++ } ++ } ++ ++ private static class PandaLookAtPlayerGoal extends LookAtPlayerGoal { ++ ++ private final Panda panda; ++ + public PandaLookAtPlayerGoal(Panda panda, Class<? extends LivingEntity> lookAtType, float lookDistance) { + super(panda, lookAtType, lookDistance); + this.panda = panda; +@@ -928,22 +1032,9 @@ + if (this.lookAtType == Player.class) { + this.lookAt = this.mob.level().getNearestPlayer(this.lookAtContext, this.mob, this.mob.getX(), this.mob.getEyeY(), this.mob.getZ()); + } else { +- this.lookAt = this.mob +- .level() +- .getNearestEntity( +- this.mob +- .level() +- .getEntitiesOfClass( +- this.lookAtType, +- this.mob.getBoundingBox().inflate((double)this.lookDistance, 3.0, (double)this.lookDistance), +- livingEntity -> true +- ), +- this.lookAtContext, +- this.mob, +- this.mob.getX(), +- this.mob.getEyeY(), +- this.mob.getZ() +- ); ++ this.lookAt = this.mob.level().getNearestEntity(this.mob.level().getEntitiesOfClass(this.lookAtType, this.mob.getBoundingBox().inflate((double) this.lookDistance, 3.0D, (double) this.lookDistance), (entityliving) -> { ++ return true; ++ }), this.lookAtContext, this.mob, this.mob.getX(), this.mob.getEyeY(), this.mob.getZ()); + } + } + +@@ -956,55 +1047,17 @@ + if (this.lookAt != null) { + super.tick(); + } +- } +- } + +- static class PandaMoveControl extends MoveControl { +- private final Panda panda; +- +- public PandaMoveControl(Panda mob) { +- super(mob); +- this.panda = mob; + } +- +- @Override +- public void tick() { +- if (this.panda.canPerformAction()) { +- super.tick(); +- } +- } + } + +- static class PandaPanicGoal extends PanicGoal { +- private final Panda panda; ++ private static class PandaRollGoal extends Goal { + +- public PandaPanicGoal(Panda panda, double speedModifier) { +- super(panda, speedModifier); +- this.panda = panda; +- } +- +- @Override +- protected boolean shouldPanic() { +- return this.mob.isFreezing() || this.mob.isOnFire(); +- } +- +- @Override +- public boolean canContinueToUse() { +- if (this.panda.isSitting()) { +- this.panda.getNavigation().stop(); +- return false; +- } else { +- return super.canContinueToUse(); +- } +- } +- } +- +- static class PandaRollGoal extends Goal { + private final Panda panda; + + public PandaRollGoal(Panda panda) { + this.panda = panda; +- this.setFlags(EnumSet.of(Goal.Flag.MOVE, Goal.Flag.LOOK, Goal.Flag.JUMP)); ++ this.setFlags(EnumSet.of(Goal.Type.MOVE, Goal.Type.LOOK, Goal.Type.JUMP)); + } + + @Override +@@ -1013,14 +1066,13 @@ + if (!this.panda.canPerformAction()) { + return false; + } else { +- float f = this.panda.getYRot() * (float) (Math.PI / 180.0); ++ float f = this.panda.getYRot() * 0.017453292F; + float f1 = -Mth.sin(f); +- float cos = Mth.cos(f); +- int i = (double)Math.abs(f1) > 0.5 ? Mth.sign((double)f1) : 0; +- int i1 = (double)Math.abs(cos) > 0.5 ? Mth.sign((double)cos) : 0; +- return this.panda.level().getBlockState(this.panda.blockPosition().offset(i, -1, i1)).isAir() +- || this.panda.isPlayful() && this.panda.random.nextInt(reducedTickDelay(60)) == 1 +- || this.panda.random.nextInt(reducedTickDelay(500)) == 1; ++ float f2 = Mth.cos(f); ++ int i = (double) Math.abs(f1) > 0.5D ? Mth.sign((double) f1) : 0; ++ int j = (double) Math.abs(f2) > 0.5D ? Mth.sign((double) f2) : 0; ++ ++ return this.panda.level().getBlockState(this.panda.blockPosition().offset(i, -1, j)).isAir() ? true : (this.panda.isPlayful() && this.panda.random.nextInt(reducedTickDelay(60)) == 1 ? true : this.panda.random.nextInt(reducedTickDelay(500)) == 1); + } + } else { + return false; +@@ -1043,91 +1095,31 @@ + } + } + +- class PandaSitGoal extends Goal { +- private int cooldown; ++ private static class PandaHurtByTargetGoal extends HurtByTargetGoal { + +- public PandaSitGoal() { +- this.setFlags(EnumSet.of(Goal.Flag.MOVE)); ++ private final Panda panda; ++ ++ public PandaHurtByTargetGoal(Panda panda, Class<?>... entityClassToIgnoreDamage) { ++ super(panda, entityClassToIgnoreDamage); ++ this.panda = panda; + } + + @Override +- public boolean canUse() { +- if (this.cooldown <= Panda.this.tickCount +- && !Panda.this.isBaby() +- && !Panda.this.isInWater() +- && Panda.this.canPerformAction() +- && Panda.this.getUnhappyCounter() <= 0) { +- List<ItemEntity> entitiesOfClass = Panda.this.level() +- .getEntitiesOfClass(ItemEntity.class, Panda.this.getBoundingBox().inflate(6.0, 6.0, 6.0), Panda.PANDA_ITEMS); +- return !entitiesOfClass.isEmpty() || !Panda.this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty(); ++ public boolean canContinueToUse() { ++ if (!this.panda.gotBamboo && !this.panda.didBite) { ++ return super.canContinueToUse(); + } else { ++ this.panda.setTarget((LivingEntity) null); + return false; + } + } + + @Override +- public boolean canContinueToUse() { +- return !Panda.this.isInWater() +- && (Panda.this.isLazy() || Panda.this.random.nextInt(reducedTickDelay(600)) != 1) +- && Panda.this.random.nextInt(reducedTickDelay(2000)) != 1; +- } +- +- @Override +- public void tick() { +- if (!Panda.this.isSitting() && !Panda.this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty()) { +- Panda.this.tryToSit(); ++ protected void alertOther(Mob mob, LivingEntity target) { ++ if (mob instanceof Panda && mob.isAggressive()) { ++ mob.setTarget(target, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit + } +- } + +- @Override +- public void start() { +- List<ItemEntity> entitiesOfClass = Panda.this.level() +- .getEntitiesOfClass(ItemEntity.class, Panda.this.getBoundingBox().inflate(8.0, 8.0, 8.0), Panda.PANDA_ITEMS); +- if (!entitiesOfClass.isEmpty() && Panda.this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty()) { +- Panda.this.getNavigation().moveTo(entitiesOfClass.get(0), 1.2F); +- } else if (!Panda.this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty()) { +- Panda.this.tryToSit(); +- } +- +- this.cooldown = 0; + } +- +- @Override +- public void stop() { +- ItemStack itemBySlot = Panda.this.getItemBySlot(EquipmentSlot.MAINHAND); +- if (!itemBySlot.isEmpty()) { +- Panda.this.spawnAtLocation(itemBySlot); +- Panda.this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY); +- int i = Panda.this.isLazy() ? Panda.this.random.nextInt(50) + 10 : Panda.this.random.nextInt(150) + 10; +- this.cooldown = Panda.this.tickCount + i * 20; +- } +- +- Panda.this.sit(false); +- } + } +- +- static class PandaSneezeGoal extends Goal { +- private final Panda panda; +- +- public PandaSneezeGoal(Panda panda) { +- this.panda = panda; +- } +- +- @Override +- public boolean canUse() { +- return this.panda.isBaby() +- && this.panda.canPerformAction() +- && (this.panda.isWeak() && this.panda.random.nextInt(reducedTickDelay(500)) == 1 || this.panda.random.nextInt(reducedTickDelay(6000)) == 1); +- } +- +- @Override +- public boolean canContinueToUse() { +- return false; +- } +- +- @Override +- public void start() { +- this.panda.sneeze(true); +- } +- } + } |