Fix npes.

This commit is contained in:
asofold 2012-12-07 05:47:16 +01:00
parent 898a9a5212
commit 934644633f
2 changed files with 8 additions and 6 deletions

View File

@ -29,26 +29,27 @@ public class BlockCacheCB2511 extends BlockCache implements IBlockAccess{
} }
@Override @Override
public void setAccess(World world) { public void setAccess(final World world) {
this.world = ((CraftWorld) world).getHandle(); this.world = world == null ? null : ((CraftWorld) world).getHandle();
} }
@Override @Override
public int fetchTypeId(int x, int y, int z) { public int fetchTypeId(final int x, final int y, final int z) {
return world.getTypeId(x, y, z); return world.getTypeId(x, y, z);
} }
@Override @Override
public int fetchData(int x, int y, int z) { public int fetchData(final int x, final int y, final int z) {
return world.getData(x, y, z); return world.getData(x, y, z);
} }
@Override @Override
public double[] fetchBounds(int x, int y, int z){ public double[] fetchBounds(final int x, final int y, final int z){
// TODO: change api for this / use nodes (!) // TODO: change api for this / use nodes (!)
final int id = getTypeId(x, y, z); final int id = getTypeId(x, y, z);
final net.minecraft.server.Block block = net.minecraft.server.Block.byId[id]; final net.minecraft.server.Block block = net.minecraft.server.Block.byId[id];
if (block == null) return null;
block.updateShape(this, x, y, z); // TODO: use THIS instead of world. block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
// minX, minY, minZ, maxX, maxY, maxZ // minX, minY, minZ, maxX, maxY, maxZ

View File

@ -30,7 +30,7 @@ public class BlockCacheCB2512 extends BlockCache implements IBlockAccess{ // TOD
@Override @Override
public void setAccess(World world) { public void setAccess(World world) {
this.world = ((CraftWorld) world).getHandle(); this.world = world == null ? null : ((CraftWorld) world).getHandle();
} }
@Override @Override
@ -49,6 +49,7 @@ public class BlockCacheCB2512 extends BlockCache implements IBlockAccess{ // TOD
// TODO: change api for this / use nodes (!) // TODO: change api for this / use nodes (!)
final int id = getTypeId(x, y, z); final int id = getTypeId(x, y, z);
final net.minecraft.server.v1_4_5.Block block = net.minecraft.server.v1_4_5.Block.byId[id]; final net.minecraft.server.v1_4_5.Block block = net.minecraft.server.v1_4_5.Block.byId[id];
if (block == null) return null;
block.updateShape(this, x, y, z); // TODO: use THIS instead of world. block.updateShape(this, x, y, z); // TODO: use THIS instead of world.
// minX, minY, minZ, maxX, maxY, maxZ // minX, minY, minZ, maxX, maxY, maxZ