From 0d983f9b9afc3105525afb33b924a155c24e6b78 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Tue, 14 Jun 2022 21:21:46 +1000 Subject: [PATCH] SPIGOT-7060: SCULK and SCULK_VEIN BlockSpreadEvents do not reference the correct source By: md_5 --- .../world/level/block/SculkBlock.patch | 2 +- .../world/level/block/SculkVeinBlock.patch | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/SculkBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/SculkBlock.patch index de00f4b3d7..b4180a5c03 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/SculkBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/SculkBlock.patch @@ -7,7 +7,7 @@ - generatoraccess.setBlock(blockposition2, iblockdata, 3); - generatoraccess.playSound((EntityHuman) null, blockposition1, iblockdata.getSoundType().getPlaceSound(), SoundCategory.BLOCKS, 1.0F, 1.0F); + // CraftBukkit start - Call BlockSpreadEvent -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(generatoraccess, blockposition1, blockposition2, iblockdata, 3)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(generatoraccess, blockposition, blockposition2, iblockdata, 3)) { + generatoraccess.playSound((EntityHuman) null, blockposition1, iblockdata.getSoundType().getPlaceSound(), SoundCategory.BLOCKS, 1.0F, 1.0F); + } + // CraftBukkit end diff --git a/paper-server/nms-patches/net/minecraft/world/level/block/SculkVeinBlock.patch b/paper-server/nms-patches/net/minecraft/world/level/block/SculkVeinBlock.patch index de8406ab90..4996259a41 100644 --- a/paper-server/nms-patches/net/minecraft/world/level/block/SculkVeinBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/level/block/SculkVeinBlock.patch @@ -1,12 +1,26 @@ --- a/net/minecraft/world/level/block/SculkVeinBlock.java +++ b/net/minecraft/world/level/block/SculkVeinBlock.java -@@ -121,7 +121,11 @@ +@@ -103,10 +103,11 @@ + + @Override + public int attemptUseCharge(SculkSpreader.a sculkspreader_a, GeneratorAccess generatoraccess, BlockPosition blockposition, RandomSource randomsource, SculkSpreader sculkspreader, boolean flag) { +- return flag && this.attemptPlaceSculk(sculkspreader, generatoraccess, sculkspreader_a.getPos(), randomsource) ? sculkspreader_a.getCharge() - 1 : (randomsource.nextInt(sculkspreader.chargeDecayRate()) == 0 ? MathHelper.floor((float) sculkspreader_a.getCharge() * 0.5F) : sculkspreader_a.getCharge()); ++ // CraftBukkit - add source block ++ return flag && this.attemptPlaceSculk(sculkspreader, generatoraccess, sculkspreader_a.getPos(), randomsource, blockposition) ? sculkspreader_a.getCharge() - 1 : (randomsource.nextInt(sculkspreader.chargeDecayRate()) == 0 ? MathHelper.floor((float) sculkspreader_a.getCharge() * 0.5F) : sculkspreader_a.getCharge()); + } + +- private boolean attemptPlaceSculk(SculkSpreader sculkspreader, GeneratorAccess generatoraccess, BlockPosition blockposition, RandomSource randomsource) { ++ private boolean attemptPlaceSculk(SculkSpreader sculkspreader, GeneratorAccess generatoraccess, BlockPosition blockposition, RandomSource randomsource, BlockPosition sourceBlock) { // CraftBukkit + IBlockData iblockdata = generatoraccess.getBlockState(blockposition); + TagKey tagkey = sculkspreader.replaceableBlocks(); + Iterator iterator = EnumDirection.allShuffled(randomsource).iterator(); +@@ -121,7 +122,11 @@ if (iblockdata1.is(tagkey)) { IBlockData iblockdata2 = Blocks.SCULK.defaultBlockState(); - generatoraccess.setBlock(blockposition1, iblockdata2, 3); + // CraftBukkit start - Call BlockSpreadEvent -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(generatoraccess, blockposition, blockposition1, iblockdata2, 3)) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(generatoraccess, sourceBlock, blockposition1, iblockdata2, 3)) { + return false; + } + // CraftBukkit end