mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-10 12:02:36 +01:00
9d740b84b0
By: md_5 <git@md-5.net>
110 lines
5.3 KiB
Diff
110 lines
5.3 KiB
Diff
--- a/net/minecraft/world/level/block/BlockSponge.java
|
|
+++ b/net/minecraft/world/level/block/BlockSponge.java
|
|
@@ -9,6 +9,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 int MAX_DEPTH = 6;
|
|
@@ -41,7 +48,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;
|
|
|
|
@@ -55,8 +63,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;
|
|
@@ -66,27 +76,64 @@
|
|
if (block instanceof IFluidSource) {
|
|
IFluidSource ifluidsource = (IFluidSource) block;
|
|
|
|
- if (!ifluidsource.pickupBlock(world, blockposition1, iblockdata).isEmpty()) {
|
|
+ if (!ifluidsource.pickupBlock(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(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
|
|
}
|
|
}
|