private InvBlockInfo getSelectedContainer() { int selected = storageList.getSelected(); if (selected != -1) { SyncedValueList<InvBlockInfo> inventories = tileEntity.getInventories(); if (selected < inventories.size()) { InvBlockInfo invBlockInfo = inventories.get(selected); return invBlockInfo; } } return null; }
private void hilightSelectedContainer(int index) { if (index == -1) { return; } SyncedValueList<InvBlockInfo> inventories = tileEntity.getInventories(); Coordinate c = inventories.get(index).getCoordinate(); RFTools.instance.clientInfo.hilightBlock( c, System.currentTimeMillis() + 1000 * StorageScannerConfiguration.hilightTime); Logging.message(mc.thePlayer, "The inventory is now highlighted"); mc.getMinecraft().thePlayer.closeScreen(); }
public void startScan(boolean start) { if (!worldObj.isRemote) { if (!start) { scanning.setValue(false); notifyBlockUpdate(); return; } int r = radius.getValue(); // Only on server int y1 = yCoord - r; if (y1 < 0) { y1 = 0; } c1.setCoordinate(new Coordinate(xCoord - r, y1, zCoord - r)); int y2 = yCoord + r; if (y2 >= worldObj.getHeight()) { y2 = worldObj.getHeight() - 1; } c2.setCoordinate(new Coordinate(xCoord + r, y2, zCoord + r)); scanning.setValue(true); cur.setCoordinate(c1.getCoordinate()); inventories.clear(); notifyBlockUpdate(); } }
@Override public void writeToNBT(NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); tagCompound.setBoolean("scanning", scanning.getValue()); c1.writeToNBT(tagCompound, "c1"); c2.writeToNBT(tagCompound, "c2"); cur.writeToNBT(tagCompound, "cur"); inventories.writeToNBT(tagCompound, "inv"); }
@Override public void readFromNBT(NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); scanning.setValue(tagCompound.getBoolean("scanning")); c1.readFromNBT(tagCompound, "c1"); c2.readFromNBT(tagCompound, "c2"); cur.readFromNBT(tagCompound, "cur"); inventories.readFromNBT(tagCompound, "inv"); }
private void checkInventoryStatus(int cx, int cy, int cz) { TileEntity tileEntity = worldObj.getTileEntity(cx, cy, cz); if (tileEntity instanceof IInventory) { IInventory inventory = (IInventory) tileEntity; if (inventory.getSizeInventory() > 0) { inventories.add(new InvBlockInfo(new Coordinate(cx, cy, cz), inventory.getSizeInventory())); notifyBlockUpdate(); } } }
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++; } }