diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Dolphin.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Dolphin.java.patch | 650 |
1 files changed, 650 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Dolphin.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Dolphin.java.patch new file mode 100644 index 0000000000..5460efbb50 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Dolphin.java.patch @@ -0,0 +1,650 @@ +--- a/net/minecraft/world/entity/animal/Dolphin.java ++++ b/net/minecraft/world/entity/animal/Dolphin.java +@@ -19,20 +19,20 @@ + import net.minecraft.tags.StructureTags; + import net.minecraft.util.Mth; + 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; + import net.minecraft.world.effect.MobEffects; + 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.EnumMoveType; + import net.minecraft.world.entity.EquipmentSlot; ++import net.minecraft.world.entity.GroupDataEntity; + import net.minecraft.world.entity.Mob; +-import net.minecraft.world.entity.MobSpawnType; +-import net.minecraft.world.entity.MoverType; +-import net.minecraft.world.entity.Pose; +-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.SmoothSwimmingLookControl; +@@ -44,8 +44,8 @@ + import net.minecraft.world.entity.ai.goal.Goal; + import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal; + import net.minecraft.world.entity.ai.goal.MeleeAttackGoal; ++import net.minecraft.world.entity.ai.goal.PathfinderGoalRandomSwim; + import net.minecraft.world.entity.ai.goal.RandomLookAroundGoal; +-import net.minecraft.world.entity.ai.goal.RandomSwimmingGoal; + import net.minecraft.world.entity.ai.goal.TryFindWaterGoal; + import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; + import net.minecraft.world.entity.ai.navigation.PathNavigation; +@@ -58,17 +58,30 @@ + import net.minecraft.world.item.ItemStack; + import net.minecraft.world.level.Level; + import net.minecraft.world.level.ServerLevelAccessor; +-import net.minecraft.world.level.pathfinder.PathComputationType; ++import net.minecraft.world.level.pathfinder.PathMode; + import net.minecraft.world.phys.Vec3; ++// CraftBukkit start ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++import org.bukkit.event.entity.EntityPotionEffectEvent; ++// CraftBukkit end + + public class Dolphin extends WaterAnimal { ++ ++ // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() ++ @Override ++ public int getDefaultMaxAirSupply() { ++ return TOTAL_AIR_SUPPLY; ++ } ++ // CraftBukkit end + private static final EntityDataAccessor<BlockPos> TREASURE_POS = SynchedEntityData.defineId(Dolphin.class, EntityDataSerializers.BLOCK_POS); + private static final EntityDataAccessor<Boolean> GOT_FISH = SynchedEntityData.defineId(Dolphin.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor<Integer> MOISTNESS_LEVEL = SynchedEntityData.defineId(Dolphin.class, EntityDataSerializers.INT); +- static final TargetingConditions SWIM_WITH_PLAYER_TARGETING = TargetingConditions.forNonCombat().range(10.0).ignoreLineOfSight(); ++ static final TargetingConditions SWIM_WITH_PLAYER_TARGETING = TargetingConditions.forNonCombat().range(10.0D).ignoreLineOfSight(); + public static final int TOTAL_AIR_SUPPLY = 4800; + private static final int TOTAL_MOISTNESS_LEVEL = 2400; +- public static final Predicate<ItemEntity> ALLOWED_ITEMS = itemEntity -> !itemEntity.hasPickUpDelay() && itemEntity.isAlive() && itemEntity.isInWater(); ++ public static final Predicate<ItemEntity> ALLOWED_ITEMS = (entityitem) -> { ++ return !entityitem.hasPickUpDelay() && entityitem.isAlive() && entityitem.isInWater(); ++ }; + + public Dolphin(EntityType<? extends Dolphin> entityType, Level level) { + super(entityType, level); +@@ -79,48 +92,45 @@ + + @Nullable + @Override +- public SpawnGroupData finalizeSpawn( +- ServerLevelAccessor level, DifficultyInstance difficulty, MobSpawnType reason, @Nullable SpawnGroupData spawnData, @Nullable CompoundTag dataTag +- ) { ++ public GroupDataEntity finalizeSpawn(ServerLevelAccessor level, DifficultyInstance difficulty, EnumMobSpawn reason, @Nullable GroupDataEntity spawnData, @Nullable CompoundTag dataTag) { + this.setAirSupply(this.getMaxAirSupply()); + this.setXRot(0.0F); + return super.finalizeSpawn(level, difficulty, reason, spawnData, dataTag); + } + + @Override +- protected void handleAirSupply(int airSupply) { +- } ++ protected void handleAirSupply(int airSupply) {} + + public void setTreasurePos(BlockPos pos) { +- this.entityData.set(TREASURE_POS, pos); ++ this.entityData.set(Dolphin.TREASURE_POS, pos); + } + + public BlockPos getTreasurePos() { +- return this.entityData.get(TREASURE_POS); ++ return (BlockPos) this.entityData.get(Dolphin.TREASURE_POS); + } + + public boolean gotFish() { +- return this.entityData.get(GOT_FISH); ++ return (Boolean) this.entityData.get(Dolphin.GOT_FISH); + } + + public void setGotFish(boolean gotFish) { +- this.entityData.set(GOT_FISH, gotFish); ++ this.entityData.set(Dolphin.GOT_FISH, gotFish); + } + + public int getMoistnessLevel() { +- return this.entityData.get(MOISTNESS_LEVEL); ++ return (Integer) this.entityData.get(Dolphin.MOISTNESS_LEVEL); + } + + public void setMoisntessLevel(int moistnessLevel) { +- this.entityData.set(MOISTNESS_LEVEL, moistnessLevel); ++ this.entityData.set(Dolphin.MOISTNESS_LEVEL, moistnessLevel); + } + + @Override + protected void defineSynchedData() { + super.defineSynchedData(); +- this.entityData.define(TREASURE_POS, BlockPos.ZERO); +- this.entityData.define(GOT_FISH, false); +- this.entityData.define(MOISTNESS_LEVEL, 2400); ++ this.entityData.define(Dolphin.TREASURE_POS, BlockPos.ZERO); ++ this.entityData.define(Dolphin.GOT_FISH, false); ++ this.entityData.define(Dolphin.MOISTNESS_LEVEL, 2400); + } + + @Override +@@ -135,10 +145,11 @@ + + @Override + public void readAdditionalSaveData(CompoundTag compound) { +- int _int = compound.getInt("TreasurePosX"); +- int _int1 = compound.getInt("TreasurePosY"); +- int _int2 = compound.getInt("TreasurePosZ"); +- this.setTreasurePos(new BlockPos(_int, _int1, _int2)); ++ int i = compound.getInt("TreasurePosX"); ++ int j = compound.getInt("TreasurePosY"); ++ int k = compound.getInt("TreasurePosZ"); ++ ++ this.setTreasurePos(new BlockPos(i, j, k)); + super.readAdditionalSaveData(compound); + this.setGotFish(compound.getBoolean("GotFish")); + this.setMoisntessLevel(compound.getInt("Moistness")); +@@ -149,20 +160,20 @@ + this.goalSelector.addGoal(0, new BreathAirGoal(this)); + this.goalSelector.addGoal(0, new TryFindWaterGoal(this)); + this.goalSelector.addGoal(1, new Dolphin.DolphinSwimToTreasureGoal(this)); +- this.goalSelector.addGoal(2, new Dolphin.DolphinSwimWithPlayerGoal(this, 4.0)); +- this.goalSelector.addGoal(4, new RandomSwimmingGoal(this, 1.0, 10)); ++ this.goalSelector.addGoal(2, new Dolphin.DolphinSwimWithPlayerGoal(this, 4.0D)); ++ this.goalSelector.addGoal(4, new PathfinderGoalRandomSwim(this, 1.0D, 10)); + this.goalSelector.addGoal(4, new RandomLookAroundGoal(this)); + this.goalSelector.addGoal(5, new LookAtPlayerGoal(this, Player.class, 6.0F)); + this.goalSelector.addGoal(5, new DolphinJumpGoal(this, 10)); +- this.goalSelector.addGoal(6, new MeleeAttackGoal(this, 1.2F, true)); ++ this.goalSelector.addGoal(6, new MeleeAttackGoal(this, 1.2000000476837158D, true)); + this.goalSelector.addGoal(8, new Dolphin.PlayWithItemsGoal()); + this.goalSelector.addGoal(8, new FollowBoatGoal(this)); +- this.goalSelector.addGoal(9, new AvoidEntityGoal<>(this, Guardian.class, 8.0F, 1.0, 1.0)); +- this.targetSelector.addGoal(1, new HurtByTargetGoal(this, Guardian.class).setAlertOthers()); ++ this.goalSelector.addGoal(9, new AvoidEntityGoal<>(this, Guardian.class, 8.0F, 1.0D, 1.0D)); ++ this.targetSelector.addGoal(1, (new HurtByTargetGoal(this, new Class[]{Guardian.class})).setAlertOthers()); + } + + public static AttributeSupplier.Builder createAttributes() { +- return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 10.0).add(Attributes.MOVEMENT_SPEED, 1.2F).add(Attributes.ATTACK_DAMAGE, 3.0); ++ return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 10.0D).add(Attributes.MOVEMENT_SPEED, 1.2000000476837158D).add(Attributes.ATTACK_DAMAGE, 3.0D); + } + + @Override +@@ -172,7 +183,8 @@ + + @Override + public boolean doHurtTarget(Entity entity) { +- boolean flag = entity.hurt(this.damageSources().mobAttack(this), (float)((int)this.getAttributeValue(Attributes.ATTACK_DAMAGE))); ++ boolean flag = entity.hurt(this.damageSources().mobAttack(this), (float) ((int) this.getAttributeValue(Attributes.ATTACK_DAMAGE))); ++ + if (flag) { + this.doEnchantDamageEffects(this, entity); + this.playSound(SoundEvents.DOLPHIN_ATTACK, 1.0F, 1.0F); +@@ -183,7 +195,7 @@ + + @Override + public int getMaxAirSupply() { +- return 4800; ++ return maxAirTicks; // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() + } + + @Override +@@ -192,7 +204,7 @@ + } + + @Override +- protected float getStandingEyeHeight(Pose pose, EntityDimensions size) { ++ protected float getStandingEyeHeight(EntityPose pose, EntityDimensions size) { + return 0.3F; + } + +@@ -213,22 +225,31 @@ + + @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); + } + + @Override + protected void pickUpItem(ItemEntity itemEntity) { + if (this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty()) { +- ItemStack item = itemEntity.getItem(); +- if (this.canHoldItem(item)) { ++ ItemStack itemstack = itemEntity.getItem(); ++ ++ if (this.canHoldItem(itemstack)) { ++ // CraftBukkit start - call EntityPickupItemEvent ++ if (CraftEventFactory.callEntityPickupItemEvent(this, itemEntity, 0, false).isCancelled()) { ++ return; ++ } ++ itemstack = itemEntity.getItem(); // CraftBukkit- update ItemStack from event ++ // CraftBukkit start + this.onItemPickup(itemEntity); +- this.setItemSlot(EquipmentSlot.MAINHAND, item); ++ this.setItemSlot(EquipmentSlot.MAINHAND, itemstack); + this.setGuaranteedDrop(EquipmentSlot.MAINHAND); +- this.take(itemEntity, item.getCount()); ++ this.take(itemEntity, itemstack.getCount()); + itemEntity.discard(); + } + } ++ + } + + @Override +@@ -246,45 +267,25 @@ + } + + if (this.onGround()) { +- this.setDeltaMovement( +- this.getDeltaMovement() +- .add((double)((this.random.nextFloat() * 2.0F - 1.0F) * 0.2F), 0.5, (double)((this.random.nextFloat() * 2.0F - 1.0F) * 0.2F)) +- ); ++ this.setDeltaMovement(this.getDeltaMovement().add((double) ((this.random.nextFloat() * 2.0F - 1.0F) * 0.2F), 0.5D, (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 0.2F))); + this.setYRot(this.random.nextFloat() * 360.0F); + this.setOnGround(false); + this.hasImpulse = true; + } + } + +- if (this.level().isClientSide && this.isInWater() && this.getDeltaMovement().lengthSqr() > 0.03) { +- Vec3 viewVector = this.getViewVector(0.0F); +- float f = Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)) * 0.3F; +- float f1 = Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)) * 0.3F; ++ if (this.level().isClientSide && this.isInWater() && this.getDeltaMovement().lengthSqr() > 0.03D) { ++ Vec3 vec3d = this.getViewVector(0.0F); ++ float f = Mth.cos(this.getYRot() * 0.017453292F) * 0.3F; ++ float f1 = Mth.sin(this.getYRot() * 0.017453292F) * 0.3F; + float f2 = 1.2F - this.random.nextFloat() * 0.7F; + +- for (int i = 0; i < 2; i++) { +- this.level() +- .addParticle( +- ParticleTypes.DOLPHIN, +- this.getX() - viewVector.x * (double)f2 + (double)f, +- this.getY() - viewVector.y, +- this.getZ() - viewVector.z * (double)f2 + (double)f1, +- 0.0, +- 0.0, +- 0.0 +- ); +- this.level() +- .addParticle( +- ParticleTypes.DOLPHIN, +- this.getX() - viewVector.x * (double)f2 - (double)f, +- this.getY() - viewVector.y, +- this.getZ() - viewVector.z * (double)f2 - (double)f1, +- 0.0, +- 0.0, +- 0.0 +- ); ++ for (int i = 0; i < 2; ++i) { ++ this.level().addParticle(ParticleTypes.DOLPHIN, this.getX() - vec3d.x * (double) f2 + (double) f, this.getY() - vec3d.y, this.getZ() - vec3d.z * (double) f2 + (double) f1, 0.0D, 0.0D, 0.0D); ++ this.level().addParticle(ParticleTypes.DOLPHIN, this.getX() - vec3d.x * (double) f2 - (double) f, this.getY() - vec3d.y, this.getZ() - vec3d.z * (double) f2 - (double) f1, 0.0D, 0.0D, 0.0D); + } + } ++ + } + } + +@@ -295,28 +296,32 @@ + } else { + super.handleEntityEvent(id); + } ++ + } + + private void addParticlesAroundSelf(ParticleOptions particleOption) { +- for (int i = 0; i < 7; i++) { +- double d = this.random.nextGaussian() * 0.01; +- double d1 = this.random.nextGaussian() * 0.01; +- double d2 = this.random.nextGaussian() * 0.01; +- this.level().addParticle(particleOption, this.getRandomX(1.0), this.getRandomY() + 0.2, this.getRandomZ(1.0), d, d1, d2); ++ for (int i = 0; i < 7; ++i) { ++ double d0 = this.random.nextGaussian() * 0.01D; ++ double d1 = this.random.nextGaussian() * 0.01D; ++ double d2 = this.random.nextGaussian() * 0.01D; ++ ++ this.level().addParticle(particleOption, this.getRandomX(1.0D), this.getRandomY() + 0.2D, this.getRandomZ(1.0D), d0, d1, d2); + } ++ + } + + @Override +- protected InteractionResult mobInteract(Player player, InteractionHand hand) { +- ItemStack itemInHand = player.getItemInHand(hand); +- if (!itemInHand.isEmpty() && itemInHand.is(ItemTags.FISHES)) { ++ protected InteractionResult mobInteract(Player player, EnumHand hand) { ++ ItemStack itemstack = player.getItemInHand(hand); ++ ++ if (!itemstack.isEmpty() && itemstack.is(ItemTags.FISHES)) { + if (!this.level().isClientSide) { + this.playSound(SoundEvents.DOLPHIN_EAT, 1.0F, 1.0F); + } + + this.setGotFish(true); + if (!player.getAbilities().instabuild) { +- itemInHand.shrink(1); ++ itemstack.shrink(1); + } + + return InteractionResult.sidedSuccess(this.level().isClientSide); +@@ -353,22 +358,24 @@ + } + + protected boolean closeToNextPos() { +- BlockPos targetPos = this.getNavigation().getTargetPos(); +- return targetPos != null && targetPos.closerToCenterThan(this.position(), 12.0); ++ BlockPos blockposition = this.getNavigation().getTargetPos(); ++ ++ return blockposition != null ? blockposition.closerToCenterThan(this.position(), 12.0D) : false; + } + + @Override + public void travel(Vec3 travelVector) { + if (this.isEffectiveAi() && this.isInWater()) { + this.moveRelative(this.getSpeed(), travelVector); +- this.move(MoverType.SELF, this.getDeltaMovement()); +- this.setDeltaMovement(this.getDeltaMovement().scale(0.9)); ++ this.move(EnumMoveType.SELF, this.getDeltaMovement()); ++ this.setDeltaMovement(this.getDeltaMovement().scale(0.9D)); + if (this.getTarget() == null) { +- this.setDeltaMovement(this.getDeltaMovement().add(0.0, -0.005, 0.0)); ++ this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.005D, 0.0D)); + } + } else { + super.travel(travelVector); + } ++ + } + + @Override +@@ -376,13 +383,14 @@ + return true; + } + +- static class DolphinSwimToTreasureGoal extends Goal { ++ private static class DolphinSwimToTreasureGoal extends Goal { ++ + private final Dolphin dolphin; + private boolean stuck; + + DolphinSwimToTreasureGoal(Dolphin dolphin) { + this.dolphin = dolphin; +- this.setFlags(EnumSet.of(Goal.Flag.MOVE, Goal.Flag.LOOK)); ++ this.setFlags(EnumSet.of(Goal.Type.MOVE, Goal.Type.LOOK)); + } + + @Override +@@ -397,24 +405,24 @@ + + @Override + public boolean canContinueToUse() { +- BlockPos treasurePos = this.dolphin.getTreasurePos(); +- return !BlockPos.containing((double)treasurePos.getX(), this.dolphin.getY(), (double)treasurePos.getZ()) +- .closerToCenterThan(this.dolphin.position(), 4.0) +- && !this.stuck +- && this.dolphin.getAirSupply() >= 100; ++ BlockPos blockposition = this.dolphin.getTreasurePos(); ++ ++ return !BlockPos.containing((double) blockposition.getX(), this.dolphin.getY(), (double) blockposition.getZ()).closerToCenterThan(this.dolphin.position(), 4.0D) && !this.stuck && this.dolphin.getAirSupply() >= 100; + } + + @Override + public void start() { + if (this.dolphin.level() instanceof ServerLevel) { +- ServerLevel serverLevel = (ServerLevel)this.dolphin.level(); ++ ServerLevel worldserver = (ServerLevel) this.dolphin.level(); ++ + this.stuck = false; + this.dolphin.getNavigation().stop(); +- BlockPos blockPos = this.dolphin.blockPosition(); +- BlockPos blockPos1 = serverLevel.findNearestMapStructure(StructureTags.DOLPHIN_LOCATED, blockPos, 50, false); +- if (blockPos1 != null) { +- this.dolphin.setTreasurePos(blockPos1); +- serverLevel.broadcastEntityEvent(this.dolphin, (byte)38); ++ BlockPos blockposition = this.dolphin.blockPosition(); ++ BlockPos blockposition1 = worldserver.findNearestMapStructure(StructureTags.DOLPHIN_LOCATED, blockposition, 50, false); ++ ++ if (blockposition1 != null) { ++ this.dolphin.setTreasurePos(blockposition1); ++ worldserver.broadcastEntityEvent(this.dolphin, (byte) 38); + } else { + this.stuck = true; + } +@@ -423,49 +431,51 @@ + + @Override + public void stop() { +- BlockPos treasurePos = this.dolphin.getTreasurePos(); +- if (BlockPos.containing((double)treasurePos.getX(), this.dolphin.getY(), (double)treasurePos.getZ()) +- .closerToCenterThan(this.dolphin.position(), 4.0) +- || this.stuck) { ++ BlockPos blockposition = this.dolphin.getTreasurePos(); ++ ++ if (BlockPos.containing((double) blockposition.getX(), this.dolphin.getY(), (double) blockposition.getZ()).closerToCenterThan(this.dolphin.position(), 4.0D) || this.stuck) { + this.dolphin.setGotFish(false); + } ++ + } + + @Override + public void tick() { +- Level level = this.dolphin.level(); ++ Level world = this.dolphin.level(); ++ + if (this.dolphin.closeToNextPos() || this.dolphin.getNavigation().isDone()) { +- Vec3 vec3 = Vec3.atCenterOf(this.dolphin.getTreasurePos()); +- Vec3 posTowards = DefaultRandomPos.getPosTowards(this.dolphin, 16, 1, vec3, (float) (Math.PI / 8)); +- if (posTowards == null) { +- posTowards = DefaultRandomPos.getPosTowards(this.dolphin, 8, 4, vec3, (float) (Math.PI / 2)); ++ Vec3 vec3d = Vec3.atCenterOf(this.dolphin.getTreasurePos()); ++ Vec3 vec3d1 = DefaultRandomPos.getPosTowards(this.dolphin, 16, 1, vec3d, 0.39269909262657166D); ++ ++ if (vec3d1 == null) { ++ vec3d1 = DefaultRandomPos.getPosTowards(this.dolphin, 8, 4, vec3d, 1.5707963705062866D); + } + +- if (posTowards != null) { +- BlockPos blockPos = BlockPos.containing(posTowards); +- if (!level.getFluidState(blockPos).is(FluidTags.WATER) +- || !level.getBlockState(blockPos).isPathfindable(level, blockPos, PathComputationType.WATER)) { +- posTowards = DefaultRandomPos.getPosTowards(this.dolphin, 8, 5, vec3, (float) (Math.PI / 2)); ++ if (vec3d1 != null) { ++ BlockPos blockposition = BlockPos.containing(vec3d1); ++ ++ if (!world.getFluidState(blockposition).is(FluidTags.WATER) || !world.getBlockState(blockposition).isPathfindable(world, blockposition, PathMode.WATER)) { ++ vec3d1 = DefaultRandomPos.getPosTowards(this.dolphin, 8, 5, vec3d, 1.5707963705062866D); + } + } + +- if (posTowards == null) { ++ if (vec3d1 == null) { + this.stuck = true; + return; + } + +- this.dolphin +- .getLookControl() +- .setLookAt(posTowards.x, posTowards.y, posTowards.z, (float)(this.dolphin.getMaxHeadYRot() + 20), (float)this.dolphin.getMaxHeadXRot()); +- this.dolphin.getNavigation().moveTo(posTowards.x, posTowards.y, posTowards.z, 1.3); +- if (level.random.nextInt(this.adjustedTickDelay(80)) == 0) { +- level.broadcastEntityEvent(this.dolphin, (byte)38); ++ this.dolphin.getLookControl().setLookAt(vec3d1.x, vec3d1.y, vec3d1.z, (float) (this.dolphin.getMaxHeadYRot() + 20), (float) this.dolphin.getMaxHeadXRot()); ++ this.dolphin.getNavigation().moveTo(vec3d1.x, vec3d1.y, vec3d1.z, 1.3D); ++ if (world.random.nextInt(this.adjustedTickDelay(80)) == 0) { ++ world.broadcastEntityEvent(this.dolphin, (byte) 38); + } + } ++ + } + } + +- static class DolphinSwimWithPlayerGoal extends Goal { ++ private static class DolphinSwimWithPlayerGoal extends Goal { ++ + private final Dolphin dolphin; + private final double speedModifier; + @Nullable +@@ -474,23 +484,23 @@ + DolphinSwimWithPlayerGoal(Dolphin dolphin, double speedModifier) { + this.dolphin = dolphin; + this.speedModifier = speedModifier; +- this.setFlags(EnumSet.of(Goal.Flag.MOVE, Goal.Flag.LOOK)); ++ this.setFlags(EnumSet.of(Goal.Type.MOVE, Goal.Type.LOOK)); + } + + @Override + public boolean canUse() { + this.player = this.dolphin.level().getNearestPlayer(Dolphin.SWIM_WITH_PLAYER_TARGETING, this.dolphin); +- return this.player != null && this.player.isSwimming() && this.dolphin.getTarget() != this.player; ++ return this.player == null ? false : this.player.isSwimming() && this.dolphin.getTarget() != this.player; + } + + @Override + public boolean canContinueToUse() { +- return this.player != null && this.player.isSwimming() && this.dolphin.distanceToSqr(this.player) < 256.0; ++ return this.player != null && this.player.isSwimming() && this.dolphin.distanceToSqr((Entity) this.player) < 256.0D; + } + + @Override + public void start() { +- this.player.addEffect(new MobEffectInstance(MobEffects.DOLPHINS_GRACE, 100), this.dolphin); ++ this.player.addEffect(new MobEffectInstance(MobEffects.DOLPHINS_GRACE, 100), this.dolphin, EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit + } + + @Override +@@ -501,39 +511,43 @@ + + @Override + public void tick() { +- this.dolphin.getLookControl().setLookAt(this.player, (float)(this.dolphin.getMaxHeadYRot() + 20), (float)this.dolphin.getMaxHeadXRot()); +- if (this.dolphin.distanceToSqr(this.player) < 6.25) { ++ this.dolphin.getLookControl().setLookAt(this.player, (float) (this.dolphin.getMaxHeadYRot() + 20), (float) this.dolphin.getMaxHeadXRot()); ++ if (this.dolphin.distanceToSqr((Entity) this.player) < 6.25D) { + this.dolphin.getNavigation().stop(); + } else { +- this.dolphin.getNavigation().moveTo(this.player, this.speedModifier); ++ this.dolphin.getNavigation().moveTo((Entity) this.player, this.speedModifier); + } + + if (this.player.isSwimming() && this.player.level().random.nextInt(6) == 0) { +- this.player.addEffect(new MobEffectInstance(MobEffects.DOLPHINS_GRACE, 100), this.dolphin); ++ this.player.addEffect(new MobEffectInstance(MobEffects.DOLPHINS_GRACE, 100), this.dolphin, EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit + } ++ + } + } + +- class PlayWithItemsGoal extends Goal { ++ private class PlayWithItemsGoal extends Goal { ++ + private int cooldown; + ++ PlayWithItemsGoal() {} ++ + @Override + public boolean canUse() { + if (this.cooldown > Dolphin.this.tickCount) { + return false; + } else { +- List<ItemEntity> entitiesOfClass = Dolphin.this.level() +- .getEntitiesOfClass(ItemEntity.class, Dolphin.this.getBoundingBox().inflate(8.0, 8.0, 8.0), Dolphin.ALLOWED_ITEMS); +- return !entitiesOfClass.isEmpty() || !Dolphin.this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty(); ++ List<ItemEntity> list = Dolphin.this.level().getEntitiesOfClass(ItemEntity.class, Dolphin.this.getBoundingBox().inflate(8.0D, 8.0D, 8.0D), Dolphin.ALLOWED_ITEMS); ++ ++ return !list.isEmpty() || !Dolphin.this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty(); + } + } + + @Override + public void start() { +- List<ItemEntity> entitiesOfClass = Dolphin.this.level() +- .getEntitiesOfClass(ItemEntity.class, Dolphin.this.getBoundingBox().inflate(8.0, 8.0, 8.0), Dolphin.ALLOWED_ITEMS); +- if (!entitiesOfClass.isEmpty()) { +- Dolphin.this.getNavigation().moveTo(entitiesOfClass.get(0), 1.2F); ++ List<ItemEntity> list = Dolphin.this.level().getEntitiesOfClass(ItemEntity.class, Dolphin.this.getBoundingBox().inflate(8.0D, 8.0D, 8.0D), Dolphin.ALLOWED_ITEMS); ++ ++ if (!list.isEmpty()) { ++ Dolphin.this.getNavigation().moveTo((Entity) list.get(0), 1.2000000476837158D); + Dolphin.this.playSound(SoundEvents.DOLPHIN_PLAY, 1.0F, 1.0F); + } + +@@ -542,48 +556,43 @@ + + @Override + public void stop() { +- ItemStack itemBySlot = Dolphin.this.getItemBySlot(EquipmentSlot.MAINHAND); +- if (!itemBySlot.isEmpty()) { +- this.drop(itemBySlot); ++ ItemStack itemstack = Dolphin.this.getItemBySlot(EquipmentSlot.MAINHAND); ++ ++ if (!itemstack.isEmpty()) { ++ this.drop(itemstack); + Dolphin.this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY); + this.cooldown = Dolphin.this.tickCount + Dolphin.this.random.nextInt(100); + } ++ + } + + @Override + public void tick() { +- List<ItemEntity> entitiesOfClass = Dolphin.this.level() +- .getEntitiesOfClass(ItemEntity.class, Dolphin.this.getBoundingBox().inflate(8.0, 8.0, 8.0), Dolphin.ALLOWED_ITEMS); +- ItemStack itemBySlot = Dolphin.this.getItemBySlot(EquipmentSlot.MAINHAND); +- if (!itemBySlot.isEmpty()) { +- this.drop(itemBySlot); ++ List<ItemEntity> list = Dolphin.this.level().getEntitiesOfClass(ItemEntity.class, Dolphin.this.getBoundingBox().inflate(8.0D, 8.0D, 8.0D), Dolphin.ALLOWED_ITEMS); ++ ItemStack itemstack = Dolphin.this.getItemBySlot(EquipmentSlot.MAINHAND); ++ ++ if (!itemstack.isEmpty()) { ++ this.drop(itemstack); + Dolphin.this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY); +- } else if (!entitiesOfClass.isEmpty()) { +- Dolphin.this.getNavigation().moveTo(entitiesOfClass.get(0), 1.2F); ++ } else if (!list.isEmpty()) { ++ Dolphin.this.getNavigation().moveTo((Entity) list.get(0), 1.2000000476837158D); + } ++ + } + + private void drop(ItemStack stack) { + if (!stack.isEmpty()) { +- double d = Dolphin.this.getEyeY() - 0.3F; +- ItemEntity itemEntity = new ItemEntity(Dolphin.this.level(), Dolphin.this.getX(), d, Dolphin.this.getZ(), stack); +- itemEntity.setPickUpDelay(40); +- itemEntity.setThrower(Dolphin.this); ++ double d0 = Dolphin.this.getEyeY() - 0.30000001192092896D; ++ ItemEntity entityitem = new ItemEntity(Dolphin.this.level(), Dolphin.this.getX(), d0, Dolphin.this.getZ(), stack); ++ ++ entityitem.setPickUpDelay(40); ++ entityitem.setThrower(Dolphin.this); + float f = 0.3F; +- float f1 = Dolphin.this.random.nextFloat() * (float) (Math.PI * 2); ++ float f1 = Dolphin.this.random.nextFloat() * 6.2831855F; + float f2 = 0.02F * Dolphin.this.random.nextFloat(); +- itemEntity.setDeltaMovement( +- (double)( +- 0.3F * -Mth.sin(Dolphin.this.getYRot() * (float) (Math.PI / 180.0)) * Mth.cos(Dolphin.this.getXRot() * (float) (Math.PI / 180.0)) +- + Mth.cos(f1) * f2 +- ), +- (double)(0.3F * Mth.sin(Dolphin.this.getXRot() * (float) (Math.PI / 180.0)) * 1.5F), +- (double)( +- 0.3F * Mth.cos(Dolphin.this.getYRot() * (float) (Math.PI / 180.0)) * Mth.cos(Dolphin.this.getXRot() * (float) (Math.PI / 180.0)) +- + Mth.sin(f1) * f2 +- ) +- ); +- Dolphin.this.level().addFreshEntity(itemEntity); ++ ++ entityitem.setDeltaMovement((double) (0.3F * -Mth.sin(Dolphin.this.getYRot() * 0.017453292F) * Mth.cos(Dolphin.this.getXRot() * 0.017453292F) + Mth.cos(f1) * f2), (double) (0.3F * Mth.sin(Dolphin.this.getXRot() * 0.017453292F) * 1.5F), (double) (0.3F * Mth.cos(Dolphin.this.getYRot() * 0.017453292F) * Mth.cos(Dolphin.this.getXRot() * 0.017453292F) + Mth.sin(f1) * f2)); ++ Dolphin.this.level().addFreshEntity(entityitem); + } + } + } |