From cf1be6f026107eda46b31cf534256d22ef0e2c90 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Fri, 9 Nov 2018 18:11:32 +0000 Subject: [PATCH] Further extend BlockStateListPopulator Upon "real world testing", there was needed and unimplemented methods on BlockStateListPopulator; This commit (which should fix #1663) aims to improve the coverage of this class. We should aim to look into expanding this class down the line, or aim to improve the servers ability to capture these changes --- .../Extend-BlockStateListPopulator.patch | 75 ++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/Spigot-Server-Patches/Extend-BlockStateListPopulator.patch b/Spigot-Server-Patches/Extend-BlockStateListPopulator.patch index 75ed037934..e499ad5d8d 100644 --- a/Spigot-Server-Patches/Extend-BlockStateListPopulator.patch +++ b/Spigot-Server-Patches/Extend-BlockStateListPopulator.patch @@ -36,9 +36,64 @@ index 987af9c3de..6e52d46952 100644 world.setTypeAndData(blockposition2, block.getHandle(), block.getFlag()); } diff --git a/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java b/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java -index 165843ddfe..c5612b2f43 100644 +index 165843ddfe..8482abd054 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java +++ b/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java +@@ -0,0 +0,0 @@ import java.util.ArrayList; + import java.util.LinkedHashMap; + import java.util.List; + ++import net.minecraft.server.Block; + import net.minecraft.server.BlockPosition; ++import net.minecraft.server.FluidType; + import net.minecraft.server.IBlockData; ++import net.minecraft.server.TickList; ++import net.minecraft.server.TickListPriority; + import net.minecraft.server.World; + + import org.bukkit.block.BlockState; +@@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.block.CraftBlockState; + public class BlockStateListPopulator extends DummyGeneratorAccess { + private final World world; + private final LinkedHashMap list; ++ // Paper start ++ private final TickList fluidTickList = new TickList() { ++ @Override ++ public boolean a(BlockPosition var1, FluidType var2) { ++ return BlockStateListPopulator.super.I().a(var1, var2); ++ } ++ ++ @Override ++ public void a(BlockPosition var1, FluidType var2, int var3, TickListPriority var4) { ++ ++ } ++ ++ @Override ++ public boolean b(BlockPosition var1, FluidType var2) { ++ return false; ++ } ++ }; ++ ++ private TickList blockTickList = new TickList() { ++ @Override ++ public boolean a(BlockPosition var1, Block var2) { ++ return BlockStateListPopulator.super.J().a(var1, var2); ++ } ++ ++ @Override ++ public void a(BlockPosition var1, Block var2, int var3, TickListPriority var4) { ++ ++ } ++ ++ @Override ++ public boolean b(BlockPosition var1, Block var2) { ++ return false; ++ } ++ }; ++ // Paper end + + public BlockStateListPopulator(World world) { + this(world, new LinkedHashMap<>()); @@ -0,0 +0,0 @@ public class BlockStateListPopulator extends DummyGeneratorAccess { public World getWorld() { return world; @@ -54,6 +109,24 @@ index 165843ddfe..c5612b2f43 100644 + return world.getType(bp); + } + } ++ ++ // Do nothing, this will be ran when the block is actually placed into the world ++ @Override ++ public void update(BlockPosition bp, Block block) {} ++ ++ // Dumb tick lists, we rely upon block placement into the world updating this info ++ // no obfhelpers intentional, design of these classes do not favor them, and easier ++ // to just rework on upgrade... ++ @Override ++ public TickList I() { ++ return fluidTickList; ++ } ++ ++ @Override ++ public TickList J() { ++ return blockTickList; ++ } ++ + // paper end } -- \ No newline at end of file