MFF

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

    Recette smelting custom.

    Planifier Épinglé Verrouillé Déplacé Résolu 1.7.x
    1.7.10
    43 Messages 3 Publieurs 8.1k Vues 1 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.
    • FlowF Hors-ligne
      Flow
      dernière édition par

      J’ai créer l’interface que j’implements mais je bloque sur quelques points …

      Quand tu dis l’inventaire de ta machine ca correspond à quoi … Car j’ai plusieurs classes

      • ContainerAnalyzer ( pas sur )
      • GuiAnalyzer (non ?)
      • GuiHandler ( non ? )
      • SlotResult ( jpense pas)
      • BlockAnlayzer ( ceci ? )

      Sinon j’ai créer l’interface IRecipeEgg et j’ai mis

      
      @Override
      public boolean matches(BlockAnalyzer analyzer , World world)
      {
      for (int i = 0; i < 2; i++)
      {
      for (int j = 0; j < 2; j++)
      {
      if (!AnalyzerRecipes.corresponds(AnalyzerRecipes.matrix[ i ][j], blockanalyzer.getStackInSlot(i * 2 + j))) return false;
      }
      }
      return true;
      }
      
      @Override
      public Item getRecipeOutput(BlockAnalyzer analayzer ,  World world)
      {
      
      return new Item();
      }
      

      mais il veut tout le temps supprimé le body , en gros je peut rien mettre dedans x-)

      Une fois que j’aurais réussi a faire l’interface tu pourra re faire une liste de ce que je dois faire , car n’empeche sa m’aide x)

      Oui ce gif est drôle.

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

        • ContainerAnalyzer -> c’est ce qui fait la connexion entre client et serveur
        • GuiAnalyzer -> seulement côté client, il va y avoir un problème
        • GuiHandler -> aussi côté client
        • SlotResult -> on va pas faire grand chose avec un seul slot
        • BlockAnlayzer -> on peut rien faire avec juste un block
          Il faut mettre l’inventaire.

        Dans le tuto que j’ai fais, j’IMPLEMENTE l’interface, eclipse te dit de supprimer le corps car c’est une interface. Il faut juste y mettre les méthodes mais pas leur corps.

        Fait quelque chose comme çà (ici j’ai supposé que l’inventaire que tu as utilisé s’appelait InventoryAnalyzer, il faut changer çà en fonction du nom que tu as mis) :

        public interface IAnalyzerRecipe
        {
        public boolean matches(InventoryAnalyzer inv, World world);
        public ItemStack getOutput(InventoryAnalyzer, World world);
        }
        

        Ensuite tu crées une classe implémentant IAnalyzerRecipe.

        Site web contenant mes scripts : http://SCAREXgaming.github.io

        Pas de demandes de support par MP ni par skype SVP.
        Je n'accepte sur skype que l…

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

          Mais c’est un smelting donc je n’ai pas d’inventory… C’est ca que je ne comprend pas …

          Oui ce gif est drôle.

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

            Tu as forcément un inventaire, une classe implémentant IInventory, regarde ta TileEntity.

            Site web contenant mes scripts : http://SCAREXgaming.github.io

            Pas de demandes de support par MP ni par skype SVP.
            Je n'accepte sur skype que l…

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

              Ah oui d’accord j’ai compris c’est pour utiliser ma machine avec le IRecipe ( ca y est j’ai pigé )

              Voici ma classe AnalyzerRecipes

              package mod.common.block;
              
              import java.util.ArrayList;
              import java.util.HashMap;
              import java.util.Iterator;
              import java.util.Map;
              import java.util.Map.Entry;
              import java.util.Random;
              
              import mod.common.block.entity.TileEntityAnalyzer;
              import mod.common.item.ItemRegister;
              import net.minecraft.block.Block;
              import net.minecraft.init.Items;
              import net.minecraft.inventory.InventoryCrafting;
              import net.minecraft.item.Item;
              import net.minecraft.item.ItemDye;
              import net.minecraft.item.ItemStack;
              import net.minecraft.item.crafting.IRecipe;
              import net.minecraft.nbt.NBTTagCompound;
              import net.minecraft.nbt.NBTTagList;
              import net.minecraft.world.World;
              
              @SuppressWarnings("rawtypes")
              public class AnalyzerRecipes implements IAnalyzerRecipe
              {
              
              public static final Item[][] matrix = new Item[][]
              {
              new Item[]
              
              {
              
              ItemRegister.itemSevewithmosquito,
              ItemRegister.itemADNofFrog
              
              }
              };
              
              @Override
              public boolean matches(TileEntityAnalyzer inv, World world) {
              
              for (int i = 0; i < 2; i++) {
              for (int j = 0; j < 2; j++) {
              if (!AnalyzerRecipes.corresponds(AnalyzerRecipes.matrix[ i ][j], inv.getStackInSlot(i * 2 + j))) return false;
              }
              }
              return true;
              }
              
              public static boolean corresponds(Item item, ItemStack stack) {
              // Si les 2 sont "null", on retourne true car il ne doit rien y avoir dans ce slot et il n'y a rien.
              if (stack == null && item == null) return true;
              // Si l'un est null mais pas l'autre, on retourne false (ici j'ai séparé la condition en 2 parties pour plus de clarté)
              if (stack == null && item != null) return false;
              if (stack != null && item == null) return false;
              // Et pour finir si les 2 ne sont pas égaux, on retourne false
              if (stack.getItem() != item) return false;
              // Sinon, on retourne true
              return true;
              }
              
              @Override
              public ItemStack getOutput(TileEntityAnalyzer inv, World world) {
              
              return new ItemStack(BlockRegister.BlockEgg);
              }
              
              }
              
              

              IAnalyzer

              
              package mod.common.block;
              
              import mod.common.block.entity.TileEntityAnalyzer;
              import net.minecraft.item.ItemStack;
              import net.minecraft.world.World;
              
              public interface IAnalyzerRecipe
              {
              public boolean matches(TileEntityAnalyzer inv, World world);
              public ItemStack getOutput(TileEntityAnalyzer inv , World world);
              }
              
              

              Par contre pour le TileEntityAnalyzer j’avais des .smelting()

              mais maintenant je dois remplacer par quoi ? .corresponds ?

              
              @Override
              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 = AnalyzerRecipes.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[2] == null) //Si il y a rien dans le slot d'output
              {
              this.contents[2] = itemstack.copy(); //On met directement l'ItemStack
              }
              else if (this.contents[2].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[2].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;
              
              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;
              }
              
              }
              }
              
              

              Merci en tout cas de ton aide ! 🙂

              Oui ce gif est drôle.

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

                getSmeltingResult doit parcourir tous les IAnalyzerRecipe pour trouver un recipe qui correspond et retourner l’ItemStack donné avec la fonction getOutput de IAnalyzerRecipe

                Site web contenant mes scripts : http://SCAREXgaming.github.io

                Pas de demandes de support par MP ni par skype SVP.
                Je n'accepte sur skype que l…

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

                  Désoler mais je vois pas comment je dois faire , je débute , je comprend ce que tu veut dire mais , je vois pas comment l’interpréter en java …

                  Pour l’instant j’ai ca :

                  
                  .getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]})
                  
                  

                  je n’ai plus de content donc je suppose qu’ils doivent être remplacer mais je ne vois pas par quoi je dois remplacer j’ai regarder le this. pour voir tous se qu’il y avais d’autre mais je n’ai pas trouver … Désoler j’ai vraiment l’impression de demander mais je ne comprend vraiment pas 😕

                  Oui ce gif est drôle.

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

                    Envoi tes sources, je te fais un code commenté

                    Site web contenant mes scripts : http://SCAREXgaming.github.io

                    Pas de demandes de support par MP ni par skype SVP.
                    Je n'accepte sur skype que l…

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

                      Wow euh c’est super gentil … Je sais pas quoi dire ^^ Merci , je vais essayer de comprendre le code que tu me donnera ! 😉

                      AnalyzerRecipes

                      
                      package mod.common.block;
                      
                      import java.util.ArrayList;
                      import java.util.HashMap;
                      import java.util.Iterator;
                      import java.util.Map;
                      import java.util.Map.Entry;
                      import java.util.Random;
                      
                      import mod.common.block.entity.TileEntityAnalyzer;
                      import mod.common.item.ItemRegister;
                      import net.minecraft.block.Block;
                      import net.minecraft.init.Items;
                      import net.minecraft.inventory.InventoryCrafting;
                      import net.minecraft.item.Item;
                      import net.minecraft.item.ItemDye;
                      import net.minecraft.item.ItemStack;
                      import net.minecraft.item.crafting.IRecipe;
                      import net.minecraft.nbt.NBTTagCompound;
                      import net.minecraft.nbt.NBTTagList;
                      import net.minecraft.world.World;
                      
                      @SuppressWarnings("rawtypes")
                      public class AnalyzerRecipes implements IAnalyzerRecipe
                      {
                      
                      public static final Item[][] matrix = new Item[][]
                      {
                      new Item[]
                      
                      {
                      
                      ItemRegister.itemSevewithmosquito,
                      ItemRegister.itemADNofFrog
                      
                      }
                      };
                      
                      @Override
                      public boolean matches(TileEntityAnalyzer inv, World world) {
                      
                      for (int i = 0; i < 2; i++) {
                      for (int j = 0; j < 2; j++) {
                      if (!AnalyzerRecipes.corresponds(AnalyzerRecipes.matrix[ i ][j], inv.getStackInSlot(i * 2 + j))) return false;
                      }
                      }
                      return true;
                      }
                      
                      public static boolean corresponds(Item item, ItemStack stack) {
                      // Si les 2 sont "null", on retourne true car il ne doit rien y avoir dans ce slot et il n'y a rien.
                      if (stack == null && item == null) return true;
                      // Si l'un est null mais pas l'autre, on retourne false (ici j'ai séparé la condition en 2 parties pour plus de clarté)
                      if (stack == null && item != null) return false;
                      if (stack != null && item == null) return false;
                      // Et pour finir si les 2 ne sont pas égaux, on retourne false
                      if (stack.getItem() != item) return false;
                      // Sinon, on retourne true
                      return true;
                      }
                      
                      @Override
                      public ItemStack getOutput(TileEntityAnalyzer inv, World world) {
                      
                      return new ItemStack(BlockRegister.BlockEgg);
                      }
                      
                      }
                      
                      

                      ContainerAnalyzer

                      
                      package mod.common.block;
                      
                      import mod.common.block.entity.TileEntityAnalyzer;
                      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 ContainerAnalyzer extends Container {
                      
                      private TileEntityAnalyzer tileBlockAnalyzer;
                      
                      public ContainerAnalyzer(TileEntityAnalyzer tile, InventoryPlayer inventory)
                      {
                      this.tileBlockAnalyzer = tile;
                      this.addSlotToContainer(new Slot(tile, 0, 117, 31)); //Lancez votre jeu en debug pour calibrer vos slots
                      this.addSlotToContainer(new Slot(tile, 1, 61, 31));
                      this.addSlotToContainer(new SlotResult(tile, 2, 89, 87)); //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.tileBlockAnalyzer.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, 125 + i * 18));
                      }
                      }
                      
                      for (i = 0; i < 9; ++i)
                      {
                      this.addSlotToContainer(new Slot(inventory, i, 17 + i * 18, 183));
                      }
                      }
                      
                      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.tileBlockAnalyzer.getSizeInventory())
                      {
                      if (!this.mergeItemStack(itemstack1, this.tileBlockAnalyzer.getSizeInventory(), this.inventorySlots.size(), true))
                      {
                      return null;
                      }
                      }
                      else if (!this.mergeItemStack(itemstack1, 0, this.tileBlockAnalyzer.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.tileBlockAnalyzer.closeInventory();
                      }
                      }
                      
                      

                      GuiAnalyzer

                      package mod.common.block;
                      
                      import org.lwjgl.opengl.GL11;
                      
                      import mod.ModMinecraft;
                      import mod.common.block.entity.TileEntityAnalyzer;
                      import net.minecraft.client.gui.inventory.GuiContainer;
                      import net.minecraft.entity.player.InventoryPlayer;
                      import net.minecraft.inventory.IInventory;
                      import net.minecraft.util.ResourceLocation;
                      import net.minecraft.client.resources.I18n;
                      
                      public class GuiAnalyzer extends GuiContainer {
                      
                      private static final ResourceLocation texture = new ResourceLocation(ModMinecraft.MODID,"textures/gui/container/guiAnalyzer.png");
                      @SuppressWarnings("unused")
                      private TileEntityAnalyzer tileBlockAnalyzer;
                      private IInventory playerInv;
                      
                      public GuiAnalyzer(TileEntityAnalyzer tile, InventoryPlayer inventory)
                      {
                      super(new ContainerAnalyzer(tile, inventory));
                      this.tileBlockAnalyzer = tile;
                      this.playerInv = inventory;
                      this.allowUserInput = false;
                      this.ySize = 207;
                      this.xSize = 195;
                      }
                      
                      @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, 46, this.xSize, this.ySize);
                      
                      if(this.tileBlockAnalyzer.isBurning())
                      {
                      int i = this.tileBlockAnalyzer.getCookProgress();
                      this.drawTexturedModalRect(k + 59, l + 47, 0, 1, 76, i);
                      
                      }
                      }
                      
                      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);
                      }
                      
                      }
                      
                      

                      GuiHandler

                      
                      package mod.common.block;
                      
                      import mod.common.block.entity.TileEntityAnalyzer;
                      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) {
                      switch (ID) {
                      
                      case 0:
                      TileEntity tile = world.getTileEntity(x, y, z);
                      if(tile instanceof TileEntityAnalyzer)
                      {
                      return new ContainerAnalyzer((TileEntityAnalyzer)tile, player.inventory);
                      }
                      }
                      
                      return null;
                      }
                      
                      @Override
                      public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
                      switch (ID) {
                      
                      case 0:
                      TileEntity tile = world.getTileEntity(x, y, z);
                      if(tile instanceof TileEntityAnalyzer)
                      {
                      return new GuiAnalyzer((TileEntityAnalyzer)tile, player.inventory);
                      }
                      }
                      
                      return null;
                      }
                      
                      }
                      

                      IAnalyzerRecipes

                      package mod.common.block;
                      
                      import mod.common.block.entity.TileEntityAnalyzer;
                      import net.minecraft.item.ItemStack;
                      import net.minecraft.world.World;
                      
                      public interface IAnalyzerRecipe
                      {
                      public boolean matches(TileEntityAnalyzer inv, World world);
                      public ItemStack getOutput(TileEntityAnalyzer inv , World world);
                      }
                      

                      SlotResult

                      
                      package mod.common.block;
                      
                      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);
                      }
                      
                      }
                      
                      

                      TileEntityAnalyzer

                      package mod.common.block.entity;
                      
                      import cpw.mods.fml.relauncher.Side;
                      import cpw.mods.fml.relauncher.SideOnly;
                      import mod.common.block.AnalyzerRecipes;
                      import net.minecraft.entity.player.EntityPlayer;
                      import net.minecraft.inventory.IInventory;
                      import net.minecraft.item.Item;
                      import net.minecraft.item.ItemStack;
                      import net.minecraft.nbt.NBTTagCompound;
                      import net.minecraft.nbt.NBTTagList;
                      import net.minecraft.tileentity.TileEntity;
                      
                      public class TileEntityAnalyzer extends TileEntity implements IInventory
                      {
                      
                      private ItemStack[] contents = new ItemStack[4]; //0, 1 sont les inputs et 2 est l'output
                      
                      private int workingTime = 1999; //Temps de cuisson actuel
                      private int workingTimeNeeded = 256; //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) //pour les slots
                      {
                      if (this.contents* != null)
                      {
                      NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                      nbttagcompound1.setByte("Slot", (byte)i);
                      this.contents*.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");
                      }
                      
                      /*@Override*/
                      public int getSizeInventory() { //Tout est dans le nom, retourne la taille de l'inventaire, pour notre bloc c'est quatre
                      return this.contents.length;
                      }
                      
                      /*@Override*/
                      public ItemStack getStackInSlot(int slotIndex) { //Renvoie L'itemStack se trouvant dans le slot passé en argument
                      return this.contents[slotIndex];
                      }
                      
                      @Override //Comme dit plus haut, c'est expliqué dans le tutoriel de robin
                      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;
                      }
                      }
                      
                      @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 void setInventorySlotContents(int slotIndex, ItemStack stack) {
                      this.contents[slotIndex] = stack;
                      
                      if (stack != null && stack.stackSize > this.getInventoryStackLimit())
                      {
                      stack.stackSize = this.getInventoryStackLimit();
                      }
                      
                      this.markDirty();
                      }
                      
                      @Override
                      public String getInventoryName() { //J'ai décider qu'on ne pouvait pas mettre de nom custom
                      return "tile.BlockAnalyzer";
                      }
                      
                      @Override
                      public boolean hasCustomInventoryName() {
                      return false;
                      }
                      
                      @Override
                      public int getInventoryStackLimit() {
                      return 64;
                      }
                      
                      @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 == 2 ? false : true;
                      }
                      
                      public boolean isBurning()
                      {
                      return this.workingTime > 0;
                      }
                      
                      /* private boolean canSmelt()
                      {
                      if (this.contents[0] == null || this.contents[1] == null) //Si les deux premiers slots sont vides
                      {
                      return false; //On ne peut pas lancer le processus
                      }
                      else
                      {
                      
                      ItemStack itemstack = AnalyzerRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1]}); //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[2] == null) return true; //vérifications du slot d'output
                      if (!this.contents[2].isItemEqual(itemstack)) return false; //ici aussi
                      int result = contents[2].stackSize + itemstack.stackSize;
                      return result <= getInventoryStackLimit() && result <= this.contents[2].getMaxStackSize(); //Et là aussi décidément
                      }
                      }
                      
                      @Override
                      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 = AnalyzerRecipes.getSmeltingResult(new ItemStack[]{this.], this.contents[1], this.contents[2]}); //On récupère l'output de la recette
                      if (this.contents[2] == null) //Si il y a rien dans le slot d'output
                      {
                      this.contents[2] = itemstack.copy(); //On met directement l'ItemStack
                      }
                      else if (this.contents[2].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[2].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;
                      
                      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;
                      }
                      
                      }
                      }*/
                      
                      @SideOnly(Side.CLIENT)
                      public int getCookProgress()
                      {
                      return this.workingTime * 33 / this.workingTimeNeeded; //33 correspond à la hauteur de la barre de progression car notre barre de progression se déroule de haut en bas
                      }
                      }
                      
                      

                      Oui ce gif est drôle.

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

                        La classe AnalyzerManager qui sert juste à faire le lien entre tes recettes et ta TileEntity :

                        package fr.scarex.st17.recipe;
                        
                        import java.util.ArrayList;
                        import java.util.Collections;
                        import java.util.HashMap;
                        import java.util.Iterator;
                        import java.util.ListIterator;
                        
                        import fr.scarex.st17.ST17;
                        import fr.scarex.st17.tileentity.TileEntityAnalyzer;
                        import net.minecraft.item.ItemStack;
                        
                        public class AnalyzerManager
                        {
                        private static ArrayList <ianalyzerrecipe>recipes = new ArrayList<ianalyzerrecipe>();
                        
                        /**
                        * @param stacks tile content
                        * @return the recipe output
                        */
                        public static ItemStack getOutput(TileEntityAnalyzer tile, ItemStack … stacks) {
                        ListIterator <ianalyzerrecipe>ite = recipes.listIterator();
                        while (ite.hasNext()) {
                        IAnalyzerRecipe r = ite.next();
                        if (r.matches(tile, tile.getWorldObj())) return r.getOutput(tile, tile.getWorldObj()); // Si le recipe correspond, on récupère l'output
                        }
                        return null;
                        }
                        
                        /**
                        * @return the recipe map
                        */
                        public static ArrayList <ianalyzerrecipe>getRecipes() {
                        return recipes; // Si tu veux plus de sécurité, tu peux en créer une copie
                        }
                        
                        /**
                        * init your recipes (called from your main class)
                        */
                        public static void initRecipes() { // C'est là que tu dois initialiser tes recettes (appelle cette fonction depuis ta classe principale)
                        AnalyzerManager.addRecipe(new AnalyzerTestRecipe()); // Ici c'est une classe custom, mais tu peux utiliser AnalyzerSimpleRecipe
                        }
                        
                        /**
                        * @param recipe
                        */
                        public static void addRecipe(IAnalyzerRecipe recipe) {
                        recipes.add(recipe);
                        }
                        
                        /**
                        * @param stack first stack
                        * @param stack1 second stack
                        * @return true if the 2 stacks are equals
                        */
                        public static boolean corresponds(ItemStack stack, ItemStack stack1) {
                        if (stack == null && stack1 == null) return true;
                        if (stack == null && stack1 != null) return false;
                        if (stack != null && stack1 == null) return false;
                        if (stack.getItem() != stack1.getItem()) return false;
                        if (stack.getItemDamage() != stack1.getItemDamage()) return false;
                        return true;
                        }
                        }
                        
                        

                        Ta TileEntity modifiée :

                        package fr.scarex.st17.tileentity;
                        
                        import cpw.mods.fml.relauncher.Side;
                        import cpw.mods.fml.relauncher.SideOnly;
                        import fr.scarex.st17.recipe.AnalyzerManager;
                        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 TileEntityAnalyzer extends TileEntity implements IInventory
                        {
                        private ItemStack[] contents = new ItemStack[3]; // J'ai réduit à 3 slots car tu n'en as que 3
                        
                        private int workingTime = 1999;
                        private int workingTimeNeeded = 256;
                        
                        @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* != null) {
                        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                        nbttagcompound1.setByte("Slot", (byte) i);
                        this.contents*.writeToNBT(nbttagcompound1);
                        nbttaglist.appendTag(nbttagcompound1);
                        }
                        }
                        
                        compound.setTag("Items", nbttaglist);
                        compound.setShort("workingTime", (short) this.workingTime);
                        
                        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)
                        
                        {
                        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");
                        
                        this.workingTimeNeeded = compound.getShort("workingTimeNeeded");
                        }
                        
                        @Override
                        public int getSizeInventory() { // Pourquoi le override est en commentaire ?!
                        return this.contents.length;
                        }
                        
                        @Override
                        public ItemStack getStackInSlot(int slotIndex) {// Pourquoi le override est en commentaire ?!
                        return this.contents[slotIndex];
                        }
                        
                        @Override
                        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;
                        }
                        }
                        
                        @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 void setInventorySlotContents(int slotIndex, ItemStack stack) {
                        this.contents[slotIndex] = stack;
                        
                        if (stack != null && stack.stackSize > this.getInventoryStackLimit()) {
                        stack.stackSize = this.getInventoryStackLimit();
                        }
                        
                        this.markDirty();
                        }
                        
                        @Override
                        public String getInventoryName() {
                        return "tile.BlockAnalyzer";
                        }
                        
                        @Override
                        public boolean hasCustomInventoryName() {
                        return false;
                        }
                        
                        @Override
                        public int getInventoryStackLimit() {
                        return 64;
                        }
                        
                        @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 == 2 ? false : true;
                        }
                        
                        public boolean isBurning() {
                        return this.workingTime > 0;
                        }
                        
                        private boolean canSmelt() {
                        if (this.contents[0] == null || this.contents[1] == null) {
                        return false;
                        } else {
                        ItemStack itemstack = AnalyzerManager.getOutput(this); // On récupère le recipe avec AnalyzerManager qui est une classe pour t'aider
                        
                        if (itemstack == null) return false;
                        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();
                        }
                        }
                        
                        @Override
                        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 = AnalyzerManager.getOutput(this); // On récupère le recipe
                        if (this.contents[2] == null) {
                        this.contents[2] = itemstack.copy();
                        } else if (this.contents[2].getItem() == itemstack.getItem()) {
                        this.contents[2].stackSize += itemstack.stackSize;
                        }
                        
                        –this.contents[0].stackSize;
                        –this.contents[1].stackSize;
                        
                        if (this.contents[0].stackSize <= 0) {
                        this.contents[0] = null;
                        }
                        if (this.contents[1].stackSize <= 0) {
                        this.contents[1] = null;
                        }
                        
                        }
                        }
                        
                        @SideOnly(Side.CLIENT)
                        public int getCookProgress() {
                        return this.workingTime * 33 / this.workingTimeNeeded;
                        }
                        }
                        
                        

                        Ton container avec juste un commentaire en plus :

                        package fr.scarex.st17.container;
                        
                        import fr.scarex.st17.inventory.SlotResult;
                        import fr.scarex.st17.tileentity.TileEntityAnalyzer;
                        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 ContainerAnalyzer extends Container
                        {
                        
                        private TileEntityAnalyzer tileBlockAnalyzer;
                        
                        public ContainerAnalyzer(TileEntityAnalyzer tile, InventoryPlayer inventory) {
                        this.tileBlockAnalyzer = tile;
                        this.addSlotToContainer(new Slot(tile, 0, 117, 31));
                        this.addSlotToContainer(new Slot(tile, 1, 61, 31)); // Ces 2 slots sont inversés
                        this.addSlotToContainer(new SlotResult(tile, 2, 89, 87));
                        this.bindPlayerInventory(inventory);
                        }
                        
                        @Override
                        public boolean canInteractWith(EntityPlayer player) {
                        return this.tileBlockAnalyzer.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, 125 + i * 18));
                        }
                        }
                        
                        for (i = 0; i < 9; ++i) {
                        this.addSlotToContainer(new Slot(inventory, i, 17 + i * 18, 183));
                        }
                        }
                        
                        public ItemStack transferStackInSlot(EntityPlayer player, int index) {
                        ItemStack itemstack = null;
                        Slot slot = (Slot) this.inventorySlots.get(index);
                        
                        if (slot != null && slot.getHasStack()) {
                        ItemStack itemstack1 = slot.getStack();
                        itemstack = itemstack1.copy();
                        
                        if (index < this.tileBlockAnalyzer.getSizeInventory()) {
                        if (!this.mergeItemStack(itemstack1, this.tileBlockAnalyzer.getSizeInventory(), this.inventorySlots.size(), true)) { return null; }
                        } else if (!this.mergeItemStack(itemstack1, 0, this.tileBlockAnalyzer.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.tileBlockAnalyzer.closeInventory();
                        }
                        }
                        
                        

                        L’interface IAnalyzerRecipe, si tu veux rajouter quelques fonctions pour t’aider (comme la fonction corresponds) je te conseille à la place de créer une classe abstraite et de rajouter ces fonctions dedans.

                        package fr.scarex.st17.recipe;
                        
                        import fr.scarex.st17.tileentity.TileEntityAnalyzer;
                        import net.minecraft.item.ItemStack;
                        import net.minecraft.world.World;
                        
                        public interface IAnalyzerRecipe
                        {
                        public boolean matches(TileEntityAnalyzer tile, World world);
                        
                        public ItemStack getOutput(TileEntityAnalyzer tile, World world);
                        }
                        
                        

                        AnalyzerTestRecipe, c’est juste une classe pour te monter comment modifier tes valeurs :

                        package fr.scarex.st17.recipe;
                        
                        import java.util.Random;
                        
                        import fr.scarex.st17.tileentity.TileEntityAnalyzer;
                        import net.minecraft.init.Items;
                        import net.minecraft.item.Item;
                        import net.minecraft.item.ItemStack;
                        import net.minecraft.world.World;
                        
                        public class AnalyzerTestRecipe implements IAnalyzerRecipe
                        {
                        public static final Random RNG = new Random();
                        public static final Item[] matrix = new Item[] {
                        Items.apple, // Second slot (car tes slots sont inversés)
                        Items.baked_potato }; // Premier slot
                        
                        @Override
                        public boolean matches(TileEntityAnalyzer tile, World world) {
                        for (int i = 0; i < tile.getSizeInventory(); i++) { // On parcourt tous les slots de l'inventaire de la TileEntity
                        if (!AnalyzerTestRecipe.corresponds(AnalyzerTestRecipe.matrix*, tile.getStackInSlot(i))) return false; // S'ils ne correspondent pas, alors on retourne "faux"
                        }
                        return true; // Sinon on retourne "vrai"
                        }
                        
                        @Override
                        public ItemStack getOutput(TileEntityAnalyzer tile, World world) {
                        return new ItemStack(Items.diamond, RNG.nextInt(30)); // Ici j'utilise un random pour te montrer comment le faire
                        }
                        
                        public static boolean corresponds(Item item, ItemStack stack) {
                        if (stack == null && item == null) return true;
                        if (stack == null && item != null) return false;
                        if (stack != null && item == null) return false;
                        if (stack.getItem() != item) return false;
                        return true;
                        }
                        }
                        
                        

                        La classe AnalyzerSimpleRecipe, elle permet de créer des recettes toutes simples comme tu faisais avant, tu as juste à appeler AnalyzerManager.addRecipe(new AnalyzerSimpleRecipe(tonOutput, taRecette)) :

                        package fr.scarex.st17.recipe;
                        
                        import fr.scarex.st17.tileentity.TileEntityAnalyzer;
                        import net.minecraft.item.ItemStack;
                        import net.minecraft.world.World;
                        
                        public class AnalyzerSimpleRecipe implements IAnalyzerRecipe
                        {
                        private final ItemStack[] recipe;
                        private final ItemStack output;
                        
                        /**
                        * Create a new instance of IAnalyzerRecipe.
                        
                        * Just for simples recipes
                        * @param output the result
                        * @param recipe the recipe
                        */
                        public AnalyzerSimpleRecipe(ItemStack output, ItemStack … recipe) { // Si tu veux faire une recette simple, utilise cette classe
                        this.output = output;
                        this.recipe = recipe;
                        }
                        
                        @Override
                        public boolean matches(TileEntityAnalyzer tile, World world) {
                        for (int i = 0; i < tile.getSizeInventory(); i++) {
                        if (!AnalyzerManager.corresponds(recipe*, tile.getStackInSlot(i))) return false;
                        }
                        return true;
                        }
                        
                        @Override
                        public ItemStack getOutput(TileEntityAnalyzer tile, World world) {
                        return output;
                        }
                        }
                        
                        

                        Si tu as d’autres questions, n’hésite pas.</ianalyzerrecipe></ianalyzerrecipe></ianalyzerrecipe></ianalyzerrecipe>

                        Site web contenant mes scripts : http://SCAREXgaming.github.io

                        Pas de demandes de support par MP ni par skype SVP.
                        Je n'accepte sur skype que l…

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

                          Ok je pense avoir compris le code juste quelques choses que je ne comprend pas c’est :

                          public static ArrayList <ianalyzerrecipe>getRecipes() {
                                 return recipes; // Si tu veux plus de sécurité, tu peux en créer une copie
                             }
                          

                          Comment ca plus de sécurité ?

                          Ensuite pour enregister mes recettes je dois placer ceci alors ?

                          AnalyzerRecipes.initRecipes();
                          

                          Si je fais ca j’ai un crash

                          
                          This crash report has been saved to: C:\Users\Legrandfifou\Pictures\forge\eclipse\.\crash-reports\crash-2015-08-06_21.01.42-server.txt
                          [21:01:42] [Server thread/INFO]: Stopping server
                          [21:01:42] [Server thread/INFO]: Saving players
                          [21:01:42] [Server thread/INFO]: Saving worlds
                          [21:01:42] [Server thread/INFO]: Saving chunks for level 'New World'/Overworld
                          [21:01:42] [Server thread/INFO]: Saving chunks for level 'New World'/Nether
                          [21:01:42] [Server thread/INFO]: Saving chunks for level 'New World'/The End
                          [21:01:42] [Server thread/INFO] [FML]: Unloading dimension 0
                          [21:01:42] [Server thread/INFO] [FML]: Unloading dimension -1
                          [21:01:42] [Server thread/INFO] [FML]: Unloading dimension 1
                          [21:01:42] [Server thread/INFO] [FML]: Applying holder lookups
                          [21:01:42] [Server thread/INFO] [FML]: Holder lookups applied
                          [21:01:42] [Server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded.
                          [21:01:43] [Client thread/FATAL]: Reported exception thrown!
                          net.minecraft.util.ReportedException: Ticking block entity
                          at net.minecraft.world.World.updateEntities(World.java:2175) ~[World.class:?]
                          at net.minecraft.client.Minecraft.runTick(Minecraft.java:2097) ~[Minecraft.class:?]
                          at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039) ~[Minecraft.class:?]
                          at net.minecraft.client.Minecraft.run(Minecraft.java:962) [Minecraft.class:?]
                          at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]
                          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_75]
                          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_75]
                          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_75]
                          at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_75]
                          at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]
                          at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]
                          at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]
                          at GradleStart.main(Unknown Source) [start/:?]
                          Caused by: java.lang.ArrayIndexOutOfBoundsException: 2
                          at mod.common.block.AnalyzerSimpleRecipe.matches(AnalyzerSimpleRecipe.java:22) ~[AnalyzerSimpleRecipe.class:?]
                          at mod.common.block.AnalyzerRecipes.getOutput(AnalyzerRecipes.java:24) ~[AnalyzerRecipes.class:?]
                          at mod.common.block.entity.TileEntityAnalyzer.canSmelt(TileEntityAnalyzer.java:164) ~[TileEntityAnalyzer.class:?]
                          at mod.common.block.entity.TileEntityAnalyzer.updateEntity(TileEntityAnalyzer.java:181) ~[TileEntityAnalyzer.class:?]
                          at net.minecraft.world.World.updateEntities(World.java:2160) ~[World.class:?]
                          … 12 more
                          [21:01:43] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: –-- Minecraft Crash Report ----
                          // This is a token for 1 free hug. Redeem at your nearest Mojangsta: [~~HUG~~]
                          
                          Time: 6/08/15 21:01
                          Description: Ticking block entity
                          
                          java.lang.ArrayIndexOutOfBoundsException: 2
                          at mod.common.block.AnalyzerSimpleRecipe.matches(AnalyzerSimpleRecipe.java:22)
                          at mod.common.block.AnalyzerRecipes.getOutput(AnalyzerRecipes.java:24)
                          at mod.common.block.entity.TileEntityAnalyzer.canSmelt(TileEntityAnalyzer.java:164)
                          at mod.common.block.entity.TileEntityAnalyzer.updateEntity(TileEntityAnalyzer.java:181)
                          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)
                          
                          A detailed walkthrough of the error, its code path and all known details is as follows:
                          –-------------------------------------------------------------------------------------
                          
                          -- Head --
                          Stacktrace:
                          at mod.common.block.AnalyzerSimpleRecipe.matches(AnalyzerSimpleRecipe.java:22)
                          at mod.common.block.AnalyzerRecipes.getOutput(AnalyzerRecipes.java:24)
                          at mod.common.block.entity.TileEntityAnalyzer.canSmelt(TileEntityAnalyzer.java:164)
                          at mod.common.block.entity.TileEntityAnalyzer.updateEntity(TileEntityAnalyzer.java:181)
                          
                          -- Block entity being ticked --
                          Details:
                          Name: entity_analyzer // mod.common.block.entity.TileEntityAnalyzer
                          Block type: ID #165 (tile.blockAnalyzer // mod.common.block.BlockAnalyzer)
                          Block data value: 2 / 0x2 / 0b0010
                          Block location: World: (-160,67,304), Chunk: (at 0,4,0 in -10,19; contains blocks -160,0,304 to -145,255,319), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
                          Actual block type: ID #165 (tile.blockAnalyzer // mod.common.block.BlockAnalyzer)
                          Actual block data value: 2 / 0x2 / 0b0010
                          Stacktrace:
                          at net.minecraft.world.World.updateEntities(World.java:2160)
                          
                          -- Affected level --
                          Details:
                          Level name: MpServer
                          All players: 1 total; [EntityClientPlayerMP['Player734'/209, l='MpServer', x=-161,14, y=68,62, z=306,95]]
                          Chunk stats: MultiplayerChunkCache: 613, 613
                          Level seed: 0
                          Level generator: ID 00 - default, ver 1\. Features enabled: false
                          Level generator options:
                          Level spawn location: World: (244,64,228), Chunk: (at 4,4,4 in 15,14; contains blocks 240,0,224 to 255,255,239), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
                          Level time: 47015 game time, 47015 day time
                          Level dimension: 0
                          Level storage version: 0x00000 - Unknown?
                          Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
                          Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
                          Forced entities: 118 total; [EntitySkeleton['Skeleton'/273, l='MpServer', x=-115,50, y=39,00, z=321,50], EntitySheep['Sheep'/279, l='MpServer', x=-156,47, y=69,00, z=352,97], EntitySheep['Sheep'/277, l='MpServer', x=-148,50, y=73,00, z=357,72], EntitySquid['Squid'/283, l='MpServer', x=-204,75, y=54,66, z=357,31], EntitySquid['Squid'/285, l='MpServer', x=-195,13, y=57,19, z=357,66], EntitySquid['Squid'/259, l='MpServer', x=-208,94, y=56,38, z=321,97], EntitySquid['Squid'/257, l='MpServer', x=-208,25, y=57,00, z=319,50], EntityBat['Bat'/263, l='MpServer', x=-177,31, y=26,81, z=264,31], EntitySheep['Sheep'/264, l='MpServer', x=-186,97, y=64,00, z=269,03], EntitySkeleton['Skeleton'/270, l='MpServer', x=-118,50, y=39,00, z=321,50], EntitySpider['Spider'/306, l='MpServer', x=-201,06, y=24,11, z=271,66], EntitySpider['Spider'/312, l='MpServer', x=-121,28, y=69,00, z=340,84], EntitySpider['Spider'/314, l='MpServer', x=-120,94, y=69,00, z=337,91], EntitySheep['Sheep'/318, l='MpServer', x=-128,50, y=71,00, z=353,91], EntitySquid['Squid'/288, l='MpServer', x=-194,81, y=59,34, z=363,69], EntitySquid['Squid'/292, l='MpServer', x=-209,78, y=59,34, z=353,97], EntitySquid['Squid'/294, l='MpServer', x=-207,75, y=58,31, z=340,81], EntitySquid['Squid'/296, l='MpServer', x=-211,19, y=53,28, z=354,09], EntitySquid['Squid'/298, l='MpServer', x=-208,50, y=55,28, z=347,53], EntityBat['Bat'/343, l='MpServer', x=-94,84, y=30,99, z=299,09], EntitySkeleton['Skeleton'/342, l='MpServer', x=-144,38, y=64,00, z=243,91], EntityBat['Bat'/341, l='MpServer', x=-235,72, y=22,74, z=288,75], EntitySpider['Spider'/340, l='MpServer', x=-101,09, y=65,00, z=306,00], EntityCreeper['Creeper'/339, l='MpServer', x=-101,50, y=52,00, z=307,50], EntitySquid['Squid'/351, l='MpServer', x=-208,75, y=55,31, z=360,13], EntityCreeper['Creeper'/350, l='MpServer', x=-219,50, y=19,00, z=364,50], EntityZombie['Zombie'/349, l='MpServer', x=-157,94, y=25,00, z=382,59], EntitySkeleton['Skeleton'/348, l='MpServer', x=-156,44, y=25,00, z=383,53], EntitySkeleton['Skeleton'/347, l='MpServer', x=-107,13, y=42,00, z=322,63], EntityBat['Bat'/346, l='MpServer', x=-106,97, y=40,12, z=305,31], EntityBat['Bat'/345, l='MpServer', x=-108,34, y=38,00, z=311,78], EntityBat['Bat'/344, l='MpServer', x=-94,66, y=31,15, z=297,84], EntityCreeper['Creeper'/635, l='MpServer', x=-127,50, y=40,00, z=309,50], EntityCreeper['Creeper'/634, l='MpServer', x=-124,69, y=40,00, z=310,92], EntityCreeper['Creeper'/633, l='MpServer', x=-124,11, y=40,00, z=309,99], EntityCreeper['Creeper'/636, l='MpServer', x=-122,75, y=40,00, z=311,13], EntityCreeper['Creeper'/373, l='MpServer', x=-188,72, y=63,00, z=244,47], EntityCreeper['Creeper'/375, l='MpServer', x=-87,50, y=51,00, z=298,50], EntitySpider['Spider'/374, l='MpServer', x=-150,41, y=63,00, z=237,34], EntityCreeper['Creeper'/368, l='MpServer', x=-166,50, y=33,00, z=384,50], EntityZombie['Zombie'/381, l='MpServer', x=-89,50, y=14,00, z=342,50], EntityZombie['Zombie'/380, l='MpServer', x=-193,50, y=63,00, z=238,50], EntityBat['Bat'/383, l='MpServer', x=-91,22, y=25,27, z=342,84], EntityZombie['Zombie'/382, l='MpServer', x=-94,50, y=25,00, z=349,50], EntitySpider['Spider'/379, l='MpServer', x=-192,00, y=63,00, z=235,00], EntitySkeleton['Skeleton'/378, l='MpServer', x=-192,94, y=63,00, z=228,53], EntitySkeleton['Skeleton'/356, l='MpServer', x=-108,38, y=14,00, z=337,94], EntityCow['Cow'/357, l='MpServer', x=-139,78, y=69,00, z=378,38], EntitySheep['Sheep'/352, l='MpServer', x=-126,50, y=71,00, z=352,50], EntitySheep['Sheep'/353, l='MpServer', x=-125,09, y=69,00, z=365,94], EntityBat['Bat'/354, l='MpServer', x=-236,03, y=20,91, z=284,19], EntityBat['Bat'/355, l='MpServer', x=-102,16, y=28,00, z=289,72], EntityCreeper['Creeper'/364, l='MpServer', x=-98,41, y=69,00, z=365,97], EntityCow['Cow'/365, l='MpServer', x=-126,91, y=72,00, z=374,78], EntityZombie['Zombie'/366, l='MpServer', x=-118,50, y=70,00, z=377,50], EntityZombie['Zombie'/367, l='MpServer', x=-112,50, y=72,00, z=379,50], EntitySpider['Spider'/360, l='MpServer', x=-130,41, y=67,00, z=245,30], EntityZombie['Zombie'/361, l='MpServer', x=-99,50, y=63,00, z=265,50], EntityCreeper['Creeper'/362, l='MpServer', x=-95,03, y=15,00, z=305,47], EntityBat['Bat'/363, l='MpServer', x=-107,81, y=32,37, z=367,75], EntitySkeleton['Skeleton'/395, l='MpServer', x=-86,50, y=66,00, z=355,50], EntitySkeleton['Skeleton'/394, l='MpServer', x=-82,50, y=65,00, z=353,50], EntityZombie['Zombie'/393, l='MpServer', x=-121,13, y=64,00, z=230,25], EntityCreeper['Creeper'/396, l='MpServer', x=-93,50, y=68,00, z=366,50], EntityCow['Cow'/385, l='MpServer', x=-137,53, y=68,00, z=386,41], EntityBat['Bat'/432, l='MpServer', x=-235,25, y=37,10, z=238,25], EntityBat['Bat'/433, l='MpServer', x=-229,25, y=38,03, z=235,72], EntitySkeleton['Skeleton'/434, l='MpServer', x=-102,50, y=64,00, z=234,50], EntitySkeleton['Skeleton'/641, l='MpServer', x=-123,34, y=40,00, z=308,72], EntityCreeper['Creeper'/431, l='MpServer', x=-226,69, y=41,00, z=228,34], EntitySquid['Squid'/220, l='MpServer', x=-181,06, y=55,34, z=330,75], EntitySquid['Squid'/221, l='MpServer', x=-188,78, y=58,19, z=338,63], EntitySquid['Squid'/222, l='MpServer', x=-183,09, y=59,19, z=333,66], EntitySkeleton['Skeleton'/460, l='MpServer', x=-95,16, y=64,00, z=235,91], EntitySquid['Squid'/223, l='MpServer', x=-213,19, y=61,34, z=319,06], EntitySkeleton['Skeleton'/459, l='MpServer', x=-95,53, y=64,00, z=236,88], EntitySheep['Sheep'/216, l='MpServer', x=-164,19, y=67,00, z=310,56], EntitySquid['Squid'/217, l='MpServer', x=-185,19, y=61,38, z=330,47], EntitySquid['Squid'/218, l='MpServer', x=-193,84, y=57,13, z=332,41], EntitySquid['Squid'/219, l='MpServer', x=-183,91, y=58,10, z=324,19], EntityZombie['Zombie'/212, l='MpServer', x=-172,06, y=36,00, z=301,59], EntitySkeleton['Skeleton'/213, l='MpServer', x=-171,50, y=62,00, z=294,97], EntityClientPlayerMP['Player734'/209, l='MpServer', x=-161,14, y=68,62, z=306,95], EntityZombie['Zombie'/215, l='MpServer', x=-173,69, y=65,48, z=289,38], EntityBat['Bat'/210, l='MpServer', x=-165,50, y=45,10, z=301,50], EntityZombie['Zombie'/211, l='MpServer', x=-174,34, y=40,00, z=301,09], EntitySquid['Squid'/239, l='MpServer', x=-208,69, y=53,75, z=347,91], EntitySquid['Squid'/238, l='MpServer', x=-200,69, y=56,09, z=344,22], EntitySquid['Squid'/237, l='MpServer', x=-208,53, y=60,38, z=342,06], EntitySquid['Squid'/236, l='MpServer', x=-200,69, y=51,34, z=349,84], EntityBat['Bat'/235, l='MpServer', x=-152,25, y=57,10, z=282,34], EntityBat['Bat'/234, l='MpServer', x=-151,28, y=56,10, z=278,72], EntitySheep['Sheep'/233, l='MpServer', x=-187,75, y=66,00, z=287,41], EntitySheep['Sheep'/232, l='MpServer', x=-184,91, y=68,00, z=288,91], EntitySquid['Squid'/231, l='MpServer', x=-203,28, y=59,31, z=333,78], EntitySquid['Squid'/230, l='MpServer', x=-202,53, y=59,13, z=320,28], EntitySquid['Squid'/229, l='MpServer', x=-179,25, y=58,31, z=339,44], EntitySquid['Squid'/228, l='MpServer', x=-169,47, y=57,00, z=343,25], EntitySheep['Sheep'/227, l='MpServer', x=-172,41, y=71,00, z=275,13], EntitySquid['Squid'/226, l='MpServer', x=-185,65, y=56,53, z=307,21], EntitySquid['Squid'/225, l='MpServer', x=-205,66, y=61,38, z=317,75], EntitySquid['Squid'/224, l='MpServer', x=-196,56, y=58,34, z=316,75], EntitySquid['Squid'/254, l='MpServer', x=-186,66, y=60,34, z=362,84], EntitySquid['Squid'/255, l='MpServer', x=-188,94, y=60,34, z=360,53], EntitySquid['Squid'/252, l='MpServer', x=-187,69, y=56,31, z=361,91], EntitySquid['Squid'/253, l='MpServer', x=-192,22, y=55,13, z=353,19], EntitySheep['Sheep'/250, l='MpServer', x=-162,50, y=71,00, z=363,72], EntitySheep['Sheep'/251, l='MpServer', x=-163,75, y=70,00, z=359,63], EntityBat['Bat'/248, l='MpServer', x=-114,75, y=37,09, z=316,34], EntityBat['Bat'/249, l='MpServer', x=-113,72, y=39,74, z=317,06], EntitySquid['Squid'/246, l='MpServer', x=-209,72, y=60,38, z=313,66], EntitySkeleton['Skeleton'/247, l='MpServer', x=-114,56, y=37,00, z=316,03], EntitySheep['Sheep'/244, l='MpServer', x=-136,75, y=73,00, z=345,63], EntitySquid['Squid'/245, l='MpServer', x=-207,94, y=59,09, z=320,19], EntitySheep['Sheep'/242, l='MpServer', x=-205,06, y=64,00, z=279,03], EntitySheep['Sheep'/243, l='MpServer', x=-139,44, y=75,00, z=337,34], EntitySheep['Sheep'/240, l='MpServer', x=-191,17, y=64,00, z=279,39], EntitySheep['Sheep'/241, l='MpServer', x=-196,16, y=64,00, z=287,09]]
                          Retry entities: 0 total; []
                          Server brand: fml,forge
                          Server type: Integrated singleplayer server
                          Stacktrace:
                          at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:415)
                          at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2566)
                          at net.minecraft.client.Minecraft.run(Minecraft.java:984)
                          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)
                          
                          – System Details --
                          Details:
                          Minecraft Version: 1.7.10
                          Operating System: Windows 8.1 (amd64) version 6.3
                          Java Version: 1.7.0_75, Oracle Corporation
                          Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
                          Memory: 756458592 bytes (721 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
                          JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
                          AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
                          IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95
                          FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1448 4 mods loaded, 4 mods active
                          States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
                          UCHIJAAAA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar)
                          UCHIJAAAA FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1448-1.7.10.jar)
                          UCHIJAAAA Forge{10.13.4.1448} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1448-1.7.10.jar)
                          UCHIJAAAA modminecraft{1.0} [Mod Minecraft] (bin)
                          GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 353.62' Renderer: 'GeForce GTX 770/PCIe/SSE2'
                          Launched Version: 1.7.10
                          LWJGL: 2.9.1
                          OpenGL: GeForce GTX 770/PCIe/SSE2 GL version 4.5.0 NVIDIA 353.62, NVIDIA Corporation
                          GL Caps: Using GL 1.3 multitexturing.
                          Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
                          Anisotropic filtering is supported and maximum anisotropy is 16.
                          Shaders are available because OpenGL 2.1 is supported.
                          
                          Is Modded: Definitely; Client brand changed to 'fml,forge'
                          Type: Client (map_client.txt)
                          Resource Packs: []
                          Current Language: English (US)
                          Profiler Position: N/A (disabled)
                          Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
                          Anisotropic Filtering: Off (1)
                          [21:01:43] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:398]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\Legrandfifou\Pictures\forge\eclipse\.\crash-reports\crash-2015-08-06_21.01.43-client.txt
                          AL lib: (EE) alc_cleanup: 1 device not closed
                          

                          J’ai un BoundOfException je suppose que c’est la taille de l’inventaire ?

                          Voici du coup les classes qu’il me reste

                          package mod.common.block.entity;
                          
                          import cpw.mods.fml.relauncher.Side;
                          import cpw.mods.fml.relauncher.SideOnly;
                          import mod.common.block.AnalyzerRecipes;
                          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 TileEntityAnalyzer extends TileEntity implements IInventory
                          {
                              private ItemStack[] contents = new ItemStack[4];
                          
                              private int workingTime = 1999;
                              private int workingTimeNeeded = 256;
                          
                              @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* != null) {
                                          NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                                          nbttagcompound1.setByte("Slot", (byte) i);
                                          this.contents*.writeToNBT(nbttagcompound1);
                                          nbttaglist.appendTag(nbttagcompound1);
                                      }
                                  }
                          
                                  compound.setTag("Items", nbttaglist);
                                  compound.setShort("workingTime", (short) this.workingTime);
                          
                                  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)
                          
                                  {
                                      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");
                          
                                  this.workingTimeNeeded = compound.getShort("workingTimeNeeded");
                              }
                          
                              @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) {
                                      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;
                                  }
                              }
                          
                              @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 void setInventorySlotContents(int slotIndex, ItemStack stack) {
                                  this.contents[slotIndex] = stack;
                          
                                  if (stack != null && stack.stackSize > this.getInventoryStackLimit()) {
                                      stack.stackSize = this.getInventoryStackLimit();
                                  }
                          
                                  this.markDirty();
                              }
                          
                              @Override
                              public String getInventoryName() {
                                  return "tile.BlockAnalyzer";
                              }
                          
                              @Override
                              public boolean hasCustomInventoryName() {
                                  return false;
                              }
                          
                              @Override
                              public int getInventoryStackLimit() {
                                  return 64;
                              }
                          
                              @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 == 2 ? false : true;
                              }
                          
                              public boolean isBurning() {
                                  return this.workingTime > 0;
                              }
                          
                              private boolean canSmelt() {
                                  if (this.contents[0] == null || this.contents[1] == null) {
                                      return false;
                                  } else {
                                      ItemStack itemstack = AnalyzerRecipes.getOutput(this); // On récupère le recipe avec AnalyzerManager qui est une classe pour t'aider
                          
                                      if (itemstack == null) return false;
                                      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();
                                  }
                              }
                          
                              @Override
                              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 = AnalyzerRecipes.getOutput(this); // On récupère le recipe
                                      if (this.contents[2] == null) {
                                          this.contents[2] = itemstack.copy();
                                      } else if (this.contents[2].getItem() == itemstack.getItem()) {
                                          this.contents[2].stackSize += itemstack.stackSize;
                                      }
                          
                                      –this.contents[0].stackSize;
                                      –this.contents[1].stackSize;
                          
                                      if (this.contents[0].stackSize <= 0) {
                                          this.contents[0] = null;
                                      }
                                      if (this.contents[1].stackSize <= 0) {
                                          this.contents[1] = null;
                                      }
                          
                                  }
                              }
                          
                              @SideOnly(Side.CLIENT)
                              public int getCookProgress() {
                                  return this.workingTime * 33 / this.workingTimeNeeded;
                              }
                          }
                          
                          
                          package mod.common.block;
                          
                          import java.util.ArrayList;
                          import java.util.Collections;
                          import java.util.HashMap;
                          import java.util.Iterator;
                          import java.util.ListIterator;
                          import mod.common.block.entity.TileEntityAnalyzer;
                          import net.minecraft.item.ItemStack;
                          
                          public class AnalyzerRecipes
                          {
                              private static ArrayList <ianalyzerrecipe>recipes = new ArrayList<ianalyzerrecipe>();
                          
                              /**
                               * @param stacks tile content
                               * @return the recipe output
                               */
                              public static ItemStack getOutput(TileEntityAnalyzer tile, ItemStack … stacks) {
                                  ListIterator <ianalyzerrecipe>ite = recipes.listIterator();
                                  while (ite.hasNext()) {
                                      IAnalyzerRecipe r = ite.next();
                                      if (r.matches(tile, tile.getWorldObj())) return r.getOutput(tile, tile.getWorldObj()); // Si le recipe correspond, on récupère l'output
                                  }
                                  return null;
                              }
                          
                              /**
                               * @return the recipe map
                               */
                              public static ArrayList <ianalyzerrecipe>getRecipes() {
                                  return recipes; // Si tu veux plus de sécurité, tu peux en créer une copie
                              }
                          
                              /**
                               * init your recipes (called from your main class)
                               */
                              public static void initRecipes() { // C'est là que tu dois initialiser tes recettes (appelle cette fonction depuis ta classe principale)
                                  AnalyzerRecipes.addRecipe(new AnalyzerSimpleRecipe()); 
                              }
                          
                              /**
                               * @param recipe
                               */
                              public static void addRecipe(IAnalyzerRecipe recipe) {
                                  recipes.add(recipe);
                              }
                          
                              /**
                               * @param stack first stack
                               * @param stack1 second stack
                               * @return true if the 2 stacks are equals
                               */
                              public static boolean corresponds(ItemStack stack, ItemStack stack1) {
                                  if (stack == null && stack1 == null) return true;
                                  if (stack == null && stack1 != null) return false;
                                  if (stack != null && stack1 == null) return false;
                                  if (stack.getItem() != stack1.getItem()) return false;
                                  if (stack.getItemDamage() != stack1.getItemDamage()) return false;
                                  return true;
                              }
                          }
                          
                          
                          package mod.common.block;
                          
                          import java.util.Random;
                          
                          import mod.common.block.entity.TileEntityAnalyzer;
                          import mod.common.item.ItemRegister;
                          import net.minecraft.init.Items;
                          import net.minecraft.item.Item;
                          import net.minecraft.item.ItemStack;
                          import net.minecraft.world.World;
                          
                          public class AnalyzerSimpleRecipe implements IAnalyzerRecipe
                          {
                              public static final Random RNG = new Random();
                              public static final Item[] matrix = new Item[] {
                                      ItemRegister.itemADNofFrog, // Second slot (car tes slots sont inversés)
                                      ItemRegister.itemSevewithmosquito }; // Premier slot
                          
                              @Override
                              public boolean matches(TileEntityAnalyzer tile, World world) {
                                  for (int i = 0; i < tile.getSizeInventory(); i++) { // On parcourt tous les slots de l'inventaire de la TileEntity
                                      if (!AnalyzerSimpleRecipe.corresponds(AnalyzerSimpleRecipe.matrix*, tile.getStackInSlot(i))) return false; // S'ils ne correspondent pas, alors on retourne "faux"
                                  }
                                  return true; // Sinon on retourne "vrai"
                              }
                          
                              @Override
                              public ItemStack getOutput(TileEntityAnalyzer tile, World world) {
                                  return new ItemStack(ItemRegister.itemAmbre, RNG.nextInt(30)); // Ici j'utilise un random pour te montrer comment le faire
                              }
                          
                              public static boolean corresponds(Item item, ItemStack stack) {
                                  if (stack == null && item == null) return true;
                                  if (stack == null && item != null) return false;
                                  if (stack != null && item == null) return false;
                                  if (stack.getItem() != item) return false;
                                  return true;
                              }
                          }
                          

                          Si tu as le temps de vérif pour voir si j’ai pas fait de fautes ^^</ianalyzerrecipe></ianalyzerrecipe></ianalyzerrecipe></ianalyzerrecipe></ianalyzerrecipe>

                          Oui ce gif est drôle.

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

                            Correction : dans les méthodes matches, tu dois pas avoir tile.getSizeInventory() mais 2. La méthode Analyzer.initRecipes est un méthode pour organiser, tu as juste à l’appeler depuis ta classe principale.

                            Pour l’histoire de sécurité : c’est si tu veux pas que les gens qui créent des mods dépendant du tient puissent modifier cette liste, mais c’est secondaire.

                            Site web contenant mes scripts : http://SCAREXgaming.github.io

                            Pas de demandes de support par MP ni par skype SVP.
                            Je n'accepte sur skype que l…

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

                              Oké donc la ce que j’ai mis ne sert a rien alors ^^ ?

                              Pour le random si je comprend il sélectionne un valeur de 1 à 30 et ca correspond aux nombres qu’il en donne , par contre moi j’aimerais que ca sélectionne random un des egg , je dois faire comment , car le random dois sélectionner entre plusieurs eggs différent ^^

                              Ah si ce n’est que ca ce n’est pas grave justement ca permettera des add-ons ^^

                              En tout cas ca marche 😛

                              Oui ce gif est drôle.

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

                                tu dois faire new ItemStack(tonItem, 1, TonRandom.nextInt(leNombreDeMetadatasPossibles)) (attention : l’objet random génère de 0 jusqu’à ton nombre, celui mis en paramètres n’est pas inclus)

                                Site web contenant mes scripts : http://SCAREXgaming.github.io

                                Pas de demandes de support par MP ni par skype SVP.
                                Je n'accepte sur skype que l…

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

                                  Tu es littéralement un dieux , il produit un oeuf différent ( metadata ) , je n’aurais plus que dans la prochaine machine a vérifier le metadata et donner un egg en fonction de ca 😄

                                  Par contre en créant le metadata , les particules on buggé j’avais bien mis ca :

                                  .setBlockTextureName(ModMinecraft.MODID + ":partEgg");
                                  

                                  Voici mes metadatas :

                                  BlockEgg

                                  
                                  package mod.common.block;
                                  
                                  import java.util.List;
                                  import java.util.Random;
                                  
                                  import cpw.mods.fml.relauncher.Side;
                                  import cpw.mods.fml.relauncher.SideOnly;
                                  import mod.ModMinecraft;
                                  import mod.client.ClientProxy;
                                  import mod.common.block.entity.TileEntityBarriere;
                                  import mod.common.block.entity.TileEntityEgg;
                                  import net.minecraft.block.Block;
                                  import net.minecraft.block.BlockFalling;
                                  import net.minecraft.block.material.Material;
                                  import net.minecraft.client.renderer.texture.IIconRegister;
                                  import net.minecraft.creativetab.CreativeTabs;
                                  import net.minecraft.entity.Entity;
                                  import net.minecraft.entity.EntityLivingBase;
                                  import net.minecraft.entity.item.EntityFallingBlock;
                                  import net.minecraft.item.Item;
                                  import net.minecraft.item.ItemStack;
                                  import net.minecraft.tileentity.TileEntity;
                                  import net.minecraft.util.AxisAlignedBB;
                                  import net.minecraft.util.DamageSource;
                                  import net.minecraft.util.IIcon;
                                  import net.minecraft.util.MathHelper;
                                  import net.minecraft.world.IBlockAccess;
                                  import net.minecraft.world.World;
                                  
                                  public class BlockEgg extends Block
                                  
                                  {
                                  
                                  // METADATA
                                  
                                  public static String[] subBlock = new String[] {"egg1", "egg2", "egg3", "egg4"};
                                  public IIcon[] iconArray = new IIcon[subBlock.length];
                                  
                                  public BlockEgg()
                                  {
                                  super(Material.dragonEgg);
                                  }
                                  
                                  public void registerBlockIcons(IIconRegister iconRegister)
                                  {
                                  for(int i = 0; i < subBlock.length; i++)
                                  {
                                  this.iconArray[ i] = iconRegister.registerIcon(ModMinecraft.MODID + ":" + subBlock*);
                                  }
                                  }
                                  
                                  public IIcon getIcon(int side, int metadata)
                                  {
                                  if(metadata >= 0 && metadata < subBlock.length)
                                  {
                                  return this.iconArray[metadata];
                                  }
                                  return this.iconArray[0];
                                  }
                                  
                                  public int damageDropped(int metadata)
                                  {
                                  return metadata;
                                  }
                                  
                                  //RESTE DU CODE
                                  
                                  public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack) {
                                  int direction = MathHelper.floor_double(living.rotationYaw * 4.0F / 360.0F + 2.5D) & 0x3;
                                  TileEntity te = world.getTileEntity(x, y, z);
                                  if ((te instanceof TileEntityEgg))
                                  {
                                  ((TileEntityEgg)te).setDirection((byte)direction);
                                  world.markBlockForUpdate(x, y, z);
                                  }
                                  }
                                  
                                  protected BlockEgg(Material material) {
                                  super(material);
                                  this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.8000F, 1.0F, 0.8000F);
                                  }
                                  
                                  public void onBlockAdded(World world, int x, int y, int z)
                                  {
                                  world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world));
                                  }
                                  
                                  public void onNeighborBlockChange(World world, int x, int y, int z, Block block)
                                  {
                                  world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world));
                                  }
                                  
                                  public void updateTick(World world, int x, int y, int z, Random random)
                                  {
                                  this.func_150018_e(world, x, y, z);
                                  }
                                  
                                  private void func_150018_e(World world, int x, int y, int z)
                                  {
                                  if (BlockFalling.func_149831_e(world, x, y - 1, z) && y >= 0)
                                  {
                                  byte b0 = 32;
                                  
                                  if (!BlockFalling.fallInstantly && world.checkChunksExist(x - b0, y - b0, z - b0, x + b0, y + b0, z + b0))
                                  {
                                  EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float) z + 0.5F), this);
                                  world.spawnEntityInWorld(entityfallingblock);
                                  }
                                  else
                                  {
                                  world.setBlockToAir(x, y, z);
                                  
                                  while (BlockFalling.func_149831_e(world, x, y - 1, z) && y > 0)
                                  {
                                  –y;
                                  }
                                  
                                  if (y > 0)
                                  {
                                  world.setBlock(x, y, z, this, 0, 2);
                                  }
                                  }
                                  }
                                  }
                                  
                                  public int tickRate(World world)
                                  {
                                  return 5;
                                  }
                                  
                                  @SideOnly(Side.CLIENT)
                                  public Item getItem(World world, int x, int y, int z)
                                  {
                                  return null;
                                  }
                                  
                                  @SideOnly(Side.CLIENT)
                                  public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_)
                                  {
                                  return true;
                                  }
                                  
                                  /* private void func_149830_m(World world, int x, int y, int z)
                                  {
                                  if (func_149831_e(world, x, y - 1, z) && y >= 0)
                                  {
                                  byte b0 = 32;
                                  
                                  if (!fallInstantly &&world.checkChunksExist(x - b0, y - b0, z - b0, x + b0, z + b0, z + b0))
                                  {
                                  if (!world.isRemote)
                                  {
                                  EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double)((float)x + 0.5F), (double)((float)z + 0.5F), (double)((float)z + 0.5F), this, world.getBlockMetadata(x, y, z));
                                  this.func_149829_a(entityfallingblock);
                                  world.spawnEntityInWorld(entityfallingblock);
                                  }
                                  }
                                  else
                                  {
                                  world.setBlockToAir(x, y, z);
                                  
                                  while (func_149831_e(world, x, y - 1, z) && y > 0)
                                  {
                                  --y;
                                  }
                                  
                                  if (y > 0)
                                  {
                                  world.setBlock(x, y, z, this);
                                  }
                                  }
                                  }
                                  }*/
                                  
                                  protected void func_149829_a(EntityFallingBlock entityfallingblock) {}
                                  
                                  @Override
                                  public TileEntity createTileEntity(World world, int metadata)
                                  {
                                  if(metadata == 0)
                                  {
                                  return new TileEntityEgg();
                                  }
                                  else if(metadata == 1)
                                  {
                                  return new TileEntityEgg();
                                  }
                                  else if(metadata == 2)
                                  {
                                  return new TileEntityEgg();
                                  }
                                  return null;
                                  }
                                  
                                  @Override
                                  public boolean hasTileEntity(int metadata)
                                  {
                                  if(metadata >= 0 && metadata <= 2)
                                  return true;
                                  return false;
                                  }
                                  public boolean isOpaqueCube()
                                  {
                                  return false;
                                  }
                                  
                                  public boolean renderAsNormalBlock()
                                  {
                                  return false;
                                  }
                                  
                                  public int getRenderType()
                                  {
                                  return ClientProxy.tesrRenderId; }
                                  
                                  }
                                  
                                  

                                  ItemBlockEgg

                                  
                                  package mod.common.block;
                                  
                                  import cpw.mods.fml.relauncher.Side;
                                  import cpw.mods.fml.relauncher.SideOnly;
                                  import net.minecraft.block.Block;
                                  import net.minecraft.item.ItemBlock;
                                  import net.minecraft.item.ItemStack;
                                  import net.minecraft.util.IIcon;
                                  
                                  public class ItemBlockEgg extends ItemBlock
                                  {
                                  public ItemBlockEgg(Block block)
                                  {
                                  super(block);
                                  this.setMaxDamage(0);
                                  this.setHasSubtypes(true);
                                  }
                                  
                                  public int getMetadata(int metadata)
                                  {
                                  return metadata;
                                  }
                                  
                                  @SideOnly(Side.CLIENT)
                                  public IIcon getIconFromDamage(int metadata)
                                  {
                                  return this.field_150939_a.getIcon(2, metadata);
                                  }
                                  
                                  public String getUnlocalizedName(ItemStack stack)
                                  {
                                  int metadata = stack.getItemDamage();
                                  if(metadata < 0 || metadata >= BlockEgg.subBlock.length)
                                  {
                                  metadata = 0;
                                  }
                                  return super.getUnlocalizedName() + "." + BlockEgg.subBlock[metadata];
                                  }
                                  }
                                  
                                  

                                  Aussi je peut ajouter une nouvelle recette ?

                                  
                                  public static final Item[] matrix = new Item[]
                                  {
                                  ItemRegister.itemADNofFrog,
                                  ItemRegister.itemSevewithmosquito
                                  };
                                  
                                  

                                  Je suppose que je dois l’add ici mais comment ?

                                  Oui ce gif est drôle.

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

                                    Essaie de clarifier ton code, car tu as un constructeur au début, tu en as un après 4 méthodes, tu as une fonction qui n’est utilisée que par les BlockFalling, et le code dans ta fonction getTileEntity est inutile.

                                    Site web contenant mes scripts : http://SCAREXgaming.github.io

                                    Pas de demandes de support par MP ni par skype SVP.
                                    Je n'accepte sur skype que l…

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

                                      BlockEgg clarifier 😄

                                      
                                      package mod.common.block;
                                      
                                      import java.util.List;
                                      import java.util.Random;
                                      
                                      import cpw.mods.fml.relauncher.Side;
                                      import cpw.mods.fml.relauncher.SideOnly;
                                      import mod.ModMinecraft;
                                      import mod.client.ClientProxy;
                                      import mod.common.block.entity.TileEntityAnalyzer;
                                      import mod.common.block.entity.TileEntityBarriere;
                                      import mod.common.block.entity.TileEntityEgg;
                                      import net.minecraft.block.Block;
                                      import net.minecraft.block.BlockFalling;
                                      import net.minecraft.block.material.Material;
                                      import net.minecraft.client.renderer.texture.IIconRegister;
                                      import net.minecraft.creativetab.CreativeTabs;
                                      import net.minecraft.entity.Entity;
                                      import net.minecraft.entity.EntityLivingBase;
                                      import net.minecraft.entity.item.EntityFallingBlock;
                                      import net.minecraft.item.Item;
                                      import net.minecraft.item.ItemStack;
                                      import net.minecraft.tileentity.TileEntity;
                                      import net.minecraft.util.AxisAlignedBB;
                                      import net.minecraft.util.DamageSource;
                                      import net.minecraft.util.IIcon;
                                      import net.minecraft.util.MathHelper;
                                      import net.minecraft.world.IBlockAccess;
                                      import net.minecraft.world.World;
                                      
                                      public class BlockEgg extends Block
                                      
                                      {
                                      
                                      // METADATA
                                      
                                      public static String[] subBlock = new String[] {"egg1", "egg2", "egg3", "egg4"};
                                      public IIcon[] iconArray = new IIcon[subBlock.length];
                                      
                                      public void registerBlockIcons(IIconRegister iconRegister)
                                      {
                                      for(int i = 0; i < subBlock.length; i++)
                                      {
                                      this.iconArray[ i] = iconRegister.registerIcon(ModMinecraft.MODID + ":" + subBlock*);
                                      }
                                      }
                                      
                                      public IIcon getIcon(int side, int metadata)
                                      {
                                      if(metadata >= 0 && metadata < subBlock.length)
                                      {
                                      return this.iconArray[metadata];
                                      }
                                      return this.iconArray[0];
                                      }
                                      
                                      public int damageDropped(int metadata)
                                      {
                                      return metadata;
                                      }
                                      
                                      //AJOUT DU TILEENTITY
                                      public BlockEgg()
                                      {
                                      super(Material.dragonEgg);
                                      }
                                      
                                      public boolean isOpaqueCube()
                                      {
                                      return false;
                                      }
                                      
                                      public boolean renderAsNormalBlock()
                                      {
                                      return false;
                                      }
                                      
                                      public int getRenderType()
                                      {
                                      return ClientProxy.tesrRenderId;
                                      }
                                      
                                      @Override
                                      public TileEntity createTileEntity(World world, int metadata)
                                      {
                                      return new TileEntityEgg();
                                      }
                                      
                                      @Override
                                      public boolean hasTileEntity(int metadata)
                                      {
                                      return true;
                                      }
                                      
                                      }
                                      
                                      

                                      J’avais un problème avec le rendu dans le monde de mon block mais j’ai résolu le soucis 😄

                                      Du coup je me demandais car j’ai ajouté des metadatas mais c’est comme si il n’y en avais pas par exemple si je les met dans le tabBlock ca me met #0177 pour chaque y a pas de /2 😕

                                      Oui ce gif est drôle.

                                      1 réponse Dernière réponse Répondre Citer 0
                                      • robin4002R Hors-ligne
                                        robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                                        dernière édition par

                                        Il te manque surement l’item bloc.

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

                                          Je me posais la question car mon blockEgg est un rendu TESR , donc il a un rendu dans l’inventaire dois utiliser celui la ou faire un nouveau j’ai bien fait l’itemBlockEgg je l’ai juste oublier

                                          
                                          package mod.common.block;
                                          
                                          import cpw.mods.fml.relauncher.Side;
                                          import cpw.mods.fml.relauncher.SideOnly;
                                          import net.minecraft.block.Block;
                                          import net.minecraft.item.ItemBlock;
                                          import net.minecraft.item.ItemStack;
                                          import net.minecraft.util.IIcon;
                                          
                                          public class ItemBlockEgg extends ItemBlock
                                          {
                                          public ItemBlockEgg(Block block)
                                          {
                                          super(block);
                                          this.setMaxDamage(0);
                                          this.setHasSubtypes(true);
                                          }
                                          
                                          public int getMetadata(int metadata)
                                          {
                                          return metadata;
                                          }
                                          
                                          @SideOnly(Side.CLIENT)
                                          public IIcon getIconFromDamage(int metadata)
                                          {
                                          return this.field_150939_a.getIcon(2, metadata);
                                          }
                                          
                                          public String getUnlocalizedName(ItemStack stack)
                                          {
                                          int metadata = stack.getItemDamage();
                                          if(metadata < 0 || metadata >= BlockEgg.subBlock.length)
                                          {
                                          metadata = 0;
                                          }
                                          return super.getUnlocalizedName() + "." + BlockEgg.subBlock[metadata];
                                          }
                                          }
                                          
                                          

                                          Oui ce gif est drôle.

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

                                            Il te manque la méthode getSubItems

                                            Site web contenant mes scripts : http://SCAREXgaming.github.io

                                            Pas de demandes de support par MP ni par skype SVP.
                                            Je n'accepte sur skype que l…

                                            1 réponse Dernière réponse Répondre Citer 0
                                            • 1
                                            • 2
                                            • 3
                                            • 1 / 3
                                            • Premier message
                                              Dernier message
                                            Design by Woryk
                                            ContactMentions Légales

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB