diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/monster/Guardian.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/entity/monster/Guardian.java.patch | 574 |
1 files changed, 574 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/monster/Guardian.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/monster/Guardian.java.patch new file mode 100644 index 0000000000..b2e7e561b7 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/monster/Guardian.java.patch @@ -0,0 +1,574 @@ +--- a/net/minecraft/world/entity/monster/Guardian.java ++++ b/net/minecraft/world/entity/monster/Guardian.java +@@ -19,12 +19,12 @@ + import net.minecraft.world.damagesource.DamageTypes; + 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.EnumMonsterType; ++import net.minecraft.world.entity.EnumMoveType; + import net.minecraft.world.entity.LivingEntity; +-import net.minecraft.world.entity.MobSpawnType; +-import net.minecraft.world.entity.MobType; +-import net.minecraft.world.entity.MoverType; +-import net.minecraft.world.entity.Pose; + import net.minecraft.world.entity.ai.attributes.AttributeSupplier; + import net.minecraft.world.entity.ai.attributes.Attributes; + import net.minecraft.world.entity.ai.control.LookControl; +@@ -48,6 +48,7 @@ + import org.joml.Vector3f; + + public class Guardian extends Monster { ++ + protected static final int ATTACK_TIME = 80; + private static final EntityDataAccessor<Boolean> DATA_ID_MOVING = SynchedEntityData.defineId(Guardian.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor<Integer> DATA_ID_ATTACK_TARGET = SynchedEntityData.defineId(Guardian.class, EntityDataSerializers.INT); +@@ -61,7 +62,8 @@ + private int clientSideAttackTime; + private boolean clientSideTouchedGround; + @Nullable +- protected RandomStrollGoal randomStrollGoal; ++ public RandomStrollGoal randomStrollGoal; ++ public Guardian.GuardianAttackGoal guardianAttackGoal; // CraftBukkit - add field + + public Guardian(EntityType<? extends Guardian> entityType, Level level) { + super(entityType, level); +@@ -74,25 +76,22 @@ + + @Override + protected void registerGoals() { +- MoveTowardsRestrictionGoal moveTowardsRestrictionGoal = new MoveTowardsRestrictionGoal(this, 1.0); +- this.randomStrollGoal = new RandomStrollGoal(this, 1.0, 80); +- this.goalSelector.addGoal(4, new Guardian.GuardianAttackGoal(this)); +- this.goalSelector.addGoal(5, moveTowardsRestrictionGoal); ++ MoveTowardsRestrictionGoal pathfindergoalmovetowardsrestriction = new MoveTowardsRestrictionGoal(this, 1.0D); ++ ++ this.randomStrollGoal = new RandomStrollGoal(this, 1.0D, 80); ++ this.goalSelector.addGoal(4, guardianAttackGoal = new Guardian.GuardianAttackGoal(this)); // CraftBukkit - assign field ++ this.goalSelector.addGoal(5, pathfindergoalmovetowardsrestriction); + this.goalSelector.addGoal(7, this.randomStrollGoal); + this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Player.class, 8.0F)); + this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Guardian.class, 12.0F, 0.01F)); + this.goalSelector.addGoal(9, new RandomLookAroundGoal(this)); +- this.randomStrollGoal.setFlags(EnumSet.of(Goal.Flag.MOVE, Goal.Flag.LOOK)); +- moveTowardsRestrictionGoal.setFlags(EnumSet.of(Goal.Flag.MOVE, Goal.Flag.LOOK)); ++ this.randomStrollGoal.setFlags(EnumSet.of(Goal.Type.MOVE, Goal.Type.LOOK)); ++ pathfindergoalmovetowardsrestriction.setFlags(EnumSet.of(Goal.Type.MOVE, Goal.Type.LOOK)); + this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, LivingEntity.class, 10, true, false, new Guardian.GuardianAttackSelector(this))); + } + + public static AttributeSupplier.Builder createAttributes() { +- return Monster.createMonsterAttributes() +- .add(Attributes.ATTACK_DAMAGE, 6.0) +- .add(Attributes.MOVEMENT_SPEED, 0.5) +- .add(Attributes.FOLLOW_RANGE, 16.0) +- .add(Attributes.MAX_HEALTH, 30.0); ++ return Monster.createMonsterAttributes().add(Attributes.ATTACK_DAMAGE, 6.0D).add(Attributes.MOVEMENT_SPEED, 0.5D).add(Attributes.FOLLOW_RANGE, 16.0D).add(Attributes.MAX_HEALTH, 30.0D); + } + + @Override +@@ -103,33 +102,33 @@ + @Override + protected void defineSynchedData() { + super.defineSynchedData(); +- this.entityData.define(DATA_ID_MOVING, false); +- this.entityData.define(DATA_ID_ATTACK_TARGET, 0); ++ this.entityData.define(Guardian.DATA_ID_MOVING, false); ++ this.entityData.define(Guardian.DATA_ID_ATTACK_TARGET, 0); + } + + @Override +- public MobType getMobType() { +- return MobType.WATER; ++ public EnumMonsterType getMobType() { ++ return EnumMonsterType.WATER; + } + + public boolean isMoving() { +- return this.entityData.get(DATA_ID_MOVING); ++ return (Boolean) this.entityData.get(Guardian.DATA_ID_MOVING); + } + + void setMoving(boolean moving) { +- this.entityData.set(DATA_ID_MOVING, moving); ++ this.entityData.set(Guardian.DATA_ID_MOVING, moving); + } + + public int getAttackDuration() { + return 80; + } + +- void setActiveAttackTarget(int activeAttackTargetId) { +- this.entityData.set(DATA_ID_ATTACK_TARGET, activeAttackTargetId); ++ public void setActiveAttackTarget(int activeAttackTargetId) { ++ this.entityData.set(Guardian.DATA_ID_ATTACK_TARGET, activeAttackTargetId); + } + + public boolean hasActiveAttackTarget() { +- return this.entityData.get(DATA_ID_ATTACK_TARGET) != 0; ++ return (Integer) this.entityData.get(Guardian.DATA_ID_ATTACK_TARGET) != 0; + } + + @Nullable +@@ -140,9 +139,10 @@ + if (this.clientSideCachedAttackTarget != null) { + return this.clientSideCachedAttackTarget; + } else { +- Entity entity = this.level().getEntity(this.entityData.get(DATA_ID_ATTACK_TARGET)); ++ Entity entity = this.level().getEntity((Integer) this.entityData.get(Guardian.DATA_ID_ATTACK_TARGET)); ++ + if (entity instanceof LivingEntity) { +- this.clientSideCachedAttackTarget = (LivingEntity)entity; ++ this.clientSideCachedAttackTarget = (LivingEntity) entity; + return this.clientSideCachedAttackTarget; + } else { + return null; +@@ -156,10 +156,11 @@ + @Override + public void onSyncedDataUpdated(EntityDataAccessor<?> key) { + super.onSyncedDataUpdated(key); +- if (DATA_ID_ATTACK_TARGET.equals(key)) { ++ if (Guardian.DATA_ID_ATTACK_TARGET.equals(key)) { + this.clientSideAttackTime = 0; + this.clientSideCachedAttackTarget = null; + } ++ + } + + @Override +@@ -188,7 +189,7 @@ + } + + @Override +- protected float getStandingEyeHeight(Pose pose, EntityDimensions size) { ++ protected float getStandingEyeHeight(EntityPose pose, EntityDimensions size) { + return size.height * 0.5F; + } + +@@ -202,82 +203,68 @@ + if (this.isAlive()) { + if (this.level().isClientSide) { + this.clientSideTailAnimationO = this.clientSideTailAnimation; ++ Vec3 vec3d; ++ + if (!this.isInWater()) { + this.clientSideTailAnimationSpeed = 2.0F; +- Vec3 deltaMovement = this.getDeltaMovement(); +- if (deltaMovement.y > 0.0 && this.clientSideTouchedGround && !this.isSilent()) { ++ vec3d = this.getDeltaMovement(); ++ if (vec3d.y > 0.0D && this.clientSideTouchedGround && !this.isSilent()) { + this.level().playLocalSound(this.getX(), this.getY(), this.getZ(), this.getFlopSound(), this.getSoundSource(), 1.0F, 1.0F, false); + } + +- this.clientSideTouchedGround = deltaMovement.y < 0.0 && this.level().loadedAndEntityCanStandOn(this.blockPosition().below(), this); ++ this.clientSideTouchedGround = vec3d.y < 0.0D && this.level().loadedAndEntityCanStandOn(this.blockPosition().below(), this); + } else if (this.isMoving()) { + if (this.clientSideTailAnimationSpeed < 0.5F) { + this.clientSideTailAnimationSpeed = 4.0F; + } else { +- this.clientSideTailAnimationSpeed = this.clientSideTailAnimationSpeed + (0.5F - this.clientSideTailAnimationSpeed) * 0.1F; ++ this.clientSideTailAnimationSpeed += (0.5F - this.clientSideTailAnimationSpeed) * 0.1F; + } + } else { +- this.clientSideTailAnimationSpeed = this.clientSideTailAnimationSpeed + (0.125F - this.clientSideTailAnimationSpeed) * 0.2F; ++ this.clientSideTailAnimationSpeed += (0.125F - this.clientSideTailAnimationSpeed) * 0.2F; + } + +- this.clientSideTailAnimation = this.clientSideTailAnimation + this.clientSideTailAnimationSpeed; ++ this.clientSideTailAnimation += this.clientSideTailAnimationSpeed; + this.clientSideSpikesAnimationO = this.clientSideSpikesAnimation; + if (!this.isInWaterOrBubble()) { + this.clientSideSpikesAnimation = this.random.nextFloat(); + } else if (this.isMoving()) { +- this.clientSideSpikesAnimation = this.clientSideSpikesAnimation + (0.0F - this.clientSideSpikesAnimation) * 0.25F; ++ this.clientSideSpikesAnimation += (0.0F - this.clientSideSpikesAnimation) * 0.25F; + } else { +- this.clientSideSpikesAnimation = this.clientSideSpikesAnimation + (1.0F - this.clientSideSpikesAnimation) * 0.06F; ++ this.clientSideSpikesAnimation += (1.0F - this.clientSideSpikesAnimation) * 0.06F; + } + + if (this.isMoving() && this.isInWater()) { +- Vec3 deltaMovement = this.getViewVector(0.0F); ++ vec3d = this.getViewVector(0.0F); + +- for (int i = 0; i < 2; i++) { +- this.level() +- .addParticle( +- ParticleTypes.BUBBLE, +- this.getRandomX(0.5) - deltaMovement.x * 1.5, +- this.getRandomY() - deltaMovement.y * 1.5, +- this.getRandomZ(0.5) - deltaMovement.z * 1.5, +- 0.0, +- 0.0, +- 0.0 +- ); ++ for (int i = 0; i < 2; ++i) { ++ this.level().addParticle(ParticleTypes.BUBBLE, this.getRandomX(0.5D) - vec3d.x * 1.5D, this.getRandomY() - vec3d.y * 1.5D, this.getRandomZ(0.5D) - vec3d.z * 1.5D, 0.0D, 0.0D, 0.0D); + } + } + + if (this.hasActiveAttackTarget()) { + if (this.clientSideAttackTime < this.getAttackDuration()) { +- this.clientSideAttackTime++; ++ ++this.clientSideAttackTime; + } + +- LivingEntity activeAttackTarget = this.getActiveAttackTarget(); +- if (activeAttackTarget != null) { +- this.getLookControl().setLookAt(activeAttackTarget, 90.0F, 90.0F); ++ LivingEntity entityliving = this.getActiveAttackTarget(); ++ ++ if (entityliving != null) { ++ this.getLookControl().setLookAt(entityliving, 90.0F, 90.0F); + this.getLookControl().tick(); +- double d = (double)this.getAttackAnimationScale(0.0F); +- double d1 = activeAttackTarget.getX() - this.getX(); +- double d2 = activeAttackTarget.getY(0.5) - this.getEyeY(); +- double d3 = activeAttackTarget.getZ() - this.getZ(); +- double squareRoot = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3); +- double var17 = d1 / squareRoot; +- double var18 = d2 / squareRoot; +- double var19 = d3 / squareRoot; +- double randomDouble = this.random.nextDouble(); ++ double d0 = (double) this.getAttackAnimationScale(0.0F); ++ double d1 = entityliving.getX() - this.getX(); ++ double d2 = entityliving.getY(0.5D) - this.getEyeY(); ++ double d3 = entityliving.getZ() - this.getZ(); ++ double d4 = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3); + +- while (randomDouble < squareRoot) { +- randomDouble += 1.8 - d + this.random.nextDouble() * (1.7 - d); +- this.level() +- .addParticle( +- ParticleTypes.BUBBLE, +- this.getX() + var17 * randomDouble, +- this.getEyeY() + var18 * randomDouble, +- this.getZ() + var19 * randomDouble, +- 0.0, +- 0.0, +- 0.0 +- ); ++ d1 /= d4; ++ d2 /= d4; ++ d3 /= d4; ++ double d5 = this.random.nextDouble(); ++ ++ while (d5 < d4) { ++ d5 += 1.8D - d0 + this.random.nextDouble() * (1.7D - d0); ++ this.level().addParticle(ParticleTypes.BUBBLE, this.getX() + d1 * d5, this.getEyeY() + d2 * d5, this.getZ() + d3 * d5, 0.0D, 0.0D, 0.0D); + } + } + } +@@ -286,10 +273,7 @@ + if (this.isInWaterOrBubble()) { + this.setAirSupply(300); + } else if (this.onGround()) { +- this.setDeltaMovement( +- this.getDeltaMovement() +- .add((double)((this.random.nextFloat() * 2.0F - 1.0F) * 0.4F), 0.5, (double)((this.random.nextFloat() * 2.0F - 1.0F) * 0.4F)) +- ); ++ this.setDeltaMovement(this.getDeltaMovement().add((double) ((this.random.nextFloat() * 2.0F - 1.0F) * 0.4F), 0.5D, (double) ((this.random.nextFloat() * 2.0F - 1.0F) * 0.4F))); + this.setYRot(this.random.nextFloat() * 360.0F); + this.setOnGround(false); + this.hasImpulse = true; +@@ -316,11 +300,11 @@ + } + + public float getAttackAnimationScale(float partialTick) { +- return ((float)this.clientSideAttackTime + partialTick) / (float)this.getAttackDuration(); ++ return ((float) this.clientSideAttackTime + partialTick) / (float) this.getAttackDuration(); + } + + public float getClientSideAttackTime() { +- return (float)this.clientSideAttackTime; ++ return (float) this.clientSideAttackTime; + } + + @Override +@@ -328,13 +312,8 @@ + return level.isUnobstructed(this); + } + +- public static boolean checkGuardianSpawnRules( +- EntityType<? extends Guardian> guardian, LevelAccessor level, MobSpawnType spawnType, BlockPos pos, RandomSource random +- ) { +- return (random.nextInt(20) == 0 || !level.canSeeSkyFromBelowWater(pos)) +- && level.getDifficulty() != Difficulty.PEACEFUL +- && (MobSpawnType.isSpawner(spawnType) || level.getFluidState(pos).is(FluidTags.WATER)) +- && level.getFluidState(pos.below()).is(FluidTags.WATER); ++ public static boolean checkGuardianSpawnRules(EntityType<? extends Guardian> guardian, LevelAccessor level, EnumMobSpawn spawnType, BlockPos pos, RandomSource random) { ++ return (random.nextInt(20) == 0 || !level.canSeeSkyFromBelowWater(pos)) && level.getDifficulty() != Difficulty.PEACEFUL && (EnumMobSpawn.isSpawner(spawnType) || level.getFluidState(pos).is(FluidTags.WATER)) && level.getFluidState(pos.below()).is(FluidTags.WATER); + } + + @Override +@@ -342,11 +321,14 @@ + if (this.level().isClientSide) { + return false; + } else { +- if (!this.isMoving() +- && !source.is(DamageTypeTags.AVOIDS_GUARDIAN_THORNS) +- && !source.is(DamageTypes.THORNS) +- && source.getDirectEntity() instanceof LivingEntity livingEntity) { +- livingEntity.hurt(this.damageSources().thorns(this), 2.0F); ++ if (!this.isMoving() && !source.is(DamageTypeTags.AVOIDS_GUARDIAN_THORNS) && !source.is(DamageTypes.THORNS)) { ++ Entity entity = source.getDirectEntity(); ++ ++ if (entity instanceof LivingEntity) { ++ LivingEntity entityliving = (LivingEntity) entity; ++ ++ entityliving.hurt(this.damageSources().thorns(this), 2.0F); ++ } + } + + if (this.randomStrollGoal != null) { +@@ -366,51 +348,108 @@ + public void travel(Vec3 travelVector) { + if (this.isControlledByLocalInstance() && this.isInWater()) { + this.moveRelative(0.1F, 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.isMoving() && 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 +- protected Vector3f getPassengerAttachmentPoint(Entity entity, EntityDimensions entityDimensions, float f) { +- return new Vector3f(0.0F, entityDimensions.height + 0.125F * f, 0.0F); ++ protected Vector3f getPassengerAttachmentPoint(Entity entity, EntityDimensions entitysize, float f) { ++ return new Vector3f(0.0F, entitysize.height + 0.125F * f, 0.0F); + } + +- static class GuardianAttackGoal extends Goal { ++ private static class GuardianMoveControl extends MoveControl { ++ + private final Guardian guardian; +- private int attackTime; ++ ++ public GuardianMoveControl(Guardian guardian) { ++ super(guardian); ++ this.guardian = guardian; ++ } ++ ++ @Override ++ public void tick() { ++ if (this.operation == MoveControl.Operation.MOVE_TO && !this.guardian.getNavigation().isDone()) { ++ Vec3 vec3d = new Vec3(this.wantedX - this.guardian.getX(), this.wantedY - this.guardian.getY(), this.wantedZ - this.guardian.getZ()); ++ double d0 = vec3d.length(); ++ double d1 = vec3d.x / d0; ++ double d2 = vec3d.y / d0; ++ double d3 = vec3d.z / d0; ++ float f = (float) (Mth.atan2(vec3d.z, vec3d.x) * 57.2957763671875D) - 90.0F; ++ ++ this.guardian.setYRot(this.rotlerp(this.guardian.getYRot(), f, 90.0F)); ++ this.guardian.yBodyRot = this.guardian.getYRot(); ++ float f1 = (float) (this.speedModifier * this.guardian.getAttributeValue(Attributes.MOVEMENT_SPEED)); ++ float f2 = Mth.lerp(0.125F, this.guardian.getSpeed(), f1); ++ ++ this.guardian.setSpeed(f2); ++ double d4 = Math.sin((double) (this.guardian.tickCount + this.guardian.getId()) * 0.5D) * 0.05D; ++ double d5 = Math.cos((double) (this.guardian.getYRot() * 0.017453292F)); ++ double d6 = Math.sin((double) (this.guardian.getYRot() * 0.017453292F)); ++ double d7 = Math.sin((double) (this.guardian.tickCount + this.guardian.getId()) * 0.75D) * 0.05D; ++ ++ this.guardian.setDeltaMovement(this.guardian.getDeltaMovement().add(d4 * d5, d7 * (d6 + d5) * 0.25D + (double) f2 * d2 * 0.1D, d4 * d6)); ++ LookControl controllerlook = this.guardian.getLookControl(); ++ double d8 = this.guardian.getX() + d1 * 2.0D; ++ double d9 = this.guardian.getEyeY() + d2 / d0; ++ double d10 = this.guardian.getZ() + d3 * 2.0D; ++ double d11 = controllerlook.getWantedX(); ++ double d12 = controllerlook.getWantedY(); ++ double d13 = controllerlook.getWantedZ(); ++ ++ if (!controllerlook.isLookingAtTarget()) { ++ d11 = d8; ++ d12 = d9; ++ d13 = d10; ++ } ++ ++ this.guardian.getLookControl().setLookAt(Mth.lerp(0.125D, d11, d8), Mth.lerp(0.125D, d12, d9), Mth.lerp(0.125D, d13, d10), 10.0F, 40.0F); ++ this.guardian.setMoving(true); ++ } else { ++ this.guardian.setSpeed(0.0F); ++ this.guardian.setMoving(false); ++ } ++ } ++ } ++ ++ public static class GuardianAttackGoal extends Goal { ++ ++ private final Guardian guardian; ++ public int attackTime; + private final boolean elder; + + public GuardianAttackGoal(Guardian guardian) { + this.guardian = guardian; + this.elder = guardian instanceof ElderGuardian; +- this.setFlags(EnumSet.of(Goal.Flag.MOVE, Goal.Flag.LOOK)); ++ this.setFlags(EnumSet.of(Goal.Type.MOVE, Goal.Type.LOOK)); + } + + @Override + public boolean canUse() { +- LivingEntity target = this.guardian.getTarget(); +- return target != null && target.isAlive(); ++ LivingEntity entityliving = this.guardian.getTarget(); ++ ++ return entityliving != null && entityliving.isAlive(); + } + + @Override + public boolean canContinueToUse() { +- return super.canContinueToUse() +- && (this.elder || this.guardian.getTarget() != null && this.guardian.distanceToSqr(this.guardian.getTarget()) > 9.0); ++ return super.canContinueToUse() && (this.elder || this.guardian.getTarget() != null && this.guardian.distanceToSqr((Entity) this.guardian.getTarget()) > 9.0D); + } + + @Override + public void start() { + this.attackTime = -10; + this.guardian.getNavigation().stop(); +- LivingEntity target = this.guardian.getTarget(); +- if (target != null) { +- this.guardian.getLookControl().setLookAt(target, 90.0F, 90.0F); ++ LivingEntity entityliving = this.guardian.getTarget(); ++ ++ if (entityliving != null) { ++ this.guardian.getLookControl().setLookAt(entityliving, 90.0F, 90.0F); + } + + this.guardian.hasImpulse = true; +@@ -419,7 +458,7 @@ + @Override + public void stop() { + this.guardian.setActiveAttackTarget(0); +- this.guardian.setTarget(null); ++ this.guardian.setTarget((LivingEntity) null); + this.guardian.randomStrollGoal.trigger(); + } + +@@ -430,21 +469,23 @@ + + @Override + public void tick() { +- LivingEntity target = this.guardian.getTarget(); +- if (target != null) { ++ LivingEntity entityliving = this.guardian.getTarget(); ++ ++ if (entityliving != null) { + this.guardian.getNavigation().stop(); +- this.guardian.getLookControl().setLookAt(target, 90.0F, 90.0F); +- if (!this.guardian.hasLineOfSight(target)) { +- this.guardian.setTarget(null); ++ this.guardian.getLookControl().setLookAt(entityliving, 90.0F, 90.0F); ++ if (!this.guardian.hasLineOfSight(entityliving)) { ++ this.guardian.setTarget((LivingEntity) null); + } else { +- this.attackTime++; ++ ++this.attackTime; + if (this.attackTime == 0) { +- this.guardian.setActiveAttackTarget(target.getId()); ++ this.guardian.setActiveAttackTarget(entityliving.getId()); + if (!this.guardian.isSilent()) { +- this.guardian.level().broadcastEntityEvent(this.guardian, (byte)21); ++ this.guardian.level().broadcastEntityEvent(this.guardian, (byte) 21); + } + } else if (this.attackTime >= this.guardian.getAttackDuration()) { + float f = 1.0F; ++ + if (this.guardian.level().getDifficulty() == Difficulty.HARD) { + f += 2.0F; + } +@@ -453,9 +494,9 @@ + f += 2.0F; + } + +- target.hurt(this.guardian.damageSources().indirectMagic(this.guardian, this.guardian), f); +- target.hurt(this.guardian.damageSources().mobAttack(this.guardian), (float)this.guardian.getAttributeValue(Attributes.ATTACK_DAMAGE)); +- this.guardian.setTarget(null); ++ entityliving.hurt(this.guardian.damageSources().indirectMagic(this.guardian, this.guardian), f); ++ entityliving.hurt(this.guardian.damageSources().mobAttack(this.guardian), (float) this.guardian.getAttributeValue(Attributes.ATTACK_DAMAGE)); ++ this.guardian.setTarget((LivingEntity) null); + } + + super.tick(); +@@ -464,67 +505,16 @@ + } + } + +- static class GuardianAttackSelector implements Predicate<LivingEntity> { ++ private static class GuardianAttackSelector implements Predicate<LivingEntity> { ++ + private final Guardian guardian; + + public GuardianAttackSelector(Guardian guardian) { + this.guardian = guardian; + } + +- @Override + public boolean test(@Nullable LivingEntity entity) { +- return (entity instanceof Player || entity instanceof Squid || entity instanceof Axolotl) && entity.distanceToSqr(this.guardian) > 9.0; ++ return (entity instanceof Player || entity instanceof Squid || entity instanceof Axolotl) && entity.distanceToSqr((Entity) this.guardian) > 9.0D; + } + } +- +- static class GuardianMoveControl extends MoveControl { +- private final Guardian guardian; +- +- public GuardianMoveControl(Guardian mob) { +- super(mob); +- this.guardian = mob; +- } +- +- @Override +- public void tick() { +- if (this.operation == MoveControl.Operation.MOVE_TO && !this.guardian.getNavigation().isDone()) { +- Vec3 vec3 = new Vec3(this.wantedX - this.guardian.getX(), this.wantedY - this.guardian.getY(), this.wantedZ - this.guardian.getZ()); +- double len = vec3.length(); +- double d = vec3.x / len; +- double d1 = vec3.y / len; +- double d2 = vec3.z / len; +- float f = (float)(Mth.atan2(vec3.z, vec3.x) * 180.0F / (float)Math.PI) - 90.0F; +- this.guardian.setYRot(this.rotlerp(this.guardian.getYRot(), f, 90.0F)); +- this.guardian.yBodyRot = this.guardian.getYRot(); +- float f1 = (float)(this.speedModifier * this.guardian.getAttributeValue(Attributes.MOVEMENT_SPEED)); +- float f2 = Mth.lerp(0.125F, this.guardian.getSpeed(), f1); +- this.guardian.setSpeed(f2); +- double d3 = Math.sin((double)(this.guardian.tickCount + this.guardian.getId()) * 0.5) * 0.05; +- double cos = Math.cos((double)(this.guardian.getYRot() * (float) (Math.PI / 180.0))); +- double sin = Math.sin((double)(this.guardian.getYRot() * (float) (Math.PI / 180.0))); +- double d4 = Math.sin((double)(this.guardian.tickCount + this.guardian.getId()) * 0.75) * 0.05; +- this.guardian.setDeltaMovement(this.guardian.getDeltaMovement().add(d3 * cos, d4 * (sin + cos) * 0.25 + (double)f2 * d1 * 0.1, d3 * sin)); +- LookControl lookControl = this.guardian.getLookControl(); +- double d5 = this.guardian.getX() + d * 2.0; +- double d6 = this.guardian.getEyeY() + d1 / len; +- double d7 = this.guardian.getZ() + d2 * 2.0; +- double wantedX = lookControl.getWantedX(); +- double wantedY = lookControl.getWantedY(); +- double wantedZ = lookControl.getWantedZ(); +- if (!lookControl.isLookingAtTarget()) { +- wantedX = d5; +- wantedY = d6; +- wantedZ = d7; +- } +- +- this.guardian +- .getLookControl() +- .setLookAt(Mth.lerp(0.125, wantedX, d5), Mth.lerp(0.125, wantedY, d6), Mth.lerp(0.125, wantedZ, d7), 10.0F, 40.0F); +- this.guardian.setMoving(true); +- } else { +- this.guardian.setSpeed(0.0F); +- this.guardian.setMoving(false); +- } +- } +- } + } |