From 934644633f3f98f35ba58f04097473c0471d3c87 Mon Sep 17 00:00:00 2001 From: asofold Date: Fri, 7 Dec 2012 05:47:16 +0100 Subject: [PATCH] Fix npes. --- .../nocheatplus/compat/cb2511/BlockCacheCB2511.java | 11 ++++++----- .../nocheatplus/compat/cb2512/BlockCacheCB2512.java | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/fr/neatmonster/nocheatplus/compat/cb2511/BlockCacheCB2511.java b/src/fr/neatmonster/nocheatplus/compat/cb2511/BlockCacheCB2511.java index aa3e8a28..7ab9a39b 100644 --- a/src/fr/neatmonster/nocheatplus/compat/cb2511/BlockCacheCB2511.java +++ b/src/fr/neatmonster/nocheatplus/compat/cb2511/BlockCacheCB2511.java @@ -29,26 +29,27 @@ public class BlockCacheCB2511 extends BlockCache implements IBlockAccess{ } @Override - public void setAccess(World world) { - this.world = ((CraftWorld) world).getHandle(); + public void setAccess(final World world) { + this.world = world == null ? null : ((CraftWorld) world).getHandle(); } @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); } @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); } @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 (!) final int id = getTypeId(x, y, z); 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. // minX, minY, minZ, maxX, maxY, maxZ diff --git a/src/fr/neatmonster/nocheatplus/compat/cb2512/BlockCacheCB2512.java b/src/fr/neatmonster/nocheatplus/compat/cb2512/BlockCacheCB2512.java index 0d0935a4..0bbcf7fd 100644 --- a/src/fr/neatmonster/nocheatplus/compat/cb2512/BlockCacheCB2512.java +++ b/src/fr/neatmonster/nocheatplus/compat/cb2512/BlockCacheCB2512.java @@ -30,7 +30,7 @@ public class BlockCacheCB2512 extends BlockCache implements IBlockAccess{ // TOD @Override public void setAccess(World world) { - this.world = ((CraftWorld) world).getHandle(); + this.world = world == null ? null : ((CraftWorld) world).getHandle(); } @Override @@ -49,6 +49,7 @@ public class BlockCacheCB2512 extends BlockCache implements IBlockAccess{ // TOD // TODO: change api for this / use nodes (!) 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]; + if (block == null) return null; block.updateShape(this, x, y, z); // TODO: use THIS instead of world. // minX, minY, minZ, maxX, maxY, maxZ