MFF

    Minecraft Forge France
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes
    • Forge Events
      • Automatique
      • Foncé
      • Clair
    • S'inscrire
    • Se connecter

    Créer un bloc type four (machine)

    Planifier Épinglé Verrouillé Déplacé Les interfaces (GUI) et les container
    1.7.10
    236 Messages 39 Publieurs 69.0k Vues 15 Watching
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • RavenR Hors-ligne
      Raven
      dernière édition par

      Bonjour , excellent tuto mais évidemment puisque je poste un commentaire : j’ai un problème étant donné que mon four n’est composé que de 2 slots d’input et 1 slot d’output j’ai du bidouiller un peu le code pour faire quelque chose et quand je met deux items dans les 2 slots d’input et bien…mon jeu crash :

      Description: Ticking block entity
      
      java.lang.ArrayIndexOutOfBoundsException: 2
      	at raven.tacoscraft.recipes.RecipesCustomFurnace.isSameKey(RecipesCustomFurnace.java:67)
      	at raven.tacoscraft.recipes.RecipesCustomFurnace.getSmeltingResult(RecipesCustomFurnace.java:57)
      	at raven.tacoscraft.tileentity.TileEntityFactoriteForge.canSmelt(TileEntityFactoriteForge.java:228)
      	at raven.tacoscraft.tileentity.TileEntityFactoriteForge.updateEntity(TileEntityFactoriteForge.java:203)
      	at net.minecraft.world.World.updateEntities(World.java:2160)
      	at net.minecraft.client.Minecraft.runTick(Minecraft.java:2097)
      	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039)
      	at net.minecraft.client.Minecraft.run(Minecraft.java:962)
      	at net.minecraft.client.main.Main.main(Main.java:164)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
      	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
      	at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
      	at GradleStart.main(Unknown Source)
      

      Voici le crash-report et voici les classes des erreurs en question
      La Classe des Recettes :

      package raven.tacoscraft.recipes;
      
      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.Items;
      import net.minecraft.item.Item;
      import net.minecraft.item.ItemStack;
      import raven.tacoscraft.Factoria;
      
      public class RecipesCustomFurnace {
      	
      	  private static final RecipesCustomFurnace smeltingBase = new RecipesCustomFurnace(); 
      	  private Map smeltingList = new HashMap(); 
      	  
      	  public RecipesCustomFurnace()
      	    {
      	        this.addRecipe(Factoria.itemFactoriteIngot, Factoria.itemTinIngot, new ItemStack(Factoria.itemFactoriteTinIngot));
      	        this.addRecipe(Factoria.itemFactoriteIngot, Items.diamond, new ItemStack(Factoria.itemFactoriteDiamondIngot));
      	        this.addRecipe(Factoria.itemFactoriteIngot, Factoria.itemVoltitePowder, new ItemStack(Factoria.itemFactoriteVoltiteIngot));
      	    }
      	  
      	  public void addRecipe(ItemStack stack1, ItemStack stack2, ItemStack stack3) 
      	    {
      	        ItemStack[] stackList = new ItemStack[]{stack1, stack2, stack3};
      	        this.smeltingList.put(stackList, stack3);
      	    }
      	 
      	        public void addRecipe(Item item1, Item item2, ItemStack stack) 
      	    {
      	        this.addRecipe(new ItemStack(item1), new ItemStack(item2), stack);
      	    }
      	 
      	    public void addRecipe(Block block1, Item item2, ItemStack stack) 
      	    {
      	        this.addRecipe(Item.getItemFromBlock(block1), item2, stack);
      	    }
      	 
      	    
      	        
      	        public ItemStack getSmeltingResult(ItemStack[] stack) 
      	        {
      	            Iterator iterator = this.smeltingList.entrySet().iterator();
      	            Entry entry;
      	     
      	            do
      	            {
      	                if (!iterator.hasNext()) 
      	                {
      	                    return null; 
      	                }
      	            entry = (Entry)iterator.next(); 
      	        }
      	        while (!this.isSameKey(stack, (ItemStack[])entry.getKey())); 
      	        return (ItemStack)entry.getValue(); 
      	        }
      	        
      	        private boolean isSameKey(ItemStack[] stackList, ItemStack[] stackList2)
      	        {
      	            boolean isSame = false; 
      	            for(int i=0; i<=2; i++) 
      	            {
      	                if(stackList[i].getItem() == stackList2[i].getItem())
      	                {
      	                    isSame = true;
      	                }
      	                else
      	                {
      	                    return false; 
      	                }
      	            }
      	            return isSame;
      	        }
      	        
      	        public Map getSmeltingList()
      	        {
      	            return this.smeltingList;
      	        }
      	     
      	        public static RecipesCustomFurnace smelting()
      	        {
      	            return smeltingBase;
      	        }
      
      		
      }
      
      

      La fonction CanSmelt et Updateentity de la classe TileEntity :

      public void updateEntity() 
          {
              if(this.isBurning() && this.canSmelt()) 
              {
                  ++this.workingTime; 
              }
              if(this.canSmelt() && !this.isBurning()) 
              {
                  this.workingTime = 1; 
              }
              if(this.canSmelt() && this.workingTime == this.workingTimeNeeded) 
              {
                  this.smeltItem(); 
                  this.workingTime = 0; 
              }
              if(!this.canSmelt()) 
              {
                      this.workingTime= 0; 
              }
          }
      	    
      
      	
      	 private boolean canSmelt()
      	    {
      	        if (this.contents[0] == null || this.contents[3] == null) 
      	        {
      	            return false;
      	        }
      	        else
      	        {
      	            ItemStack itemstack = RecipesCustomFurnace.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[3]}); 
      	            if (this.contents[2] == null) return true; 
      	            if (!this.contents[2].isItemEqual(itemstack)) return false; 
      	            int result = contents[2].stackSize + itemstack.stackSize;
      	            return result <= getInventoryStackLimit() && result <= this.contents[2].getMaxStackSize(); }
      	    }
      	
      

      Ah et mon premier slot d’input est [0] et le deuxième est [3]

      Merci d’avance !

      AmaA 1 réponse Dernière réponse Répondre Citer 0
      • AmaA Hors-ligne
        Ama @Raven
        dernière édition par

        @Raven a dit dans Créer un bloc type four (machine) :

        java.lang.ArrayIndexOutOfBoundsException: 2

        Renseignes toi sur cette erreur, et tu sauras la corriger 😉

        Si je t'ai filé un coup de main n'oublie pas le + / -
        Par contre évite les demandes d'aides en MP, tu sera sympa'

        La JavaDoc c'est comme le PQ, ça sert à ce démerder tous seul. -Victor Hugo- 2017

        Une superbe API pour animer vos super modèles CraftStudio dans Minecraft !

        RavenR 1 réponse Dernière réponse Répondre Citer 0
        • RavenR Hors-ligne
          Raven @Ama
          dernière édition par

          Ce message a été supprimé !
          RavenR 1 réponse Dernière réponse Répondre Citer 0
          • RavenR Hors-ligne
            Raven @Raven
            dernière édition par

            Ce message a été supprimé !
            1 réponse Dernière réponse Répondre Citer 0
            • RavenR Hors-ligne
              Raven
              dernière édition par

              Ce message a été supprimé !
              1 réponse Dernière réponse Répondre Citer 0
              • A Hors-ligne
                Aiko
                dernière édition par

                Bonjour,
                Cela fonctionne-t-il en version 1.12.2 ?

                RavenR 1 réponse Dernière réponse Répondre Citer 0
                • RavenR Hors-ligne
                  Raven @Aiko
                  dernière édition par

                  @Aiko voici le turoriel pour la 1.12.2 (par Brokenswing de plus) https://www.minecraftforgefrance.fr/topic/4114/1-12-créer-un-four

                  1 réponse Dernière réponse Répondre Citer 2
                  • T Hors-ligne
                    TionebBen3119
                    dernière édition par

                    Bonjour j’ai un problème lorsque le block est posé en jeu, un click droit dessus ne fais absolument rien quel est le problème. Est ce que quelqu’un aurais discord pour simplifier la communication^^

                    RavenR 1 réponse Dernière réponse Répondre Citer 0
                    • John_71J Hors-ligne
                      John_71
                      dernière édition par

                      Ton code ??? (s’il te plaît ?)

                      • Maintient des mods et modpacks en `1.18.2`
                      • Je suis un membre apprécié et joueur, j'ai déjà obtenu 2 points de réputation.

                      T 2 réponses Dernière réponse Répondre Citer 1
                      • T Hors-ligne
                        TionebBen3119 @John_71
                        dernière édition par

                        @JohnProgrammer ```
                        package com.mod.heaven.init;

                        import com.mod.heaven.blocks.MachineTuto;

                        import cpw.mods.fml.common.Mod.EventHandler;
                        import cpw.mods.fml.common.event.FMLPreInitializationEvent;
                        import cpw.mods.fml.common.registry.GameRegistry;
                        import net.minecraft.block.Block;

                        public class MachineBlockMod
                        {
                        public static Block machineTuto;

                        public static void init()
                        {
                        machineTuto = new MachineTuto().setBlockName("machineTuto");
                        }
                        
                        
                        public static void register() 
                        {
                        	GameRegistry.registerBlock(machineTuto, machineTuto.getUnlocalizedName().substring(5));
                        }
                        

                        }

                        package com.mod.heaven.blocks;

                        import com.mod.heaven.HeavenMod;
                        import com.mod.heaven.Reference;
                        import com.mod.heaven.tileentity.tileentitymachinetuto;

                        import cpw.mods.fml.common.registry.GameRegistry;
                        import net.minecraft.block.Block;
                        import net.minecraft.block.BlockContainer;
                        import net.minecraft.block.material.Material;
                        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 MachineTuto extends BlockContainer
                        {

                        protected MachineTuto(Material p_i45386_1_) {
                        	super(p_i45386_1_);
                        }
                        
                        public MachineTuto()
                        {
                            super(Material.rock);
                            this.setResistance(8.0F);
                            this.setHarvestLevel("pickaxe", 2);
                            this.setBlockTextureName(Reference.MOD_ID + ":MachineTuto");
                          
                        }
                        
                        @Override
                        public TileEntity createNewTileEntity(World world, int metadata)
                        {
                            return new tileentitymachinetuto();
                        }
                        
                        @Override
                        public boolean hasTileEntity(int metadata)
                        {
                            return true;
                        }
                        
                        //Méthode de minecraft pour loot les items dans le block quand il est cassé
                        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 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(HeavenMod.instance, 0, world, x, y, z);
                                return true;
                            }
                        }
                        public static void register()  
                        {
                        	 GameRegistry.registerTileEntity(tileentitymachinetuto.class, "ModTutoriel:MachineTutoTileEntity"); 
                        }
                        

                        }

                        package com.mod.heaven.tileentity;
                        
                        import com.mod.heaven.recipe.MachineTutoRecipes;
                        
                        import net.minecraft.entity.player.EntityPlayer;
                        import net.minecraft.inventory.IInventory;
                        import net.minecraft.item.ItemStack;
                        import net.minecraft.nbt.NBTTagCompound;
                        import net.minecraft.nbt.NBTTagList;
                        import net.minecraft.tileentity.TileEntity;
                        
                        public class tileentitymachinetuto extends TileEntity implements IInventory 
                        {
                        	private ItemStack[] contents = new ItemStack[4]; //0, 1 et 2 sont les inputs et 3 est l'output 
                        	
                        	private int workingTime = 0; //Temps de cuisson actuel
                        
                        	private int workingTimeNeeded = 200; //Temps de cuisson nécessaire
                        	
                            @Override
                            public void writeToNBT(NBTTagCompound compound)
                            {
                                super.writeToNBT(compound);
                                NBTTagList nbttaglist = new NBTTagList();
                        
                                for (int i = 0; i < this.contents.length; ++i)
                                {
                                    if (this.contents[i] != null)
                                    {
                                        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                                        nbttagcompound1.setByte("Slot", (byte)i);
                                        this.contents[i].writeToNBT(nbttagcompound1);
                                        nbttaglist.appendTag(nbttagcompound1);
                                    }
                                }
                         
                                compound.setTag("Items", nbttaglist);
                                compound.setShort("workingTime",(short)this.workingTime); //On les enregistrent en short
                                compound.setShort("workingTimeNeeded", (short)this.workingTimeNeeded);
                            }
                            
                            @Override
                            public void readFromNBT(NBTTagCompound compound)
                            {
                                super.readFromNBT(compound);
                         
                                NBTTagList nbttaglist = compound.getTagList("Items", 10);
                                this.contents = new ItemStack[this.getSizeInventory()];
                         
                                for (int i = 0; i < nbttaglist.tagCount(); ++i) //Encore une fois pour les slots
                                {
                                    NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
                                    int j = nbttagcompound1.getByte("Slot") & 255;
                         
                                    if (j >= 0 && j < this.contents.length)
                                    {
                                        this.contents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
                                    }
                                }
                         
                                this.workingTime = compound.getShort("workingTime"); //On lit nos valeurs
                                this.workingTimeNeeded = compound.getShort("workingTimeNeeded");
                            }
                        
                            public int getSizeInventory() 
                            {
                                return this.contents.length;
                            }
                            
                            public ItemStack getStackInSlot(int slotIndex) 
                            {
                                return this.contents[slotIndex];
                            }
                            
                            public ItemStack decrStackSize(int slotIndex, int amount) {
                                    if (this.contents[slotIndex] != null)
                                    {
                                        ItemStack itemstack;
                         
                                        if (this.contents[slotIndex].stackSize <= amount)
                                        {
                                            itemstack = this.contents[slotIndex];
                                            this.contents[slotIndex] = null;
                                            this.markDirty();
                                            return itemstack;
                                        }
                                        else
                                        {
                                            itemstack = this.contents[slotIndex].splitStack(amount);
                         
                                            if (this.contents[slotIndex].stackSize == 0)
                                            {
                                                this.contents[slotIndex] = null;
                                            }
                         
                                            this.markDirty();
                                            return itemstack;
                                        }
                                    }
                                    else
                                    {
                                        return null;
                                    }
                            }
                         
                            public ItemStack getStackInSlotOnClosing(int slotIndex) {
                                if (this.contents[slotIndex] != null)
                                {
                                    ItemStack itemstack = this.contents[slotIndex];
                                    this.contents[slotIndex] = null;
                                    return itemstack;
                                }
                                else
                                {
                                    return null;
                                }
                            }
                         
                            public void setInventorySlotContents(int slotIndex, ItemStack stack) {
                                this.contents[slotIndex] = stack;
                         
                                if (stack != null && stack.stackSize > this.getInventoryStackLimit())
                                {
                                    stack.stackSize = this.getInventoryStackLimit();
                                }
                         
                                this.markDirty();
                            }
                         
                            public String getInventoryName() 
                            {
                                return "tile.machineTuto";
                            }
                         
                            public boolean hasCustomInventoryName() 
                            {
                                return false;
                            }
                         
                            public int getInventoryStackLimit() 
                            {
                                return 64;
                            }
                        
                            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;
                            }
                         
                            public void openInventory() 
                            {
                         
                            }
                         
                            public void closeInventory() 
                            {
                         
                            }
                         
                            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 = MachineTutoRecipes.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;
                                    if (this.contents[3] == null) return true; //vérifications du slot d'output
                                    if (!this.contents[3].isItemEqual(itemstack)) return false;
                                    int result = contents[3].stackSize + itemstack.stackSize;
                                    return result <= getInventoryStackLimit() && result <= this.contents[3].getMaxStackSize();
                                }
                            }
                        
                            public void updateEntity()
                            {
                                if(this.isBurning() && this.canSmelt())
                                {
                                    ++this.workingTime;
                                }
                                if(this.canSmelt() && !this.isBurning())
                                {
                                    this.workingTime = 1;
                                }
                                if(this.canSmelt() && this.workingTime == this.workingTimeNeeded)
                                {
                                    this.smeltItem();
                                    this.workingTime = 0;
                                }
                                if(!this.canSmelt())
                                {
                                        this.workingTime= 0;
                                }
                            }
                        
                            public void smeltItem()
                            {
                                if (this.canSmelt())
                                {
                                    ItemStack itemstack = MachineTutoRecipes.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;
                                    --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;
                                    }
                                }
                            }
                        }
                        

                        package com.mod.heaven.recipe;

                        import java.util.HashMap;
                        import java.util.Iterator;
                        import java.util.Map;
                        import java.util.Map.Entry;

                        import com.mod.heaven.init.ItemModOre;

                        import net.minecraft.block.Block;
                        import net.minecraft.init.Items;
                        import net.minecraft.item.Item;
                        import net.minecraft.item.ItemStack;

                        public class MachineTutoRecipes
                        {
                        private static final MachineTutoRecipes smeltingBase = new MachineTutoRecipes();
                        private Map smeltingList = new HashMap();

                        public MachineTutoRecipes()
                        {
                            this.addRecipe(ItemModOre.platinium_ingot, Items.diamond, ItemModOre.platinium_ingot, new ItemStack(ItemModOre.shiny_ingot)); 
                            
                        }
                        
                        public void addRecipe(ItemStack stack1, ItemStack stack2, ItemStack stack3, ItemStack stack4)
                        {
                            ItemStack[] stackList = new ItemStack[]{stack1, stack2, stack3};
                            this.smeltingList.put(stackList, stack4);
                        }
                        
                            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);
                        }
                        
                        public void addRecipe(Block block1, Item item2, Item item3, ItemStack stack) //2nd cas
                        {
                            this.addRecipe(Item.getItemFromBlock(block1), item2, item3, stack);
                        }
                        
                        public void addRecipe(Block block1, Block block2, Item item3, ItemStack stack) //3ème cas
                        {
                            this.addRecipe(Item.getItemFromBlock(block1), Item.getItemFromBlock(block2), item3, stack);
                        }
                        
                        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 MachineTutoRecipes smelting()
                        {
                            return smeltingBase;
                        }
                        

                        }

                        package com.mod.heaven.container;
                        
                        import com.mod.heaven.blocks.SlotResult;
                        import com.mod.heaven.tileentity.tileentitymachinetuto;
                        
                        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 ContainerMachineTuto extends Container 
                        {
                        	private tileentitymachinetuto tileMachineTuto;
                        	
                            public ContainerMachineTuto(tileentitymachinetuto tile, InventoryPlayer inventory)
                            {
                                this.tileMachineTuto = tile;
                                tile.openInventory();
                                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));
                                this.bindPlayerInventory(inventory);
                            }
                            
                            @Override
                            public boolean canInteractWith(EntityPlayer player) {
                                return this.tileMachineTuto.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.tileMachineTuto.getSizeInventory())
                                    {
                                        if (!this.mergeItemStack(itemstack1, this.tileMachineTuto.getSizeInventory(), this.inventorySlots.size(), true))
                                        {
                                            return null;
                                        }
                                    }
                                    else if (!this.mergeItemStack(itemstack1, 0, this.tileMachineTuto.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.tileMachineTuto.closeInventory();
                            }
                            
                            
                        }
                        

                        package com.mod.heaven.container;

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

                        }```
                        package com.mod.heaven.gui;

                        import com.mod.heaven.Reference;
                        import com.mod.heaven.container.ContainerMachineTuto;
                        import com.mod.heaven.tileentity.tileentitymachinetuto;

                        import net.minecraft.client.gui.inventory.GuiContainer;
                        import net.minecraft.entity.player.InventoryPlayer;
                        import net.minecraft.inventory.IInventory;
                        import net.minecraft.util.ResourceLocation;

                        public class GuiMachineTuto extends GuiContainer
                        {
                        private static final ResourceLocation texture = new ResourceLocation(Reference.MOD_ID,“textures/gui/container/guiMachineTuto.png”);
                        @SuppressWarnings(“unused”)
                        private tileentitymachinetuto tileMachineTuto;
                        private IInventory playerInv;

                        public GuiMachineTuto(tileentitymachinetuto tile, InventoryPlayer inventory)
                        {
                            super(new ContainerMachineTuto(tile, inventory));
                            this.tileMachineTuto = tile;
                            this.playerInv = inventory;
                            this.allowUserInput = false;
                            this.ySize = 256;
                            this.xSize = 256;
                        }
                        
                        @Override
                        protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) 
                        {
                        	
                        }
                        

                        }

                        1 réponse Dernière réponse Répondre Citer 0
                        • T Hors-ligne
                          TionebBen3119 @John_71
                          dernière édition par

                          @JohnProgrammer Excuse j’avais oublié ^^

                          1 réponse Dernière réponse Répondre Citer 0
                          • John_71J Hors-ligne
                            John_71
                            dernière édition par

                            Ton GuiHandler ?

                            • Maintient des mods et modpacks en `1.18.2`
                            • Je suis un membre apprécié et joueur, j'ai déjà obtenu 2 points de réputation.

                            T 1 réponse Dernière réponse Répondre Citer 1
                            • T Hors-ligne
                              TionebBen3119 @John_71
                              dernière édition par robin4002

                              @JohnProgrammer Euh oui

                              package com.mod.heaven.gui;
                              
                              import com.mod.heaven.Reference;
                              import com.mod.heaven.container.ContainerMachineTuto;
                              import com.mod.heaven.tileentity.tileentitymachinetuto;
                              
                              import net.minecraft.client.gui.inventory.GuiContainer;
                              import net.minecraft.entity.player.InventoryPlayer;
                              import net.minecraft.inventory.IInventory;
                              import net.minecraft.util.ResourceLocation;
                              
                              public class GuiMachineTuto extends GuiContainer 
                              {
                                 private static final ResourceLocation texture = new ResourceLocation(Reference.MOD_ID,"textures/gui/container/guiMachineTuto.png");
                                 @SuppressWarnings("unused")
                                 private tileentitymachinetuto tileMachineTuto;
                                 private IInventory playerInv;
                              
                                 public GuiMachineTuto(tileentitymachinetuto tile, InventoryPlayer inventory)
                                 {
                                     super(new ContainerMachineTuto(tile, inventory));
                                     this.tileMachineTuto = tile;
                                     this.playerInv = inventory;
                                     this.allowUserInput = false;
                                     this.ySize = 256;
                                     this.xSize = 256;
                                 }
                              
                                 @Override
                                 protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) 
                                 {
                                 	
                                 }
                              }
                              
                              
                              
                              1 réponse Dernière réponse Répondre Citer 0
                              • John_71J Hors-ligne
                                John_71
                                dernière édition par

                                Ce n’est pas cette classe. Je veux ton GuiHandler (si la 1.7.10 en demande un, car elle n’est plus supportée ici)
                                ||#1.7.10-Nope #MàJ||

                                • Maintient des mods et modpacks en `1.18.2`
                                • Je suis un membre apprécié et joueur, j'ai déjà obtenu 2 points de réputation.

                                T 1 réponse Dernière réponse Répondre Citer 0
                                • T Hors-ligne
                                  TionebBen3119 @John_71
                                  dernière édition par

                                  @JohnProgrammer JE n’ai pas de class guihandler ^^ c’est peut etre ca mon probleme je suis en 1.7.10

                                  1 réponse Dernière réponse Répondre Citer 0
                                  • John_71J Hors-ligne
                                    John_71
                                    dernière édition par

                                    Débrouille toi comme un grand alors … bonne chance !
                                    Ou mets toi à jour en 1.12.2 ou +.

                                    PS: arrête de voter systématiquement aux message qu’on envoie, ça spam notifications inutilement

                                    • Maintient des mods et modpacks en `1.18.2`
                                    • Je suis un membre apprécié et joueur, j'ai déjà obtenu 2 points de réputation.

                                    T 1 réponse Dernière réponse Répondre Citer 1
                                    • T Hors-ligne
                                      TionebBen3119 @John_71
                                      dernière édition par

                                      @JohnProgrammer Est ce que jele passage de 1.7.10 a 1.12.2 est simple niveau code ?

                                      1 réponse Dernière réponse Répondre Citer 0
                                      • John_71J Hors-ligne
                                        John_71
                                        dernière édition par John_71

                                        Il y a des changements de package comme les cpw.* qui deviennent net.minecraftforge.* etc …
                                        Mais il y a de nombreux tutos sur du “facile” (=> Par ici <=) sur ce site.

                                        • Maintient des mods et modpacks en `1.18.2`
                                        • Je suis un membre apprécié et joueur, j'ai déjà obtenu 2 points de réputation.

                                        T 1 réponse Dernière réponse Répondre Citer 0
                                        • T Hors-ligne
                                          TionebBen3119 @John_71
                                          dernière édition par

                                          @JohnProgrammer Merci beaucoup ^^

                                          1 réponse Dernière réponse Répondre Citer 0
                                          • RavenR Hors-ligne
                                            Raven @TionebBen3119
                                            dernière édition par

                                            Ce message a été supprimé !
                                            1 réponse Dernière réponse Répondre Citer 0
                                            • 1
                                            • 2
                                            • 8
                                            • 9
                                            • 10
                                            • 11
                                            • 12
                                            • 12 / 12
                                            • Premier message
                                              Dernier message
                                            Design by Woryk
                                            ContactMentions Légales

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB