Posted January 19, 201312 yr I have been modding on this mod for a few days now. (I've got a nice tad of experience modding. dont worry ) Evertything works fine, apart from one thing. Here's the idea : When the Player opens the Vanilla Inventory, I open an ALternative gui, with two buttons : close and Rpg Inventory. I got that working fine trought the ClientTickHandler. The second button, the one that makes us go to a new Gui : My Rpg Inventory, is where the problems are. I've tried opening it with ModLoader.openGui(). I've tried opening trough EntityPlayer.openGui(). I've tried sending a packet to the ServerPacketHandler opening either ModLoader.openGui or EntityPlayer.openGui(). I've tried going trough the Client and Commen Proxy to open the new gui, with gui client and server side, and container trough server side. In any of those ways, either it wont show the gui, and just pops me back in to the 'playng minecraft' mode, or it shows the gui, with container, which is completely (sorry for the word) f**ked up.* *definition of that word : I can pick up items 1 chance out of 100. if i can, i can or not put it back, or put it back, but it will pop in another slot. or i can take out items, but the whole inventory gets mixed up, or i click a slot, and the item 4 slots away will be taken out. I've been told this is a server/client problem, which I do think it is too. I would show you my code, but it's completly messed up atm. Though, here are a few of them. CommonProxy package RpgInventory; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.inventory.GuiInventory; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ContainerPlayer; import net.minecraft.src.ModLoader; import net.minecraft.world.World; import cpw.mods.fml.common.TickType; import cpw.mods.fml.common.network.FMLNetworkHandler; import cpw.mods.fml.common.network.IGuiHandler; public class CommonProxy implements IGuiHandler { public void registerRenderInformation() { } // public void openGui(EntityPlayer player, int id) // { // int x = (int)player.posX; // int y = (int)player.posY; // int z = (int)player.posZ; // // if(id == 1) // { // this.getServerGuiElement(1,player,Minecraft.getMinecraft().theWorld,x,y,z); // this.getClientGuiElement(1,player,Minecraft.getMinecraft().theWorld,x,y,z); // } // } @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { System.out.println("COMMON PROXY READ CONTAINER"); return new RpgContainer(player); } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { System.out.println("COMMON PROXY READ GUI"); return new RpgGui(player); } } ClientProxy package RpgInventory; import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelBlaze; import net.minecraft.client.model.ModelCreeper; import net.minecraft.client.renderer.entity.RenderBiped; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ContainerPlayer; import net.minecraft.src.ModLoader; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.client.MinecraftForgeClient; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.registry.GameRegistry; public class ClientProxy extends CommonProxy { public void registerRenderInformation() { MinecraftForgeClient.preloadTexture("/subaraki/RPGinventoryTM.png"); } // public void openGui(EntityPlayer player, int id) // { // // int x = (int)player.posX; // int y = (int)player.posY; // int z = (int)player.posZ; // // if(id == 1) // { // this.getClientGuiElement(1,player,Minecraft.getMinecraft().theWorld,x,y,z); // } // } @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { System.out.println("CLIENT PROXY READ CONTAINER"); return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { System.out.println("CLIENT PROXY READ GUI "); return new RpgGui(player); } } Alternative Gui package RpgInventory; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.inventory.GuiContainerCreative; import net.minecraft.client.gui.inventory.GuiInventory; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.src.ModLoader; import cpw.mods.fml.common.network.FMLNetworkHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class AlternativeGui extends GuiInventory{ public int var1 = 75; public int var2 = -110; @SideOnly(Side.CLIENT) public AlternativeGui(EntityPlayer par1EntityPlayer) { super(par1EntityPlayer); } /** * Adds the buttons (and other controls) to the screen in question. */ @Override public void initGui() { this.controlList.clear(); if (this.mc.playerController.isInCreativeMode()) { this.mc.displayGuiScreen(new GuiContainerCreative(this.mc.thePlayer)); } else { super.initGui(); int posX = (this.width) / 2; int posY = (this.height) / 2; this.controlList.add(new GuiButton(0, posX-var1, posY+var2, 75, 20, "Rpg Inventory")); this.controlList.add(new GuiButton(1, posX-var1+ 80, posY+var2, 75, 20, "Close")); } } public void actionPerformed(GuiButton button){ if(button.id == 0) { ByteArrayOutputStream bytes = new ByteArrayOutputStream() ; ObjectOutput out; try { out = new ObjectOutputStream(bytes); out.writeInt(1); out.close(); Packet250CustomPayload packet = new Packet250CustomPayload("RPGInv",bytes.toByteArray()); ModLoader.clientSendPacket(packet); } catch (IOException e) { e.printStackTrace(); } } if(button.id == 1) { this.mc.thePlayer.closeScreen(); } } } RpgGui package RpgInventory; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ContainerPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.src.ModLoader; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RpgGui extends GuiContainer { private float xSize_lo; private float ySize_lo; public RpgGui(EntityPlayer player) { super(new RpgContainer(player)); IInventory inv = new InventoryRpg(player); IInventory invplayer = InventoryPlayer(player); // xSize = 176; // ySize = 166; } private IInventory InventoryPlayer(EntityPlayer player) { return player.inventory; } public static String hi = "Rpg Inventory"; public void drawScreen(int par1, int par2, float par3) { super.drawScreen(par1, par2, par3); this.xSize_lo = (float)par1; this.ySize_lo = (float)par2; } protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) { int var4 = this.mc.renderEngine.getTexture("/subaraki/RpgInv.png"); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.renderEngine.bindTexture(var4); int var5 = this.height; int var6 = this.width; int posX = (this.width - xSize) / 2; int posY = (this.height - ySize) / 2; drawTexturedModalRect(posX, posY, 0, 0, xSize, ySize); drawString(fontRenderer, hi, this.width/2 + 15, this.height/2-15, 0xffffff); renderPlayerinInv(this.mc, posX + 51, posY + 75, 30, (float)(posX + 51) - this.xSize_lo, (float)(posY + 75 - 50) - this.ySize_lo); } public static void renderPlayerinInv(Minecraft par0Minecraft, int par1, int par2, int par3, float par4, float par5) { GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glPushMatrix(); GL11.glTranslatef((float)par1, (float)par2, 50.0F); GL11.glScalef((float)(-par3), (float)par3, (float)par3); GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); float var6 = par0Minecraft.thePlayer.renderYawOffset; float var7 = par0Minecraft.thePlayer.rotationYaw; float var8 = par0Minecraft.thePlayer.rotationPitch; GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-((float)Math.atan((double)(par5 / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F); par0Minecraft.thePlayer.renderYawOffset = (float)Math.atan((double)(par4 / 40.0F)) * 20.0F; par0Minecraft.thePlayer.rotationYaw = (float)Math.atan((double)(par4 / 40.0F)) * 40.0F; par0Minecraft.thePlayer.rotationPitch = -((float)Math.atan((double)(par5 / 40.0F))) * 20.0F; par0Minecraft.thePlayer.rotationYawHead = par0Minecraft.thePlayer.rotationYaw; GL11.glTranslatef(0.0F, par0Minecraft.thePlayer.yOffset, 0.0F); RenderManager.instance.playerViewY = 180.0F; RenderManager.instance.renderEntityWithPosYaw(par0Minecraft.thePlayer, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); par0Minecraft.thePlayer.renderYawOffset = var6; par0Minecraft.thePlayer.rotationYaw = var7; par0Minecraft.thePlayer.rotationPitch = var8; GL11.glPopMatrix(); RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); GL11.glDisable(GL11.GL_TEXTURE_2D); OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); } public void initGui() { super.initGui(); this.controlList.clear(); int posX = (this.width - xSize) / 2; int posY = (this.height - ySize) / 2; this.controlList.add(new GuiButton(0, posX + 115, posY + 20, 50, 20, "Back")); } public boolean doesGuiPauseGame() { return false; } public void actionPerformed(GuiButton button){ if(button.id == 0) { EntityPlayer player = ModLoader.getMinecraftInstance().thePlayer; player.inventoryContainer = new ContainerPlayer(Minecraft.getMinecraft().thePlayer.inventory, !Minecraft.getMinecraft().theWorld.isRemote, player); ModLoader.openGUI(player, new AlternativeGui(Minecraft.getMinecraft().thePlayer)); } } } and offcourse, the @mod package RpgInventory; import net.minecraft.item.Item; import net.minecraft.network.packet.Packet250CustomPayload; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkMod.SidedPacketHandler; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.common.registry.TickRegistry; import cpw.mods.fml.relauncher.Side; @Mod(modid = "RPGInventoryMod", name = "Subarakis RPG Inventory mod", version = "14710") @NetworkMod(clientSideRequired = true, serverSideRequired = false, clientPacketHandlerSpec = @SidedPacketHandler(channels = {"RPGInv" }, packetHandler = ClientPacketHandler.class), serverPacketHandlerSpec = @SidedPacketHandler(channels = {"RPGInv" }, packetHandler = ServerPacketHandler.class)) public class AARpgBaseClass { public static Item neckleather; public static Item neckiron; public static Item neckgold; public static Item shieldwood; public static Item shieldiron; public static Item shieldgold; public static Item glovesleather; public static Item glovesiron; public static Item glovesbutter; public static Item cloak; public static Item cloakI; public static Item ringleath; public static Item ringiron; public static Item ringgold; @SidedProxy(serverSide = "RpgInventory.CommonProxy",clientSide = "RpgInventory.ClientProxy") public static CommonProxy proxy; @Instance(value= "RPGInventoryMod") public static AARpgBaseClass instance = new AARpgBaseClass(); @Init public void load(FMLInitializationEvent event) { // Args : Mineral, effect, (nrItems, timeInSecs/hearts%2) // With Diamond : Regen Effect (1,10),(2,5),(3,4),(4,3) // With Emerald : Damage reduction Effect (1,1),(2,2),(3,3),(4,4) // With Lapis : Damage+ (1,2),(2,3),(3,4),(4,5) neckleather = new ItemArmorRpg(5784, 5).setIconIndex(0).setItemName("lethernecklace"); neckiron = new ItemArmorRpg(5785, 5).setIconIndex(1).setItemName("ironnecklace"); neckgold = new ItemArmorRpg(5786, 5).setIconIndex(2).setItemName("buddernecklace"); shieldwood = new ItemArmorRpg(5787, 7).setIconIndex(3).setItemName("woodshield"); shieldiron = new ItemArmorRpg(5788, 7).setIconIndex(4).setItemName("ironshield"); shieldgold = new ItemArmorRpg(5789, 7).setIconIndex(5).setItemName("buddershield"); glovesleather= new ItemArmorRpg(5790, .setIconIndex(6).setItemName("leddergloves"); glovesiron = new ItemArmorRpg(5791, .setIconIndex(7).setItemName("irongloves"); glovesbutter = new ItemArmorRpg(5792, .setIconIndex(.setItemName("budderrrgloves"); cloak = new ItemArmorRpg(5793, 6).setIconIndex(12).setItemName("cloak"); cloakI = new ItemArmorRpg(5794, 6).setIconIndex(13).setItemName("InvisibilityCloak"); ringleath = new ItemArmorRpg(5795, 7).setIconIndex(9).setItemName("leatherring"); ringiron = new ItemArmorRpg(5796, 7).setIconIndex(9).setItemName("anodefer"); ringgold = new ItemArmorRpg(5797, 7).setIconIndex(9).setItemName("budderring"); LanguageRegistry.addName(neckleather, "Wooden Necklace"); LanguageRegistry.addName(neckiron , "Iron Necklace"); LanguageRegistry.addName(neckgold , "Gold Necklace"); LanguageRegistry.addName(shieldwood , "Wooden Shield"); LanguageRegistry.addName(shieldiron , "Iron Shield"); LanguageRegistry.addName(shieldgold , "Golden Shield"); LanguageRegistry.addName(glovesleather, "Leather Gloves"); LanguageRegistry.addName(glovesiron , "Iron Gloves"); LanguageRegistry.addName(glovesbutter , "Gold Gloves"); LanguageRegistry.addName(cloak,"Cloak"); LanguageRegistry.addName(cloakI,"Invisibility Cloak"); LanguageRegistry.addName(ringleath,"Leather Ring"); LanguageRegistry.addName(ringiron,"Iron Ring"); LanguageRegistry.addName(ringgold,"Golden Ring"); NetworkRegistry.instance().registerGuiHandler(instance, new CommonProxy()); TickRegistry.registerTickHandler(new ClientTickHandler(), Side.CLIENT); Packet250CustomPayload packet = new Packet250CustomPayload(); packet.channel = "RPGInv"; } } https://minecraft.curseforge.com/members/Subaraki/projects
January 19, 201312 yr Author It could also be a problem for how its called. im so confused and really could use some help https://minecraft.curseforge.com/members/Subaraki/projects
January 20, 201312 yr Probably you shouldn't register the gui into the CommonProxy,you need a seperate GuiHandler http://www.minecraftforge.net/wiki/Containers_and_GUIs For opening gui i'm using : par5EntityPlayer.openGui(YourMod.instance, YourGuiID, par1World, par2, par3, par4); par2,par3,par4 are coordinates: x,y,z
January 20, 201312 yr Author its been a day or two since i posted these. I got onto that right now. i got it 'working' only problem now is, the gui wont launch anymore. thanks for the post btw https://minecraft.curseforge.com/members/Subaraki/projects
January 20, 201312 yr the gui may not work because you will need to register your guihandler in you mod.class and the instance is just YourMod instance = new YourMod() The Korecraft Mod
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.