Guje Posted March 23, 2015 Share Posted March 23, 2015 Sometimes, when I open my customGui, the server shuts down and shows this error: Stacktrace: at net.minecraft.client.gui.GuiScreen.drawWorldBackground(GuiScreen.java:396) at net.minecraft.client.gui.GuiScreen.drawDefaultBackground(GuiScreen.java:391) at com.guje.test_mod.TestBlockGui.drawScreen(TestBlockGui.java:71) Quote Link to comment Share on other sites More sharing options...
61352151511 Posted March 23, 2015 Share Posted March 23, 2015 "com.guje.test_mod.TestBlockGui.drawScreen(TestBlockGui.java:71)" Well that's the line your error is on, and something about it is null, feel like providing code so we can help you? Quote Link to comment Share on other sites More sharing options...
Guje Posted March 23, 2015 Author Share Posted March 23, 2015 In line 71 there is only drawDefaultBackground(); rest of the class: package com.guje.test_mod; import org.lwjgl.opengl.GL11; import net.minecraft.block.Block; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiTextField; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; public class TestBlockGui extends GuiScreen { private int textureX; private int textureY; private int posY; private int posX; private int bY; private int bX; private int bZ; private ResourceLocation texture; private World world; private String blockId; private String blockMetadata; private GuiTextField text_BlockId; private GuiTextField text_BlockMetadata; public TestBlockGui(Block block, World world, int bX, int bY, int bZ) { super(); this.textureX = 175; this.textureY = 221; this.bX = bX; this.bY = bY; this.bZ = bZ; this.world = world; this.blockId = block.getIdFromBlock(block)+""; this.blockMetadata = world.getBlockMetadata(bX, bY, bZ)+""; texture = new ResourceLocation(Hack_n_Mine.MODID, "textures/gui/hackingGui.png"); } @Override public void initGui() { buttonList.clear(); posX = (this.width - textureX) / 2; posY = (this.height - textureY) / 2; text_BlockId = new GuiTextField(fontRendererObj, posX + 77, posY + 5, 40, 10); text_BlockId.setText(blockId); text_BlockId.setMaxStringLength(5); text_BlockMetadata = new GuiTextField(fontRendererObj, posX + 77, posY + 18, 40, 10); text_BlockMetadata.setText(blockMetadata); text_BlockMetadata.setMaxStringLength(5); super.initGui(); } @Override protected void keyTyped(char c, int i) { text_BlockId.textboxKeyTyped(c, i); text_BlockMetadata.textboxKeyTyped(c, i); super.keyTyped(c, i); } @Override protected void mouseClicked(int i, int j, int f) { text_BlockId.mouseClicked(i, j, f); text_BlockMetadata.mouseClicked(i, j, f); super.mouseClicked(i, j, f); } @Override public void drawScreen(int x, int y, float f) { drawDefaultBackground(); GL11.glColor4f(1F,1F,1F,1F); posX = (this.width - textureX) / 2; posY = (this.height - textureY) / 2; mc.renderEngine.bindTexture(texture); drawTexturedModalRect(posX, posY, 0, 0, textureX, textureY); text_BlockId.drawTextBox(); text_BlockMetadata.drawTextBox(); fontRendererObj.drawString("BlockID", posX + 5, posY + 7, 0x404040); fontRendererObj.drawString("BlockMetadata", posX + 5, posY + 19, 0x404040); super.drawScreen(x, y, f); } @Override public void onGuiClosed() { //Set blockId and metadata Block b = Block.getBlockById(Integer.parseInt(text_BlockId.getText())); int m = Integer.parseInt(text_BlockMetadata.getText()); world.setBlock(bX, bY, bZ, b, m, 3); super.onGuiClosed(); } } Quote Link to comment Share on other sites More sharing options...
Guje Posted March 23, 2015 Author Share Posted March 23, 2015 in this function @Override public boolean onItemUse(ItemStack item, EntityPlayer player, World world, int x, int y, int z, int par7, float xFloat, float yFloat, float zFloat) { if (!player.canPlayerEdit(x, y, z, par7, item)){ return false; } if (!world.isRemote){ Block target = world.getBlock(x, y, z); Minecraft.getMinecraft().displayGuiScreen(new TestBlockGui(target,world,x,y,z)); } return true; Quote Link to comment Share on other sites More sharing options...
61352151511 Posted March 23, 2015 Share Posted March 23, 2015 if (!world.isRemote){ Block target = world.getBlock(x, y, z); Minecraft.getMinecraft().displayGuiScreen(new TestBlockGui(target,world,x,y,z)); } You're checking to see if it's on the server side, isRemote returns true for client and false for servers. Minecraft is a client only class. Quote Link to comment Share on other sites More sharing options...
Guje Posted March 23, 2015 Author Share Posted March 23, 2015 So how can I fix this? Quote Link to comment Share on other sites More sharing options...
61352151511 Posted March 23, 2015 Share Posted March 23, 2015 Really? Change !world.isRemote to world.isRemote Quote Link to comment Share on other sites More sharing options...
Guje Posted March 23, 2015 Author Share Posted March 23, 2015 I thought about that. But when i change it like that, there aren't any changes made to the server, so it doesn't work Quote Link to comment Share on other sites More sharing options...
61352151511 Posted March 23, 2015 Share Posted March 23, 2015 If you're opening a GUI like that you have to do it on the client side, if your GUI is going to interact with the server, you will probably need to use packets to tell the server what to do. Quote Link to comment Share on other sites More sharing options...
Guje Posted March 23, 2015 Author Share Posted March 23, 2015 Thanks, i will try that! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.