diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/entity/monster/Guardian.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/entity/monster/Guardian.java.patch | 486 |
1 files changed, 486 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/entity/monster/Guardian.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/entity/monster/Guardian.java.patch new file mode 100644 index 0000000000..83f18b5691 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/entity/monster/Guardian.java.patch @@ -0,0 +1,486 @@ +--- 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; +@@ -62,10 +62,11 @@ + 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); ++ public Guardian(EntityType<? extends Guardian> entityType, Level level) { ++ super(entityType, level); + this.xpReward = 10; + this.setPathfindingMalus(BlockPathTypes.WATER, 0.0F); + this.moveControl = new Guardian.GuardianMoveControl(this); +@@ -74,19 +75,18 @@ + } + + @Override +- @Override + protected void registerGoals() { +- MoveTowardsRestrictionGoal movetowardsrestrictiongoal = new MoveTowardsRestrictionGoal(this, 1.0D); ++ MoveTowardsRestrictionGoal pathfindergoalmovetowardsrestriction = new MoveTowardsRestrictionGoal(this, 1.0D); + + this.randomStrollGoal = new RandomStrollGoal(this, 1.0D, 80); +- this.goalSelector.addGoal(4, new Guardian.GuardianAttackGoal(this)); +- this.goalSelector.addGoal(5, movetowardsrestrictiongoal); ++ 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))); + } + +@@ -95,13 +95,11 @@ + } + + @Override +- @Override + protected PathNavigation createNavigation(Level level) { + return new WaterBoundPathNavigation(this, level); + } + + @Override +- @Override + protected void defineSynchedData() { + super.defineSynchedData(); + this.entityData.define(Guardian.DATA_ID_MOVING, false); +@@ -109,25 +107,24 @@ + } + + @Override +- @Override +- public MobType getMobType() { +- return MobType.WATER; ++ public EnumMonsterType getMobType() { ++ return EnumMonsterType.WATER; + } + + public boolean isMoving() { + return (Boolean) this.entityData.get(Guardian.DATA_ID_MOVING); + } + +- void setMoving(boolean flag) { +- this.entityData.set(Guardian.DATA_ID_MOVING, flag); ++ void setMoving(boolean moving) { ++ this.entityData.set(Guardian.DATA_ID_MOVING, moving); + } + + public int getAttackDuration() { + return 80; + } + +- void setActiveAttackTarget(int i) { +- this.entityData.set(Guardian.DATA_ID_ATTACK_TARGET, i); ++ public void setActiveAttackTarget(int activeAttackTargetId) { ++ this.entityData.set(Guardian.DATA_ID_ATTACK_TARGET, activeAttackTargetId); + } + + public boolean hasActiveAttackTarget() { +@@ -157,10 +154,9 @@ + } + + @Override +- @Override +- public void onSyncedDataUpdated(EntityDataAccessor<?> entitydataaccessor) { +- super.onSyncedDataUpdated(entitydataaccessor); +- if (Guardian.DATA_ID_ATTACK_TARGET.equals(entitydataaccessor)) { ++ public void onSyncedDataUpdated(EntityDataAccessor<?> key) { ++ super.onSyncedDataUpdated(key); ++ if (Guardian.DATA_ID_ATTACK_TARGET.equals(key)) { + this.clientSideAttackTime = 0; + this.clientSideCachedAttackTarget = null; + } +@@ -168,63 +164,55 @@ + } + + @Override +- @Override + public int getAmbientSoundInterval() { + return 160; + } + + @Override +- @Override + protected SoundEvent getAmbientSound() { + return this.isInWaterOrBubble() ? SoundEvents.GUARDIAN_AMBIENT : SoundEvents.GUARDIAN_AMBIENT_LAND; + } + + @Override +- @Override +- protected SoundEvent getHurtSound(DamageSource damagesource) { ++ protected SoundEvent getHurtSound(DamageSource damageSource) { + return this.isInWaterOrBubble() ? SoundEvents.GUARDIAN_HURT : SoundEvents.GUARDIAN_HURT_LAND; + } + + @Override +- @Override + protected SoundEvent getDeathSound() { + return this.isInWaterOrBubble() ? SoundEvents.GUARDIAN_DEATH : SoundEvents.GUARDIAN_DEATH_LAND; + } + + @Override +- @Override + protected Entity.MovementEmission getMovementEmission() { + return Entity.MovementEmission.EVENTS; + } + + @Override +- @Override +- protected float getStandingEyeHeight(Pose pose, EntityDimensions entitydimensions) { +- return entitydimensions.height * 0.5F; ++ protected float getStandingEyeHeight(EntityPose pose, EntityDimensions size) { ++ return size.height * 0.5F; + } + + @Override +- @Override +- public float getWalkTargetValue(BlockPos blockpos, LevelReader levelreader) { +- return levelreader.getFluidState(blockpos).is(FluidTags.WATER) ? 10.0F + levelreader.getPathfindingCostFromLightLevels(blockpos) : super.getWalkTargetValue(blockpos, levelreader); ++ public float getWalkTargetValue(BlockPos pos, LevelReader level) { ++ return level.getFluidState(pos).is(FluidTags.WATER) ? 10.0F + level.getPathfindingCostFromLightLevels(pos) : super.getWalkTargetValue(pos, level); + } + + @Override +- @Override + public void aiStep() { + if (this.isAlive()) { + if (this.level().isClientSide) { + this.clientSideTailAnimationO = this.clientSideTailAnimation; +- Vec3 vec3; ++ Vec3 vec3d; + + if (!this.isInWater()) { + this.clientSideTailAnimationSpeed = 2.0F; +- vec3 = this.getDeltaMovement(); +- if (vec3.y > 0.0D && 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 = vec3.y < 0.0D && 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; +@@ -246,10 +234,10 @@ + } + + if (this.isMoving() && this.isInWater()) { +- vec3 = this.getViewVector(0.0F); ++ vec3d = this.getViewVector(0.0F); + + for (int i = 0; i < 2; ++i) { +- this.level().addParticle(ParticleTypes.BUBBLE, this.getRandomX(0.5D) - vec3.x * 1.5D, this.getRandomY() - vec3.y * 1.5D, this.getRandomZ(0.5D) - vec3.z * 1.5D, 0.0D, 0.0D, 0.0D); ++ 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); + } + } + +@@ -258,15 +246,15 @@ + ++this.clientSideAttackTime; + } + +- LivingEntity livingentity = this.getActiveAttackTarget(); ++ LivingEntity entityliving = this.getActiveAttackTarget(); + +- if (livingentity != null) { +- this.getLookControl().setLookAt(livingentity, 90.0F, 90.0F); ++ if (entityliving != null) { ++ this.getLookControl().setLookAt(entityliving, 90.0F, 90.0F); + this.getLookControl().tick(); + double d0 = (double) this.getAttackAnimationScale(0.0F); +- double d1 = livingentity.getX() - this.getX(); +- double d2 = livingentity.getY(0.5D) - this.getEyeY(); +- double d3 = livingentity.getZ() - this.getZ(); ++ 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); + + d1 /= d4; +@@ -303,16 +291,16 @@ + return SoundEvents.GUARDIAN_FLOP; + } + +- public float getTailAnimation(float f) { +- return Mth.lerp(f, this.clientSideTailAnimationO, this.clientSideTailAnimation); ++ public float getTailAnimation(float partialTick) { ++ return Mth.lerp(partialTick, this.clientSideTailAnimationO, this.clientSideTailAnimation); + } + +- public float getSpikesAnimation(float f) { +- return Mth.lerp(f, this.clientSideSpikesAnimationO, this.clientSideSpikesAnimation); ++ public float getSpikesAnimation(float partialTick) { ++ return Mth.lerp(partialTick, this.clientSideSpikesAnimationO, this.clientSideSpikesAnimation); + } + +- public float getAttackAnimationScale(float f) { +- return ((float) this.clientSideAttackTime + f) / (float) this.getAttackDuration(); ++ public float getAttackAnimationScale(float partialTick) { ++ return ((float) this.clientSideAttackTime + partialTick) / (float) this.getAttackDuration(); + } + + public float getClientSideAttackTime() { +@@ -320,28 +308,26 @@ + } + + @Override +- @Override +- public boolean checkSpawnObstruction(LevelReader levelreader) { +- return levelreader.isUnobstructed(this); ++ public boolean checkSpawnObstruction(LevelReader level) { ++ return level.isUnobstructed(this); + } + +- public static boolean checkGuardianSpawnRules(EntityType<? extends Guardian> entitytype, LevelAccessor levelaccessor, MobSpawnType mobspawntype, BlockPos blockpos, RandomSource randomsource) { +- return (randomsource.nextInt(20) == 0 || !levelaccessor.canSeeSkyFromBelowWater(blockpos)) && levelaccessor.getDifficulty() != Difficulty.PEACEFUL && (MobSpawnType.isSpawner(mobspawntype) || levelaccessor.getFluidState(blockpos).is(FluidTags.WATER)) && levelaccessor.getFluidState(blockpos.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 +- @Override +- public boolean hurt(DamageSource damagesource, float f) { ++ public boolean hurt(DamageSource source, float amount) { + if (this.level().isClientSide) { + return false; + } else { +- if (!this.isMoving() && !damagesource.is(DamageTypeTags.AVOIDS_GUARDIAN_THORNS) && !damagesource.is(DamageTypes.THORNS)) { +- Entity entity = damagesource.getDirectEntity(); ++ if (!this.isMoving() && !source.is(DamageTypeTags.AVOIDS_GUARDIAN_THORNS) && !source.is(DamageTypes.THORNS)) { ++ Entity entity = source.getDirectEntity(); + + if (entity instanceof LivingEntity) { +- LivingEntity livingentity = (LivingEntity) entity; ++ LivingEntity entityliving = (LivingEntity) entity; + +- livingentity.hurt(this.damageSources().thorns(this), 2.0F); ++ entityliving.hurt(this.damageSources().thorns(this), 2.0F); + } + } + +@@ -349,36 +335,33 @@ + this.randomStrollGoal.trigger(); + } + +- return super.hurt(damagesource, f); ++ return super.hurt(source, amount); + } + } + + @Override +- @Override + public int getMaxHeadXRot() { + return 180; + } + + @Override +- @Override +- public void travel(Vec3 vec3) { ++ public void travel(Vec3 travelVector) { + if (this.isControlledByLocalInstance() && this.isInWater()) { +- this.moveRelative(0.1F, vec3); +- this.move(MoverType.SELF, this.getDeltaMovement()); ++ this.moveRelative(0.1F, travelVector); ++ 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.0D, -0.005D, 0.0D)); + } + } else { +- super.travel(vec3); ++ super.travel(travelVector); + } + + } + + @Override +- @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); + } + + private static class GuardianMoveControl extends MoveControl { +@@ -391,15 +374,14 @@ + } + + @Override +- @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 d0 = vec3.length(); +- double d1 = vec3.x / d0; +- double d2 = vec3.y / d0; +- double d3 = vec3.z / d0; +- float f = (float) (Mth.atan2(vec3.z, vec3.x) * 57.2957763671875D) - 90.0F; ++ 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(); +@@ -413,15 +395,15 @@ + 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 lookcontrol = this.guardian.getLookControl(); ++ 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 = lookcontrol.getWantedX(); +- double d12 = lookcontrol.getWantedY(); +- double d13 = lookcontrol.getWantedZ(); ++ double d11 = controllerlook.getWantedX(); ++ double d12 = controllerlook.getWantedY(); ++ double d13 = controllerlook.getWantedZ(); + +- if (!lookcontrol.isLookingAtTarget()) { ++ if (!controllerlook.isLookingAtTarget()) { + d11 = d8; + d12 = d9; + d13 = d10; +@@ -436,48 +418,44 @@ + } + } + +- private static class GuardianAttackGoal extends Goal { ++ public static class GuardianAttackGoal extends Goal { + + private final Guardian guardian; +- private int attackTime; ++ 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 +- @Override + public boolean canUse() { +- LivingEntity livingentity = this.guardian.getTarget(); ++ LivingEntity entityliving = this.guardian.getTarget(); + +- return livingentity != null && livingentity.isAlive(); ++ return entityliving != null && entityliving.isAlive(); + } + + @Override +- @Override + public boolean canContinueToUse() { + return super.canContinueToUse() && (this.elder || this.guardian.getTarget() != null && this.guardian.distanceToSqr((Entity) this.guardian.getTarget()) > 9.0D); + } + + @Override +- @Override + public void start() { + this.attackTime = -10; + this.guardian.getNavigation().stop(); +- LivingEntity livingentity = this.guardian.getTarget(); ++ LivingEntity entityliving = this.guardian.getTarget(); + +- if (livingentity != null) { +- this.guardian.getLookControl().setLookAt(livingentity, 90.0F, 90.0F); ++ if (entityliving != null) { ++ this.guardian.getLookControl().setLookAt(entityliving, 90.0F, 90.0F); + } + + this.guardian.hasImpulse = true; + } + + @Override +- @Override + public void stop() { + this.guardian.setActiveAttackTarget(0); + this.guardian.setTarget((LivingEntity) null); +@@ -485,25 +463,23 @@ + } + + @Override +- @Override + public boolean requiresUpdateEveryTick() { + return true; + } + + @Override +- @Override + public void tick() { +- LivingEntity livingentity = this.guardian.getTarget(); ++ LivingEntity entityliving = this.guardian.getTarget(); + +- if (livingentity != null) { ++ if (entityliving != null) { + this.guardian.getNavigation().stop(); +- this.guardian.getLookControl().setLookAt(livingentity, 90.0F, 90.0F); +- if (!this.guardian.hasLineOfSight(livingentity)) { ++ this.guardian.getLookControl().setLookAt(entityliving, 90.0F, 90.0F); ++ if (!this.guardian.hasLineOfSight(entityliving)) { + this.guardian.setTarget((LivingEntity) null); + } else { + ++this.attackTime; + if (this.attackTime == 0) { +- this.guardian.setActiveAttackTarget(livingentity.getId()); ++ this.guardian.setActiveAttackTarget(entityliving.getId()); + if (!this.guardian.isSilent()) { + this.guardian.level().broadcastEntityEvent(this.guardian, (byte) 21); + } +@@ -518,8 +494,8 @@ + f += 2.0F; + } + +- livingentity.hurt(this.guardian.damageSources().indirectMagic(this.guardian, this.guardian), f); +- livingentity.hurt(this.guardian.damageSources().mobAttack(this.guardian), (float) this.guardian.getAttributeValue(Attributes.ATTACK_DAMAGE)); ++ 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); + } + +@@ -537,9 +513,8 @@ + this.guardian = guardian; + } + +- @Override +- public boolean test(@Nullable LivingEntity livingentity) { +- return (livingentity instanceof Player || livingentity instanceof Squid || livingentity instanceof Axolotl) && livingentity.distanceToSqr((Entity) this.guardian) > 9.0D; ++ public boolean test(@Nullable LivingEntity entity) { ++ return (entity instanceof Player || entity instanceof Squid || entity instanceof Axolotl) && entity.distanceToSqr((Entity) this.guardian) > 9.0D; + } + } + } |