Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

RR55

Members
  • Joined

  • Last visited

Everything posted by RR55

  1. Where do you use .setInventorySlotContents(int slot, ItemStack itemstack) ?
  2. Thank you, but that's too deep for me :'(. I found another solution. I created a Dummy Container which displays the GUI. Now I cant use GuiScreen but it works.
  3. Changes: GuiHandler }else if(ID == 100){ System.out.println("GuiHandler: getServerGuiElement ID == 100 called"); return null; } Command @SideOnly(Side.CLIENT) public void processCommand(ICommandSender commandSender, String[] strArray){ int i; WorldServer worldserver = MinecraftServer.getServer().worldServers[1]; commandSender.addChatMessage(new ChatComponentTranslation("commands.main.heading", new Object[0])); EntityPlayer p = (EntityPlayer)commandSender; World w = p.getEntityWorld(); ChunkCoordinates c = commandSender.getPlayerCoordinates(); int x = c.posX; int y = c.posY; int z = c.posZ; System.out.println("CommandMain.java: call GUI"); if(w.isRemote){ System.out.println("CommandMain.java:CLIENT - World is remote"); p.openGui(Main.instance, 100, w, x, y, z); }else{ System.out.println("CommandMain.java:SERVER - World is not remote"); } System.out.println("CommandMain.java: done"); } But it doesnt work. Console output: CommandMain.java: call GUI CommandMain.java:SERVER - World is not remote CommandMain.java: done
  4. Hello, I want to make a simple GUI and I want to open this GUI with a command. The GUI should only display a "Help" with icons (Blocks and Items) and text (Description) but that's not my problem. I cant open the GUI. Whenever I run the command I get an error. [server thread/ERROR]: Couldn't process command: 'mycommand' java.lang.ClassCastException: tk.MyName.MyMod.gui.GuiHelp cannot be cast to net.minecraft.inventory.Container Command Class: public class CommandMain extends CommandBase { protected Minecraft mc; public String getCommandName(){ return "mycommand"; } /** * Return the required permission level for this command. */ public int getRequiredPermissionLevel(){ return 0; } /** * Return the required permission level for this command. */ public String getCommandUsage(ICommandSender commandSender){ return "Usage"; } public void processCommand(ICommandSender commandSender, String[] strArray){ int i; WorldServer worldserver = MinecraftServer.getServer().worldServers[1]; commandSender.addChatMessage(new ChatComponentTranslation("commands.main.heading", new Object[0])); EntityPlayer p = (EntityPlayer)commandSender; World w = p.getEntityWorld(); ChunkCoordinates c = commandSender.getPlayerCoordinates(); int x = c.posX; int y = c.posY; int z = c.posZ; System.out.println("CommandMain.java: call GUI"); p.openGui(Main.instance, 100, w, x, y, z); System.out.println("CommandMain.java: done"); } } GuiHandler Class: public class GuiHandler implements IGuiHandler{ public GuiHandler (){ } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == 0){ --- }else if(ID == 1){ --- }else if(ID == 100){ System.out.println("GuiHandler: getClientGuiElement ID == 100 called"); return new GuiHelp(player); } return null; } @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == 0){ --- }else if(ID == 1){ --- }else if(ID == 100){ System.out.println("GuiHandler: getServerGuiElement ID == 100 called"); return new GuiHelp(player); } return null; } } Gui Class: (its a modified copy of the DemoGui) @SideOnly(Side.CLIENT) public class GuiHelp extends GuiScreen{ private static final Logger logger = LogManager.getLogger(); private static final ResourceLocation field_146348_f = new ResourceLocation("textures/gui/demo_background.png"); public GuiHelp(EntityPlayer player){ } @Override public boolean doesGuiPauseGame() { return false; } /** * Adds the buttons (and other controls) to the screen in question. */ public void initGui() { this.buttonList.clear(); byte b0 = -16; this.buttonList.add(new GuiButton(1, this.width / 2 - 116, this.height / 2 + 62 + b0, 114, 20, I18n.format("gui.help.ok", new Object[0]))); } protected void actionPerformed(GuiButton button) { switch (button.id) { case 1: button.enabled = false; this.mc.displayGuiScreen((GuiScreen)null); this.mc.setIngameFocus(); } } /** * Called from the main game loop to update the screen. */ public void updateScreen() { super.updateScreen(); } /** * Draws either a gradient over the background screen (when it exists) or a flat gradient over background.png */ public void drawDefaultBackground() { super.drawDefaultBackground(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(field_146348_f); int i = (this.width - 248) / 2; int j = (this.height - 166) / 2; this.drawTexturedModalRect(i, j, 0, 0, 248, 166); } /** * Draws the screen and all the components in it. */ public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_) { this.drawDefaultBackground(); int k = (this.width - 248) / 2 + 10; int l = (this.height - 166) / 2 + 8; this.fontRendererObj.drawString(I18n.format("demo.help.title", new Object[0]), k, l, 2039583); l += 12; GameSettings gamesettings = this.mc.gameSettings; this.fontRendererObj.drawString(I18n.format("demo.help.movementShort", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindForward.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindLeft.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindBack.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindRight.getKeyCode())}), k, l, 5197647); this.fontRendererObj.drawString(I18n.format("demo.help.movementMouse", new Object[0]), k, l + 12, 5197647); this.fontRendererObj.drawString(I18n.format("demo.help.jump", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindJump.getKeyCode())}), k, l + 24, 5197647); this.fontRendererObj.drawString(I18n.format("demo.help.inventory", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindInventory.getKeyCode())}), k, l + 36, 5197647); this.fontRendererObj.drawSplitString(I18n.format("demo.help.fullWrapped", new Object[0]), k, l + 68, 218, 2039583); super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_); } } What am I doing wrong? I think my GuiHandler is not right.

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.