aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/og/net/minecraft/world/level/block/BlockSponge.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/og/net/minecraft/world/level/block/BlockSponge.patch')
-rw-r--r--patch-remap/og/net/minecraft/world/level/block/BlockSponge.patch110
1 files changed, 110 insertions, 0 deletions
diff --git a/patch-remap/og/net/minecraft/world/level/block/BlockSponge.patch b/patch-remap/og/net/minecraft/world/level/block/BlockSponge.patch
new file mode 100644
index 0000000000..ae282d2920
--- /dev/null
+++ b/patch-remap/og/net/minecraft/world/level/block/BlockSponge.patch
@@ -0,0 +1,110 @@
+--- a/net/minecraft/world/level/block/BlockSponge.java
++++ b/net/minecraft/world/level/block/BlockSponge.java
+@@ -13,6 +13,13 @@
+ import net.minecraft.world.level.block.state.IBlockData;
+ import net.minecraft.world.level.material.Fluid;
+
++// CraftBukkit start
++import java.util.List;
++import org.bukkit.craftbukkit.block.CraftBlockState;
++import org.bukkit.craftbukkit.util.BlockStateListPopulator;
++import org.bukkit.event.block.SpongeAbsorbEvent;
++// CraftBukkit end
++
+ public class BlockSponge extends Block {
+
+ public static final MapCodec<BlockSponge> CODEC = simpleCodec(BlockSponge::new);
+@@ -51,7 +58,8 @@
+ }
+
+ private boolean removeWaterBreadthFirstSearch(World world, BlockPosition blockposition) {
+- return BlockPosition.breadthFirstTraversal(blockposition, 6, 65, (blockposition1, consumer) -> {
++ BlockStateListPopulator blockList = new BlockStateListPopulator(world); // CraftBukkit - Use BlockStateListPopulator
++ BlockPosition.breadthFirstTraversal(blockposition, 6, 65, (blockposition1, consumer) -> {
+ EnumDirection[] aenumdirection = BlockSponge.ALL_DIRECTIONS;
+ int i = aenumdirection.length;
+
+@@ -65,8 +73,10 @@
+ if (blockposition1.equals(blockposition)) {
+ return true;
+ } else {
+- IBlockData iblockdata = world.getBlockState(blockposition1);
+- Fluid fluid = world.getFluidState(blockposition1);
++ // CraftBukkit start
++ IBlockData iblockdata = blockList.getBlockState(blockposition1);
++ Fluid fluid = blockList.getFluidState(blockposition1);
++ // CraftBukkit end
+
+ if (!fluid.is(TagsFluid.WATER)) {
+ return false;
+@@ -76,27 +86,64 @@
+ if (block instanceof IFluidSource) {
+ IFluidSource ifluidsource = (IFluidSource) block;
+
+- if (!ifluidsource.pickupBlock((EntityHuman) null, world, blockposition1, iblockdata).isEmpty()) {
++ if (!ifluidsource.pickupBlock((EntityHuman) null, blockList, blockposition1, iblockdata).isEmpty()) { // CraftBukkit
+ return true;
+ }
+ }
+
+ if (iblockdata.getBlock() instanceof BlockFluids) {
+- world.setBlock(blockposition1, Blocks.AIR.defaultBlockState(), 3);
++ blockList.setBlock(blockposition1, Blocks.AIR.defaultBlockState(), 3); // CraftBukkit
+ } else {
+ if (!iblockdata.is(Blocks.KELP) && !iblockdata.is(Blocks.KELP_PLANT) && !iblockdata.is(Blocks.SEAGRASS) && !iblockdata.is(Blocks.TALL_SEAGRASS)) {
+ return false;
+ }
+
+- TileEntity tileentity = iblockdata.hasBlockEntity() ? world.getBlockEntity(blockposition1) : null;
++ // CraftBukkit start
++ // TileEntity tileentity = iblockdata.hasBlockEntity() ? world.getBlockEntity(blockposition1) : null;
+
+- dropResources(iblockdata, world, blockposition1, tileentity);
+- world.setBlock(blockposition1, Blocks.AIR.defaultBlockState(), 3);
++ // dropResources(iblockdata, world, blockposition1, tileentity);
++ blockList.setBlock(blockposition1, Blocks.AIR.defaultBlockState(), 3);
++ // CraftBukkit end
+ }
+
+ return true;
+ }
+ }
+- }) > 1;
++ });
++ // CraftBukkit start
++ List<CraftBlockState> blocks = blockList.getList(); // Is a clone
++ if (!blocks.isEmpty()) {
++ final org.bukkit.block.Block bblock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
++
++ SpongeAbsorbEvent event = new SpongeAbsorbEvent(bblock, (List<org.bukkit.block.BlockState>) (List) blocks);
++ world.getCraftServer().getPluginManager().callEvent(event);
++
++ if (event.isCancelled()) {
++ return false;
++ }
++
++ for (CraftBlockState block : blocks) {
++ BlockPosition blockposition1 = block.getPosition();
++ IBlockData iblockdata = world.getBlockState(blockposition1);
++ Fluid fluid = world.getFluidState(blockposition1);
++
++ if (fluid.is(TagsFluid.WATER)) {
++ if (iblockdata.getBlock() instanceof IFluidSource && !((IFluidSource) iblockdata.getBlock()).pickupBlock((EntityHuman) null, blockList, blockposition1, iblockdata).isEmpty()) {
++ // NOP
++ } else if (iblockdata.getBlock() instanceof BlockFluids) {
++ // NOP
++ } else if (iblockdata.is(Blocks.KELP) || iblockdata.is(Blocks.KELP_PLANT) || iblockdata.is(Blocks.SEAGRASS) || iblockdata.is(Blocks.TALL_SEAGRASS)) {
++ TileEntity tileentity = iblockdata.hasBlockEntity() ? world.getBlockEntity(blockposition1) : null;
++
++ dropResources(iblockdata, world, blockposition1, tileentity);
++ }
++ }
++ world.setBlock(blockposition1, block.getHandle(), block.getFlag());
++ }
++
++ return true;
++ }
++ return false;
++ // CraftBukkit end
+ }
+ }