diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Parrot.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Parrot.java.patch | 553 |
1 files changed, 553 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Parrot.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Parrot.java.patch new file mode 100644 index 0000000000..9df47fb787 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Parrot.java.patch @@ -0,0 +1,553 @@ +--- a/net/minecraft/world/entity/animal/Parrot.java ++++ b/net/minecraft/world/entity/animal/Parrot.java +@@ -4,7 +4,7 @@ + import com.google.common.collect.Maps; + import com.google.common.collect.Sets; + import com.mojang.serialization.Codec; +-import java.util.HashMap; ++import java.util.Iterator; + import java.util.List; + import java.util.Map; + import java.util.Set; +@@ -29,7 +29,7 @@ + import net.minecraft.util.StringRepresentable; + 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.effect.MobEffectInstance; +@@ -37,12 +37,12 @@ + import net.minecraft.world.entity.AgeableMob; + import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.EntityDimensions; ++import net.minecraft.world.entity.EntityPose; + import net.minecraft.world.entity.EntityType; ++import net.minecraft.world.entity.EnumMobSpawn; ++import net.minecraft.world.entity.GroupDataEntity; + import net.minecraft.world.entity.Mob; +-import net.minecraft.world.entity.MobSpawnType; + import net.minecraft.world.entity.PathfinderMob; +-import net.minecraft.world.entity.Pose; +-import net.minecraft.world.entity.SpawnGroupData; + import net.minecraft.world.entity.VariantHolder; + import net.minecraft.world.entity.ai.attributes.AttributeSupplier; + import net.minecraft.world.entity.ai.attributes.Attributes; +@@ -53,8 +53,8 @@ + import net.minecraft.world.entity.ai.goal.LandOnOwnersShoulderGoal; + import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal; + import net.minecraft.world.entity.ai.goal.PanicGoal; ++import net.minecraft.world.entity.ai.goal.PathfinderGoalRandomFly; + import net.minecraft.world.entity.ai.goal.SitWhenOrderedToGoal; +-import net.minecraft.world.entity.ai.goal.WaterAvoidingRandomFlyingGoal; + import net.minecraft.world.entity.ai.navigation.FlyingPathNavigation; + import net.minecraft.world.entity.ai.navigation.PathNavigation; + import net.minecraft.world.entity.ai.util.LandRandomPos; +@@ -67,59 +67,57 @@ + import net.minecraft.world.level.ServerLevelAccessor; + import net.minecraft.world.level.block.Blocks; + import net.minecraft.world.level.block.LeavesBlock; +-import net.minecraft.world.level.block.state.BlockState; ++import net.minecraft.world.level.block.state.IBlockData; + import net.minecraft.world.level.pathfinder.BlockPathTypes; + import net.minecraft.world.phys.Vec3; + import org.joml.Vector3f; + +-public class Parrot extends ShoulderRidingEntity implements VariantHolder<Parrot.Variant>, FlyingAnimal { ++public class Parrot extends ShoulderRidingEntity implements VariantHolder<Parrot.Variant>, EntityBird { ++ + private static final EntityDataAccessor<Integer> DATA_VARIANT_ID = SynchedEntityData.defineId(Parrot.class, EntityDataSerializers.INT); + private static final Predicate<Mob> NOT_PARROT_PREDICATE = new Predicate<Mob>() { +- @Override + public boolean test(@Nullable Mob mob) { + return mob != null && Parrot.MOB_SOUND_MAP.containsKey(mob.getType()); + } + }; + private static final Item POISONOUS_FOOD = Items.COOKIE; +- private static final Set<Item> TAME_FOOD = Sets.newHashSet( +- Items.WHEAT_SEEDS, Items.MELON_SEEDS, Items.PUMPKIN_SEEDS, Items.BEETROOT_SEEDS, Items.TORCHFLOWER_SEEDS, Items.PITCHER_POD +- ); +- static final Map<EntityType<?>, SoundEvent> MOB_SOUND_MAP = Util.make(Maps.newHashMap(), map -> { +- map.put(EntityType.BLAZE, SoundEvents.PARROT_IMITATE_BLAZE); +- map.put(EntityType.BREEZE, SoundEvents.PARROT_IMITATE_BREEZE); +- map.put(EntityType.CAVE_SPIDER, SoundEvents.PARROT_IMITATE_SPIDER); +- map.put(EntityType.CREEPER, SoundEvents.PARROT_IMITATE_CREEPER); +- map.put(EntityType.DROWNED, SoundEvents.PARROT_IMITATE_DROWNED); +- map.put(EntityType.ELDER_GUARDIAN, SoundEvents.PARROT_IMITATE_ELDER_GUARDIAN); +- map.put(EntityType.ENDER_DRAGON, SoundEvents.PARROT_IMITATE_ENDER_DRAGON); +- map.put(EntityType.ENDERMITE, SoundEvents.PARROT_IMITATE_ENDERMITE); +- map.put(EntityType.EVOKER, SoundEvents.PARROT_IMITATE_EVOKER); +- map.put(EntityType.GHAST, SoundEvents.PARROT_IMITATE_GHAST); +- map.put(EntityType.GUARDIAN, SoundEvents.PARROT_IMITATE_GUARDIAN); +- map.put(EntityType.HOGLIN, SoundEvents.PARROT_IMITATE_HOGLIN); +- map.put(EntityType.HUSK, SoundEvents.PARROT_IMITATE_HUSK); +- map.put(EntityType.ILLUSIONER, SoundEvents.PARROT_IMITATE_ILLUSIONER); +- map.put(EntityType.MAGMA_CUBE, SoundEvents.PARROT_IMITATE_MAGMA_CUBE); +- map.put(EntityType.PHANTOM, SoundEvents.PARROT_IMITATE_PHANTOM); +- map.put(EntityType.PIGLIN, SoundEvents.PARROT_IMITATE_PIGLIN); +- map.put(EntityType.PIGLIN_BRUTE, SoundEvents.PARROT_IMITATE_PIGLIN_BRUTE); +- map.put(EntityType.PILLAGER, SoundEvents.PARROT_IMITATE_PILLAGER); +- map.put(EntityType.RAVAGER, SoundEvents.PARROT_IMITATE_RAVAGER); +- map.put(EntityType.SHULKER, SoundEvents.PARROT_IMITATE_SHULKER); +- map.put(EntityType.SILVERFISH, SoundEvents.PARROT_IMITATE_SILVERFISH); +- map.put(EntityType.SKELETON, SoundEvents.PARROT_IMITATE_SKELETON); +- map.put(EntityType.SLIME, SoundEvents.PARROT_IMITATE_SLIME); +- map.put(EntityType.SPIDER, SoundEvents.PARROT_IMITATE_SPIDER); +- map.put(EntityType.STRAY, SoundEvents.PARROT_IMITATE_STRAY); +- map.put(EntityType.VEX, SoundEvents.PARROT_IMITATE_VEX); +- map.put(EntityType.VINDICATOR, SoundEvents.PARROT_IMITATE_VINDICATOR); +- map.put(EntityType.WARDEN, SoundEvents.PARROT_IMITATE_WARDEN); +- map.put(EntityType.WITCH, SoundEvents.PARROT_IMITATE_WITCH); +- map.put(EntityType.WITHER, SoundEvents.PARROT_IMITATE_WITHER); +- map.put(EntityType.WITHER_SKELETON, SoundEvents.PARROT_IMITATE_WITHER_SKELETON); +- map.put(EntityType.ZOGLIN, SoundEvents.PARROT_IMITATE_ZOGLIN); +- map.put(EntityType.ZOMBIE, SoundEvents.PARROT_IMITATE_ZOMBIE); +- map.put(EntityType.ZOMBIE_VILLAGER, SoundEvents.PARROT_IMITATE_ZOMBIE_VILLAGER); ++ private static final Set<Item> TAME_FOOD = Sets.newHashSet(new Item[]{Items.WHEAT_SEEDS, Items.MELON_SEEDS, Items.PUMPKIN_SEEDS, Items.BEETROOT_SEEDS, Items.TORCHFLOWER_SEEDS, Items.PITCHER_POD}); ++ static final Map<EntityType<?>, SoundEvent> MOB_SOUND_MAP = (Map) Util.make(Maps.newHashMap(), (hashmap) -> { ++ hashmap.put(EntityType.BLAZE, SoundEvents.PARROT_IMITATE_BLAZE); ++ hashmap.put(EntityType.BREEZE, SoundEvents.PARROT_IMITATE_BREEZE); ++ hashmap.put(EntityType.CAVE_SPIDER, SoundEvents.PARROT_IMITATE_SPIDER); ++ hashmap.put(EntityType.CREEPER, SoundEvents.PARROT_IMITATE_CREEPER); ++ hashmap.put(EntityType.DROWNED, SoundEvents.PARROT_IMITATE_DROWNED); ++ hashmap.put(EntityType.ELDER_GUARDIAN, SoundEvents.PARROT_IMITATE_ELDER_GUARDIAN); ++ hashmap.put(EntityType.ENDER_DRAGON, SoundEvents.PARROT_IMITATE_ENDER_DRAGON); ++ hashmap.put(EntityType.ENDERMITE, SoundEvents.PARROT_IMITATE_ENDERMITE); ++ hashmap.put(EntityType.EVOKER, SoundEvents.PARROT_IMITATE_EVOKER); ++ hashmap.put(EntityType.GHAST, SoundEvents.PARROT_IMITATE_GHAST); ++ hashmap.put(EntityType.GUARDIAN, SoundEvents.PARROT_IMITATE_GUARDIAN); ++ hashmap.put(EntityType.HOGLIN, SoundEvents.PARROT_IMITATE_HOGLIN); ++ hashmap.put(EntityType.HUSK, SoundEvents.PARROT_IMITATE_HUSK); ++ hashmap.put(EntityType.ILLUSIONER, SoundEvents.PARROT_IMITATE_ILLUSIONER); ++ hashmap.put(EntityType.MAGMA_CUBE, SoundEvents.PARROT_IMITATE_MAGMA_CUBE); ++ hashmap.put(EntityType.PHANTOM, SoundEvents.PARROT_IMITATE_PHANTOM); ++ hashmap.put(EntityType.PIGLIN, SoundEvents.PARROT_IMITATE_PIGLIN); ++ hashmap.put(EntityType.PIGLIN_BRUTE, SoundEvents.PARROT_IMITATE_PIGLIN_BRUTE); ++ hashmap.put(EntityType.PILLAGER, SoundEvents.PARROT_IMITATE_PILLAGER); ++ hashmap.put(EntityType.RAVAGER, SoundEvents.PARROT_IMITATE_RAVAGER); ++ hashmap.put(EntityType.SHULKER, SoundEvents.PARROT_IMITATE_SHULKER); ++ hashmap.put(EntityType.SILVERFISH, SoundEvents.PARROT_IMITATE_SILVERFISH); ++ hashmap.put(EntityType.SKELETON, SoundEvents.PARROT_IMITATE_SKELETON); ++ hashmap.put(EntityType.SLIME, SoundEvents.PARROT_IMITATE_SLIME); ++ hashmap.put(EntityType.SPIDER, SoundEvents.PARROT_IMITATE_SPIDER); ++ hashmap.put(EntityType.STRAY, SoundEvents.PARROT_IMITATE_STRAY); ++ hashmap.put(EntityType.VEX, SoundEvents.PARROT_IMITATE_VEX); ++ hashmap.put(EntityType.VINDICATOR, SoundEvents.PARROT_IMITATE_VINDICATOR); ++ hashmap.put(EntityType.WARDEN, SoundEvents.PARROT_IMITATE_WARDEN); ++ hashmap.put(EntityType.WITCH, SoundEvents.PARROT_IMITATE_WITCH); ++ hashmap.put(EntityType.WITHER, SoundEvents.PARROT_IMITATE_WITHER); ++ hashmap.put(EntityType.WITHER_SKELETON, SoundEvents.PARROT_IMITATE_WITHER_SKELETON); ++ hashmap.put(EntityType.ZOGLIN, SoundEvents.PARROT_IMITATE_ZOGLIN); ++ hashmap.put(EntityType.ZOMBIE, SoundEvents.PARROT_IMITATE_ZOMBIE); ++ hashmap.put(EntityType.ZOMBIE_VILLAGER, SoundEvents.PARROT_IMITATE_ZOMBIE_VILLAGER); + }); + public float flap; + public float flapSpeed; +@@ -141,15 +139,13 @@ + + @Nullable + @Override +- public SpawnGroupData finalizeSpawn( +- ServerLevelAccessor level, DifficultyInstance difficulty, MobSpawnType reason, @Nullable SpawnGroupData spawnData, @Nullable CompoundTag dataTag +- ) { +- this.setVariant(Util.getRandom(Parrot.Variant.values(), level.getRandom())); ++ public GroupDataEntity finalizeSpawn(ServerLevelAccessor level, DifficultyInstance difficulty, EnumMobSpawn reason, @Nullable GroupDataEntity spawnData, @Nullable CompoundTag dataTag) { ++ this.setVariant((Parrot.Variant) Util.getRandom((Object[]) Parrot.Variant.values(), level.getRandom())); + if (spawnData == null) { + spawnData = new AgeableMob.AgeableMobGroupData(false); + } + +- return super.finalizeSpawn(level, difficulty, reason, spawnData, dataTag); ++ return super.finalizeSpawn(level, difficulty, reason, (GroupDataEntity) spawnData, dataTag); + } + + @Override +@@ -159,37 +155,38 @@ + + @Override + protected void registerGoals() { +- this.goalSelector.addGoal(0, new PanicGoal(this, 1.25)); ++ this.goalSelector.addGoal(0, new PanicGoal(this, 1.25D)); + this.goalSelector.addGoal(0, new FloatGoal(this)); + this.goalSelector.addGoal(1, new LookAtPlayerGoal(this, Player.class, 8.0F)); + this.goalSelector.addGoal(2, new SitWhenOrderedToGoal(this)); +- this.goalSelector.addGoal(2, new FollowOwnerGoal(this, 1.0, 5.0F, 1.0F, true)); +- this.goalSelector.addGoal(2, new Parrot.ParrotWanderGoal(this, 1.0)); ++ this.goalSelector.addGoal(2, new FollowOwnerGoal(this, 1.0D, 5.0F, 1.0F, true)); ++ this.goalSelector.addGoal(2, new Parrot.a(this, 1.0D)); + this.goalSelector.addGoal(3, new LandOnOwnersShoulderGoal(this)); +- this.goalSelector.addGoal(3, new FollowMobGoal(this, 1.0, 3.0F, 7.0F)); ++ this.goalSelector.addGoal(3, new FollowMobGoal(this, 1.0D, 3.0F, 7.0F)); + } + + public static AttributeSupplier.Builder createAttributes() { +- return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 6.0).add(Attributes.FLYING_SPEED, 0.4F).add(Attributes.MOVEMENT_SPEED, 0.2F); ++ return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 6.0D).add(Attributes.FLYING_SPEED, 0.4000000059604645D).add(Attributes.MOVEMENT_SPEED, 0.20000000298023224D); + } + + @Override + protected PathNavigation createNavigation(Level level) { +- FlyingPathNavigation flyingPathNavigation = new FlyingPathNavigation(this, level); +- flyingPathNavigation.setCanOpenDoors(false); +- flyingPathNavigation.setCanFloat(true); +- flyingPathNavigation.setCanPassDoors(true); +- return flyingPathNavigation; ++ FlyingPathNavigation navigationflying = new FlyingPathNavigation(this, level); ++ ++ navigationflying.setCanOpenDoors(false); ++ navigationflying.setCanFloat(true); ++ navigationflying.setCanPassDoors(true); ++ return navigationflying; + } + + @Override +- protected float getStandingEyeHeight(Pose pose, EntityDimensions size) { ++ protected float getStandingEyeHeight(EntityPose pose, EntityDimensions size) { + return size.height * 0.6F; + } + + @Override + public void aiStep() { +- if (this.jukebox == null || !this.jukebox.closerToCenterThan(this.position(), 3.46) || !this.level().getBlockState(this.jukebox).is(Blocks.JUKEBOX)) { ++ if (this.jukebox == null || !this.jukebox.closerToCenterThan(this.position(), 3.46D) || !this.level().getBlockState(this.jukebox).is(Blocks.JUKEBOX)) { + this.partyParrot = false; + this.jukebox = null; + } +@@ -215,29 +212,33 @@ + private void calculateFlapping() { + this.oFlap = this.flap; + this.oFlapSpeed = this.flapSpeed; +- this.flapSpeed = this.flapSpeed + (float)(!this.onGround() && !this.isPassenger() ? 4 : -1) * 0.3F; ++ this.flapSpeed += (float) (!this.onGround() && !this.isPassenger() ? 4 : -1) * 0.3F; + this.flapSpeed = Mth.clamp(this.flapSpeed, 0.0F, 1.0F); + if (!this.onGround() && this.flapping < 1.0F) { + this.flapping = 1.0F; + } + + this.flapping *= 0.9F; +- Vec3 deltaMovement = this.getDeltaMovement(); +- if (!this.onGround() && deltaMovement.y < 0.0) { +- this.setDeltaMovement(deltaMovement.multiply(1.0, 0.6, 1.0)); ++ Vec3 vec3d = this.getDeltaMovement(); ++ ++ if (!this.onGround() && vec3d.y < 0.0D) { ++ this.setDeltaMovement(vec3d.multiply(1.0D, 0.6D, 1.0D)); + } + +- this.flap = this.flap + this.flapping * 2.0F; ++ this.flap += this.flapping * 2.0F; + } + + public static boolean imitateNearbyMobs(Level level, Entity parrot) { + if (parrot.isAlive() && !parrot.isSilent() && level.random.nextInt(2) == 0) { +- List<Mob> entitiesOfClass = level.getEntitiesOfClass(Mob.class, parrot.getBoundingBox().inflate(20.0), NOT_PARROT_PREDICATE); +- if (!entitiesOfClass.isEmpty()) { +- Mob mob = entitiesOfClass.get(level.random.nextInt(entitiesOfClass.size())); +- if (!mob.isSilent()) { +- SoundEvent imitatedSound = getImitatedSound(mob.getType()); +- level.playSound(null, parrot.getX(), parrot.getY(), parrot.getZ(), imitatedSound, parrot.getSoundSource(), 0.7F, getPitch(level.random)); ++ List<Mob> list = level.getEntitiesOfClass(Mob.class, parrot.getBoundingBox().inflate(20.0D), Parrot.NOT_PARROT_PREDICATE); ++ ++ if (!list.isEmpty()) { ++ Mob entityinsentient = (Mob) list.get(level.random.nextInt(list.size())); ++ ++ if (!entityinsentient.isSilent()) { ++ SoundEvent soundeffect = getImitatedSound(entityinsentient.getType()); ++ ++ level.playSound((Player) null, parrot.getX(), parrot.getY(), parrot.getZ(), soundeffect, parrot.getSoundSource(), 0.7F, getPitch(level.random)); + return true; + } + } +@@ -249,43 +250,34 @@ + } + + @Override +- public InteractionResult mobInteract(Player player, InteractionHand hand) { +- ItemStack itemInHand = player.getItemInHand(hand); +- if (!this.isTame() && TAME_FOOD.contains(itemInHand.getItem())) { ++ public InteractionResult mobInteract(Player player, EnumHand hand) { ++ ItemStack itemstack = player.getItemInHand(hand); ++ ++ if (!this.isTame() && Parrot.TAME_FOOD.contains(itemstack.getItem())) { + if (!player.getAbilities().instabuild) { +- itemInHand.shrink(1); ++ itemstack.shrink(1); + } + + if (!this.isSilent()) { +- this.level() +- .playSound( +- null, +- this.getX(), +- this.getY(), +- this.getZ(), +- SoundEvents.PARROT_EAT, +- this.getSoundSource(), +- 1.0F, +- 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.2F +- ); ++ this.level().playSound((Player) null, this.getX(), this.getY(), this.getZ(), SoundEvents.PARROT_EAT, this.getSoundSource(), 1.0F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.2F); + } + + if (!this.level().isClientSide) { +- if (this.random.nextInt(10) == 0) { ++ if (this.random.nextInt(10) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit + this.tame(player); +- this.level().broadcastEntityEvent(this, (byte)7); ++ this.level().broadcastEntityEvent(this, (byte) 7); + } else { +- this.level().broadcastEntityEvent(this, (byte)6); ++ this.level().broadcastEntityEvent(this, (byte) 6); + } + } + + return InteractionResult.sidedSuccess(this.level().isClientSide); +- } else if (itemInHand.is(POISONOUS_FOOD)) { ++ } else if (itemstack.is(Parrot.POISONOUS_FOOD)) { + if (!player.getAbilities().instabuild) { +- itemInHand.shrink(1); ++ itemstack.shrink(1); + } + +- this.addEffect(new MobEffectInstance(MobEffects.POISON, 900)); ++ this.addEffect(new MobEffectInstance(MobEffects.POISON, 900), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // CraftBukkit + if (player.isCreative() || !this.isInvulnerable()) { + this.hurt(this.damageSources().playerAttack(player), Float.MAX_VALUE); + } +@@ -307,13 +299,12 @@ + return false; + } + +- public static boolean checkParrotSpawnRules(EntityType<Parrot> parrot, LevelAccessor level, MobSpawnType spawnType, BlockPos pos, RandomSource random) { ++ public static boolean checkParrotSpawnRules(EntityType<Parrot> parrot, LevelAccessor level, EnumMobSpawn spawnType, BlockPos pos, RandomSource random) { + return level.getBlockState(pos.below()).is(BlockTags.PARROTS_SPAWNABLE_ON) && isBrightEnoughToSpawn(level, pos); + } + + @Override +- protected void checkFallDamage(double y, boolean onGround, BlockState state, BlockPos pos) { +- } ++ protected void checkFallDamage(double y, boolean flag, IBlockData onGround, BlockPos state) {} + + @Override + public boolean canMate(Animal otherAnimal) { +@@ -339,15 +330,16 @@ + + public static SoundEvent getAmbient(Level level, RandomSource random) { + if (level.getDifficulty() != Difficulty.PEACEFUL && random.nextInt(1000) == 0) { +- List<EntityType<?>> list = Lists.newArrayList(MOB_SOUND_MAP.keySet()); +- return getImitatedSound(list.get(random.nextInt(list.size()))); ++ List<EntityType<?>> list = Lists.newArrayList(Parrot.MOB_SOUND_MAP.keySet()); ++ ++ return getImitatedSound((EntityType) list.get(random.nextInt(list.size()))); + } else { + return SoundEvents.PARROT_AMBIENT; + } + } + + private static SoundEvent getImitatedSound(EntityType<?> type) { +- return MOB_SOUND_MAP.getOrDefault(type, SoundEvents.PARROT_AMBIENT); ++ return (SoundEvent) Parrot.MOB_SOUND_MAP.getOrDefault(type, SoundEvents.PARROT_AMBIENT); + } + + @Override +@@ -361,7 +353,7 @@ + } + + @Override +- protected void playStepSound(BlockPos pos, BlockState block) { ++ protected void playStepSound(BlockPos pos, IBlockData block) { + this.playSound(SoundEvents.PARROT_STEP, 0.15F, 1.0F); + } + +@@ -392,7 +384,7 @@ + + @Override + public boolean isPushable() { +- return true; ++ return super.isPushable(); // CraftBukkit - collidable API + } + + @Override +@@ -407,28 +399,30 @@ + if (this.isInvulnerableTo(source)) { + return false; + } else { +- if (!this.level().isClientSide) { ++ // CraftBukkit start ++ boolean result = super.hurt(source, amount); ++ if (!this.level().isClientSide && result) { ++ // CraftBukkit end + this.setOrderedToSit(false); + } + +- return super.hurt(source, amount); ++ return result; // CraftBukkit + } + } + + @Override + public Parrot.Variant getVariant() { +- return Parrot.Variant.byId(this.entityData.get(DATA_VARIANT_ID)); ++ return Parrot.Variant.byId((Integer) this.entityData.get(Parrot.DATA_VARIANT_ID)); + } + +- @Override + public void setVariant(Parrot.Variant variant) { +- this.entityData.set(DATA_VARIANT_ID, variant.id); ++ this.entityData.set(Parrot.DATA_VARIANT_ID, variant.id); + } + + @Override + protected void defineSynchedData() { + super.defineSynchedData(); +- this.entityData.define(DATA_VARIANT_ID, 0); ++ this.entityData.define(Parrot.DATA_VARIANT_ID, 0); + } + + @Override +@@ -450,55 +444,81 @@ + + @Override + public Vec3 getLeashOffset() { +- return new Vec3(0.0, (double)(0.5F * this.getEyeHeight()), (double)(this.getBbWidth() * 0.4F)); ++ return new Vec3(0.0D, (double) (0.5F * this.getEyeHeight()), (double) (this.getBbWidth() * 0.4F)); + } + + @Override +- protected Vector3f getPassengerAttachmentPoint(Entity entity, EntityDimensions entityDimensions, float f) { +- return new Vector3f(0.0F, entityDimensions.height - 0.4375F * f, 0.0F); ++ protected Vector3f getPassengerAttachmentPoint(Entity entity, EntityDimensions entitysize, float f) { ++ return new Vector3f(0.0F, entitysize.height - 0.4375F * f, 0.0F); + } + +- static class ParrotWanderGoal extends WaterAvoidingRandomFlyingGoal { +- public ParrotWanderGoal(PathfinderMob mob, double speedModifier) { ++ public static enum Variant implements StringRepresentable { ++ ++ RED_BLUE(0, "red_blue"), BLUE(1, "blue"), GREEN(2, "green"), YELLOW_BLUE(3, "yellow_blue"), GRAY(4, "gray"); ++ ++ public static final Codec<Parrot.Variant> CODEC = StringRepresentable.fromEnum(Parrot.Variant::values); ++ private static final IntFunction<Parrot.Variant> BY_ID = ByIdMap.continuous(Parrot.Variant::getId, values(), ByIdMap.a.CLAMP); ++ final int id; ++ private final String name; ++ ++ private Variant(int i, String s) { ++ this.id = i; ++ this.name = s; ++ } ++ ++ public int getId() { ++ return this.id; ++ } ++ ++ public static Parrot.Variant byId(int id) { ++ return (Parrot.Variant) Parrot.Variant.BY_ID.apply(id); ++ } ++ ++ @Override ++ public String getSerializedName() { ++ return this.name; ++ } ++ } ++ ++ private static class a extends PathfinderGoalRandomFly { ++ ++ public a(PathfinderMob mob, double speedModifier) { + super(mob, speedModifier); + } + + @Nullable + @Override + protected Vec3 getPosition() { +- Vec3 vec3 = null; ++ Vec3 vec3d = null; ++ + if (this.mob.isInWater()) { +- vec3 = LandRandomPos.getPos(this.mob, 15, 15); ++ vec3d = LandRandomPos.getPos(this.mob, 15, 15); + } + + if (this.mob.getRandom().nextFloat() >= this.probability) { +- vec3 = this.getTreePos(); ++ vec3d = this.getTreePos(); + } + +- return vec3 == null ? super.getPosition() : vec3; ++ return vec3d == null ? super.getPosition() : vec3d; + } + + @Nullable + private Vec3 getTreePos() { +- BlockPos blockPos = this.mob.blockPosition(); +- BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); +- BlockPos.MutableBlockPos mutableBlockPos1 = new BlockPos.MutableBlockPos(); ++ BlockPos blockposition = this.mob.blockPosition(); ++ BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); ++ BlockPos.MutableBlockPos blockposition_mutableblockposition1 = new BlockPos.MutableBlockPos(); ++ Iterable<BlockPos> iterable = BlockPos.betweenClosed(Mth.floor(this.mob.getX() - 3.0D), Mth.floor(this.mob.getY() - 6.0D), Mth.floor(this.mob.getZ() - 3.0D), Mth.floor(this.mob.getX() + 3.0D), Mth.floor(this.mob.getY() + 6.0D), Mth.floor(this.mob.getZ() + 3.0D)); ++ Iterator iterator = iterable.iterator(); + +- for (BlockPos blockPos1 : BlockPos.betweenClosed( +- Mth.floor(this.mob.getX() - 3.0), +- Mth.floor(this.mob.getY() - 6.0), +- Mth.floor(this.mob.getZ() - 3.0), +- Mth.floor(this.mob.getX() + 3.0), +- Mth.floor(this.mob.getY() + 6.0), +- Mth.floor(this.mob.getZ() + 3.0) +- )) { +- if (!blockPos.equals(blockPos1)) { +- BlockState blockState = this.mob.level().getBlockState(mutableBlockPos1.setWithOffset(blockPos1, Direction.DOWN)); +- boolean flag = blockState.getBlock() instanceof LeavesBlock || blockState.is(BlockTags.LOGS); +- if (flag +- && this.mob.level().isEmptyBlock(blockPos1) +- && this.mob.level().isEmptyBlock(mutableBlockPos.setWithOffset(blockPos1, Direction.UP))) { +- return Vec3.atBottomCenterOf(blockPos1); ++ while (iterator.hasNext()) { ++ BlockPos blockposition1 = (BlockPos) iterator.next(); ++ ++ if (!blockposition.equals(blockposition1)) { ++ IBlockData iblockdata = this.mob.level().getBlockState(blockposition_mutableblockposition1.setWithOffset(blockposition1, Direction.DOWN)); ++ boolean flag = iblockdata.getBlock() instanceof LeavesBlock || iblockdata.is(BlockTags.LOGS); ++ ++ if (flag && this.mob.level().isEmptyBlock(blockposition1) && this.mob.level().isEmptyBlock(blockposition_mutableblockposition.setWithOffset(blockposition1, Direction.UP))) { ++ return Vec3.atBottomCenterOf(blockposition1); + } + } + } +@@ -506,35 +526,4 @@ + return null; + } + } +- +- public static enum Variant implements StringRepresentable { +- RED_BLUE(0, "red_blue"), +- BLUE(1, "blue"), +- GREEN(2, "green"), +- YELLOW_BLUE(3, "yellow_blue"), +- GRAY(4, "gray"); +- +- public static final Codec<Parrot.Variant> CODEC = StringRepresentable.fromEnum(Parrot.Variant::values); +- private static final IntFunction<Parrot.Variant> BY_ID = ByIdMap.continuous(Parrot.Variant::getId, values(), ByIdMap.OutOfBoundsStrategy.CLAMP); +- final int id; +- private final String name; +- +- private Variant(int id, String name) { +- this.id = id; +- this.name = name; +- } +- +- public int getId() { +- return this.id; +- } +- +- public static Parrot.Variant byId(int id) { +- return BY_ID.apply(id); +- } +- +- @Override +- public String getSerializedName() { +- return this.name; +- } +- } + } |