Jump to content

Recommended Posts

Posted

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;
		 }
}



}

Posted

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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