use of mcjty.rftools.craftinggrid.CraftingGridProvider in project RFTools by McJty.
the class GuiModularStorage method initGui.
@Override
public void initGui() {
super.initGui();
itemList = new WidgetList(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(5, 3, 235, ySize - 89)).setNoSelectionMode(true).setUserObject(new Integer(-1)).setLeftMargin(0).setRowheight(-1);
Slider slider = new Slider(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(241, 3, 11, ySize - 89)).setDesiredWidth(11).setVertical().setScrollable(itemList);
Panel modePanel = setupModePanel();
cycleButton = new Button(mc, this).setText("C").setTooltips("Cycle to the next storage module").setLayoutHint(new PositionalLayout.PositionalHint(5, ySize - 23, 16, 16)).addButtonEvent(parent -> cycleStorage());
Panel toplevel = new Panel(mc, this).setLayout(new PositionalLayout()).addChild(itemList).addChild(slider).addChild(modePanel).addChild(cycleButton);
toplevel.setBackgrounds(iconLocationTop, iconLocation);
toplevel.setBackgroundLayout(false, ySize - STORAGE_HEIGHT0 + 2);
if (tileEntity == null) {
// We must hide three slots.
ImageLabel hideLabel = new ImageLabel(mc, this);
hideLabel.setLayoutHint(new PositionalLayout.PositionalHint(4, ySize - 26 - 3 * 18, 20, 55));
hideLabel.setImage(guiElements, 32, 32);
toplevel.addChild(hideLabel);
}
toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
window = new Window(this, toplevel);
if (ModularStorageConfiguration.autofocusSearch) {
window.setTextFocus(filter);
}
CraftingGridProvider provider;
BlockPos pos = null;
if (tileEntity != null) {
provider = tileEntity;
pos = tileEntity.getPos();
} else if (inventorySlots instanceof ModularStorageItemContainer) {
ModularStorageItemContainer storageItemContainer = (ModularStorageItemContainer) inventorySlots;
provider = storageItemContainer.getCraftingGridProvider();
} else if (inventorySlots instanceof RemoteStorageItemContainer) {
RemoteStorageItemContainer storageItemContainer = (RemoteStorageItemContainer) inventorySlots;
provider = storageItemContainer.getCraftingGridProvider();
} else {
throw new RuntimeException("Should not happen!");
}
craftingGrid.initGui(modBase, network, mc, this, pos, provider, guiLeft, guiTop, xSize, ySize);
sendServerCommand(RFTools.MODID, CommandHandler.CMD_REQUEST_GRID_SYNC, Arguments.builder().value(pos).build());
}
use of mcjty.rftools.craftinggrid.CraftingGridProvider in project RFTools by McJty.
the class StorageTerminalBlock method createClientGui.
@SideOnly(Side.CLIENT)
@Override
public GuiContainer createClientGui(EntityPlayer entityPlayer, TileEntity tileEntity) {
if (!entityPlayer.isSneaking()) {
ItemStack module = getModule(tileEntity);
if (!module.isEmpty()) {
int monitordim = RFToolsTools.getDimensionFromModule(module);
BlockPos pos = RFToolsTools.getPositionFromModule(module);
StorageScannerTileEntity te = new StorageScannerTileEntity(entityPlayer, monitordim) {
@Override
public BlockPos getCraftingGridContainerPos() {
// for this terminal itself.
return tileEntity.getPos();
}
@Override
public CraftingGridProvider getCraftingGridProvider() {
return (CraftingGridProvider) tileEntity;
}
@Override
public boolean isOpenWideView() {
TileEntity realTe = RFTools.proxy.getClientWorld().getTileEntity(pos);
if (realTe instanceof StorageScannerTileEntity) {
return ((StorageScannerTileEntity) realTe).isOpenWideView();
}
return true;
}
@Override
public BlockPos getStorageScannerPos() {
return pos;
}
};
// The position of the actual storage scanner is set on the dummy te
te.setPos(pos);
return new GuiStorageScanner(te, new StorageScannerContainer(entityPlayer, te, (CraftingGridProvider) tileEntity));
}
}
return super.createClientGui(entityPlayer, tileEntity);
}
Aggregations