Skip to content

Commit

Permalink
Fix crashes/issues with WailaWorldWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
tterrag1098 committed Apr 1, 2015
1 parent 6d98bbe commit 5d08a9d
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/main/java/crazypants/enderio/waila/WailaCompat.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,25 @@ public int getBlockMetadata(int x, int y, int z) {
}
return wrapped.getBlockMetadata(x, y, z);
}

@Override
public TileEntity getTileEntity(int p_147438_1_, int p_147438_2_, int p_147438_3_) {
return wrapped.getTileEntity(p_147438_1_, p_147438_2_, p_147438_3_);
public TileEntity getTileEntity(int x, int y, int z) {
int meta = getBlockMetadata(x, y, z);
Block block = getBlock(x, y, z);
if(block == null || !block.hasTileEntity(meta)) {
return null;
}
TileEntity te = block.createTileEntity(this, meta);
if(te == null) {
return null;
}

te.setWorldObj(this);
te.xCoord = x;
te.yCoord = y;
te.zCoord = z;

return te;
}

@Override
Expand Down Expand Up @@ -153,13 +168,13 @@ public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, I
@SuppressWarnings("unchecked")
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {

_accessor = accessor;

EntityPlayer player = accessor.getPlayer();
MovingObjectPosition pos = accessor.getPosition();
int x = pos.blockX, y = pos.blockY, z = pos.blockZ;
World world = new WailaWorldWrapper(player.worldObj);
World world = accessor.getWorld();
Block block = world.getBlock(x, y, z);
TileEntity te = world.getTileEntity(x, y, z);
Item item = Item.getItemFromBlock(block);
Expand Down

0 comments on commit 5d08a9d

Please sign in to comment.