Problème d'ouverture du GUI de mon four 1.7.10



  • Bonjour,
    Je n'arrive pas, une fois mon tileentity container placé, à ouvrir son GUI.
    Je n'ai pas de rapport de crash, alors voici mes classes :

    Ma classe principale (ModReality) :

    package fr.minecraft.reality.common;
    
    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.NetworkRegistry;
    import cpw.mods.fml.common.registry.GameRegistry;
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    import fr.minecraft.reality.proxy.CommonProxy;
    import net.minecraft.block.Block;
    import net.minecraft.block.material.Material;
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemArmor.ArmorMaterial;
    import net.minecraft.network.NetworkManager;
    import net.minecraft.network.NetworkSystem;
    import net.minecraftforge.common.util.EnumHelper;
    
    @Mod(modid = ModReality.MODID, name = "Mod Reality", version = "1.0.0")
    
    public class ModReality
    {
    	public static final String MODID = "modreality";
    	@Instance(MODID)
    	public static ModReality instance;
    	
    	@SidedProxy(clientSide = "fr.minecraft.reality.proxy.ClientProxy", serverSide = "fr.minecraft.reality.proxy.CommonProxy")
    	public static CommonProxy proxy;
    	
    	//blocks
    	public static Block plastic;
    	public static Block compacted_plastic;
    	public static Block craftingTable5x5;
    	public static Block decomposeurChimique;
    	public static Block petrolFurnace;
    	
    	//items
    	
    	//lingots
    	public static Item plasticIngot;
    	public static Item silverIngot;
    	
    	//armures
    	public static Item silverHelmet;
    	public static Item silverChestPlate; 
    	public static Item silverLeggins; 
    	public static Item silverBoots; 
    
    	
    	//atomes
    	public static Item atome_hydrogene;
    	public static Item atome_helium;
    	public static Item atome_lithium;
    	public static Item atome_beryllium;
    	public static Item atome_bore;
    	public static Item atome_carbone;
    	public static Item atome_azote;
    	public static Item atome_oxygene;
    	public static Item atome_fluor;
    	public static Item atome_neon;
    	public static Item atome_sodium;
    	public static Item atome_magnesium;
    	public static Item atome_aluminium;
    	public static Item atome_silicium;
    	public static Item atome_phosphore;
    	public static Item atome_soufre;
    	public static Item atome_chlore;
    	public static Item atome_argon;
    	
    	//Creatives Tabs
    	public static CreativeTabs tabAtomes = new CreativeTabs("atomes")
    	{
    		@SideOnly(Side.CLIENT)
    		public Item getTabIconItem()
    		{
    			return ModReality.atome_hydrogene;
    		}
    	};
    	public static CreativeTabs tabPlastic = new CreativeTabs("plastic")
    	{
    		@SideOnly(Side.CLIENT)
    		public Item getTabIconItem()
    		{
    			return ModReality.plasticIngot;
    		}
    	};
    
    	public static ArmorMaterial silverArmor = EnumHelper.addArmorMaterial("silverArmor", 13, new int[]{2, 6, 4, 2}, 17);
    	
    	//fonction de pré-initialisation
    	@EventHandler
    	public void preInit(FMLPreInitializationEvent event)
    	{
    		//blocks
    		plastic = new Plastic(Material.rock).setBlockName("plastic").setHardness(1.5F).setResistance(8.0F).setBlockTextureName(MODID + ":plastic").setCreativeTab(tabPlastic);
    		compacted_plastic = new Plastic(Material.rock).setHardness(1.5F).setResistance(11.0F).setBlockName("compacted_plastic").setBlockTextureName(MODID + ":compacted_plastic").setCreativeTab(tabPlastic);
    		decomposeurChimique = new DecomposeurChimique().setHardness(1.5F).setResistance(10.0F).setBlockName("decomposeur_chimique").setBlockTextureName(MODID + ":decomposeur_chimique").setCreativeTab(tabAtomes);
    		craftingTable5x5 = new CraftingTable5x5().setHardness(2.0F).setResistance(5.0F).setBlockName("crafting_table_5x5").setStepSound(Block.soundTypeWood).setCreativeTab(CreativeTabs.tabDecorations);
    		petrolFurnace = new PetrolFurnace().setHardness(3.5F).setStepSound(Block.soundTypePiston).setResistance(9.0F).setBlockName("petrol_furnace").setCreativeTab(CreativeTabs.tabDecorations);
    		
    		//items
    		plasticIngot = new PlasticIngot().setUnlocalizedName("plasticIngot").setTextureName(MODID + ":plastic_ingot").setCreativeTab(tabPlastic);
    		silverIngot = new SilverIngot().setUnlocalizedName("silverIngot").setTextureName(MODID + ":silver_ingot").setCreativeTab(CreativeTabs.tabMaterials);
    		
    		//armures
    		silverHelmet = new ItemSilverArmor(silverArmor, 0).setUnlocalizedName("silverHelmet").setTextureName(MODID + ":silver_helmet");
    		silverChestPlate = new ItemSilverArmor(silverArmor, 1).setUnlocalizedName("silverChestPlate").setTextureName(MODID + ":silver_chestplate");
    		silverLeggins = new ItemSilverArmor(silverArmor, 2).setUnlocalizedName("silverLeggins").setTextureName(MODID + ":silver_leggins");
    		silverBoots = new ItemSilverArmor(silverArmor, 3).setUnlocalizedName("silverBoots").setTextureName(MODID + ":silver_boots");
    
    		//atomes
    		atome_hydrogene = new Item().setUnlocalizedName("atome_hydrogene").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_hydrogene");
    		atome_helium = new Item().setUnlocalizedName("atome_helium").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_helium");
    		atome_lithium = new Item().setUnlocalizedName("atome_lithium").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_lithium");
    		atome_beryllium = new Item().setUnlocalizedName("atome_beryllium").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_beryllium");
    		atome_bore = new Item().setUnlocalizedName("atome_bore").setCreativeTab(ModReality.tabAtomes).setTextureName(MODID + ":atome_bore");
    		atome_carbone = new Item().setUnlocalizedName("atome_carbone").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_carbone");
    		atome_azote = new Item().setUnlocalizedName("atome_azote").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_azote");
    		atome_oxygene = new Item().setUnlocalizedName("atome_oxygene").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_oxygene");
    		atome_fluor = new Item().setUnlocalizedName("atome_fluor").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_fluor");
    		atome_neon = new Item().setUnlocalizedName("atome_neon").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_neon");
    		atome_sodium = new Item().setUnlocalizedName("atome_sodium").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_sodium");
    		atome_magnesium = new Item().setUnlocalizedName("atome_magnesium").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_magnesium");
    		atome_aluminium = new Item().setUnlocalizedName("atome_aluminium").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_aluminium");
    		atome_silicium = new Item().setUnlocalizedName("atome_silicium").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_silicium");
    		atome_phosphore = new Item().setUnlocalizedName("atome_phosphore").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_phosphore");
    		atome_soufre = new Item().setUnlocalizedName("atome_soufre").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_soufre");
    		atome_chlore = new Item().setUnlocalizedName("atome_chlore").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_chlore");
    		atome_argon = new Item().setUnlocalizedName("atome_argon").setCreativeTab(tabAtomes).setTextureName(MODID + ":atome_argon");
    		
    		//enregistrement des blocks
    		GameRegistry.registerBlock(plastic, "plastic");
    		GameRegistry.registerBlock(compacted_plastic, "compacted_plastic");
    		GameRegistry.registerBlock(craftingTable5x5, "craftingTable5x5");
    		GameRegistry.registerBlock(decomposeurChimique, "decomposeurChimique");
    		GameRegistry.registerBlock(petrolFurnace, "petrolFurnace");
    		
    		//enregistrement des items
    		
    		//lingots
    		GameRegistry.registerItem(plasticIngot, "plasticIngot");
    		GameRegistry.registerItem(silverIngot, "silverIngot");
    		
    		//armures
    		GameRegistry.registerItem(silverHelmet, "silver_helmet");
    		GameRegistry.registerItem(silverChestPlate, "silver_chest_plate");
    		GameRegistry.registerItem(silverLeggins, "silver_leggins");
    		GameRegistry.registerItem(silverBoots, "silver_boots");
    		
    		//atomes
    		GameRegistry.registerItem(atome_hydrogene, "atome_hydrogene");
    		GameRegistry.registerItem(atome_helium, "atome_helium");
    		GameRegistry.registerItem(atome_lithium, "atome_lithium");
    		GameRegistry.registerItem(atome_beryllium, "atome_beryllium");
    		GameRegistry.registerItem(atome_bore, "atome_bore");
    		GameRegistry.registerItem(atome_carbone, "atome_carbone");
    		GameRegistry.registerItem(atome_azote, "atome_azote");
    		GameRegistry.registerItem(atome_oxygene, "atome_oxygene");
    		GameRegistry.registerItem(atome_fluor, "atome_fluor");
    		GameRegistry.registerItem(atome_neon, "atome_neon");
    		GameRegistry.registerItem(atome_sodium, "atome_sodium");
    		GameRegistry.registerItem(atome_magnesium, "atome_magnesium");
    		GameRegistry.registerItem(atome_aluminium, "atome_aluminium");
    		GameRegistry.registerItem(atome_silicium, "atome_silicium");
    		GameRegistry.registerItem(atome_phosphore, "atome_phosphore");
    		GameRegistry.registerItem(atome_soufre, "atome_soufre");
    		GameRegistry.registerItem(atome_chlore, "atome_chlore");
    		GameRegistry.registerItem(atome_argon, "atome_argon");
    		
    		//TileEntity
    		GameRegistry.registerTileEntity(TileEntityPetrolFurnace.class, MODID + "PetrolFunace"); 
    	}	
    	//fonction d'initialisation
    	@EventHandler
    	public void init(FMLInitializationEvent event)
    	{
    		proxy.registerRender();
    	}
    
    	//fonction de post-initialisation
    	@EventHandler
    	public void postInit(FMLPostInitializationEvent event)
    	{
    
    	}
    }
    

    Mon block (PetrolFurnace) :

    package fr.minecraft.reality.common;
    
    import net.minecraft.block.Block;
    import net.minecraft.block.material.Material;
    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.entity.item.EntityItem;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.inventory.IInventory;
    import net.minecraft.item.ItemStack;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.world.World;
    
    public class PetrolFurnace extends Block
    {
    	protected PetrolFurnace()
    	{
    		super(Material.rock);
    	}
    	
        @Override
    
        public TileEntity createTileEntity(World world, int metadata)
    
        {
    
            return new TileEntityPetrolFurnace();
    
        }
    
        @Override
    
        public boolean hasTileEntity(int metadata)
    
        {
    
            return true;
    
        }
        
        public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
    
        {
    
            if(world.isRemote)
    
            {
    
                return true;
    
            }
    
            else
    
            {
    
                player.openGui(ModReality.instance, 0, world, x, y, z);
    
                return true;
    
            }
    
        }
    
        public void breakBlock(World world, int x, int y, int z, Block block, int metadata)
    
        {
    
            TileEntity tileentity = world.getTileEntity(x, y, z);
    
     
    
            if(tileentity instanceof IInventory)
    
            {
    
                IInventory inv = (IInventory)tileentity;
    
                for(int i1 = 0; i1 < inv.getSizeInventory(); ++i1)
    
                {
    
                    ItemStack itemstack = inv.getStackInSlot(i1);
    
     
    
                    if(itemstack != null)
    
                    {
    
                        float f = world.rand.nextFloat() * 0.8F + 0.1F;
    
                        float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
    
                        EntityItem entityitem;
    
     
    
                        for(float f2 = world.rand.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; world.spawnEntityInWorld(entityitem))
    
                        {
    
                            int j1 = world.rand.nextInt(21) + 10;
    
     
    
                            if(j1 > itemstack.stackSize)
    
                            {
    
                                j1 = itemstack.stackSize;
    
                            }
    
     
    
                            itemstack.stackSize -= j1;
    
                            entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
    
                            float f3 = 0.05F;
    
                            entityitem.motionX = (double)((float)world.rand.nextGaussian() * f3);
    
                            entityitem.motionY = (double)((float)world.rand.nextGaussian() * f3 + 0.2F);
    
                            entityitem.motionZ = (double)((float)world.rand.nextGaussian() * f3);
    
     
    
                            if(itemstack.hasTagCompound())
    
                            {
    
                                entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
    
                            }
    
                        }
    
                    }
    
                }
    
                world.func_147453_f(x, y, z, block);
    
            }
    
            super.breakBlock(world, x, y, z, block, metadata);
    
        }
    
        public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack)
    
        {
    
        	TileEntity tile = world.getTileEntity(x, y, z);
    
            if(tile instanceof TileEntityPetrolFurnace)
    
            {
    
                if(stack.hasDisplayName())
    
                {
    
                    ((TileEntityPetrolFurnace)tile).setCustomName(stack.getDisplayName());
    
                }
    
            }
    
        }
    }
    

    Mon tileentity (TileEntityPetrolFurnace) :

    package fr.minecraft.reality.common;
    
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.init.Items;
    import net.minecraft.inventory.IInventory;
    import net.minecraft.item.ItemStack;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.nbt.NBTTagList;
    import net.minecraft.network.NetworkManager;
    import net.minecraft.network.Packet;
    import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraftforge.common.util.Constants;
    
    public class TileEntityPetrolFurnace extends TileEntity implements IInventory
    {
        private ItemStack[] contents = new ItemStack[4];
        private String customName;
    
        //Temps de cuisson actuel
        private int workingTime = 0;
        
        //Temps de cuisson nécessaire
        private int workingTimeNeeded = 200;
    	
        @Override
    	public void readFromNBT(NBTTagCompound compound)
    	{
    
        super.readFromNBT(compound); // exécute ce qui se trouve dans la fonction readFromNBT de la classe mère (lecture de la position du tile entity)
    
        if(compound.hasKey("CustomName", Constants.NBT.TAG_STRING)) // si un tag custom name de type string existe
    
        {
    
            this.customName = compound.getString("CustomName"); // on le lit
    
        }
    
    
    
        NBTTagList nbttaglist = compound.getTagList("Items", 10); // on obtient la liste de tags nommée Items
    
        this.contents = new ItemStack[this.getSizeInventory()]; // on réinitialise le tableau
    
        for(int i = 0; i < nbttaglist.tagCount(); ++i) // i varie de 0 à la taille la liste
    
        {
    
            NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); // on lit le tag nbt
    
            int j = nbttagcompound1.getByte("Slot") & 255; // on lit à quel slot se trouve l'item stack
    
    
    
            if(j >= 0 && j < this.contents.length)
    
            {
    
                this.contents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); // on lit l'item stack qui se trouve dans le tag
    
            }
    
        }
    
    }
    
        @Override
        public void writeToNBT(NBTTagCompound compound)
        {
    
        super.writeToNBT(compound); // exécute se qui se trouve dans la fonction writeToNBT de la classe mère (écriture de la position du tile entity)
    
        if(this.hasCustomInventoryName()) // s'il y a un nom custom
    
        {
    
            compound.setString("CustomName", this.customName); // on le met dans le tag nbt
    
        }
    
    
    
        NBTTagList nbttaglist = new NBTTagList(); // on créé une nouvelle liste de tags
    
        for(int i = 0; i < this.contents.length; ++i) // i varie de 0 à la taille de notre tableau
    
        {
    
            if(this.contents[ i] != null) // si l'item stack à l'emplacement i du tableau n'est pas null
    
            {
    
                NBTTagCompound nbttagcompound1 = new NBTTagCompound(); // on créé un tag nbt
    
                nbttagcompound1.setByte("Slot", (byte)i); // on enregistre son emplacement dans le tableau
    
                this.contents[ i].writeToNBT(nbttagcompound1); // on écrit l'item dans le tag
    
                nbttaglist.appendTag(nbttagcompound1); // on ajoute le tab à la liste
    
            }
            }
        compound.setTag("Items", nbttaglist);
        compound.setShort("workingTime",(short)this.workingTime); //On les enregistrent en short
        compound.setShort("workingTimeNeeded", (short)this.workingTimeNeeded);
        }
       
        public Packet getDescriptionPacket()
    
        {
    
            NBTTagCompound nbttagcompound = new NBTTagCompound();
    
            this.writeToNBT(nbttagcompound);
    
            return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbttagcompound);
    
        }
    
        public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)
    
        {
    
            this.readFromNBT(pkt.func_148857_g());
    
        }
    
    	@Override
        public int getSizeInventory()
        {
            return this.contents.length;
        }
    
        @Override
    
        public ItemStack getStackInSlot(int slotIndex)
    
        {
    
            return this.contents[slotIndex];
    
        }
    
        @Override
    
        public ItemStack decrStackSize(int slotIndex, int amount)
    
        {
    
            if(this.contents[slotIndex] != null) // si le contenu dans l'emplacement n'est pas null
    
            {
    
                ItemStack itemstack;
    
     
    
                if(this.contents[slotIndex].stackSize <= amount) // si la quantité est inférieur où égale à ce qu'on souhaite retirer
    
                {
    
                    itemstack = this.contents[slotIndex]; // la variable itemstack prends la valeur du contenu
    
                    this.contents[slotIndex] = null; // on retire ce qui est dans la variable contents
    
                    this.markDirty(); // met à jour le tile entity
    
                    return itemstack; // renvoie itemstack
    
                }
    
                else // sinon
    
                {
    
                    itemstack = this.contents[slotIndex].splitStack(amount); // la fonction splitStack(quantité) retire dans this.contents[slotIndex] le contenu et le met dans itemstack
    
     
    
                    if(this.contents[slotIndex].stackSize == 0) // au cas où la quantité passe à 0 (ce qui ne devrait pas arriver en temps normal)
    
                    {
    
                        this.contents[slotIndex] = null; // on met sur null, ça évite de se retrouver avec des itemstack bugué qui contiennent 0
    
                    }
    
                    this.markDirty(); // met à jour le tile entity
    
                    return itemstack; // renvoie itemstack
    
                }
    
            }
    
            else // sinon si le contenu dans cette emplacement est null
    
            {
    
                return null; // renvoie null, puisqu'il n'y a rien dans cette emplacement
    
            }
    
        }
    
        @Override
    
        public void setInventorySlotContents(int slotIndex, ItemStack stack)
    
        {
    
            this.contents[slotIndex] = stack; // met l'item stack dans le tableau
    
     
    
            if(stack != null && stack.stackSize > this.getInventoryStackLimit()) // si la taille de l'item stack dépasse la limite maximum de l'inventaire
    
            {
    
                stack.stackSize = this.getInventoryStackLimit(); // on le remet sur la limite
    
            }
    
     
    
            this.markDirty(); // met à jour le tile entity
    
        }
    
        @Override
        public String getInventoryName()
        {
            return this.hasCustomInventoryName() ? this.customName : "tile.petrolFurnace";
        }
    
        public void setCustomName(String customName)
    
        {
    
            this.customName = customName;
    
        }
    
        @Override
    
        public int getInventoryStackLimit()
    
        {
    
            return 64;
    
        }
    
        @Override
    
        public ItemStack getStackInSlotOnClosing(int slotIndex) {
    
            if (this.contents[slotIndex] != null)
    
            {
    
                ItemStack itemstack = this.contents[slotIndex];
    
                this.contents[slotIndex] = null;
    
                return itemstack;
    
            }
    
            else
    
            {
    
                return null;
    
            }
    
        }
    
        @Override
    
        public boolean hasCustomInventoryName() {
    
            return false;
    
        }
    
        @Override
    
        public boolean isUseableByPlayer(EntityPlayer player) {
    
            return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
    
        }
    
        @Override
    
        public void openInventory() {
    
     
    
        }
    
        @Override
    
        public void closeInventory() {
    
     
    
        }
    
        @Override
    
        public boolean isItemValidForSlot(int slot, ItemStack stack) {
    
            return slot == 3 ? false : true;
    
        }
       
        public boolean isBurning()
    
        {
    
            return this.workingTime > 0;
    
        }
    
        private boolean canSmelt()
    
        {
    
            if (this.contents[0] == null || this.contents[1] == null || this.contents[2] == null) //Si les trois premiers slots sont vides
    
            {
    
                return false; //On ne peut pas lancer le processus
    
            }
    
            else
    
            {
    
                ItemStack itemstack = PetrolFurnaceRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]}); //Il y a une erreur ici, c'est normal, on y vient après (c'est pour les recettes)
    
                if (itemstack == null) return false; //rapport avec les recettes
    
                if (this.contents[3] == null) return true; //vérifications du slot d'output
    
                if (!this.contents[3].isItemEqual(itemstack)) return false; //ici aussi
    
                int result = contents[3].stackSize + itemstack.stackSize;
    
                return result <= getInventoryStackLimit() && result <= this.contents[3].getMaxStackSize(); //Et là aussi décidément
    
            }
    
        }
    
        public void updateEntity() //Méthode exécutée à chaque tick
    
        {
    
            if(this.isBurning() && this.canSmelt()) //Si on "cuit" et que notre recette et toujours bonne, on continue
    
            {
    
                ++this.workingTime; //incrémentation
    
            }
    
            if(this.canSmelt() && !this.isBurning()) //Si la recette est bonne mais qu'elle n'est toujours pas lancée, on la lance
    
            {
    
                this.workingTime = 1; //La méthode isBurning() renverra true maintenant (1>0)
    
            }
    
            if(this.canSmelt() && this.workingTime == this.workingTimeNeeded) //Si on est arrivé au bout du temps de cuisson et que la recette est toujours bonne
    
            {
    
                this.smeltItem(); //on "cuit" les items
    
                this.workingTime = 0; //et on réinitialise le temps de cuisson
    
            }
    
            if(!this.canSmelt()) //Si la recette la recette n'est plus bonne
    
            {
    
                    this.workingTime= 0; //le temps de cuisson est de 0
    
            }
    
        }
    
        public void smeltItem()
    
        {
    
            if (this.canSmelt())
    
            {
    
                ItemStack itemstack = PetrolFurnaceRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]}); //On récupère l'output de la recette
    
                if (this.contents[3] == null) //Si il y a rien dans le slot d'output
    
                {
    
                    this.contents[3] = itemstack.copy(); //On met directement l'ItemStack
    
                }
    
                else if (this.contents[3].getItem() == itemstack.getItem()) //Et si l'item que l'on veut est le même que celui qu'il y a déjà
    
                {
    
                    this.contents[3].stackSize += itemstack.stackSize; // Alors ont incrémente l'ItemStack
    
                }
    
     
    
                --this.contents[0].stackSize; //On décrémente les slots d'input
    
                --this.contents[1].stackSize;
    
                --this.contents[2].stackSize;
    
     
    
                if (this.contents[0].stackSize <= 0) //Si les slots sont vides, on remet à null le slot
    
                {
    
                    this.contents[0] = null;
    
                }
    
                if (this.contents[1].stackSize <= 0)
    
                {
    
                    this.contents[1] = null;
    
                }
    
                if (this.contents[2].stackSize <= 0)
    
                {
    
                    this.contents[2] = null;
    
                }
    
            }
    
        }
    }
    

    Mon container (PetrolFurnaceContainer) :

    package fr.minecraft.reality.common;
    
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.entity.player.InventoryPlayer;
    import net.minecraft.inventory.Container;
    import net.minecraft.inventory.Slot;
    import net.minecraft.item.ItemStack;
    
    public class PetrolFurnaceContainer extends Container
    {
        private final TileEntityPetrolFurnace tilePetrolFurnace;
    
        public PetrolFurnaceContainer(TileEntityPetrolFurnace tile, InventoryPlayer inventory)
        {
            this.tilePetrolFurnace = tile;
    
            this.addSlotToContainer(new Slot(tile, 0, 49, 75)); //Lancez votre jeu en debug pour calibrer vos slots
    
            this.addSlotToContainer(new Slot(tile, 1, 89, 75));
    
            this.addSlotToContainer(new Slot(tile, 2, 129, 75));
    
            this.addSlotToContainer(new SlotResult(tile, 3, 89, 135)); //Ici c'est un slot que j'ai créer, on le fera après
    
            this.bindPlayerInventory(inventory); //Les containers ont été vus dans un tutoriel de robin, merci de d'y référer
        }
    
        @Override
        public boolean canInteractWith(EntityPlayer player)
        {
            return this.tilePetrolFurnace.isUseableByPlayer(player);
        }
    
     
    
        private void bindPlayerInventory(InventoryPlayer inventory)
    
        {
    
            int i;
    
            for (i = 0; i < 3; ++i)
    
            {
    
                for (int j = 0; j < 9; ++j)
    
                {
    
                    this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 17 + j * 18, 171 + i * 18));
    
                }
    
            }
    
     
    
            for (i = 0; i < 9; ++i)
    
            {
    
                this.addSlotToContainer(new Slot(inventory, i, 17 + i * 18, 229));
    
            }
    
        }
    
     
    
        public ItemStack transferStackInSlot(EntityPlayer player, int quantity)
    
        {
    
            ItemStack itemstack = null;
    
            Slot slot = (Slot)this.inventorySlots.get(quantity);
    
     
    
            if (slot != null && slot.getHasStack())
    
            {
    
                ItemStack itemstack1 = slot.getStack();
    
                itemstack = itemstack1.copy();
    
     
    
                if (quantity < this.tilePetrolFurnace.getSizeInventory())
    
                {
    
                    if (!this.mergeItemStack(itemstack1, this.tilePetrolFurnace.getSizeInventory(), this.inventorySlots.size(), true))
    
                    {
    
                        return null;
    
                    }
    
                }
    
                else if (!this.mergeItemStack(itemstack1, 0, this.tilePetrolFurnace.getSizeInventory(), false))
    
                {
    
                    return null;
    
                }
    
     
    
                if (itemstack1.stackSize == 0)
    
                {
    
                    slot.putStack((ItemStack)null);
    
                }
    
                else
    
                {
    
                    slot.onSlotChanged();
    
                }
    
            }
    
     
    
            return itemstack;
    
        }
    
     
    
        public void onContainerClosed(EntityPlayer player)
    
        {
    
            super.onContainerClosed(player);
    
            this.tilePetrolFurnace.closeInventory();
    
        }
    }
    

    Mes recettes (PetrolFurnaceRecipes) :

    package fr.minecraft.reality.common;
    
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.Map;
    import java.util.Map.Entry;
    
    import net.minecraft.block.Block;
    import net.minecraft.init.Blocks;
    import net.minecraft.init.Items;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    
    public class PetrolFurnaceRecipes
    {
        private static final PetrolFurnaceRecipes smeltingBase = new PetrolFurnaceRecipes(); //Permet d'instancier votre classe car vous le l'instancierez nul part ailleur
        private Map smeltingList = new HashMap(); //Ceci permet de mettre vos recettes
        
        public PetrolFurnaceRecipes()
        {
            this.addRecipe(Items.apple, Items.apple, Items.arrow, new ItemStack(Blocks.diamond_block)); //Ajout d'une recette, on fait un bloc de diamant à partie de deux pommes et une flèche
        }
    
        public void addRecipe(ItemStack stack1, ItemStack stack2, ItemStack stack3, ItemStack stack4) //Cette fonction de comprend que des ItemStack, c'est celle qui ajoute les recettes à la HashMap
    
        {
    
            ItemStack[] stackList = new ItemStack[]{stack1, stack2, stack3};
    
            this.smeltingList.put(stackList, stack4);
    
        }
    
        //3 items
        public void addRecipe(Item item1, Item item2, Item item3, ItemStack stack) //1er cas
        {
            this.addRecipe(new ItemStack(item1), new ItemStack(item2), new ItemStack(item3), stack);
        }
    
        //1 block et 2 items
        public void addRecipe(Block block1, Item item2, Item item3, ItemStack stack) //2nd cas
    
        {
    
            this.addRecipe(Item.getItemFromBlock(block1), item2, item3, stack);
    
        }
    
        //2 blocks et 1 item
        public void addRecipe(Block block1, Block block2, Item item3, ItemStack stack) //3ème cas
    
        {
    
            this.addRecipe(Item.getItemFromBlock(block1), Item.getItemFromBlock(block2), item3, stack);
    
        }
    
        //3 blocks
        public void addRecipe(Block block1, Block block2, Block block3, ItemStack stack) //4ème cas
    
        {
    
            this.addRecipe(Item.getItemFromBlock(block1), Item.getItemFromBlock(block2), Item.getItemFromBlock(block3), stack);
    
        }
    
        public ItemStack getSmeltingResult(ItemStack[] stack) // En argument : un tableau avec le contenu des trois slots d'input
    
        {
    
            Iterator iterator = this.smeltingList.entrySet().iterator();
    
            Entry entry;
    
     
    
            do
    
            {
    
                if (!iterator.hasNext()) // Si il n'y a plus de recettes dans la liste
    
                {
    
                    return null; //Il n'y a pas de recette correspondante
    
                }
    
            entry = (Entry)iterator.next(); //prend la recette suivante
    
        }
    
        while (!this.isSameKey(stack, (ItemStack[])entry.getKey())); //Check si le tableau passé en argument correspond à celui de la recette, vous avez une erreur ici, on crée la fonction tout de suite.
    
     
    
        return (ItemStack)entry.getValue(); //retourne l'itemstack : resultat de la recette
    
        }
    
        private boolean isSameKey(ItemStack[] stackList, ItemStack[] stackList2)
    
        {
    
            boolean isSame = false; //Au début ce n'est pas la même
    
            for(int i=0; i<=2; i++) // Pour les 3 items
    
            {
    
                if(stackList[i].getItem() == stackList2[i].getItem()) //On vérifie si ce sont les même
    
                {
    
                    isSame = true; // Si c'est le cas alors isSame vaut true
    
                }
    
                else
    
                {
    
                    return false; //Si un seul n'est pas bon, on cherche pas, c'est pas la bonne recette
    
                }
    
            }
    
            return isSame;
    
        }
    
        public Map getSmeltingList()
    
        {
    
            return this.smeltingList;
    
        }
    
        public static PetrolFurnaceRecipes smelting()
    
        {
    
            return smeltingBase;
    
        }
    }
    

    Ma classe de résultat (SlotResult) :

    
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.inventory.IInventory;
    import net.minecraft.inventory.Slot;
    import net.minecraft.item.ItemStack;
    
    public class SlotResult extends Slot {
    
    	 
    
        public SlotResult(IInventory inventory, int id, int x, int y)
    
        {
    
            super(inventory, id, x, y);
    
        }
    
     
    
        @Override
    
        public boolean isItemValid(ItemStack stack) //Interdit la pose d'items dans le slot
    
        {
    
            return false;
    
        }
    
     
    
        public ItemStack decrStackSize(int amount)
    
        {
    
            return super.decrStackSize(amount);
    
        }
    
     
    
        public void onPickupFromSlot(EntityPlayer player, ItemStack stack)
    
        {
    
            super.onCrafting(stack);
    
            super.onPickupFromSlot(player, stack);
    
        }
    
    }
    

    Mon Gui (GuiPetrolFurnace) :

    package fr.minecraft.reality.common;
    
    import org.lwjgl.opengl.GL11;
    
    import net.minecraft.client.gui.inventory.GuiContainer;
    import net.minecraft.client.resources.I18n;
    import net.minecraft.entity.player.InventoryPlayer;
    import net.minecraft.inventory.Container;
    import net.minecraft.inventory.IInventory;
    import net.minecraft.util.ResourceLocation;
    
    public class GuiPetrolFurnace extends GuiContainer
    {
    	 
    
        private static final ResourceLocation texture = new ResourceLocation(ModReality.MODID,"textures/gui/container/guiMachineTuto.png");
    
        @SuppressWarnings("unused")
    
        private TileEntityPetrolFurnace tilePetrolFurnace;
    
        private IInventory playerInv;
    
     
    
        public GuiPetrolFurnace(TileEntityPetrolFurnace tile, InventoryPlayer inventory)
    
        {
    
            super(new PetrolFurnaceContainer(tile, inventory));
    
            this.tilePetrolFurnace = tile;
    
            this.playerInv = inventory;
    
            this.allowUserInput = false;
    
            this.ySize = 256;
    
            this.xSize = 256;
    
        }
    
     
    
        @Override
    
        protected void drawGuiContainerBackgroundLayer(float partialRenderTick, int x, int y)
    
        {
    
     
    
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    
            this.mc.getTextureManager().bindTexture(texture);
    
            int k = (this.width - this.xSize) / 2;
    
            int l = (this.height - this.ySize) / 2;
    
            this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
    
            this.drawTexturedModalRect(0, 0, 176, 14, 100 + 1, 16);
    
     
    
        }
    
     
    
        protected void drawGuiContainerForegroundLayer(int x, int y)
    
        {
    
            this.fontRendererObj.drawString(this.playerInv.hasCustomInventoryName() ? this.playerInv.getInventoryName() : I18n.format(this.playerInv.getInventoryName()), 10, this.ySize - 98, 4210752);
    
        }
    }
    

    PS: certaines lignes ne veulent sûrement rien dire ou le/les problèmes peuvent être évidents.
    Merci d'avance


  • Moddeurs confirmés Rédacteurs Administrateurs

    Bonjour,
    Il manque le gui handler, vérifies que tu en as bien un et qu'il est bien enregistré.



  • Merci beaucoup, je m'améliore grâce à vous


Log in to reply