• S'inscrire
    • Se connecter
    • Recherche
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes

    Résolu Création nouvelle recette sur une machine

    1.7.x
    1.7.10
    3
    20
    2439
    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.
    • M
      mosca421 dernière édition par

      Bonjours j’aurais besoin de votre aide, j’ai crée un bloc (four) qui a 12 slots 11 et 1 de reception de craft le soucis c’est que le craft ne marche pas (la GUI s’ouvre je ne crash pas le craft ne s’effectue pas)
      Je vous met le code du four si jamais quelqu’un connais la solution

      
      package fr.serveur.mods.MachinePala;
      
      import java.util.HashMap;
      import java.util.Iterator;
      import java.util.Map;
      import java.util.Map.Entry;
      
      import fr.serveur.mods.Mods;
      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;
      
      @SuppressWarnings("rawtypes")
      public class MachineRecipes {
      
      private static final MachineRecipes smeltingBase = new MachineRecipes();
      private Map smeltingList = new HashMap(); 
      
      public MachineRecipes()
      {
      this.addRecipe(Mods.Paladium, Mods.Paladium, Mods.Paladium, Mods.Paladium, Mods.Paladium, Mods.Paladium, Mods.Paladium, Mods.Paladium, Mods.Paladium, Mods.Paladium, Mods.Paladium, new ItemStack(Mods.bigring)); 
      }
      
      @SuppressWarnings("unchecked")
      public void addRecipe(ItemStack stack1, ItemStack stack2, ItemStack stack3, ItemStack stack4, ItemStack stack5, ItemStack stack6, ItemStack stack7, ItemStack stack8, ItemStack stack9, ItemStack stack10, ItemStack stack11, ItemStack stack) 
      {
      ItemStack[] stackList = new ItemStack[]{stack1, stack2, stack3, stack4, stack5, stack6, stack7, stack8, stack9, stack10, stack11};
      this.smeltingList.put(stackList, stack);
      }
      
              public void addRecipe(Item item1, Item item2, Item item3, Item item4, Item item5, Item item6, Item item7, Item item8, Item item9, Item item10, Item item11, ItemStack stack) 
      {
      this.addRecipe(new ItemStack(item1), new ItemStack(item2), new ItemStack(item3), new ItemStack(item4), new ItemStack(item5), new ItemStack(item6), new ItemStack(item7), new ItemStack(item8), new ItemStack(item9), new ItemStack(item10), new ItemStack(item11), stack);
      }
      
      public ItemStack getSmeltingResult(ItemStack[] stack) 
      {
          Iterator iterator = this.smeltingList.entrySet().iterator();
          Entry entry;
      
          do
          {
              if (!iterator.hasNext()) 
              {
                  return null;
              }
                 entry = (Entry)iterator.next(); 
             }
             while (!this.isSameKey(stack, (ItemStack[])entry.getKey()));
      
             return (ItemStack)entry.getValue(); 
       }
      
      private boolean isSameKey(ItemStack[] stackList, ItemStack[] stackList2)
      {
      boolean isSame = false; 
      for(int i=0; i<=10; i++) 
      {
      if(stackList*.getItem() == stackList2*.getItem())
      {
      isSame = true; 
      }
      else
      {
      return false; 
      }
      }
      return isSame;
      }
      
      public Map getSmeltingList()
      {
             return this.smeltingList;
          }
      
      public static MachineRecipes smelting()
      {
      return smeltingBase;
      }
      
      }
      

      Merci !

      1 réponse Dernière réponse Répondre Citer 0
      • jglrxavpok
        jglrxavpok Modérateurs dernière édition par

        Il nous faut le code du Gui et du Container aussi

        Sent from my GT-I9000 using Tapatalk 2

        Modérateur sur MFF. 
        Mon Github: http://github.com/jglrxavpok
        Mon compte Steam si vous voulez jouer à CS:GO ou TF2 avec moi: https://steamcommunity.com/id/jglrxavpok/

        1 réponse Dernière réponse Répondre Citer 0
        • M
          mosca421 dernière édition par

          de suite

          
          package fr.serveur.mods.MachinePala;
          
          import net.minecraft.client.gui.inventory.GuiContainer;
          import net.minecraft.client.resources.I18n;
          import net.minecraft.entity.player.InventoryPlayer;
          import net.minecraft.inventory.IInventory;
          import net.minecraft.util.ResourceLocation;
          
          import org.lwjgl.opengl.GL11;
          
          import fr.serveur.mods.Mods;
          
          public class GuiMachine extends GuiContainer {
          
          private static final ResourceLocation texture = new ResourceLocation(Mods.MODID,"textures/gui/container/guiMachineTuto.png");
             @SuppressWarnings("unused")
          private TileEntityMachinePala tileCompressor;
             private IInventory playerInv;
          
          public GuiMachine(TileEntityMachinePala tile, InventoryPlayer inventory) 
          {
          super(new ContainerMachine(tile, inventory));
                 this.tileCompressor = tile;
                 this.playerInv = inventory;
                 this.allowUserInput = false;
                 this.ySize = 256;
                 this.xSize = 256;
          }
          
          @Override
          protected void drawGuiContainerBackgroundLayer(float partialRenderTick, int x, int y) 
          {
          
          GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                 this.mc.getTextureManager().bindTexture(texture);
                 int k = (this.width - this.xSize) / 2;
                 int l = (this.height - this.ySize) / 2;
                 this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
                 this.drawTexturedModalRect(0, 0, 176, 14, 100 + 1, 16);
          
          }
          
          protected void drawGuiContainerForegroundLayer(int x, int y)
             {
                 this.fontRendererObj.drawString(this.playerInv.hasCustomInventoryName() ? this.playerInv.getInventoryName() : I18n.format(this.playerInv.getInventoryName()), 10, this.ySize - 98, 4210752);
             }
          
          }
          
          
          
          package fr.serveur.mods.MachinePala;
          
          import net.minecraft.entity.player.EntityPlayer;
          import net.minecraft.tileentity.TileEntity;
          import net.minecraft.world.World;
          import cpw.mods.fml.common.network.IGuiHandler;
          
          public class GuiHandler implements IGuiHandler
          {
              @Override
              public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
              {
                  TileEntity tile = world.getTileEntity(x, y, z);
          
                  if(tile instanceof TileEntityMachinePala)
                  {
                  return new ContainerMachine((TileEntityMachinePala)tile, player.inventory);
                  }
                  return null;
              }
          
              @Override
              public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
              {
                  TileEntity tile = world.getTileEntity(x, y, z);
          
                  if(tile instanceof TileEntityMachinePala)
                  {
                  return new GuiMachine((TileEntityMachinePala)tile, player.inventory);
                  }
                  return null;
              }
          }
          
          
          
          package fr.serveur.mods.MachinePala;
          
          import fr.serveur.mods.MachinePala.*;
          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 ContainerMachine extends Container {
          
          private TileEntityMachinePala tileMachinePala;
          
          public ContainerMachine(TileEntityMachinePala tile, InventoryPlayer inventory)
          {
                  this.tileMachinePala = tile;
                  this.addSlotToContainer(new Slot(tile, 0, 10, 75)); 
                  this.addSlotToContainer(new Slot(tile, 1, 30, 75));
                  this.addSlotToContainer(new Slot(tile, 3, 50, 75));
                  this.addSlotToContainer(new Slot(tile, 4, 70, 75));
                  this.addSlotToContainer(new Slot(tile, 5, 90, 75));
                  this.addSlotToContainer(new Slot(tile, 6, 120, 75));
                  this.addSlotToContainer(new Slot(tile, 7, 150, 75));
                  this.addSlotToContainer(new Slot(tile, 8, 170, 75));
                  this.addSlotToContainer(new Slot(tile, 9, 190, 75));
                  this.addSlotToContainer(new Slot(tile, 10, 210, 75));
                  this.addSlotToContainer(new Slot(tile, 11, 230, 75));
          
                  this.addSlotToContainer(new SlotResulte(tile, 12, 120, 119)); 
                  this.bindPlayerInventory(inventory);
          }
          
          @Override
          public boolean canInteractWith(EntityPlayer player) {
          return this.tileMachinePala.isUseableByPlayer(player);
          }
          
          private void bindPlayerInventory(InventoryPlayer inventory)
          {
          int i;
          for (i = 0; i < 3; ++i)
                  {
                      for (int j = 0; j < 9; ++j)
                      {
                          this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 17 + j * 18, 171 + i * 18));
                      }
                  }
          
                  for (i = 0; i < 9; ++i)
                  {
                      this.addSlotToContainer(new Slot(inventory, i, 17 + i * 18, 229));
                  }
          }
          
          public ItemStack transferStackInSlot(EntityPlayer player, int quantity)
              {
                  ItemStack itemstack = null;
                  Slot slot = (Slot)this.inventorySlots.get(quantity);
          
                  if (slot != null && slot.getHasStack())
                  {
                      ItemStack itemstack1 = slot.getStack();
                      itemstack = itemstack1.copy();
          
                      if (quantity < this.tileMachinePala.getSizeInventory())
                      {
                          if (!this.mergeItemStack(itemstack1, this.tileMachinePala.getSizeInventory(), this.inventorySlots.size(), true))
                          {
                              return null;
                          }
                      }
                      else if (!this.mergeItemStack(itemstack1, 0, this.tileMachinePala.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.tileMachinePala.closeInventory();
              }
          
          }
          
          
          1 réponse Dernière réponse Répondre Citer 0
          • BrokenSwing
            BrokenSwing Moddeurs confirmés Rédacteurs dernière édition par

            Et la classe du TileEntity ?

            1 réponse Dernière réponse Répondre Citer 0
            • M
              mosca421 dernière édition par

              
              package fr.serveur.mods.MachinePala;
              
              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 TileEntityMachinePala extends TileEntity implements IInventory {
              
              private ItemStack[] contents = new ItemStack[13]; 
              private int workingTime = 0; 
              private int workingTimeNeeded = 10; //Test
              
              @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.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) 
                      {
                          return false; //On ne peut pas lancer le processus
                      }
                      else
                      {
                          ItemStack itemstack = MachineRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]}); //Il y a une erreur ici, c'est normal, on y vient après (c'est pour les recettes)
                          if (itemstack == null) return false; 
                          if (this.contents[3] == null) return true; 
                          if (!this.contents[3].isItemEqual(itemstack)) return false; 
                          int result = contents[3].stackSize + itemstack.stackSize;
                          return result <= getInventoryStackLimit() && result <= this.contents[3].getMaxStackSize(); 
                      }
                  }
              
              public void updateEntity() 
                  {
                  if(this.isBurning() && this.canSmelt()) 
                  {
                  ++this.workingTime; 
                  }
                  if(this.canSmelt() && !this.isBurning()) 
                  {
                  this.workingTime = 1; 
                  }
                  if(this.canSmelt() && this.workingTime == this.workingTimeNeeded) 
                  {
                  this.smeltItem(); 
                  this.workingTime = 0; 
                  }
                      if(!this.canSmelt()) 
                      {
                             this.workingTime= 0; 
                      }
                  }
              
              public void smeltItem()
                  {
                      if (this.canSmelt())
                      {
                          ItemStack itemstack = MachineRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]}); 
                           if (this.contents[3] == null) 
                           {
                                this.contents[3] = itemstack.copy(); 
                           }
                           else if (this.contents[3].getItem() == itemstack.getItem()) 
                           {
                                this.contents[3].stackSize += itemstack.stackSize; 
                           }
              
                           –this.contents[0].stackSize; 
                           –this.contents[1].stackSize;
                           –this.contents[2].stackSize;
              
                           if (this.contents[0].stackSize <= 0) 
                           {
                               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
              • BrokenSwing
                BrokenSwing Moddeurs confirmés Rédacteurs dernière édition par

                Bah voilà, il est là le problème, il faut que tu modifie correctement les fonctions canSmelt() et smeltItem(). Elles sont ici faites pour 3 slots, or tu en as beaucoup plus

                1 réponse Dernière réponse Répondre Citer 0
                • M
                  mosca421 dernière édition par

                  Toujours pareil j’ai modifier tileentity :

                  package fr.serveur.mods.MachinePala;
                  
                  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 TileEntityMachinePala extends TileEntity implements IInventory {
                  
                  private ItemStack[] contents = new ItemStack[13]; 
                  private int workingTime = 0; 
                  private int workingTimeNeeded = 10; //Test
                  
                  @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.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 == 12 ? 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 || this.contents[3] == null || this.contents[4] == null || this.contents[5] == null || this.contents[6] == null || this.contents[7] == null || this.contents[8] == null || this.contents[9] == null || this.contents[10] == null || this.contents[11] == null) 
                          {
                              return false; //On ne peut pas lancer le processus
                          }
                          else
                          {
                              ItemStack itemstack = MachineRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]}); //Il y a une erreur ici, c'est normal, on y vient après (c'est pour les recettes)
                              if (itemstack == null) return false; 
                              if (this.contents[12] == null) return true; 
                              if (!this.contents[12].isItemEqual(itemstack)) return false; 
                              int result = contents[12].stackSize + itemstack.stackSize;
                              return result <= getInventoryStackLimit() && result <= this.contents[3].getMaxStackSize(); 
                          }
                      }
                  
                  public void updateEntity() 
                      {
                      if(this.isBurning() && this.canSmelt()) 
                      {
                      ++this.workingTime; 
                      }
                      if(this.canSmelt() && !this.isBurning()) 
                      {
                      this.workingTime = 1; 
                      }
                      if(this.canSmelt() && this.workingTime == this.workingTimeNeeded) 
                      {
                      this.smeltItem(); 
                      this.workingTime = 0; 
                      }
                          if(!this.canSmelt()) 
                          {
                                 this.workingTime= 0; 
                          }
                      }
                  
                  public void smeltItem()
                      {
                          if (this.canSmelt())
                          {
                              ItemStack itemstack = MachineRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2],this.contents[3], this.contents[4], this.contents[5],this.contents[6], this.contents[7], this.contents[8],this.contents[9], this.contents[10], this.contents[11]}); 
                               if (this.contents[12] == null) 
                               {
                                    this.contents[12] = itemstack.copy(); 
                               }
                               else if (this.contents[12].getItem() == itemstack.getItem()) 
                               {
                                    this.contents[12].stackSize += itemstack.stackSize; 
                               }
                  
                               –this.contents[0].stackSize; 
                               –this.contents[1].stackSize;
                               –this.contents[2].stackSize;
                               –this.contents[3].stackSize; 
                               –this.contents[4].stackSize;
                               –this.contents[5].stackSize;
                               –this.contents[6].stackSize; 
                               –this.contents[7].stackSize;
                               –this.contents[8].stackSize;
                               –this.contents[9].stackSize; 
                               –this.contents[10].stackSize;
                               –this.contents[11].stackSize;
                  
                               if (this.contents[0].stackSize <= 0) 
                               {
                                   this.contents[0] = null;
                               }
                               if (this.contents[1].stackSize <= 0)
                               {
                                   this.contents[1] = null;
                               }
                               if (this.contents[2].stackSize <= 0)
                               {
                                   this.contents[2] = null;
                               }
                               if (this.contents[3].stackSize <= 0) 
                               {
                                   this.contents[3] = null;
                               }
                               if (this.contents[4].stackSize <= 0)
                               {
                                   this.contents[4] = null;
                               }
                               if (this.contents[5].stackSize <= 0)
                               {
                                   this.contents[5] = null;
                               }
                               if (this.contents[6].stackSize <= 0) 
                               {
                                   this.contents[6] = null;
                               }
                               if (this.contents[7].stackSize <= 0)
                               {
                                   this.contents[7] = null;
                               }
                               if (this.contents[8].stackSize <= 0)
                               {
                                   this.contents[8] = null;
                               }
                               if (this.contents[9].stackSize <= 0) 
                               {
                                   this.contents[9] = null;
                               }
                               if (this.contents[10].stackSize <= 0)
                               {
                                   this.contents[10] = null;
                               }
                               if (this.contents[11].stackSize <= 0)
                               {
                                   this.contents[11] = null;
                               }
                          }
                      }
                  }
                  
                  
                  1 réponse Dernière réponse Répondre Citer 0
                  • BrokenSwing
                    BrokenSwing Moddeurs confirmés Rédacteurs dernière édition par

                    Ligne 176, faut passer les ItemStacks en arguments sinon il trouvera jamais la recette
                    Et ligne 12 il me semble qu’il faudrait que tu mettes [12] et pas [13]

                    1 réponse Dernière réponse Répondre Citer 0
                    • M
                      mosca421 dernière édition par

                      package fr.serveur.mods.MachinePala;
                      
                      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 TileEntityMachinePala extends TileEntity implements IInventory {
                      
                      private ItemStack[] contents = new ItemStack[13]; 
                      private int workingTime = 0; 
                      private int workingTimeNeeded = 10; //Test
                      
                      @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.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 == 12 ? 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 || this.contents[3] == null || this.contents[4] == null || this.contents[5] == null || this.contents[6] == null || this.contents[7] == null || this.contents[8] == null || this.contents[9] == null || this.contents[10] == null || this.contents[11] == null) 
                              {
                                  return false; //On ne peut pas lancer le processus
                              }
                              else
                              {
                                  ItemStack itemstack = MachineRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2],this.contents[3], this.contents[4], this.contents[5],this.contents[6], this.contents[7], this.contents[8],this.contents[9], this.contents[10], this.contents[11]}); //Il y a une erreur ici, c'est normal, on y vient après (c'est pour les recettes)
                                  if (itemstack == null) return false; 
                                  if (this.contents[12] == null) return true; 
                                  if (!this.contents[12].isItemEqual(itemstack)) return false; 
                                  int result = contents[12].stackSize + itemstack.stackSize;
                                  return result <= getInventoryStackLimit() && result <= this.contents[12].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 = MachineRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2],this.contents[3], this.contents[4], this.contents[5],this.contents[6], this.contents[7], this.contents[8],this.contents[9], this.contents[10], this.contents[11]}); 
                                   if (this.contents[12] == null) 
                                   {
                                        this.contents[12] = itemstack.copy(); 
                                   }
                                   else if (this.contents[12].getItem() == itemstack.getItem()) 
                                   {
                                        this.contents[12].stackSize += itemstack.stackSize; 
                                   }
                      
                                   –this.contents[0].stackSize; 
                                   –this.contents[1].stackSize;
                                   –this.contents[2].stackSize;
                                   –this.contents[3].stackSize; 
                                   –this.contents[4].stackSize;
                                   –this.contents[5].stackSize;
                                   –this.contents[6].stackSize; 
                                   –this.contents[7].stackSize;
                                   –this.contents[8].stackSize;
                                   –this.contents[9].stackSize; 
                                   –this.contents[10].stackSize;
                                   –this.contents[11].stackSize;
                      
                                   if (this.contents[0].stackSize <= 0) 
                                   {
                                       this.contents[0] = null;
                                   }
                                   if (this.contents[1].stackSize <= 0)
                                   {
                                       this.contents[1] = null;
                                   }
                                   if (this.contents[2].stackSize <= 0)
                                   {
                                       this.contents[2] = null;
                                   }
                                   if (this.contents[3].stackSize <= 0) 
                                   {
                                       this.contents[3] = null;
                                   }
                                   if (this.contents[4].stackSize <= 0)
                                   {
                                       this.contents[4] = null;
                                   }
                                   if (this.contents[5].stackSize <= 0)
                                   {
                                       this.contents[5] = null;
                                   }
                                   if (this.contents[6].stackSize <= 0) 
                                   {
                                       this.contents[6] = null;
                                   }
                                   if (this.contents[7].stackSize <= 0)
                                   {
                                       this.contents[7] = null;
                                   }
                                   if (this.contents[8].stackSize <= 0)
                                   {
                                       this.contents[8] = null;
                                   }
                                   if (this.contents[9].stackSize <= 0) 
                                   {
                                       this.contents[9] = null;
                                   }
                                   if (this.contents[10].stackSize <= 0)
                                   {
                                       this.contents[10] = null;
                                   }
                                   if (this.contents[11].stackSize <= 0)
                                   {
                                       this.contents[11] = null;
                                   }
                              }
                          }
                      }
                      
                      

                      Toujours pareil =/

                      Ligne 12 = 12 = crash
                      13 cela ne crash pas

                      1 réponse Dernière réponse Répondre Citer 0
                      • BrokenSwing
                        BrokenSwing Moddeurs confirmés Rédacteurs dernière édition par

                        Ah mais tu as 13 slots, pas 12 c’est pour ça, dans ton premier post tu dit avoir 12 slots, 11 d’inputs et 1 d’output mais en fait tu as 13 slots, 12 d’input et 1 d’output

                        1 réponse Dernière réponse Répondre Citer 0
                        • M
                          mosca421 dernière édition par

                          nop j’ai bien 11 slots et 1 de sortie
                          Mais comme j’ai vue sur un tuto il y a toujours un chiffre en plus exemple 10 slot faudra mettre 11

                          1 réponse Dernière réponse Répondre Citer 0
                          • BrokenSwing
                            BrokenSwing Moddeurs confirmés Rédacteurs dernière édition par

                            
                            package fr.serveur.mods.MachinePala;
                            
                                   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 TileEntityMachinePala extends TileEntity implements IInventory {
                            
                               private ItemStack[] contents = new ItemStack[13];
                               private int workingTime = 0;
                               private int workingTimeNeeded = 10; //Test
                            
                               @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.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 != 13;
                               }
                            
                               public boolean isBurning()
                               {
                                   return this.workingTime > 0;
                               }
                            
                               private boolean canSmelt()
                               {
                                   if (this.contents[0] == null || this.contents[1] == null || this.contents[2] == null || this.contents[3] == null || this.contents[4] == null || this.contents[5] == null || this.contents[6] == null || this.contents[7] == null || this.contents[8] == null || this.contents[9] == null || this.contents[10] == null || this.contents[11] == null || this.contents[12] == null)
                                   {
                                       return false; //On ne peut pas lancer le processus
                                   }
                                   else
                                   {
                                       ItemStack itemstack = MachineRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2],this.contents[3], this.contents[4], this.contents[5],this.contents[6], this.contents[7], this.contents[8],this.contents[9], this.contents[10], this.contents[11], this.contents[12]}); //Il y a une erreur ici, c'est normal, on y vient après (c'est pour les recettes)
                                       if (itemstack == null) return false;
                                       if (this.contents[13] == null) return true;
                                       if (!this.contents[13].isItemEqual(itemstack)) return false;
                                       int result = contents[13].stackSize + itemstack.stackSize;
                                       return result <= getInventoryStackLimit() && result <= this.contents[13].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 = MachineRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2],this.contents[3], this.contents[4], this.contents[5],this.contents[6], this.contents[7], this.contents[8],this.contents[9], this.contents[10], this.contents[11], this.contents[12]});
                                       if (this.contents[13] == null)
                                       {
                                           this.contents[13] = itemstack.copy();
                                       }
                                       else if (this.contents[13].getItem() == itemstack.getItem())
                                       {
                                           this.contents[13].stackSize += itemstack.stackSize;
                                       }
                            
                                       –this.contents[0].stackSize;
                                       –this.contents[1].stackSize;
                                       –this.contents[2].stackSize;
                                       –this.contents[3].stackSize;
                                       –this.contents[4].stackSize;
                                       –this.contents[5].stackSize;
                                       –this.contents[6].stackSize;
                                       –this.contents[7].stackSize;
                                       –this.contents[8].stackSize;
                                       –this.contents[9].stackSize;
                                       –this.contents[10].stackSize;
                                       –this.contents[11].stackSize;
                                       –this.contents[12].stackSize;
                            
                                       if (this.contents[0].stackSize <= 0)
                                       {
                                           this.contents[0] = null;
                                       }
                                       if (this.contents[1].stackSize <= 0)
                                       {
                                           this.contents[1] = null;
                                       }
                                       if (this.contents[2].stackSize <= 0)
                                       {
                                           this.contents[2] = null;
                                       }
                                       if (this.contents[3].stackSize <= 0)
                                       {
                                           this.contents[3] = null;
                                       }
                                       if (this.contents[4].stackSize <= 0)
                                       {
                                           this.contents[4] = null;
                                       }
                                       if (this.contents[5].stackSize <= 0)
                                       {
                                           this.contents[5] = null;
                                       }
                                       if (this.contents[6].stackSize <= 0)
                                       {
                                           this.contents[6] = null;
                                       }
                                       if (this.contents[7].stackSize <= 0)
                                       {
                                           this.contents[7] = null;
                                       }
                                       if (this.contents[8].stackSize <= 0)
                                       {
                                           this.contents[8] = null;
                                       }
                                       if (this.contents[9].stackSize <= 0)
                                       {
                                           this.contents[9] = null;
                                       }
                                       if (this.contents[10].stackSize <= 0)
                                       {
                                           this.contents[10] = null;
                                       }
                                       if (this.contents[11].stackSize <= 0)
                                       {
                                           this.contents[11] = null;
                                       }
                                       if(this.contents[12].stackSize <= 0)
                                       {
                                           this.contents[12] = null;
                                       }
                                   }
                               }
                            }
                            
                            

                            Essai

                            1 réponse Dernière réponse Répondre Citer 0
                            • M
                              mosca421 dernière édition par

                              Nop ça ne marche pas =/

                              1 réponse Dernière réponse Répondre Citer 0
                              • BrokenSwing
                                BrokenSwing Moddeurs confirmés Rédacteurs dernière édition par

                                Bah oui, normal que ça marche pas, j’ai écrit n’importe quoi -_-’ (je viens de m’en apercevoir) J’y retourne.

                                1 réponse Dernière réponse Répondre Citer 0
                                • BrokenSwing
                                  BrokenSwing Moddeurs confirmés Rédacteurs dernière édition par

                                  Tu peux m’envoyer la classe de ton bloc que je test

                                  1 réponse Dernière réponse Répondre Citer 0
                                  • M
                                    mosca421 dernière édition par

                                    package fr.serveur.mods.MachinePala;
                                    
                                    import fr.serveur.mods.Mods;
                                    import net.minecraft.block.Block;
                                    import net.minecraft.block.BlockContainer;
                                    import net.minecraft.block.material.Material;
                                    import net.minecraft.creativetab.CreativeTabs;
                                    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 MachinePala extends BlockContainer{
                                    
                                    public MachinePala()
                                    {
                                      super(Material.rock); //Mettez le material qui convient
                                      this.setResistance(8.0F);
                                      this.setHarvestLevel("pickaxe", 2); //Outil pour casser le bloc, pour le chiffre : 0=bois, 1=pierre, 2=fer, 3=diamant
                                      this.setBlockTextureName(Mods.MODID + ":machinePala");
                                      this.setCreativeTab(CreativeTabs.tabBlock);//N'oubliez pas de remplacer "ModTutoriel"
                                      // … Mettez les attributs complémentaires que vous voulez
                                    }
                                    
                                    @Override
                                        public TileEntity createNewTileEntity(World world, int metadata) //Instancie le TileEntity
                                        {
                                            return new TileEntityMachinePala();
                                        }
                                    
                                        @Override
                                        public boolean hasTileEntity(int metadata) //Permet de savoir si le bloc a un TileEntity
                                        {
                                            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(Mods.instance, 0, world, x, y, z);
                                                return true;
                                            }
                                        }
                                    
                                    }
                                    
                                    

                                    Voila Voila

                                    1 réponse Dernière réponse Répondre Citer 0
                                    • BrokenSwing
                                      BrokenSwing Moddeurs confirmés Rédacteurs dernière édition par

                                      Il y avait un problème lors de ta déclaration de slot, tu as sauté l’id 2
                                      Je m’y remet demain si d’ici là personne n’a résolu le problème, chez moi il est 2h30, je vais dormir.

                                      1 réponse Dernière réponse Répondre Citer 0
                                      • M
                                        mosca421 dernière édition par

                                        J’ai corriger mais toujours rien =/
                                        Bod Pareil =p

                                        1 réponse Dernière réponse Répondre Citer 0
                                        • BrokenSwing
                                          BrokenSwing Moddeurs confirmés Rédacteurs dernière édition par

                                          Commit sur github

                                          1 réponse Dernière réponse Répondre Citer 0
                                          • M
                                            mosca421 dernière édition par

                                            Merci !

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

                                            MINECRAFT FORGE FRANCE © 2018

                                            Powered by NodeBB