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.

Featured Replies

Posted

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.

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.

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



}

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...

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.