use of mcjty.rftools.blocks.screens.network.PacketModuleUpdate in project RFTools by McJty.
the class GuiScreen method installModuleGui.
private void installModuleGui(int i, final ItemStack slot, IModuleProvider moduleProvider, Class<? extends IClientScreenModule> clientScreenModuleClass) {
buttons[i].setEnabled(true);
toplevel.removeChild(modulePanels[i]);
try {
IClientScreenModule<?> clientScreenModule = clientScreenModuleClass.newInstance();
clientScreenModules[i] = clientScreenModule;
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
NBTTagCompound tagCompound = slot.getTagCompound();
if (tagCompound == null) {
tagCompound = new NBTTagCompound();
}
final NBTTagCompound finalTagCompound = tagCompound;
final int finalI = i;
ScreenModuleGuiBuilder guiBuilder = new ScreenModuleGuiBuilder(mc, this, tagCompound, () -> {
slot.setTagCompound(finalTagCompound);
tileEntity.setInventorySlotContents(finalI, slot);
RFToolsMessages.INSTANCE.sendToServer(new PacketModuleUpdate(tileEntity.getPos(), finalI, finalTagCompound));
});
clientScreenModules[i].createGui(guiBuilder);
modulePanels[i] = guiBuilder.build();
modulePanels[i].setLayoutHint(new PositionalLayout.PositionalHint(80, 8, 170, 114));
modulePanels[i].setFilledRectThickness(-2).setFilledBackground(0xff8b8b8b);
toplevel.addChild(modulePanels[i]);
buttons[i].setText(moduleProvider.getName());
}
Aggregations