3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-27 00:22:46 +01:00
Paper/nms-patches/BlockSponge.patch

103 Zeilen
5.2 KiB
Diff

2018-07-23 09:20:52 +02:00
--- a/net/minecraft/server/BlockSponge.java
+++ b/net/minecraft/server/BlockSponge.java
@@ -2,6 +2,12 @@
import com.google.common.collect.Lists;
2018-12-25 22:00:00 +01:00
import java.util.Queue;
2018-07-23 09:20:52 +02:00
+// 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 {
2019-04-23 04:00:00 +02:00
@@ -35,6 +41,7 @@
2018-07-23 09:20:52 +02:00
2018-12-25 22:00:00 +01:00
queue.add(new Tuple<>(blockposition, 0));
2018-07-23 09:20:52 +02:00
int i = 0;
+ BlockStateListPopulator blockList = new BlockStateListPopulator(world); // CraftBukkit - Use BlockStateListPopulator
2018-12-25 22:00:00 +01:00
while (!queue.isEmpty()) {
Tuple<BlockPosition, Integer> tuple = (Tuple) queue.poll();
@@ -46,27 +53,31 @@
for (int l = 0; l < k; ++l) {
EnumDirection enumdirection = aenumdirection[l];
BlockPosition blockposition2 = blockposition1.shift(enumdirection);
- IBlockData iblockdata = world.getType(blockposition2);
- Fluid fluid = world.getFluid(blockposition2);
+ // CraftBukkit start
+ IBlockData iblockdata = blockList.getType(blockposition2);
+ Fluid fluid = blockList.getFluid(blockposition2);
+ // CraftBukkit end
2018-07-23 09:20:52 +02:00
Material material = iblockdata.getMaterial();
2018-08-26 04:00:00 +02:00
if (fluid.a(TagsFluid.WATER)) {
2018-12-25 22:00:00 +01:00
- if (iblockdata.getBlock() instanceof IFluidSource && ((IFluidSource) iblockdata.getBlock()).removeFluid(world, blockposition2, iblockdata) != FluidTypes.EMPTY) {
+ if (iblockdata.getBlock() instanceof IFluidSource && ((IFluidSource) iblockdata.getBlock()).removeFluid(blockList, blockposition2, iblockdata) != FluidTypes.EMPTY) { // CraftBukkit
2018-07-23 09:20:52 +02:00
++i;
if (j < 6) {
2018-12-25 22:00:00 +01:00
queue.add(new Tuple<>(blockposition2, j + 1));
2018-07-23 09:20:52 +02:00
}
} else if (iblockdata.getBlock() instanceof BlockFluids) {
- world.setTypeAndData(blockposition2, Blocks.AIR.getBlockData(), 3);
+ blockList.setTypeAndData(blockposition2, Blocks.AIR.getBlockData(), 3); // CraftBukkit
++i;
if (j < 6) {
2018-12-25 22:00:00 +01:00
queue.add(new Tuple<>(blockposition2, j + 1));
2018-07-23 09:20:52 +02:00
}
} else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) {
2019-04-23 04:00:00 +02:00
- TileEntity tileentity = iblockdata.getBlock().isTileEntity() ? world.getTileEntity(blockposition2) : null;
+ // CraftBukkit start
+ // TileEntity tileentity = iblockdata.getBlock().isTileEntity() ? world.getTileEntity(blockposition2) : null;
- a(iblockdata, world, blockposition2, tileentity);
2018-07-23 09:20:52 +02:00
- world.setTypeAndData(blockposition2, Blocks.AIR.getBlockData(), 3);
2019-04-23 04:00:00 +02:00
+ // a(iblockdata, world, blockposition2, tileentity);
+ blockList.setTypeAndData(blockposition2, Blocks.AIR.getBlockData(), 3);
+ // CraftBukkit end
2018-07-23 09:20:52 +02:00
++i;
if (j < 6) {
2018-12-25 22:00:00 +01:00
queue.add(new Tuple<>(blockposition2, j + 1));
@@ -79,6 +90,39 @@
2018-07-23 09:20:52 +02:00
break;
}
}
+ // CraftBukkit start
+ List<CraftBlockState> blocks = blockList.getList(); // Is a clone
2018-07-23 09:20:52 +02:00
+ 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.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return false;
+ }
+
+ for (CraftBlockState block : blocks) {
+ BlockPosition blockposition2 = block.getPosition();
2018-07-23 09:20:52 +02:00
+ IBlockData iblockdata = world.getType(blockposition2);
+ Fluid fluid = world.getFluid(blockposition2);
2018-07-23 09:20:52 +02:00
+ Material material = iblockdata.getMaterial();
+
+ if (fluid.a(TagsFluid.WATER)) {
2018-12-25 22:00:00 +01:00
+ if (iblockdata.getBlock() instanceof IFluidSource && ((IFluidSource) iblockdata.getBlock()).removeFluid(blockList, blockposition2, iblockdata) != FluidTypes.EMPTY) {
+ // NOP
+ } else if (iblockdata.getBlock() instanceof BlockFluids) {
+ // NOP
+ } else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) {
2019-04-23 04:00:00 +02:00
+ TileEntity tileentity = iblockdata.getBlock().isTileEntity() ? world.getTileEntity(blockposition2) : null;
+
+ a(iblockdata, world, blockposition2, tileentity);
+ }
2018-07-23 09:20:52 +02:00
+ }
+ world.setTypeAndData(blockposition2, block.getHandle(), block.getFlag());
+ }
+ }
+ // CraftBukkit end
return i > 0;
}