summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorErik Broes <erikbroes@grum.nl>2011-01-30 20:19:56 +0100
committerErik Broes <erikbroes@grum.nl>2011-01-30 20:19:56 +0100
commit6c60b54fdf92d4470228ac16c80e4b6743407692 (patch)
tree0e0e85ed0cc2ea33776034f18e014f77a1dc26b7 /src/main
parentda00e2e3a980e6559176117fe30bab95fa169965 (diff)
downloadcraftbukkit-6c60b54fdf92d4470228ac16c80e4b6743407692.tar
craftbukkit-6c60b54fdf92d4470228ac16c80e4b6743407692.tar.gz
craftbukkit-6c60b54fdf92d4470228ac16c80e4b6743407692.tar.lz
craftbukkit-6c60b54fdf92d4470228ac16c80e4b6743407692.tar.xz
craftbukkit-6c60b54fdf92d4470228ac16c80e4b6743407692.zip
Optimized blockCache, now only stores blocks asked for
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/net/minecraft/server/WorldServer.java32
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftWorld.java20
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java10
3 files changed, 35 insertions, 27 deletions
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 97316346..faed7ca7 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -34,33 +34,35 @@ public class WorldServer extends World {
private final CraftWorld world;
private final CraftServer server;
+ /**
+ * setData
+ *
+ * @param x
+ * @param y
+ * @param z
+ * @param data (actually a byte!)
+ */
@Override
- public boolean d(int i1, int j1, int k1, int l1) {
- boolean result = super.d(i1, j1, k1, l1);
- if ((result) && (world != null)) world.updateBlock(i1, j1, k1);
+ public boolean d(int x, int y, int z, int data) {
+ boolean result = super.d(x, y, z, data);
+ if ((result) && (world != null)) world.updateBlock(x, y, z, null, data);
return result;
}
@Override
- public boolean setTypeId(int i, int j, int k, int l) {
- boolean result = super.setTypeId(i, j, k, l);
- if ((result) && (world != null)) world.updateBlock(i, j, k);
+ public boolean setTypeId(int x, int y, int z, int type) {
+ boolean result = super.setTypeId(x, y, z, type);
+ if ((result) && (world != null)) world.updateBlock(x, y, z, type, null);
return result;
}
@Override
- public boolean setTypeIdAndData(int i, int j, int k, int l, int i1) {
- boolean result = super.setTypeIdAndData(i, j, k, l, i1);
- if ((result) && (world != null)) world.updateBlock(i, j, k);
+ public boolean setTypeIdAndData(int x, int y, int z, int type, int data) {
+ boolean result = super.setTypeIdAndData(x, y, z, type, data);
+ if ((result) && (world != null)) world.updateBlock(x, y, z, type, data);
return result;
}
- @Override
- public void setTileEntity(int i, int j, int k, TileEntity tileentity) {
- super.setTileEntity(i, j, k, tileentity);
- if (world != null) world.updateBlock(i, j, k);
- }
-
public CraftWorld getWorld() {
return world;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index d7d2093c..30e91359 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -83,20 +83,22 @@ public class CraftWorld implements World {
}
- public Block updateBlock(int x, int y, int z) {
+ public void updateBlock(int x, int y, int z, Integer type, Integer data) {
BlockCoordinate loc = new BlockCoordinate(x, y, z);
- CraftBlock block = (CraftBlock)blockCache.get(loc);
- final int type = world.getTypeId(x, y, z);
- final byte data = (byte)world.getData(x, y, z);
+ CraftBlock block = (CraftBlock) blockCache.get(loc);
if (block == null) {
- block = new CraftBlock(this, x, y, z, type, data);
- blockCache.put(loc, block);
- } else {
- block.update();
+ return;
}
- return block;
+ if (type == null) {
+ type = world.getTypeId(x, y, z);
+ }
+ if (data == null) {
+ data = world.getData(x, y, z);
+ }
+
+ block.update(type, data.byteValue());
}
public CraftChunk updateChunk(int x, int z) {
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
index efe07ef0..16718f86 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
@@ -346,9 +346,13 @@ public class CraftBlock implements Block {
return world.getHandle().p(x, y, z);
}
- public void update() {
- type = world.getHandle().getTypeId(x, y, z);
- data = (byte)world.getHandle().getData(x, y, z);
+ public void update(int type, byte data) {
+ this.type = type;
+ this.data = data;
light = (byte)world.getHandle().j(x, y, z);
}
+
+ public void update() {
+ this.update( world.getHandle().getTypeId(x, y, z), (byte)world.getHandle().getData(x, y, z));
+ }
}