MFF

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

    Créer un bloc type four (machine)

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

      C’est difficile d’aller regarder les classes vanilla pour savoir quoi mettre ?

      Si vous souhaitez me faire un don, il vous suffit de cliquer sur le bouton situé en dessous.

      Je suis un membre apprécié et joueur, j'ai déjà obtenu 17 points de réputation.

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

        Étant donné que rien n’est dans les classes vanilla ça risque d’être un peu compliquer

        1 réponse Dernière réponse Répondre Citer 0
        • Superloup10S Hors-ligne
          Superloup10 Modérateurs
          dernière édition par

          Bah si, tu as tout dans les classes vanilla.

          Si vous souhaitez me faire un don, il vous suffit de cliquer sur le bouton situé en dessous.

          Je suis un membre apprécié et joueur, j'ai déjà obtenu 17 points de réputation.

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

            Quand je clique sur le bloc en question sa fait bien l’annimation avec la main comme quoi je l’ai ouvert mais la gui ne s’affiche pas !!

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

              j’ai un souci ici ca me donne cette erreur:

              Cannot invoke writeToNBT(NBTTagCompound) on the array type ItemStack[]
              

              dans la ligne:

              this.contents.writeToNBT(nbttagcompound1);
              

              dans la classe:

              package fr.askipie.funfight;
              
              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;
              import net.minecraftforge.common.util.Constants;
              
              public class TileEntityFungieMachine extends TileEntity implements IInventory
              {
                  
                  private ItemStack[] contents = new ItemStack[4]; //0, 1 et 2 sont les inputs et 3 est l'output
                  
                  private int workingTime = 0; //Temps de cuisson actuel
                  private int workingTimeNeeded = 200; //Temps de cuisson nécessaire
              
                  
                
              
                  @Override
                  public void writeToNBT(NBTTagCompound compound)
                  {
                      super.writeToNBT(compound);
                      NBTTagList nbttaglist = new NBTTagList();
               
                      for (int i = 0; i < this.contents.length; ++i) //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.machineTuto";
                  }
               
                  @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 == 3 ? false : true;
                  }
              
                  public boolean isBurning()
                  {
                      return this.workingTime > 0;
                  }
                  
                  private boolean canSmelt()
                  {
                      if (this.contents[0] == null || this.contents[1] == null || this.contents[2] == null) //Si les trois premiers slots sont vides
                      {
                          return false; //On ne peut pas lancer le processus
                      }
                      else
                      {
                          ItemStack itemstack = FungieMachineRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]}); //Il y a une erreur ici, c'est normal, on y vient après (c'est pour les recettes)
                          if (itemstack == null) return false; //rapport avec les recettes
                          if (this.contents[3] == null) return true; //vérifications du slot d'output
                          if (!this.contents[3].isItemEqual(itemstack)) return false; //ici aussi
                          int result = contents[3].stackSize + itemstack.stackSize;
                          return result <= getInventoryStackLimit() && result <= this.contents[3].getMaxStackSize(); //Et là aussi décidément
                      }
                  }
                  
                  public void updateEntity() //Méthode exécutée à chaque tick
                  {
                      if(this.isBurning() && this.canSmelt()) //Si on "cuit" et que notre recette et toujours bonne, on continue
                      {
                          ++this.workingTime; //incrémentation
                      }
                      if(this.canSmelt() && !this.isBurning()) //Si la recette est bonne mais qu'elle n'est toujours pas lancée, on la lance
                      {
                          this.workingTime = 1; //La méthode isBurning() renverra true maintenant (1>0)
                      }
                      if(this.canSmelt() && this.workingTime == this.workingTimeNeeded) //Si on est arrivé au bout du temps de cuisson et que la recette est toujours bonne
                      {
                          this.smeltItem(); //on "cuit" les items
                          this.workingTime = 0; //et on réinitialise le temps de cuisson
                      }
                      if(!this.canSmelt()) //Si la recette la recette n'est plus bonne
                      {
                              this.workingTime= 0; //le temps de cuisson est de 0
                      }
                  }
                  
                  public void smeltItem()
                  {
                      if (this.canSmelt())
                      {
                          ItemStack itemstack = FungieMachineRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]}); //On récupère l'output de la recette
                          if (this.contents[3] == null) //Si il y a rien dans le slot d'output
                          {
                              this.contents[3] = itemstack.copy(); //On met directement l'ItemStack
                          }
                          else if (this.contents[3].getItem() == itemstack.getItem()) //Et si l'item que l'on veut est le même que celui qu'il y a déjà
                          {
                              this.contents[3].stackSize += itemstack.stackSize; // Alors ont incrémente l'ItemStack
                          }
               
                          --this.contents[0].stackSize; //On décrémente les slots d'input
                          --this.contents[1].stackSize;
                          --this.contents[2].stackSize;
               
                          if (this.contents[0].stackSize <= 0) //Si les slots sont vides, on remet à null le slot
                          {
                              this.contents[0] = null;
                          }
                          if (this.contents[1].stackSize <= 0)
                          {
                              this.contents[1] = null;
                          }
                          if (this.contents[2].stackSize <= 0)
                          {
                              this.contents[2] = null;
                          }
                      }
                  }
              }
              
              1 réponse Dernière réponse Répondre Citer 0
              • ZunF1xZ Hors-ligne
                ZunF1x @Superloup10
                dernière édition par

                @Superloup10 j’ai un problème stp repond

                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

                  Cela devrait être this.contents[i].writeToNBT(nbttagcompound1);

                  Par contre, tu n’as visiblement toujours pas compris ce qu’on t’as dit : ça ne sert à rien de venir demander de l’aide sur d’autres discussions, de poster plusieurs messages à la suite, ou encore de mentionner n’importe qui.
                  La prochaine fois que tu reprends ce genre de comportement insupportable, ça sera un ban. C’est le dernier avertissement.

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

                    salut, je fait mon mod en 1.7.10 mais j’ai des erreur au * qui sont après contents du tile entity

                    if (this.contents* != null) //erreur ici sur le * de contents*
                    {
                       NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                       nbttagcompound1.setByte("Slot", (byte)i);
                       this.contents*.writeToNBT(nbttagcompound1); //erreur ici sur le * de contents*
                       nbttaglist.appendTag(nbttagcompound1);
                    }
                    

                    la class au complet

                    package mod.dimancium.tileEntity;
                    
                    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 PurificatorTileEntity extends TileEntity implements IInventory {
                    	
                    	private ItemStack[] contents = new ItemStack[4]; //0, 1 et 2 sont les inputs et 3 est l'output
                    	
                    	private int workingTime = 0; //Temps de cuisson actuel
                    	private int workingTimeNeeded = 200; //Temps de cuisson nécessaire
                    	
                    	@Override
                        public void writeToNBT(NBTTagCompound compound)
                        {
                            super.writeToNBT(compound);
                            NBTTagList nbttaglist = new NBTTagList();
                     
                            for (int i = 0; i < this.contents.length; ++i) //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.machineTuto";
                        }
                     
                        @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 == 3 ? false : true;
                        }
                    	
                        public boolean isBurning()
                        {
                            return this.workingTime > 0;
                        }
                        
                        private boolean canSmelt()
                        {
                            if (this.contents[0] == null || this.contents[1] == null || this.contents[2] == null) //Si les trois premiers slots sont vides
                            {
                                return false; //On ne peut pas lancer le processus
                            }
                            else
                            {
                                ItemStack itemstack = PurificatorRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]}); //Il y a une erreur ici, c'est normal, on y vient après (c'est pour les recettes)
                                if (itemstack == null) return false; //rapport avec les recettes
                                if (this.contents[3] == null) return true; //vérifications du slot d'output
                                if (!this.contents[3].isItemEqual(itemstack)) return false; //ici aussi
                                int result = contents[3].stackSize + itemstack.stackSize;
                                return result <= getInventoryStackLimit() && result <= this.contents[3].getMaxStackSize(); //Et là aussi décidément
                            }
                        }
                        
                        public void updateEntity() //Méthode exécutée à chaque tick
                        {
                            if(this.isBurning() && this.canSmelt()) //Si on "cuit" et que notre recette et toujours bonne, on continue
                            {
                                ++this.workingTime; //incrémentation
                            }
                            if(this.canSmelt() && !this.isBurning()) //Si la recette est bonne mais qu'elle n'est toujours pas lancée, on la lance
                            {
                                this.workingTime = 1; //La méthode isBurning() renverra true maintenant (1>0)
                            }
                            if(this.canSmelt() && this.workingTime == this.workingTimeNeeded) //Si on est arrivé au bout du temps de cuisson et que la recette est toujours bonne
                            {
                                this.smeltItem(); //on "cuit" les items
                                this.workingTime = 0; //et on réinitialise le temps de cuisson
                            }
                            if(!this.canSmelt()) //Si la recette la recette n'est plus bonne
                            {
                                    this.workingTime= 0; //le temps de cuisson est de 0
                            }
                        }
                        
                        public void smeltItem()
                        {
                            if (this.canSmelt())
                            {
                                ItemStack itemstack = PurificatorRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]}); //On récupère l'output de la recette
                                if (this.contents[3] == null) //Si il y a rien dans le slot d'output
                                {
                                    this.contents[3] = itemstack.copy(); //On met directement l'ItemStack
                                }
                                else if (this.contents[3].getItem() == itemstack.getItem()) //Et si l'item que l'on veut est le même que celui qu'il y a déjà
                                {
                                    this.contents[3].stackSize += itemstack.stackSize; // Alors ont incrémente l'ItemStack
                                }
                     
                                --this.contents[0].stackSize; //On décrémente les slots d'input
                                --this.contents[1].stackSize;
                                --this.contents[2].stackSize;
                     
                                if (this.contents[0].stackSize <= 0) //Si les slots sont vides, on remet à null le slot
                                {
                                    this.contents[0] = null;
                                }
                                if (this.contents[1].stackSize <= 0)
                                {
                                    this.contents[1] = null;
                                }
                                if (this.contents[2].stackSize <= 0)
                                {
                                    this.contents[2] = null;
                                }
                            }
                        }
                        
                    }
                    
                    

                    si vous savez pourquoi ou comment le régler vous pouvez me répondre

                    BrokenSwingB 1 réponse Dernière réponse Répondre Citer 0
                    • BrokenSwingB Hors-ligne
                      BrokenSwing Moddeurs confirmés Rédacteurs @Voltorise
                      dernière édition par

                      @Voltorise Salut,
                      Cela vient d’une erreur de conversion des tutoriels depuis notre changement de moteur pour le forum. Les * correspondent en réalité à des [i].

                      VoltoriseV 1 réponse Dernière réponse Répondre Citer 0
                      • ZunF1xZ Hors-ligne
                        ZunF1x
                        dernière édition par

                        Tout mes problemes sont regler ma machine fonctionnent les crafts fonctionnent aussi mais la barre rouge au milieu qui est une fleche est grise et ne prend pas la texture rouge que j’ai faite qaudn je crafts les items !

                        VoltoriseV 1 réponse Dernière réponse Répondre Citer 0
                        • VoltoriseV Hors-ligne
                          Voltorise @BrokenSwing
                          dernière édition par Voltorise

                          @BrokenSwing MERCI je vais pouvoir crée une machine et une dimension ENFIN

                          1 réponse Dernière réponse Répondre Citer 0
                          • VoltoriseV Hors-ligne
                            Voltorise @ZunF1x
                            dernière édition par

                            @Askipie quand tu a une erreur envoi t’es scripts et tout quand tu a une erreur sinon ont peut rien faire

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

                              Pour la class des crafts faut import quoi pour Entry ?

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

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

                                Nous allons coder la classe la plus longue de ce tutoriel, alors prenez-vous un bon café et c’est partie !

                                J’ai deja un café et c’est JAVA!

                                @Wikitionnary a dit dans Java

                                Étymologie

                                (Nom propre 2) (1993) De l’anglais Java, lui-même issu de l’argot américain java (« café »). Le premier logo du langage Java était une tasse de café.

                                s

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

                                  Bonjours

                                  J’aimerais avoir de l’aide cela fait plus de 2 jours que je cherche, mais je ne trouve pas mon erreur

                                  voici mon crash report:
                                  crash-2019-05-06_17.44.12-client.txt

                                  puis voila mon code:
                                  class du block:

                                  package ca.TheMister730.server.blocks;
                                  
                                  import ca.TheMister730.server.Main;
                                  import ca.TheMister730.server.entity.TileEntityblockSecheur;
                                  import net.minecraft.block.Block;
                                  import net.minecraft.block.BlockContainer;
                                  import net.minecraft.block.material.Material;
                                  import net.minecraft.entity.item.EntityItem;
                                  import net.minecraft.entity.player.EntityPlayer;
                                  import net.minecraft.inventory.IInventory;
                                  import net.minecraft.item.ItemStack;
                                  import net.minecraft.nbt.NBTTagCompound;
                                  import net.minecraft.tileentity.TileEntity;
                                  import net.minecraft.world.World;
                                  
                                  public class blockSecheur <onBlockActivated, onBlockActivated1> extends BlockContainer{
                                  	
                                  	public blockSecheur(){
                                  		super(Material.rock);
                                  		this.setResistance(8.0F);
                                  		this.setHarvestLevel("pickaxe", 2);
                                  	}
                                  	
                                  	@Override
                                      public TileEntity createNewTileEntity(World world, int metadata)
                                      {
                                          return new TileEntityblockSecheur();
                                      }
                                   
                                      @Override
                                      public boolean hasTileEntity(int metadata)
                                      {
                                          return true;
                                      }
                                  	
                                      public void breakBlock(World world, int x, int y, int z, Block block, int metadata)
                                      {
                                          TileEntity tileentity = world.getTileEntity(x, y, z);
                                   
                                                  if (tileentity instanceof IInventory)
                                                  {
                                                      IInventory inv = (IInventory)tileentity;
                                                      for (int i1 = 0; i1 < inv.getSizeInventory(); ++i1)
                                                      {
                                                          ItemStack itemstack = inv.getStackInSlot(i1);
                                   
                                                          if (itemstack != null)
                                                          {
                                                              float f = world.rand.nextFloat() * 0.8F + 0.1F;
                                                              float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
                                                              EntityItem entityitem;
                                   
                                                              for (float f2 = world.rand.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; world.spawnEntityInWorld(entityitem))
                                                              {
                                                                  int j1 = world.rand.nextInt(21) + 10;
                                   
                                                                  if (j1 > itemstack.stackSize)
                                                                  {
                                                                      j1 = itemstack.stackSize;
                                                                  }
                                   
                                                                  itemstack.stackSize -= j1;
                                                                  entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
                                                                  float f3 = 0.05F;
                                                                  entityitem.motionX = (double)((float)world.rand.nextGaussian() * f3);
                                                                  entityitem.motionY = (double)((float)world.rand.nextGaussian() * f3 + 0.2F);
                                                                  entityitem.motionZ = (double)((float)world.rand.nextGaussian() * f3);
                                   
                                                                  if (itemstack.hasTagCompound())
                                                                  {
                                                                      entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
                                                                  }
                                                              }
                                                          }
                                                      }
                                   
                                                  world.func_147453_f(x, y, z, block);
                                              }
                                   
                                          super.breakBlock(world, x, y, z, block, metadata);
                                      }
                                      public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitx, float hity, float hitz)
                                      {
                                          if (world.isRemote)
                                          {
                                              return true;
                                          }
                                          else
                                          {
                                              player.openGui(Main.instance, 0, world, x, y, z);
                                              return true;
                                          }
                                      }
                                  }
                                  

                                  class tileEntity

                                  package ca.TheMister730.server.entity;
                                  
                                  import ca.TheMister730.server.init.SecheurRecipes; 
                                  import cpw.mods.fml.relauncher.Side;
                                  import cpw.mods.fml.relauncher.SideOnly;
                                  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 TileEntityblockSecheur extends TileEntity implements IInventory {
                                  	
                                  	private ItemStack[] contents = new ItemStack[4];
                                  	private int workingTime = 0;
                                  	private int workingTimeNeeded = 200;
                                  	
                                  	@Override
                                      public void writeToNBT(NBTTagCompound compound)
                                      {
                                          super.writeToNBT(compound);
                                          NBTTagList nbttaglist = new NBTTagList();
                                   
                                          for (int i = 0; i < this.contents.length; ++i)
                                          {
                                              if (this.contents[i] != null)
                                              {
                                                  NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                                                  nbttagcompound1.setByte("Slot", (byte)i);
                                                  this.contents[i].writeToNBT(nbttagcompound1);
                                                  nbttaglist.appendTag(nbttagcompound1);
                                              }
                                          }
                                   
                                          compound.setTag("Items", nbttaglist);
                                          compound.setShort("workingTime",(short)this.workingTime);
                                          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.Sécheur";
                                  	    }
                                  	@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 = SecheurRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1]});
                                  	            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();
                                  	        }
                                  	    }
                                  	    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 = SecheurRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1]}); //On récupère l'output de la recette
                                  	            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 * 41 / this.workingTimeNeeded;
                                  	    }
                                  }
                                  

                                  class recipe

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

                                  class gui

                                  package ca.TheMister730.server.container.gui;
                                  
                                  import org.lwjgl.opengl.GL11; 
                                  
                                  import ca.TheMister730.server.References;
                                  import ca.TheMister730.server.container.ContainerSecheur;
                                  import ca.TheMister730.server.entity.TileEntityblockSecheur;
                                  import net.minecraft.client.gui.inventory.GuiContainer;
                                  import net.minecraft.client.resources.I18n;
                                  import net.minecraft.entity.player.InventoryPlayer;
                                  import net.minecraft.inventory.Container;
                                  import net.minecraft.inventory.IInventory;
                                  import net.minecraft.util.ResourceLocation;
                                  
                                  public class GuiBlockSecheur extends GuiContainer{
                                  		 
                                  	    private final ResourceLocation textures = new ResourceLocation(References.MOD_ID + ":textures/gui/container/guiSecheur.png");
                                  	    private TileEntityblockSecheur tileblockSecheur;
                                  	    private IInventory playerInv;
                                  	 
                                  	    public GuiBlockSecheur(TileEntityblockSecheur tile, InventoryPlayer inventory)
                                  	    {
                                  	        super(new ContainerSecheur(tile, inventory));
                                  	        this.tileblockSecheur = tile;
                                  	        this.playerInv = inventory;
                                  	        this.allowUserInput = false;
                                  	        this.ySize = 165;
                                  	    }
                                  	 
                                  	    @Override
                                  	    protected void drawGuiContainerBackgroundLayer(float partialRenderTick, int x, int y)
                                  	    {
                                  	 
                                  	    	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                                  	        this.mc.getTextureManager().bindTexture(textures);
                                  	        int k = (this.width - this.xSize) / 2;
                                  	        int l = (this.height - this.ySize) / 2;
                                  	        this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
                                  	        
                                  	        if(this.tileblockSecheur.isBurning())
                                  	        {
                                  
                                  	            int i = this.tileblockSecheur.getCookProgress();
                                  				this.drawTexturedModalRect(k + 47, l + 46, 0, 2, 100, i);
                                  	        }
                                  	 
                                  	    }
                                  	 
                                  	    protected void drawGuiContainerForegroundLayer(int x, int y)
                                  	    {
                                  	    	this.fontRendererObj.drawString(this.tileblockSecheur.hasCustomInventoryName() ? this.tileblockSecheur.getInventoryName() : I18n.format(this.tileblockSecheur.getInventoryName(), new Object[0]), 8, 6, 4210752);
                                  	        this.fontRendererObj.drawString(this.playerInv.hasCustomInventoryName() ? this.playerInv.getInventoryName() : I18n.format(this.playerInv.getInventoryName()), 10, this.ySize - 92, 4210752);
                                  	    }
                                  	 
                                  	}
                                  

                                  class container

                                  package ca.TheMister730.server.container;
                                  
                                  import ca.TheMister730.server.entity.TileEntityblockSecheur;
                                  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 ContainerSecheur extends Container{
                                  	private TileEntityblockSecheur tileblockSecheur;
                                  	
                                  	public ContainerSecheur(TileEntityblockSecheur tile, InventoryPlayer inventory)
                                      {
                                          this.tileblockSecheur = tile;
                                          this.addSlotToContainer(new Slot(tile, 0, 48, 22));
                                          this.addSlotToContainer(new Slot(tile, 1, 66, 22));
                                          this.addSlotToContainer(new Slot(tile, 2, 57, 55));
                                          this.addSlotToContainer(new SlotResult(tile, 3, 135, 37));
                                          this.bindPlayerInventory(inventory);
                                      }
                                  	@Override
                                      public boolean canInteractWith(EntityPlayer player) {
                                          return this.tileblockSecheur.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, 8 + j * 18, 85 + i * 18));
                                              }
                                          }
                                   
                                          for (i = 0; i < 9; ++i)
                                          {
                                              this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 143));
                                          }
                                      }
                                   
                                      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.tileblockSecheur.getSizeInventory())
                                              {
                                                  if (!this.mergeItemStack(itemstack1, this.tileblockSecheur.getSizeInventory(), this.inventorySlots.size(), true))
                                                  {
                                                      return null;
                                                  }
                                              }
                                              else if (!this.mergeItemStack(itemstack1, 0, this.tileblockSecheur.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.tileblockSecheur.closeInventory();
                                      }
                                  
                                  }
                                  

                                  jespert que vous pourrais m’aider

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

                                    Salut, même avec très peut de skill en mod, car sur unity (c’est autre chose)… bref donc je vais essayer je pense avoir trouver mais je verif mon hypothèse.

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

                                      Une question pour m’aider, ta machine doit avoir combien de slot de ressource et combien de result ? Car je pense que sa viens du nombre de slot ton erreur. Car dans canSmelt (TileEntityblockSecheur:158) tu dit deux slots de ressource et dans la list des slots(TileEntityblockSecheur:15) tu dit qu’il y a 4 slots total, donc tu veux deux slots de résulta ? Si tu arrive à régler ton prob dit le pour pas que je continue de chercher ; )

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

                                        Autre question c’est quand que ton jeu crash ? Tu peux la lancer ou créer un nouveau monde ou rien ?

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

                                          alors je veux 4 slot mais 1 seul de result puis je crash quand je lance la cuisson
                                          entk merci pour ton aide

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

                                            merci beaucoup tu gere trop mon gas entk merci pour ton aide ❤

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

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB