Bon là je comprend pas! Jusqu’à maintenant je faisait le four dans mon mod “Test”, j’ai copy/paste le code dans mon mod principal, le bloc est en jeu mais quand je fait click-Droit le GUI ne s’ouvre plus!!Pourtant je n’ai aucune erreur!!
:::
Mon main
package havre;
import havre.proxy.HavreCommonProxy;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraftforge.common.ChestGenHooks;
import net.minecraftforge.common.EnumHelper;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
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.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
@Mod(modid = "HS", name = "Haven-Craft", version = "V.01")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class havremain {
@SidedProxy(clientSide = "havre.proxy.HavreClientProxy", serverSide = "havre.proxy.HavreCommonProxy")
public static HavreCommonProxy proxy;
@Instance("havremain")
public static havremain instance;
//Blocks peut en caller plusieur comme ca: public static Block BlockHaven, DeuximeBlock, TroixiemeBlock;
public static Block havenblock, havenexit, havencore, havenclayblock, riceblock;
public static Block fourOn, fourOff, BlockFour;
//Material
static EnumToolMaterial HavenMaterial = EnumHelper.addToolMaterial("HAVEN", 4, 1600, 8.0F, 4.0F, 10);
//Item
public static Item havenclay, HavenSword, HavenPickaxe, HavenAxe,
HavenShovel, HavenHoe, omnitool, ironraffine, goldraffine ;
//food
public static Item rice, ricebowl;
//Creative tabs
public static CreativeTabs haventabs = new HavenTabs("HavenTabs");
//Ore generation
public static HavenOreWorldGeneration GenWorld = new HavenOreWorldGeneration();
@EventHandler
public void load(FMLInitializationEvent event)
{
HavenCrafting.loadrecipes();
ChestGenHooks.addItem(ChestGenHooks.DUNGEON_CHEST, new WeightedRandomChestContent(new ItemStack(rice), 1, 3, 5));
ChestGenHooks.addItem(ChestGenHooks.MINESHAFT_CORRIDOR, new WeightedRandomChestContent(new ItemStack(rice), 1, 3, 5));
ChestGenHooks.addItem(ChestGenHooks.PYRAMID_DESERT_CHEST, new WeightedRandomChestContent(new ItemStack(rice), 1, 3, 5));
ChestGenHooks.addItem(ChestGenHooks.PYRAMID_JUNGLE_CHEST, new WeightedRandomChestContent(new ItemStack(rice), 1, 3, 5));
ChestGenHooks.addItem(ChestGenHooks.STRONGHOLD_CORRIDOR, new WeightedRandomChestContent(new ItemStack(rice), 1, 3, 5));
ChestGenHooks.addItem(ChestGenHooks.STRONGHOLD_CROSSING, new WeightedRandomChestContent(new ItemStack(rice), 1, 3, 5));
ChestGenHooks.addItem(ChestGenHooks.STRONGHOLD_LIBRARY, new WeightedRandomChestContent(new ItemStack(rice), 1, 3, 5));
ChestGenHooks.addItem(ChestGenHooks.VILLAGE_BLACKSMITH, new WeightedRandomChestContent(new ItemStack(rice), 1, 3, 5));
}
@EventHandler
//placer les configurations, compléter et enregistrer nos blocs et items, et placer les achievements.
public void PreInit(FMLPreInitializationEvent event)
{
//Configuration
//Blocks les Id sont de 601 à 4095
//Haven-Block
havenblock = new HavenBlock(700).setHardness(1.0F).setResistance(5.0F).setStepSound(Block.soundClothFootstep)
.setUnlocalizedName("HavenBlock").func_111022_d("hs:havenblock");
GameRegistry.registerBlock(havenblock, "HavenBlock");
//Haven-Exit
havenexit = new HavenExit(701).setHardness(1.0F).setResistance(5.0F).setStepSound(Block.soundClothFootstep)
.setUnlocalizedName("HavenExit").func_111022_d("hs:havenexit");
GameRegistry.registerBlock(havenexit, "Havenexit");
//Haven-Core
havencore = new HavenCore(702).setHardness(1.0F).setResistance(5.0F).setStepSound(Block.soundClothFootstep)
.setUnlocalizedName("HavenCore").func_111022_d("hs:havencore");
GameRegistry.registerBlock(havencore, "HavenCore");
//Haven-Clay Block
havenclayblock = new HavenClayBlock(703).setHardness(1.0F).setResistance(5.0F).setStepSound(Block.soundGravelFootstep)
.setUnlocalizedName("HavenClay").func_111022_d("hs:havenclayblock");
GameRegistry.registerBlock(havenclayblock, "HavenClay");
//rice
riceblock = new RiceBlock(704).setUnlocalizedName("Rice");//.func_111022_d("hs:rice");
//Rafinery
fourOn = new BlockFour(710, true).setUnlocalizedName("On");
fourOff = new BlockFour(711, false).func_111022_d("hs:fouroff").setUnlocalizedName("Off").setCreativeTab(CreativeTabs.tabBlock);
GameRegistry.registerBlock(fourOn, "fourOn");
GameRegistry.registerBlock(fourOff, "fourOff");
GameRegistry.registerTileEntity(TileEntityFour.class, "TileEntityFour");
//Items les id sont de 4096 à 31 999\. sachez aussi que l'id que vous allez mettre ici n'est pas la même qu'en jeu, en effet 256 est additionné à cette id
//Haven-Clay
havenclay = new HavenClay(4100).setUnlocalizedName("HavenClay").func_111206_d("hs:havenclay");
//Pelle de Ruel
omnitool = new ruel(4106, havremain.HavenMaterial).setUnlocalizedName("OmniTool").func_111206_d("hs:ruelshovel");
//Food
rice = new Rice(4107, 1, 0.3F, riceblock.blockID, Block.tilledField.blockID).setUnlocalizedName("Rice").func_111206_d("hs:rice");
ricebowl = new RiceBowl(4108, 10, 0.8F, false).setUnlocalizedName("RiceBowl").func_111206_d("hs:RB");
//les truc pour faire la pelle
ironraffine = new Raffine(4109).setUnlocalizedName("IronR").func_111206_d("hs:ironraffiner");
goldraffine = new Raffine(4110).setUnlocalizedName("GoldRR").func_111206_d("hs:goldraffiner");
//Achievements
}
protected static final GuiHandler guihandler = new GuiHandler();
@EventHandler
//enregistrer les tileEntity, les Entity, les rendu, etc …
public void Init(FMLInitializationEvent event)
{
//Registry
GameRegistry.registerWorldGenerator(GenWorld);
NetworkRegistry.instance().registerGuiHandler(this, guihandler);
/*GameRegistry.registerItem(rice, "Rice");
LanguageRegistry.addName(rice, "Rice");
GameRegistry.registerBlock(riceblock, "riceblock");
LanguageRegistry.addName(riceblock, "Rice Crop");*/
//Mobs
//Render
proxy.registerRender();
//NetWork
//Recipe
//tools
MinecraftForge.setToolClass(omnitool, "pickaxe", 4);
MinecraftForge.setBlockHarvestLevel(havenblock, "pickaxe", 4);
MinecraftForge.setBlockHarvestLevel(havencore, "pickaxe", 4);
MinecraftForge.setBlockHarvestLevel(havenexit, "pickaxe", 4);
MinecraftForge.setBlockHarvestLevel(havenclayblock, "pickaxe", 4);
}
@EventHandler
//dernières finissions, comme par exemple les enregistrements de langages ou de recettes.
public void PostInit(FMLPostInitializationEvent event)
{
//Intégration avec les autres mods
}
}
le BlockFour ```java
package havre;
import java.util.Random;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockFour extends BlockContainer
{
private final boolean isActive; // On dÃfini une boolean isActive qui servira pour le rendu du block ( AllumÃ
ou non )
public BlockFour(int par1, boolean par2)
{
super(par1, Material.rock);
this.isActive = par2;
}
public int idDropped(int par1, Random par2Random, int par3)
{
return havremain.fourOff.blockID;
}
@SideOnly(Side.CLIENT)
private Icon furnaceIconBottom;
@SideOnly(Side.CLIENT)
private Icon furnaceIconTop;
@SideOnly(Side.CLIENT)
private Icon furnaceIconFront;
@SideOnly(Side.CLIENT)
public Icon getIcon(int side, int metadata) {
if(side == 0) {
return furnaceIconBottom;
} else if(side == 1) {
return furnaceIconTop;
} else {
return furnaceIconFront;
}
}
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister)
{
this.blockIcon = par1IconRegister.registerIcon(“hs:raffineur_side”);
this.furnaceIconFront = par1IconRegister.registerIcon(“hs:raffineur_front_off”);
this.furnaceIconBottom = par1IconRegister.registerIcon(“hs:raffineur_bottom”);
this.furnaceIconTop = par1IconRegister.registerIcon(this.isActive ? “hs:raffineur_top_on” :“hs:raffineur_top_off” );
}
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
{
if (par1World.isRemote)
{
return true;
}
else
{
TileEntityFour tileentityfour = (TileEntityFour)par1World.getBlockTileEntity(par2, par3, par4);
if (tileentityfour != null)
{
par5EntityPlayer.openGui(havremain.instance, 1, par1World, par2, par3, par4);
}
return true;
}
}
public static void updateFurnaceBlockState(boolean par0, World par1World, int par2, int par3, int par4)
{
int l = par1World.getBlockMetadata(par2, par3, par4);
TileEntity tileentity = par1World.getBlockTileEntity(par2, par3, par4);
keepFurnaceInventory = true;
if (par0)
{
par1World.setBlock(par2, par3, par4, havremain.fourOn.blockID);
}
else
{
par1World.setBlock(par2, par3, par4, havremain.fourOff.blockID);
}
keepFurnaceInventory = false;
par1World.setBlockMetadataWithNotify(par2, par3, par4, l, 2);
if (tileentity != null)
{
tileentity.validate();
par1World.setBlockTileEntity(par2, par3, par4, tileentity);
}
}
private static boolean keepFurnaceInventory = false;
@SideOnly(Side.CLIENT)
/**
- Tick au hasard qui fait spawn des flammes et de la fumÃ
e
*/
/*public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
if (this.isActive)
{
int l = par1World.getBlockMetadata(par2, par3, par4);
float f = (float)par2 + 0.5F;
float f1 = (float)par3 + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F;
float f2 = (float)par4 + 0.5F;
float f3 = 0.52F;
float f4 = par5Random.nextFloat() * 0.6F - 0.3F;
if (l == 4)
{
par1World.spawnParticle(“smoke”, (double)(f - f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D);
par1World.spawnParticle(“flame”, (double)(f - f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D);
}
else if (l == 5)
{
par1World.spawnParticle(“smoke”, (double)(f + f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D);
par1World.spawnParticle(“flame”, (double)(f + f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D);
}
else if (l == 2)
{
par1World.spawnParticle(“smoke”, (double)(f + f4), (double)f1, (double)(f2 - f3), 0.0D, 0.0D, 0.0D);
par1World.spawnParticle(“flame”, (double)(f + f4), (double)f1, (double)(f2 - f3), 0.0D, 0.0D, 0.0D);
}
else if (l == 3)
{
par1World.spawnParticle(“smoke”, (double)(f + f4), (double)f1, (double)(f2 + f3), 0.0D, 0.0D, 0.0D);
par1World.spawnParticle(“flame”, (double)(f + f4), (double)f1, (double)(f2 + f3), 0.0D, 0.0D, 0.0D);
}
}
}
/
/*
- CrÃ
e une entitÃ
Four quand le block est placÃ
*/
public TileEntity createNewTileEntity(World par1World)
{
return new TileEntityFour();
}
/**
- AppelÃ
quand le block est placÃ
*/
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack)
{
int direction = MathHelper.floor_double((double)(living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3;
world.setBlockMetadataWithNotify(x, y, z, direction, 2);
}
public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)
{
if (!keepFurnaceInventory)
{
TileEntityFour tileentityfurnace = (TileEntityFour)par1World.getBlockTileEntity(par2, par3, par4);
if (tileentityfurnace != null)
{
for (int j1 = 0; j1 < tileentityfurnace.getSizeInventory(); ++j1)
{
ItemStack itemstack = tileentityfurnace.getStackInSlot(j1);
if (itemstack != null)
{
float f = this.furnaceRand.nextFloat() * 0.8F + 0.1F;
float f1 = this.furnaceRand.nextFloat() * 0.8F + 0.1F;
float f2 = this.furnaceRand.nextFloat() * 0.8F + 0.1F;
while (itemstack.stackSize > 0)
{
int k1 = this.furnaceRand.nextInt(21) + 10;
if (k1 > itemstack.stackSize)
{
k1 = itemstack.stackSize;
}
itemstack.stackSize -= k1;
EntityItem entityitem = new EntityItem(par1World, (double)((float)par2 + f), (double)((float)par3 + f1), (double)((float)par4 + f2), new ItemStack(itemstack.itemID, k1, itemstack.getItemDamage()));
if (itemstack.hasTagCompound())
{
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
}
float f3 = 0.05F;
entityitem.motionX = (double)((float)this.furnaceRand.nextGaussian() * f3);
entityitem.motionY = (double)((float)this.furnaceRand.nextGaussian() * f3 + 0.2F);
entityitem.motionZ = (double)((float)this.furnaceRand.nextGaussian() * f3);
par1World.spawnEntityInWorld(entityitem);
}
}
}
par1World.func_96440_m(par2, par3, par4, par5);
}
}
super.breakBlock(par1World, par2, par3, par4, par5, par6);
}
public void breakBlock1(World par1World, int par2, int par3, int par4, int par5, int par6)
{
if (!keepFurnaceInventory)
{
TileEntityFour tileentityfurnace = (TileEntityFour)par1World.getBlockTileEntity(par2, par3, par4);
if (tileentityfurnace != null)
{
for (int j1 = 0; j1 < tileentityfurnace.getSizeInventory(); ++j1)
{
ItemStack itemstack = tileentityfurnace.getStackInSlot(j1);
if (itemstack != null)
{
float f = this.furnaceRand.nextFloat() * 0.8F + 0.1F;
float f1 = this.furnaceRand.nextFloat() * 0.8F + 0.1F;
float f2 = this.furnaceRand.nextFloat() * 0.8F + 0.1F;
while (itemstack.stackSize > 0)
{
int k1 = this.furnaceRand.nextInt(21) + 10;
if (k1 > itemstack.stackSize)
{
k1 = itemstack.stackSize;
}
itemstack.stackSize -= k1;
EntityItem entityitem = new EntityItem(par1World, (double)((float)par2 + f), (double)((float)par3 + f1), (double)((float)par4 + f2), new ItemStack(itemstack.itemID, k1, itemstack.getItemDamage()));
if (itemstack.hasTagCompound())
{
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
}
float f3 = 0.05F;
entityitem.motionX = (double)((float)this.furnaceRand.nextGaussian() * f3);
entityitem.motionY = (double)((float)this.furnaceRand.nextGaussian() * f3 + 0.2F);
entityitem.motionZ = (double)((float)this.furnaceRand.nextGaussian() * f3);
par1World.spawnEntityInWorld(entityitem);
}
}
}
par1World.func_96440_m(par2, par3, par4, par5);
}
}
super.breakBlock(par1World, par2, par3, par4, par5, par6);
}
private final Random furnaceRand = new Random();
public boolean hasComparatorInputOverride()
{
return true;
}
}
GUI Handler ```java
package havre;
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 GuiHandler implements IGuiHandler{
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity tile_entity = world.getBlockTileEntity(x, y, z);
if(tile_entity instanceof TileEntityFour){
return new ContainerFour(player.inventory, (TileEntityFour) tile_entity);
}
return null;
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity tile_entity = world.getBlockTileEntity(x, y, z);
if(tile_entity instanceof TileEntityFour){
return new GuiFour(player.inventory, (TileEntityFour) tile_entity);
}
return null;
}
}
GUIFour```java
package havre;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ContainerFurnace;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiFour extends GuiContainer
{
private static final ResourceLocation field_110410_t = new ResourceLocation(“hs”, “textures/gui/container/guiFour.png”);
private TileEntityFour furnaceInventory;
public GuiFour(InventoryPlayer par1InventoryPlayer, TileEntityFour par2TileEntityFour)
{
super(new ContainerFour(par1InventoryPlayer, par2TileEntityFour));
this.furnaceInventory = par2TileEntityFour;
} protected void drawGuiContainerForegroundLayer(int par1, int par2)
{
String s = this.furnaceInventory.isInvNameLocalized() ? this.furnaceInventory.getInvName() : I18n.func_135053_a(this.furnaceInventory.getInvName());
this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 6, 4210752);
this.fontRenderer.drawString(I18n.func_135053_a(“container.inventory”), 8, this.ySize - 96 + 2, 4210752);
}
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.func_110434_K().func_110577_a(field_110410_t);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int i1;
if (this.furnaceInventory.isBurning())
{
i1 = this.furnaceInventory.getBurnTimeRemainingScaled(12);
this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2);
}
i1 = this.furnaceInventory.getCookProgressScaled(24);
this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16);
}
}
:::