From 3d026d9a1195ffcfceb3be29b9d09c5ed9e4f1c7 Mon Sep 17 00:00:00 2001 From: BillyGalbreath Date: Mon, 19 Sep 2022 19:24:47 -0500 Subject: [PATCH] Fix #1126 --- .../0219-Conduit-behavior-configuration.patch | 51 +++++++++++++++++-- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/patches/server/0219-Conduit-behavior-configuration.patch b/patches/server/0219-Conduit-behavior-configuration.patch index 86004aa5a..ca562fd94 100644 --- a/patches/server/0219-Conduit-behavior-configuration.patch +++ b/patches/server/0219-Conduit-behavior-configuration.patch @@ -5,10 +5,18 @@ Subject: [PATCH] Conduit behavior configuration diff --git a/src/main/java/net/minecraft/world/level/block/entity/ConduitBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ConduitBlockEntity.java -index 05eab04e4aec4151018f25b59f92ddbbb4c09f87..8db906e021ca57c7f2a1e7002647e5c50be180aa 100644 +index 05eab04e4aec4151018f25b59f92ddbbb4c09f87..8720ff5c7a1a05b8c7093bb618278685b29b2872 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/ConduitBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/ConduitBlockEntity.java -@@ -172,7 +172,7 @@ public class ConduitBlockEntity extends BlockEntity { +@@ -9,6 +9,7 @@ import net.minecraft.core.BlockPos; + import net.minecraft.core.particles.ParticleTypes; + import net.minecraft.nbt.CompoundTag; + import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; ++import net.minecraft.server.level.ServerLevel; + import net.minecraft.sounds.SoundEvent; + import net.minecraft.sounds.SoundEvents; + import net.minecraft.sounds.SoundSource; +@@ -172,7 +173,7 @@ public class ConduitBlockEntity extends BlockEntity { if ((l > 1 || i1 > 1 || j1 > 1) && (i == 0 && (i1 == 2 || j1 == 2) || j == 0 && (l == 2 || j1 == 2) || k == 0 && (l == 2 || i1 == 2))) { BlockPos blockposition2 = pos.offset(i, j, k); BlockState iblockdata = world.getBlockState(blockposition2); @@ -17,7 +25,7 @@ index 05eab04e4aec4151018f25b59f92ddbbb4c09f87..8db906e021ca57c7f2a1e7002647e5c5 int k1 = ablock.length; for (int l1 = 0; l1 < k1; ++l1) { -@@ -192,7 +192,7 @@ public class ConduitBlockEntity extends BlockEntity { +@@ -192,7 +193,7 @@ public class ConduitBlockEntity extends BlockEntity { private static void applyEffects(Level world, BlockPos pos, List activatingBlocks) { int i = activatingBlocks.size(); @@ -26,7 +34,15 @@ index 05eab04e4aec4151018f25b59f92ddbbb4c09f87..8db906e021ca57c7f2a1e7002647e5c5 int k = pos.getX(); int l = pos.getY(); int i1 = pos.getZ(); -@@ -230,14 +230,14 @@ public class ConduitBlockEntity extends BlockEntity { +@@ -223,21 +224,21 @@ public class ConduitBlockEntity extends BlockEntity { + blockEntity.destroyTarget = ConduitBlockEntity.findDestroyTarget(world, pos, blockEntity.destroyTargetUUID); + blockEntity.destroyTargetUUID = null; + } else if (blockEntity.destroyTarget == null) { +- List list1 = world.getEntitiesOfClass(LivingEntity.class, ConduitBlockEntity.getDestroyRangeAABB(pos), (entityliving1) -> { ++ List list1 = world.getEntitiesOfClass(LivingEntity.class, ConduitBlockEntity.getDestroyRangeAABB(pos, world), (entityliving1) -> { // Purpur + return entityliving1 instanceof Enemy && entityliving1.isInWaterOrRain(); + }); + if (!list1.isEmpty()) { blockEntity.destroyTarget = (LivingEntity) list1.get(world.random.nextInt(list1.size())); } @@ -43,8 +59,33 @@ index 05eab04e4aec4151018f25b59f92ddbbb4c09f87..8db906e021ca57c7f2a1e7002647e5c5 world.playSound((Player) null, blockEntity.destroyTarget.getX(), blockEntity.destroyTarget.getY(), blockEntity.destroyTarget.getZ(), SoundEvents.CONDUIT_ATTACK_TARGET, SoundSource.BLOCKS, 1.0F, 1.0F); } CraftEventFactory.blockDamage = null; +@@ -263,16 +264,22 @@ public class ConduitBlockEntity extends BlockEntity { + } + + private static AABB getDestroyRangeAABB(BlockPos pos) { ++ // Purpur start ++ return getDestroyRangeAABB(pos, null); ++ } ++ ++ private static AABB getDestroyRangeAABB(BlockPos pos, Level level) { ++ // Purpur end + int i = pos.getX(); + int j = pos.getY(); + int k = pos.getZ(); + +- return (new AABB((double) i, (double) j, (double) k, (double) (i + 1), (double) (j + 1), (double) (k + 1))).inflate(8.0D); ++ return (new AABB((double) i, (double) j, (double) k, (double) (i + 1), (double) (j + 1), (double) (k + 1))).inflate(level == null ? 8.0D : level.purpurConfig.conduitDamageDistance); // Purpur + } + + @Nullable + private static LivingEntity findDestroyTarget(Level world, BlockPos pos, UUID uuid) { +- List list = world.getEntitiesOfClass(LivingEntity.class, ConduitBlockEntity.getDestroyRangeAABB(pos), (entityliving) -> { ++ List list = world.getEntitiesOfClass(LivingEntity.class, ConduitBlockEntity.getDestroyRangeAABB(pos, world), (entityliving) -> { // Purpur + return entityliving.getUUID().equals(uuid); + }); + diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java -index 25ac97095cf7099f78426c56d48864299d33e96c..48ad9e06f7f035dce6c294647bfeb9a579b37a5b 100644 +index dec852113a8f359a3e37b42916df46957edcd98a..1489a5d5985271665aa55720b0ffdc3e94636f48 100644 --- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java @@ -2773,5 +2773,28 @@ public class PurpurWorldConfig {