Posted May 15, 201312 yr Hello. I cant figure out how to open a custom gui ex: GuiTest.class on item right click. I have tried many steps so please help.
May 15, 201312 yr Look at the forge wiki for gui handling, you need to return an instance of your gui in your IGuiHandler.getClientGuiElement() I think its my java of the variables.
May 16, 201312 yr Author Look at the forge wiki for gui handling, you need to return an instance of your gui in your IGuiHandler.getClientGuiElement() I really cant figure this out for the life of me. This is my item class package mods.cyphereion.MagicSwords; import java.util.List; import net.minecraft.client.gui.GuiMultiplayer; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class RecipeBook extends Item { private ItemStack info; private int index; public RecipeBook(int par1) { super(par1); this.setMaxStackSize(1); this.setCreativeTab(Core.tabMagicSwords); } public boolean hasEffecct(ItemStack par1ItemStack){ return true; } public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { //par3List.add("Use me to see the avaliable recipes. "); par3List.add("Work In Progress."); } public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer, int x, int y, int z){ return null; } And this is my guihandler: package mods.cyphereion.MagicSwords; import net.minecraft.client.gui.Gui; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import cpw.mods.fml.common.network.IGuiHandler; public class RecipeBookGuiHandler implements IGuiHandler{ @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { { if (!world.isRemote) { player.openGui(RecipeBookCore.instance, 0, world, x, y, z); return true; } return true; } } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { { if (!world.isRemote) { player.openGui(RecipeBookCore.instance, 0, world, x, y, z); return true; } return true; } } }
May 16, 201312 yr you need to change public ItemStack onItemRightClick(ItemStack i, World w, EntityPlayer e, int x, int y, int z){ e.openGui(yourMod.instance, guiId, w, x, y, z) return i;//If you return null the itemstack is set to null } also hasEffect is spelled wrong... that'll give you some issues down the road. use @Override annotations to prevent this and make updating easier I think its my java of the variables.
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.