aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/monster/Silverfish.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/monster/Silverfish.java.patch')
-rw-r--r--patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/monster/Silverfish.java.patch106
1 files changed, 106 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/monster/Silverfish.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/monster/Silverfish.java.patch
new file mode 100644
index 0000000000..bde77f90a3
--- /dev/null
+++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/monster/Silverfish.java.patch
@@ -0,0 +1,106 @@
+--- a/net/minecraft/world/entity/monster/Silverfish.java
++++ b/net/minecraft/world/entity/monster/Silverfish.java
+@@ -34,6 +34,10 @@
+ import net.minecraft.world.level.block.state.BlockState;
+ import org.joml.Vector3f;
+
++// CraftBukkit start
++import org.bukkit.craftbukkit.event.CraftEventFactory;
++// CraftBukkit end
++
+ public class Silverfish extends Monster {
+ @Nullable
+ private Silverfish.SilverfishWakeUpFriendsGoal friendsGoal;
+@@ -139,7 +143,68 @@
+ return new Vector3f(0.0F, entityDimensions.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;
+@@ -182,11 +249,17 @@
+ 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();
+ }