From 8d4bc54183719c8dd63701e12d8ba74356c10a5d Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 28 Aug 2019 20:10:04 +1000 Subject: [PATCH] SPIGOT-5293: Sponge behaviour differs from Vanilla --- nms-patches/BlockSponge.patch | 13 +++++++++++-- .../craftbukkit/util/BlockStateListPopulator.java | 13 +++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/nms-patches/BlockSponge.patch b/nms-patches/BlockSponge.patch index 0fafa5f3bc..d9b9d87abd 100644 --- a/nms-patches/BlockSponge.patch +++ b/nms-patches/BlockSponge.patch @@ -21,7 +21,16 @@ while (!queue.isEmpty()) { Tuple tuple = (Tuple) queue.poll(); -@@ -51,22 +58,24 @@ +@@ -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 Material material = iblockdata.getMaterial(); if (fluid.a(TagsFluid.WATER)) { @@ -51,7 +60,7 @@ ++i; if (j < 6) { queue.add(new Tuple<>(blockposition2, j + 1)); -@@ -79,6 +88,39 @@ +@@ -79,6 +90,39 @@ break; } } diff --git a/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java b/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java index 583761c314..88fbfc01b5 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java +++ b/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java @@ -5,6 +5,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Set; import net.minecraft.server.BlockPosition; +import net.minecraft.server.Fluid; import net.minecraft.server.IBlockData; import net.minecraft.server.World; import org.bukkit.block.BlockState; @@ -23,6 +24,18 @@ public class BlockStateListPopulator extends DummyGeneratorAccess { this.list = list; } + @Override + public IBlockData getType(BlockPosition bp) { + CraftBlockState state = list.get(bp); + return (state != null) ? state.getHandle() : world.getType(bp); + } + + @Override + public Fluid getFluid(BlockPosition bp) { + CraftBlockState state = list.get(bp); + return (state != null) ? state.getHandle().p() : world.getFluid(bp); + } + @Override public boolean setTypeAndData(BlockPosition position, IBlockData data, int flag) { CraftBlockState state = CraftBlockState.getBlockState(world, position, flag);