protected void drawContainerName() { BaseContainer<?> multiContainer = (BaseContainer<?>) this.inventorySlots; String localizedName = multiContainer.getInventoryDisplayName(); if(localizedName != null) { this.fontRenderer.drawString(localizedName, 8 + guiLeft, 6 + guiTop, 0x404040); } }
public GuiScalingChest(GuiMultiModule parent, BaseContainer container) { super(parent, container); inventory = (IInventory) container.getTile(); slotCount = inventory.getSizeInventory(); sliderActive = true; }
@Override public boolean openGui(EntityPlayer player, World world, BlockPos pos) { player.openGui(TConstruct.instance, 0, world, pos.getX(), pos.getY(), pos.getZ()); if(player.openContainer instanceof BaseContainer) { ((BaseContainer) player.openContainer).syncOnOpen((EntityPlayerMP) player); } return true; }
public void syncOnOpen(EntityPlayerMP playerOpened) { // find another player that already has the gui for this tile open WorldServer server = playerOpened.getServerWorld(); for(EntityPlayer player : server.playerEntities) { if(player == playerOpened) { continue; } if(player.openContainer instanceof BaseContainer) { if(this.sameGui((BaseContainer<T>) player.openContainer)) { syncWithOtherContainer((BaseContainer<T>) player.openContainer, playerOpened); return; } } } // no player has a container open for the tile syncNewContainer(playerOpened); }
public GuiPartChest(InventoryPlayer playerInv, World world, BlockPos pos, TilePartChest tile) { super(world, pos, (ContainerTinkerStation) tile.createContainer(playerInv, world, pos)); // we use the sideinventory class for the inventory itself // it doesn't contain the player inventory guiInventory = new GuiScalingChest(this, container.getSubContainer(ContainerPartChest.DynamicChestInventory.class)); addModule(guiInventory); }
@Override public void handleServerSafe(NetHandlerPlayServer netHandler) { Container container = netHandler.player.openContainer; if(container instanceof ContainerStencilTable) { ((ContainerStencilTable) container).setOutput(output); // find all people who also have the same gui open and update them too WorldServer server = netHandler.player.getServerWorld(); for(EntityPlayer player : server.playerEntities) { if(player == netHandler.player) { continue; } if(player.openContainer instanceof ContainerStencilTable) { if(((BaseContainer) container).sameGui((BaseContainer) player.openContainer)) { ((ContainerStencilTable) player.openContainer).setOutput(output); // same gui, send him an update TinkerNetwork.sendTo(this, (EntityPlayerMP) player); } } } } }
protected void drawContainerName() { ContainerMultiModule multiContainer = (ContainerMultiModule) this.inventorySlots; String localizedName = multiContainer.getInventoryDisplayName(); if(localizedName != null) { this.fontRenderer.drawString(localizedName, 8, 6, 0x404040); } }
this.addSlotToContainer(new SlotCraftingCustom(this, playerInventory.player, craftMatrix, craftResult, 0, 106, 35)); this.addSlotToContainer(secondarySlot = new SlotOut(tile, 3, 132, 35));
public ContainerSimpleChest(TileInventory tile, int rows, int columns, InventoryPlayer playerInventory) { super(tile); int index = 0; // chest inventory for(int i = 0; i < rows; ++i) { for(int j = 0; j < columns; ++j) { // safety if(index > tile.getSizeInventory()) { break; } this.addSlotToContainer(createSlot(tile, index, 8 + j * 18, 18 + i * 18)); index++; } } // player inventory addPlayerInventory(playerInventory, 17, 86); }
/** Searches for a sidechest to display in the UI */ public <TE extends TileEntity> TE detectTE(Class<TE> clazz) { return ObjectUtils.firstNonNull(detectChest(this.pos.north(), clazz), detectChest(this.pos.east(), clazz), detectChest(this.pos.south(), clazz), detectChest(this.pos.west(), clazz)); }
public ContainerStencilTable(InventoryPlayer playerInventory, TileStencilTable tile) { super(tile); this.output = ItemStack.EMPTY; this.craftMatrix = new InventoryCraftingPersistent(this, tile, 1, 1); this.craftResult = new InventoryCraftResult(); this.addSlotToContainer(new SlotStencil(this.craftMatrix, 0, 48, 35, true)); this.addSlotToContainer(new SlotCraftingCustom(this, playerInventory.player, craftMatrix, craftResult, 1, 106, 35)); TilePatternChest chest = detectTE(TilePatternChest.class); // TE present? if(chest != null) { patternChestSideInventory = new ContainerPatternChest.DynamicChestInventory(chest, chest, 6 + 176, 8, 6); addSubContainer(patternChestSideInventory, true); } else { patternChestSideInventory = null; } this.addPlayerInventory(playerInventory, 8, 84); onCraftMatrixChanged(null); }
protected GuiModule getModuleForSlot(int slotNumber) { return getModuleForContainer(getContainer().getSlotContainer(slotNumber)); }
public GuiPatternChest(InventoryPlayer playerInv, World world, BlockPos pos, TilePatternChest tile) { super(world, pos, (ContainerTinkerStation<TilePatternChest>) tile.createContainer(playerInv, world, pos)); // we use the sideinventory class for the inventory itself // it doesn't contain the player inventory guiInventory = new GuiScalingChest(this, container.getSubContainer(ContainerPatternChest.DynamicChestInventory.class)); addModule(guiInventory); }
@Override public void handleServerSafe(NetHandlerPlayServer netHandler) { Container container = netHandler.player.openContainer; if(container instanceof ContainerToolStation) { ((ContainerToolStation) container).setToolSelection(tool, activeSlots); // find all people who also have the same gui open and update them too WorldServer server = netHandler.player.getServerWorld(); for(EntityPlayer player : server.playerEntities) { if(player == netHandler.player) { continue; } if(player.openContainer instanceof ContainerToolStation) { if(((BaseContainer) container).sameGui((BaseContainer) player.openContainer)) { ((ContainerToolStation) player.openContainer).setToolSelection(tool, activeSlots); // same gui, send him an update TinkerNetwork.sendTo(this, (EntityPlayerMP) player); } } } } }
info.setCaption(container.getInventoryDisplayName()); info.setText(I18n.translateToLocal("gui.partbuilder.info"));
protected boolean shouldDrawName() { if(this.inventorySlots instanceof BaseContainer) { return ((BaseContainer) this.inventorySlots).getInventoryDisplayName() != null; } return false; }
@Override public void handleServerSafe(NetHandlerPlayServer netHandler) { if(netHandler.player.openContainer instanceof BaseContainer) { TileEntity te = ((BaseContainer<?>) netHandler.player.openContainer).getTile(); if(te instanceof ISmelteryTankHandler) { ISmelteryTankHandler smeltery = (ISmelteryTankHandler)te; smeltery.getTank().moveFluidToBottom(index); smeltery.onTankChanged(smeltery.getTank().getFluids(), null); } } }
@Override public boolean openGui(EntityPlayer player, World world, BlockPos pos) { if(!world.isRemote) { player.openGui(TConstruct.instance, 0, world, pos.getX(), pos.getY(), pos.getZ()); if(player.openContainer instanceof BaseContainer) { ((BaseContainer) player.openContainer).syncOnOpen((EntityPlayerMP) player); } } return true; }
public <TC extends Container> TC getSubContainer(Class<TC> clazz) { return getSubContainer(clazz, 0); }
public void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { if(shouldDrawName()) { String name = ((BaseContainer) inventorySlots).getInventoryDisplayName(); this.fontRenderer.drawString(name, border.w, border.h - 1, 0x404040);