La class de l’item :
package tutoriel.common;
import cpw.mods.fml.common.network.FMLNetworkHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class dummyitem extends Item {
public dummyitem(int id) {
super(id);
this.setCreativeTab(ModTutoriel.TutorialCreativeTabs);
}
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player)
{
player.openGui(ModTutoriel.instance, 0, world, (int)player.posX, (int)player.posY, (int)player.posZ);
return itemstack;
}
}
Et la class de GuiHandler :
package tutoriel.common.gui;
import tutoriel.common.ModTutoriel;
import tutoriel.common.TileEntityBigChest;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
public class GuiHandler implements IGuiHandler{
private InventoryItem tileEntity;
public GuiHandler() {
NetworkRegistry.instance().registerGuiHandler(ModTutoriel.instance, this);
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world,
int x, int y, int z) {
switch(ID){
default: return null;
case 0: return new ContainerDummy(player);
case 1: return new ContainerDummy2(player);
}
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world,
int x, int y, int z) {
switch(ID){
default: return null;
case 0: return new DummyGui(player);
case 1: return new DummyGui2(player);
}
}
}