diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/entity/animal/Parrot.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/entity/animal/Parrot.java.patch | 525 |
1 files changed, 525 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/entity/animal/Parrot.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/entity/animal/Parrot.java.patch new file mode 100644 index 0000000000..425ef5d4fa --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/entity/animal/Parrot.java.patch @@ -0,0 +1,525 @@ +--- a/net/minecraft/world/entity/animal/Parrot.java ++++ b/net/minecraft/world/entity/animal/Parrot.java +@@ -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,16 +67,15 @@ + 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()); + } +@@ -130,8 +129,8 @@ + @Nullable + private BlockPos jukebox; + +- public Parrot(EntityType<? extends Parrot> entitytype, Level level) { +- super(entitytype, level); ++ public Parrot(EntityType<? extends Parrot> entityType, Level level) { ++ super(entityType, level); + this.moveControl = new FlyingMoveControl(this, 10, false); + this.setPathfindingMalus(BlockPathTypes.DANGER_FIRE, -1.0F); + this.setPathfindingMalus(BlockPathTypes.DAMAGE_FIRE, -1.0F); +@@ -140,31 +139,28 @@ + + @Nullable + @Override +- @Override +- public SpawnGroupData finalizeSpawn(ServerLevelAccessor serverlevelaccessor, DifficultyInstance difficultyinstance, MobSpawnType mobspawntype, @Nullable SpawnGroupData spawngroupdata, @Nullable CompoundTag compoundtag) { +- this.setVariant((Parrot.Variant) Util.getRandom((Object[]) Parrot.Variant.values(), serverlevelaccessor.getRandom())); +- if (spawngroupdata == null) { +- spawngroupdata = new AgeableMob.AgeableMobGroupData(false); ++ 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(serverlevelaccessor, difficultyinstance, mobspawntype, (SpawnGroupData) spawngroupdata, compoundtag); ++ return super.finalizeSpawn(level, difficulty, reason, (GroupDataEntity) spawnData, dataTag); + } + + @Override +- @Override + public boolean isBaby() { + return false; + } + + @Override +- @Override + protected void registerGoals() { + 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.0D, 5.0F, 1.0F, true)); +- this.goalSelector.addGoal(2, new Parrot.ParrotWanderGoal(this, 1.0D)); ++ 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.0D, 3.0F, 7.0F)); + } +@@ -174,24 +170,21 @@ + } + + @Override +- @Override + protected PathNavigation createNavigation(Level level) { +- FlyingPathNavigation flyingpathnavigation = new FlyingPathNavigation(this, level); ++ FlyingPathNavigation navigationflying = new FlyingPathNavigation(this, level); + +- flyingpathnavigation.setCanOpenDoors(false); +- flyingpathnavigation.setCanFloat(true); +- flyingpathnavigation.setCanPassDoors(true); +- return flyingpathnavigation; ++ navigationflying.setCanOpenDoors(false); ++ navigationflying.setCanFloat(true); ++ navigationflying.setCanPassDoors(true); ++ return navigationflying; + } + + @Override +- @Override +- protected float getStandingEyeHeight(Pose pose, EntityDimensions entitydimensions) { +- return entitydimensions.height * 0.6F; ++ protected float getStandingEyeHeight(EntityPose pose, EntityDimensions size) { ++ return size.height * 0.6F; + } + + @Override +- @Override + public void aiStep() { + if (this.jukebox == null || !this.jukebox.closerToCenterThan(this.position(), 3.46D) || !this.level().getBlockState(this.jukebox).is(Blocks.JUKEBOX)) { + this.partyParrot = false; +@@ -207,10 +200,9 @@ + } + + @Override +- @Override +- public void setRecordPlayingNearby(BlockPos blockpos, boolean flag) { +- this.jukebox = blockpos; +- this.partyParrot = flag; ++ public void setRecordPlayingNearby(BlockPos pos, boolean isPartying) { ++ this.jukebox = pos; ++ this.partyParrot = isPartying; + } + + public boolean isPartyParrot() { +@@ -227,26 +219,26 @@ + } + + this.flapping *= 0.9F; +- Vec3 vec3 = this.getDeltaMovement(); ++ Vec3 vec3d = this.getDeltaMovement(); + +- if (!this.onGround() && vec3.y < 0.0D) { +- this.setDeltaMovement(vec3.multiply(1.0D, 0.6D, 1.0D)); ++ if (!this.onGround() && vec3d.y < 0.0D) { ++ this.setDeltaMovement(vec3d.multiply(1.0D, 0.6D, 1.0D)); + } + + this.flap += this.flapping * 2.0F; + } + +- public static boolean imitateNearbyMobs(Level level, Entity entity) { +- if (entity.isAlive() && !entity.isSilent() && level.random.nextInt(2) == 0) { +- List<Mob> list = level.getEntitiesOfClass(Mob.class, entity.getBoundingBox().inflate(20.0D), Parrot.NOT_PARROT_PREDICATE); ++ public static boolean imitateNearbyMobs(Level level, Entity parrot) { ++ if (parrot.isAlive() && !parrot.isSilent() && level.random.nextInt(2) == 0) { ++ List<Mob> list = level.getEntitiesOfClass(Mob.class, parrot.getBoundingBox().inflate(20.0D), Parrot.NOT_PARROT_PREDICATE); + + if (!list.isEmpty()) { +- Mob mob = (Mob) list.get(level.random.nextInt(list.size())); ++ Mob entityinsentient = (Mob) list.get(level.random.nextInt(list.size())); + +- if (!mob.isSilent()) { +- SoundEvent soundevent = getImitatedSound(mob.getType()); ++ if (!entityinsentient.isSilent()) { ++ SoundEvent soundeffect = getImitatedSound(entityinsentient.getType()); + +- level.playSound((Player) null, entity.getX(), entity.getY(), entity.getZ(), soundevent, entity.getSoundSource(), 0.7F, getPitch(level.random)); ++ level.playSound((Player) null, parrot.getX(), parrot.getY(), parrot.getZ(), soundeffect, parrot.getSoundSource(), 0.7F, getPitch(level.random)); + return true; + } + } +@@ -258,9 +250,8 @@ + } + + @Override +- @Override +- public InteractionResult mobInteract(Player player, InteractionHand interactionhand) { +- ItemStack itemstack = player.getItemInHand(interactionhand); ++ 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) { +@@ -272,7 +263,7 @@ + } + + 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); + } else { +@@ -286,7 +277,7 @@ + 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); + } +@@ -299,119 +290,104 @@ + + return InteractionResult.sidedSuccess(this.level().isClientSide); + } else { +- return super.mobInteract(player, interactionhand); ++ return super.mobInteract(player, hand); + } + } + + @Override +- @Override +- public boolean isFood(ItemStack itemstack) { ++ public boolean isFood(ItemStack stack) { + return false; + } + +- public static boolean checkParrotSpawnRules(EntityType<Parrot> entitytype, LevelAccessor levelaccessor, MobSpawnType mobspawntype, BlockPos blockpos, RandomSource randomsource) { +- return levelaccessor.getBlockState(blockpos.below()).is(BlockTags.PARROTS_SPAWNABLE_ON) && isBrightEnoughToSpawn(levelaccessor, blockpos); ++ 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 +- @Override +- protected void checkFallDamage(double d0, boolean flag, BlockState blockstate, BlockPos blockpos) {} ++ protected void checkFallDamage(double y, boolean flag, IBlockData onGround, BlockPos state) {} + + @Override +- @Override +- public boolean canMate(Animal animal) { ++ public boolean canMate(Animal otherAnimal) { + return false; + } + + @Nullable + @Override +- @Override +- public AgeableMob getBreedOffspring(ServerLevel serverlevel, AgeableMob ageablemob) { ++ public AgeableMob getBreedOffspring(ServerLevel level, AgeableMob otherParent) { + return null; + } + + @Override +- @Override + public boolean doHurtTarget(Entity entity) { + return entity.hurt(this.damageSources().mobAttack(this), 3.0F); + } + + @Nullable + @Override +- @Override + public SoundEvent getAmbientSound() { + return getAmbient(this.level(), this.level().random); + } + +- public static SoundEvent getAmbient(Level level, RandomSource randomsource) { +- if (level.getDifficulty() != Difficulty.PEACEFUL && randomsource.nextInt(1000) == 0) { ++ public static SoundEvent getAmbient(Level level, RandomSource random) { ++ if (level.getDifficulty() != Difficulty.PEACEFUL && random.nextInt(1000) == 0) { + List<EntityType<?>> list = Lists.newArrayList(Parrot.MOB_SOUND_MAP.keySet()); + +- return getImitatedSound((EntityType) list.get(randomsource.nextInt(list.size()))); ++ return getImitatedSound((EntityType) list.get(random.nextInt(list.size()))); + } else { + return SoundEvents.PARROT_AMBIENT; + } + } + +- private static SoundEvent getImitatedSound(EntityType<?> entitytype) { +- return (SoundEvent) Parrot.MOB_SOUND_MAP.getOrDefault(entitytype, SoundEvents.PARROT_AMBIENT); ++ private static SoundEvent getImitatedSound(EntityType<?> type) { ++ return (SoundEvent) Parrot.MOB_SOUND_MAP.getOrDefault(type, SoundEvents.PARROT_AMBIENT); + } + + @Override +- @Override +- protected SoundEvent getHurtSound(DamageSource damagesource) { ++ protected SoundEvent getHurtSound(DamageSource damageSource) { + return SoundEvents.PARROT_HURT; + } + + @Override +- @Override + protected SoundEvent getDeathSound() { + return SoundEvents.PARROT_DEATH; + } + + @Override +- @Override +- protected void playStepSound(BlockPos blockpos, BlockState blockstate) { ++ protected void playStepSound(BlockPos pos, IBlockData block) { + this.playSound(SoundEvents.PARROT_STEP, 0.15F, 1.0F); + } + + @Override +- @Override + protected boolean isFlapping() { + return this.flyDist > this.nextFlap; + } + + @Override +- @Override + protected void onFlap() { + this.playSound(SoundEvents.PARROT_FLY, 0.15F, 1.0F); + this.nextFlap = this.flyDist + this.flapSpeed / 2.0F; + } + + @Override +- @Override + public float getVoicePitch() { + return getPitch(this.random); + } + +- public static float getPitch(RandomSource randomsource) { +- return (randomsource.nextFloat() - randomsource.nextFloat()) * 0.2F + 1.0F; ++ public static float getPitch(RandomSource random) { ++ return (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F; + } + + @Override +- @Override + public SoundSource getSoundSource() { + return SoundSource.NEUTRAL; + } + + @Override +- @Override + public boolean isPushable() { +- return true; ++ return super.isPushable(); // CraftBukkit - collidable API + } + + @Override +- @Override + protected void doPush(Entity entity) { + if (!(entity instanceof Player)) { + super.doPush(entity); +@@ -419,67 +395,61 @@ + } + + @Override +- @Override +- public boolean hurt(DamageSource damagesource, float f) { +- if (this.isInvulnerableTo(damagesource)) { ++ public boolean hurt(DamageSource source, float amount) { ++ 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(damagesource, f); ++ return result; // CraftBukkit + } + } + + @Override +- @Override + public Parrot.Variant getVariant() { + return Parrot.Variant.byId((Integer) this.entityData.get(Parrot.DATA_VARIANT_ID)); + } + +- @Override +- public void setVariant(Parrot.Variant parrot_variant) { +- this.entityData.set(Parrot.DATA_VARIANT_ID, parrot_variant.id); ++ public void setVariant(Parrot.Variant variant) { ++ this.entityData.set(Parrot.DATA_VARIANT_ID, variant.id); + } + + @Override +- @Override + protected void defineSynchedData() { + super.defineSynchedData(); + this.entityData.define(Parrot.DATA_VARIANT_ID, 0); + } + + @Override +- @Override +- public void addAdditionalSaveData(CompoundTag compoundtag) { +- super.addAdditionalSaveData(compoundtag); +- compoundtag.putInt("Variant", this.getVariant().id); ++ public void addAdditionalSaveData(CompoundTag compound) { ++ super.addAdditionalSaveData(compound); ++ compound.putInt("Variant", this.getVariant().id); + } + + @Override +- @Override +- public void readAdditionalSaveData(CompoundTag compoundtag) { +- super.readAdditionalSaveData(compoundtag); +- this.setVariant(Parrot.Variant.byId(compoundtag.getInt("Variant"))); ++ public void readAdditionalSaveData(CompoundTag compound) { ++ super.readAdditionalSaveData(compound); ++ this.setVariant(Parrot.Variant.byId(compound.getInt("Variant"))); + } + + @Override +- @Override + public boolean isFlying() { + return !this.onGround(); + } + + @Override +- @Override + public Vec3 getLeashOffset() { + return new Vec3(0.0D, (double) (0.5F * this.getEyeHeight()), (double) (this.getBbWidth() * 0.4F)); + } + + @Override +- @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); + } + + public static enum Variant implements StringRepresentable { +@@ -487,7 +457,7 @@ + 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); ++ private static final IntFunction<Parrot.Variant> BY_ID = ByIdMap.continuous(Parrot.Variant::getId, values(), ByIdMap.a.CLAMP); + final int id; + private final String name; + +@@ -500,57 +470,55 @@ + return this.id; + } + +- public static Parrot.Variant byId(int i) { +- return (Parrot.Variant) Parrot.Variant.BY_ID.apply(i); ++ public static Parrot.Variant byId(int id) { ++ return (Parrot.Variant) Parrot.Variant.BY_ID.apply(id); + } + + @Override +- @Override + public String getSerializedName() { + return this.name; + } + } + +- private static class ParrotWanderGoal extends WaterAvoidingRandomFlyingGoal { ++ private static class a extends PathfinderGoalRandomFly { + +- public ParrotWanderGoal(PathfinderMob pathfindermob, double d0) { +- super(pathfindermob, d0); ++ public a(PathfinderMob mob, double speedModifier) { ++ super(mob, speedModifier); + } + + @Nullable + @Override +- @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 blockpos_mutableblockpos = new BlockPos.MutableBlockPos(); +- BlockPos.MutableBlockPos blockpos_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(); + + while (iterator.hasNext()) { +- BlockPos blockpos1 = (BlockPos) iterator.next(); ++ BlockPos blockposition1 = (BlockPos) iterator.next(); + +- if (!blockpos.equals(blockpos1)) { +- BlockState blockstate = this.mob.level().getBlockState(blockpos_mutableblockpos1.setWithOffset(blockpos1, Direction.DOWN)); +- boolean flag = blockstate.getBlock() instanceof LeavesBlock || blockstate.is(BlockTags.LOGS); ++ 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(blockpos1) && this.mob.level().isEmptyBlock(blockpos_mutableblockpos.setWithOffset(blockpos1, Direction.UP))) { +- return Vec3.atBottomCenterOf(blockpos1); ++ if (flag && this.mob.level().isEmptyBlock(blockposition1) && this.mob.level().isEmptyBlock(blockposition_mutableblockposition.setWithOffset(blockposition1, Direction.UP))) { ++ return Vec3.atBottomCenterOf(blockposition1); + } + } + } |