Archiviert
13
0

Keep Blocks updated when changed by the world

Dieser Commit ist enthalten in:
Dinnerbone 2010-12-28 23:52:29 +00:00
Ursprung ef622b20d1
Commit 804b5e7d2b
3 geänderte Dateien mit 135 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,116 @@
package net.minecraft.server;
import java.io.File;
import java.util.*;
import org.bukkit.craftbukkit.CraftWorld;
public class WorldServer extends World {
public ChunkProviderServer A;
public boolean B;
public boolean C;
private MinecraftServer D;
private MCHashTable E;
private final CraftWorld world; // CraftBukkit
public WorldServer(MinecraftServer minecraftserver, File file, String s, int i) {
super(file, s, (new Random()).nextLong(), WorldProvider.a(i));
B = false;
E = new MCHashTable();
D = minecraftserver;
world = (CraftWorld)D.server.getWorld(this); // CraftBukkit
}
// CraftBukkit start
@Override
public boolean c(int i1, int j1, int k1, int l1) {
boolean result = super.c(i1, j1, k1, l1);
world.updateBlock(i1, j1, k1);
return result;
}
@Override
public boolean d(int i1, int j1, int k1, int l1) {
boolean result = super.d(i1, j1, k1, l1);
world.updateBlock(i1, j1, k1);
return result;
}
// CraftBukkit stop
public void f() {
super.f();
}
public void a(Entity entity, boolean flag) {
if (!D.m && (entity instanceof EntityAnimals)) {
entity.l();
}
if (entity.j == null || !(entity.j instanceof EntityPlayer)) {
super.a(entity, flag);
}
}
public void b(Entity entity, boolean flag) {
super.a(entity, flag);
}
protected IChunkProvider a(File file) {
A = new ChunkProviderServer(this, q.a(file), q.c());
return A;
}
public List d(int i, int j, int k, int l, int i1, int j1) {
ArrayList arraylist = new ArrayList();
for (int k1 = 0; k1 < c.size(); k1++) {
TileEntity tileentity = (TileEntity) c.get(k1);
if (tileentity.b >= i && tileentity.c >= j && tileentity.d >= k && tileentity.b < l && tileentity.c < i1 && tileentity.d < j1) {
arraylist.add(tileentity);
}
}
return arraylist;
}
public boolean a(EntityPlayer entityplayer, int i, int j, int k) {
int l = (int) MathHelper.e(i - m);
int i1 = (int) MathHelper.e(k - o);
if (l > i1) {
i1 = l;
}
return i1 > 16 || D.f.g(entityplayer.aw);
}
protected void b(Entity entity) {
super.b(entity);
E.a(entity.g, entity);
}
protected void c(Entity entity) {
super.c(entity);
E.d(entity.g);
}
public Entity a(int i) {
return (Entity) E.a(i);
}
public void a(Entity entity, byte byte0) {
Packet38 packet38 = new Packet38(entity.g, byte0);
D.k.b(entity, packet38);
}
public Explosion a(Entity entity, double d1, double d2, double d3,
float f1, boolean flag) {
Explosion explosion = super.a(entity, d1, d2, d3, f1, flag);
D.f.a(d1, d2, d3, 64D, new Packet60(d1, d2, d3, f1, explosion.g));
return explosion;
}
}

Datei anzeigen

@ -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;

Datei anzeigen

@ -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;