From 8c4820f75eef82ab584b759c671343f6569dee91 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Tue, 28 Dec 2010 23:52:29 +0000 Subject: [PATCH] Keep Blocks updated when changed by the world By: Dinnerbone --- .../src/org/bukkit/craftbukkit/CraftBlock.java | 4 ++-- .../src/org/bukkit/craftbukkit/CraftWorld.java | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/paper-server/src/org/bukkit/craftbukkit/CraftBlock.java b/paper-server/src/org/bukkit/craftbukkit/CraftBlock.java index 0f40dd78ed..5d86556417 100644 --- a/paper-server/src/org/bukkit/craftbukkit/CraftBlock.java +++ b/paper-server/src/org/bukkit/craftbukkit/CraftBlock.java @@ -9,8 +9,8 @@ public class CraftBlock implements Block { private final int x; private final int y; private final int z; - private int type; - private byte data; + protected int type; + protected byte data; protected CraftBlock(final World world, final int x, final int y, final int z, final int type, final byte data) { this.world = world; diff --git a/paper-server/src/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/org/bukkit/craftbukkit/CraftWorld.java index 304f307985..ec7298aad4 100644 --- a/paper-server/src/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/org/bukkit/craftbukkit/CraftWorld.java @@ -49,6 +49,23 @@ public class CraftWorld implements World { throw new UnsupportedOperationException("Not supported yet."); } + public Block updateBlock(int x, int y, int z) { + BlockCoordinate loc = new BlockCoordinate(x, y, z); + CraftBlock block = (CraftBlock)blockCache.get(loc); + final int type = world.a(x, y, z); + final byte data = (byte)world.b(x, y, z); + + if (block == null) { + block = new CraftBlock(this, x, y, z, type, data); + blockCache.put(loc, block); + } else { + block.type = type; + block.data = data; + } + + return block; + } + private final class ChunkCoordinate { public final int x; public final int z;