diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/monster/Silverfish.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/entity/monster/Silverfish.java.patch | 282 |
1 files changed, 282 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/monster/Silverfish.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/monster/Silverfish.java.patch new file mode 100644 index 0000000000..1e5713e0bb --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/monster/Silverfish.java.patch @@ -0,0 +1,282 @@ +--- a/net/minecraft/world/entity/monster/Silverfish.java ++++ b/net/minecraft/world/entity/monster/Silverfish.java +@@ -11,10 +11,10 @@ + import net.minecraft.world.damagesource.DamageSource; + 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.MobSpawnType; +-import net.minecraft.world.entity.MobType; +-import net.minecraft.world.entity.Pose; ++import net.minecraft.world.entity.EnumMobSpawn; ++import net.minecraft.world.entity.EnumMonsterType; + import net.minecraft.world.entity.ai.attributes.AttributeSupplier; + import net.minecraft.world.entity.ai.attributes.Attributes; + import net.minecraft.world.entity.ai.goal.ClimbOnTopOfPowderSnowGoal; +@@ -31,10 +31,15 @@ + import net.minecraft.world.level.LevelReader; + import net.minecraft.world.level.block.Block; + import net.minecraft.world.level.block.InfestedBlock; +-import net.minecraft.world.level.block.state.BlockState; ++import net.minecraft.world.level.block.state.IBlockData; + import org.joml.Vector3f; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++// CraftBukkit end ++ + public class Silverfish extends Monster { ++ + @Nullable + private Silverfish.SilverfishWakeUpFriendsGoal friendsGoal; + +@@ -48,19 +53,19 @@ + this.goalSelector.addGoal(1, new FloatGoal(this)); + this.goalSelector.addGoal(1, new ClimbOnTopOfPowderSnowGoal(this, this.level())); + this.goalSelector.addGoal(3, this.friendsGoal); +- this.goalSelector.addGoal(4, new MeleeAttackGoal(this, 1.0, false)); ++ this.goalSelector.addGoal(4, new MeleeAttackGoal(this, 1.0D, false)); + this.goalSelector.addGoal(5, new Silverfish.SilverfishMergeWithStoneGoal(this)); +- this.targetSelector.addGoal(1, new HurtByTargetGoal(this).setAlertOthers()); ++ this.targetSelector.addGoal(1, (new HurtByTargetGoal(this, new Class[0])).setAlertOthers()); + this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true)); + } + + @Override +- protected float getStandingEyeHeight(Pose pose, EntityDimensions size) { ++ protected float getStandingEyeHeight(EntityPose pose, EntityDimensions size) { + return 0.13F; + } + + public static AttributeSupplier.Builder createAttributes() { +- return Monster.createMonsterAttributes().add(Attributes.MAX_HEALTH, 8.0).add(Attributes.MOVEMENT_SPEED, 0.25).add(Attributes.ATTACK_DAMAGE, 1.0); ++ return Monster.createMonsterAttributes().add(Attributes.MAX_HEALTH, 8.0D).add(Attributes.MOVEMENT_SPEED, 0.25D).add(Attributes.ATTACK_DAMAGE, 1.0D); + } + + @Override +@@ -84,7 +89,7 @@ + } + + @Override +- protected void playStepSound(BlockPos pos, BlockState block) { ++ protected void playStepSound(BlockPos pos, IBlockData block) { + this.playSound(SoundEvents.SILVERFISH_STEP, 0.15F, 1.0F); + } + +@@ -118,35 +123,95 @@ + return InfestedBlock.isCompatibleHostBlock(level.getBlockState(pos.below())) ? 10.0F : super.getWalkTargetValue(pos, level); + } + +- public static boolean checkSilverfishSpawnRules( +- EntityType<Silverfish> silverfish, LevelAccessor level, MobSpawnType spawnType, BlockPos pos, RandomSource random +- ) { ++ public static boolean checkSilverfishSpawnRules(EntityType<Silverfish> silverfish, LevelAccessor level, EnumMobSpawn spawnType, BlockPos pos, RandomSource random) { + if (checkAnyLightMonsterSpawnRules(silverfish, level, spawnType, pos, random)) { +- Player nearestPlayer = level.getNearestPlayer((double)pos.getX() + 0.5, (double)pos.getY() + 0.5, (double)pos.getZ() + 0.5, 5.0, true); +- return nearestPlayer == null; ++ Player entityhuman = level.getNearestPlayer((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, 5.0D, true); ++ ++ return entityhuman == null; + } else { + return false; + } + } + + @Override +- public MobType getMobType() { +- return MobType.ARTHROPOD; ++ public EnumMonsterType getMobType() { ++ return EnumMonsterType.ARTHROPOD; + } + + @Override +- protected Vector3f getPassengerAttachmentPoint(Entity entity, EntityDimensions entityDimensions, float f) { +- return new Vector3f(0.0F, entityDimensions.height - 0.0625F * f, 0.0F); ++ protected Vector3f getPassengerAttachmentPoint(Entity entity, EntityDimensions entitysize, float f) { ++ return new Vector3f(0.0F, entitysize.height - 0.0625F * f, 0.0F); + } + +- static class SilverfishMergeWithStoneGoal extends RandomStrollGoal { ++ private static class SilverfishWakeUpFriendsGoal extends Goal { ++ ++ private final Silverfish silverfish; ++ private int lookForFriends; ++ ++ public SilverfishWakeUpFriendsGoal(Silverfish silverfish) { ++ this.silverfish = silverfish; ++ } ++ ++ public void notifyHurt() { ++ if (this.lookForFriends == 0) { ++ this.lookForFriends = this.adjustedTickDelay(20); ++ } ++ ++ } ++ ++ @Override ++ public boolean canUse() { ++ return this.lookForFriends > 0; ++ } ++ ++ @Override ++ public void tick() { ++ --this.lookForFriends; ++ if (this.lookForFriends <= 0) { ++ Level world = this.silverfish.level(); ++ RandomSource randomsource = this.silverfish.getRandom(); ++ BlockPos blockposition = this.silverfish.blockPosition(); ++ ++ for (int i = 0; i <= 5 && i >= -5; i = (i <= 0 ? 1 : 0) - i) { ++ for (int j = 0; j <= 10 && j >= -10; j = (j <= 0 ? 1 : 0) - j) { ++ for (int k = 0; k <= 10 && k >= -10; k = (k <= 0 ? 1 : 0) - k) { ++ BlockPos blockposition1 = blockposition.offset(j, i, k); ++ IBlockData iblockdata = world.getBlockState(blockposition1); ++ Block block = iblockdata.getBlock(); ++ ++ if (block instanceof InfestedBlock) { ++ // CraftBukkit start ++ if (!CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockposition1, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState())) { ++ continue; ++ } ++ // CraftBukkit end ++ if (world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { ++ world.destroyBlock(blockposition1, true, this.silverfish); ++ } else { ++ world.setBlock(blockposition1, ((InfestedBlock) block).hostStateByInfested(world.getBlockState(blockposition1)), 3); ++ } ++ ++ if (randomsource.nextBoolean()) { ++ return; ++ } ++ } ++ } ++ } ++ } ++ } ++ ++ } ++ } ++ ++ private static class SilverfishMergeWithStoneGoal extends RandomStrollGoal { ++ + @Nullable + private Direction selectedDirection; + private boolean doMerge; + + public SilverfishMergeWithStoneGoal(Silverfish silverfish) { +- super(silverfish, 1.0, 10); +- this.setFlags(EnumSet.of(Goal.Flag.MOVE)); ++ super(silverfish, 1.0D, 10); ++ this.setFlags(EnumSet.of(Goal.Type.MOVE)); + } + + @Override +@@ -156,12 +221,14 @@ + } else if (!this.mob.getNavigation().isDone()) { + return false; + } else { +- RandomSource random = this.mob.getRandom(); +- if (this.mob.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && random.nextInt(reducedTickDelay(10)) == 0) { +- this.selectedDirection = Direction.getRandom(random); +- BlockPos blockPos = BlockPos.containing(this.mob.getX(), this.mob.getY() + 0.5, this.mob.getZ()).relative(this.selectedDirection); +- BlockState blockState = this.mob.level().getBlockState(blockPos); +- if (InfestedBlock.isCompatibleHostBlock(blockState)) { ++ RandomSource randomsource = this.mob.getRandom(); ++ ++ if (this.mob.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && randomsource.nextInt(reducedTickDelay(10)) == 0) { ++ this.selectedDirection = Direction.getRandom(randomsource); ++ BlockPos blockposition = BlockPos.containing(this.mob.getX(), this.mob.getY() + 0.5D, this.mob.getZ()).relative(this.selectedDirection); ++ IBlockData iblockdata = this.mob.level().getBlockState(blockposition); ++ ++ if (InfestedBlock.isCompatibleHostBlock(iblockdata)) { + this.doMerge = true; + return true; + } +@@ -174,7 +241,7 @@ + + @Override + public boolean canContinueToUse() { +- return !this.doMerge && super.canContinueToUse(); ++ return this.doMerge ? false : super.canContinueToUse(); + } + + @Override +@@ -182,66 +249,22 @@ + if (!this.doMerge) { + super.start(); + } else { +- LevelAccessor levelAccessor = this.mob.level(); +- BlockPos blockPos = BlockPos.containing(this.mob.getX(), this.mob.getY() + 0.5, this.mob.getZ()).relative(this.selectedDirection); +- BlockState blockState = levelAccessor.getBlockState(blockPos); +- if (InfestedBlock.isCompatibleHostBlock(blockState)) { +- levelAccessor.setBlock(blockPos, InfestedBlock.infestedStateByHost(blockState), 3); ++ Level world = this.mob.level(); ++ BlockPos blockposition = BlockPos.containing(this.mob.getX(), this.mob.getY() + 0.5D, this.mob.getZ()).relative(this.selectedDirection); ++ IBlockData iblockdata = world.getBlockState(blockposition); ++ ++ if (InfestedBlock.isCompatibleHostBlock(iblockdata)) { ++ // CraftBukkit start ++ if (!CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, InfestedBlock.infestedStateByHost(iblockdata))) { ++ return; ++ } ++ // CraftBukkit end ++ world.setBlock(blockposition, InfestedBlock.infestedStateByHost(iblockdata), 3); + this.mob.spawnAnim(); + this.mob.discard(); + } +- } +- } +- } + +- static class SilverfishWakeUpFriendsGoal extends Goal { +- private final Silverfish silverfish; +- private int lookForFriends; +- +- public SilverfishWakeUpFriendsGoal(Silverfish silverfish) { +- this.silverfish = silverfish; +- } +- +- public void notifyHurt() { +- if (this.lookForFriends == 0) { +- this.lookForFriends = this.adjustedTickDelay(20); + } + } +- +- @Override +- public boolean canUse() { +- return this.lookForFriends > 0; +- } +- +- @Override +- public void tick() { +- this.lookForFriends--; +- if (this.lookForFriends <= 0) { +- Level level = this.silverfish.level(); +- RandomSource random = this.silverfish.getRandom(); +- BlockPos blockPos = this.silverfish.blockPosition(); +- +- for (int i = 0; i <= 5 && i >= -5; i = (i <= 0 ? 1 : 0) - i) { +- for (int i1 = 0; i1 <= 10 && i1 >= -10; i1 = (i1 <= 0 ? 1 : 0) - i1) { +- for (int i2 = 0; i2 <= 10 && i2 >= -10; i2 = (i2 <= 0 ? 1 : 0) - i2) { +- BlockPos blockPos1 = blockPos.offset(i1, i, i2); +- BlockState blockState = level.getBlockState(blockPos1); +- Block block = blockState.getBlock(); +- if (block instanceof InfestedBlock) { +- if (level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { +- level.destroyBlock(blockPos1, true, this.silverfish); +- } else { +- level.setBlock(blockPos1, ((InfestedBlock)block).hostStateByInfested(level.getBlockState(blockPos1)), 3); +- } +- +- if (random.nextBoolean()) { +- return; +- } +- } +- } +- } +- } +- } +- } + } + } |