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;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
+// 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 {
|
|
|
|
|
|
|
|
@@ -33,6 +39,7 @@
|
|
|
|
|
2018-12-06 00:00:00 +01:00
|
|
|
linkedlist.add(new Tuple(blockposition, 0));
|
2018-07-23 09:20:52 +02:00
|
|
|
int i = 0;
|
|
|
|
+ BlockStateListPopulator blockList = new BlockStateListPopulator(world); // CraftBukkit - Use BlockStateListPopulator
|
|
|
|
|
|
|
|
while (!linkedlist.isEmpty()) {
|
|
|
|
Tuple tuple = (Tuple) linkedlist.poll();
|
|
|
|
@@ -49,20 +56,20 @@
|
|
|
|
Material material = iblockdata.getMaterial();
|
|
|
|
|
2018-08-26 04:00:00 +02:00
|
|
|
if (fluid.a(TagsFluid.WATER)) {
|
2018-07-23 09:20:52 +02:00
|
|
|
- if (iblockdata.getBlock() instanceof IFluidSource && ((IFluidSource) iblockdata.getBlock()).a(world, blockposition2, iblockdata) != FluidTypes.a) {
|
|
|
|
+ if (iblockdata.getBlock() instanceof IFluidSource && ((IFluidSource) iblockdata.getBlock()).a(blockList, blockposition2, iblockdata) != FluidTypes.a) { // CraftBukkit
|
|
|
|
++i;
|
|
|
|
if (j < 6) {
|
2018-12-06 00:00:00 +01:00
|
|
|
linkedlist.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-06 00:00:00 +01:00
|
|
|
linkedlist.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) {
|
|
|
|
- iblockdata.a(world, blockposition2, 0);
|
|
|
|
- world.setTypeAndData(blockposition2, Blocks.AIR.getBlockData(), 3);
|
|
|
|
+ // iblockdata.a(world, blockposition2, 0);
|
|
|
|
+ blockList.setTypeAndData(blockposition2, Blocks.AIR.getBlockData(), 3); // CraftBukkit
|
|
|
|
++i;
|
|
|
|
if (j < 6) {
|
2018-12-06 00:00:00 +01:00
|
|
|
linkedlist.add(new Tuple(blockposition2, j + 1));
|
2018-12-13 04:28:34 +01:00
|
|
|
@@ -75,6 +82,37 @@
|
2018-07-23 09:20:52 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+ // CraftBukkit start
|
2018-12-13 04:28:34 +01:00
|
|
|
+ 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 = new BlockPosition(block.getX(), block.getY(), block.getZ());
|
|
|
|
+ IBlockData iblockdata = world.getType(blockposition2);
|
2018-12-13 04:28:34 +01:00
|
|
|
+ Fluid fluid = world.getFluid(blockposition2);
|
2018-07-23 09:20:52 +02:00
|
|
|
+ Material material = iblockdata.getMaterial();
|
|
|
|
+
|
2018-12-13 04:28:34 +01:00
|
|
|
+ if (fluid.a(TagsFluid.WATER)) {
|
|
|
|
+ if (iblockdata.getBlock() instanceof IFluidSource && ((IFluidSource) iblockdata.getBlock()).a(blockList, blockposition2, iblockdata) != FluidTypes.a) {
|
|
|
|
+ // NOP
|
|
|
|
+ } else if (iblockdata.getBlock() instanceof BlockFluids) {
|
|
|
|
+ // NOP
|
|
|
|
+ } else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) {
|
|
|
|
+ iblockdata.a(world, blockposition2, 0);
|
|
|
|
+ }
|
2018-07-23 09:20:52 +02:00
|
|
|
+ }
|
|
|
|
+ world.setTypeAndData(blockposition2, block.getHandle(), block.getFlag());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
|
|
|
|
return i > 0;
|
|
|
|
}
|