Posted January 4, 20169 yr Hello, does anyone know why the following code doesn't let you open the workbench Gui? @Override public void processCommand(ICommandSender sender, String[] args) throws CommandException { if (!this.isArgSizeOkay(sender, args.length, 0)) return; if (!(sender instanceof EntityPlayer)) return; EntityPlayer player = (EntityPlayer)sender; player.displayGui(new BlockWorkbench.InterfaceCraftingTable(player.worldObj, player.getPosition())); } Regards, IceTrailer
January 4, 20169 yr Author So it's not possible in any way to open a workbench gui without having it placed in the World? Regards, IceTrailer
January 4, 20169 yr BlockWorkbench.InterfaceCraftingTable opens ContainerWorkbench , which overrides Container#canInteractWith to return false if the block at the specified position isn't a Crafting Table. This is called every tick in EntityPlayer#onUpdate , if it returns false the Container and GUIScreen are closed. You'll need to create your own Container that extends ContainerWorkbench and overrides Container#canInteractWith to return true if the player can interact with it (if there's no restrictions, just return true every time) and your own GuiScreen that extends GuiContainer , creates an instance of your Container class and renders like GuiCrafting . Use FML's IGuiHandler system to open your GUI. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
January 4, 20169 yr Author Well, I tried it to do it like you described, but I don't get the following. your own GuiScreen that extends GuiContainer , creates an instance of your Container class and renders like GuiCrafting . Use FML's IGuiHandler system to open your GUI. But thanks for your help. I think it's too ornate for only "/workbench" without having a crafting table Regards, IceTrailer
January 4, 20169 yr Look at GuiCrafting to see how the vanilla Crafting Table creates its client-side Container and renders the GUI. You can use the same code, but create an instance of your Container class instead of ContainerWorkbench . BedrockMiner has a tutorial on the GUI Handler system here. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
January 7, 20169 yr You imply it should be easy to create a workbench GUI without having an actual workbench at that location. But it's not necessarily true because the workbench GUI interacts with the workbench itself (by holding items while they get crafted etc.). That is all speculation I haven't worked with that particular object in the game.
January 7, 20169 yr You imply it should be easy to create a workbench GUI without having an actual workbench at that location. But it's not necessarily true because the workbench GUI interacts with the workbench itself (by holding items while they get crafted etc.). That is all speculation I haven't worked with that particular object in the game. ContainerWorkbench doesn't interact with the Crafting Table block at all except to check if the player is still in range of it. The Crafting Table doesn't have a TileEntity , it doesn't store any items; ContainerWorkbench creates its own temporary inventories to store the ingredients and result and drops these on the ground when the GUI closes. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.