@Override public boolean onItemUse( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float sx, float sy, float sz) { TileEntity te = world.getTileEntity(x, y, z); NBTTagCompound tagCompound = stack.getTagCompound(); if (tagCompound == null) { tagCompound = new NBTTagCompound(); } if (te instanceof CounterTileEntity) { tagCompound.setInteger("dim", world.provider.dimensionId); tagCompound.setInteger("monitorx", x); tagCompound.setInteger("monitory", y); tagCompound.setInteger("monitorz", z); Block block = player.worldObj.getBlock(x, y, z); String name = "<invalid>"; if (block != null && !block.isAir(world, x, y, z)) { name = BlockInfo.getReadableName(block, world.getBlockMetadata(x, y, z)); } tagCompound.setString("monitorname", name); if (world.isRemote) { Logging.message(player, "Counter module is set to block '" + name + "'"); } } else { tagCompound.removeTag("dim"); tagCompound.removeTag("monitorx"); tagCompound.removeTag("monitory"); tagCompound.removeTag("monitorz"); tagCompound.removeTag("monitorname"); if (world.isRemote) { Logging.message(player, "Counter module is cleared"); } } stack.setTagCompound(tagCompound); return true; }
private void updateContentsList() { List<ItemStack> items = tileEntity.getShowingItems(); if (itemList.getMaximum() == 0) { // We need to refresh. for (ItemStack stack : items) { if (stack != null) { String displayName = BlockInfo.getReadableName(stack, 0); Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout()); panel.addChild(new BlockRender(mc, this).setRenderItem(stack)); panel.addChild( new Label(mc, this) .setDynamic(true) .setText(displayName) .setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT)); itemList.addChild(panel); } } } }
private void updateStorageList() { SyncedValueList<InvBlockInfo> inventories = tileEntity.getInventories(); if (inventories.getClientVersion() != clientVersion) { clientVersion = inventories.getClientVersion(); storageList.removeChildren(); for (InvBlockInfo blockInfo : inventories) { Coordinate c = blockInfo.getCoordinate(); Block block = mc.theWorld.getBlock(c.getX(), c.getY(), c.getZ()); int meta = mc.theWorld.getBlockMetadata(c.getX(), c.getY(), c.getZ()); String displayName; if (block == null || block.isAir(mc.theWorld, c.getX(), c.getY(), c.getZ())) { displayName = "[REMOVED]"; block = null; } else { displayName = BlockInfo.getReadableName(block, meta); } Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout()); panel.addChild(new BlockRender(mc, this).setRenderItem(block)); panel.addChild( new Label(mc, this) .setText(displayName) .setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT) .setDesiredWidth(90)); panel.addChild(new Label(mc, this).setDynamic(true).setText(c.toString())); storageList.addChild(panel); } } storageList.clearHilightedRows(); Set<Coordinate> coordinates = fromServer_coordinates; int i = 0; for (InvBlockInfo blockInfo : inventories) { Coordinate c = blockInfo.getCoordinate(); if (coordinates.contains(c)) { storageList.addHilightedRow(i); } i++; } }