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

    Machine grâce au tutoriel.

    Sans suite
    1.7.10
    4
    40
    6987
    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.
    • Flow
      Flow dernière édition par

      Bonjour , je viens vers vous car j’ai un petit problème , mon problème était déja présent sur le post du tuto mais je me dit que c’est plus approprié ici.

      Voila le problème est que mon gui est ok et tout mais la recette ne se fait pas lorsque je place mes deux items ( qui doivent être utilisté ) dans l’input rien ne se fait et la barre de chargement ne se fait pas non plus 😕

      J’ai re vérifier tout mon code avec le tuto et avec le github je ne trouve rien j’ai beau lire toutes les lignes de codes pour moi tout est juste

      Voici mes classes 😞

      ModMinecraft ( classe principale )

      package mod;
      
      import mod.common.CommonProxy;
      import mod.common.block.BlockRegister;
      import mod.common.block.GuiHandler;
      import mod.common.block.entity.RegisterTileEntity;
      import mod.common.entity.EntityRegister;
      import mod.common.item.ItemRegister;
      import mod.common.item.recipe.RecipeRegister;
      import cpw.mods.fml.common.Mod;
      import cpw.mods.fml.common.Mod.EventHandler;
      import cpw.mods.fml.common.Mod.Instance;
      import cpw.mods.fml.common.SidedProxy;
      import cpw.mods.fml.common.event.FMLInitializationEvent;
      import cpw.mods.fml.common.event.FMLPostInitializationEvent;
      import cpw.mods.fml.common.event.FMLPreInitializationEvent;
      import cpw.mods.fml.common.network.NetworkRegistry;
      import cpw.mods.fml.common.registry.GameRegistry;
      
      @Mod(modid = ModMinecraft.MODID, name = ModMinecraft.Name, version = ModMinecraft.Version)
      public class ModMinecraft
      {
          public static final String MODID = "modminecraft";
          public static final String Name = "Mod Minecraft";
          public static final String Version = "1.0";
          @Instance("modminecraft")
          public static ModMinecraft instance;
      
          @SidedProxy(clientSide = "mod.client.ClientProxy", serverSide = "mod.common.CommonProxy")
          public static CommonProxy proxy;
      
          @EventHandler
          public void preInit(FMLPreInitializationEvent event)
          {
              BlockRegister.register();
              ItemRegister.register();
      
          }
      
          @EventHandler
          public void init(FMLInitializationEvent event)
          {
              RegisterTileEntity.register();
              RecipeRegister.register();
      
              EntityRegister.register();
      
              proxy.registerRender();
              proxy.registerTileEntityRender();
      
              NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
          }
      
          @EventHandler
          public void postInit(FMLPostInitializationEvent event)
          {
      
          }
      }
      

      AnalyzerRecipes

      package mod.common.block;
      
      import java.util.HashMap;
      import java.util.Iterator;
      import java.util.Map;
      import java.util.Map.Entry;
      
      import mod.common.item.ItemRegister;
      import net.minecraft.item.Item;
      import net.minecraft.item.ItemStack;
      
      @SuppressWarnings("rawtypes")
      public class AnalyzerRecipes {
      
      private static final AnalyzerRecipes smeltingBase = new AnalyzerRecipes(); //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 AnalyzerRecipes()
      {
      
      this.addRecipe(ItemRegister.itemADNofFrog, ItemRegister.itemSevewithmosquito, new ItemStack(BlockRegister.BlockBarriere)); //Ajout d'une recette, on fait un bloc de diamant à partie de deux pommes et une flèche
      }
      
      @SuppressWarnings("unchecked")
      public void addRecipe(ItemStack stack1, ItemStack stack2, ItemStack stack3) //Cette fonction de comprend que des ItemStack, c'est celle qui ajoute les recettes à la HashMap
      {
      ItemStack[] stackList = new ItemStack[]{stack1, stack2};
      this.smeltingList.put(stackList, stack3);
      }
      
              public void addRecipe(Item item1, Item item2, ItemStack stack) //1er cas
      {
      this.addRecipe(new ItemStack(item1), new ItemStack(item2), 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<=1; i++) // Pour les 3 items
          {
          if(stackList*.getItem() == stackList2*.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 AnalyzerRecipes smelting()
              {
              return smeltingBase;
              }
      }
      

      BlockAnalyzer

      package mod.common.block;
      
      import java.util.List;
      
      import cpw.mods.fml.relauncher.Side;
      import cpw.mods.fml.relauncher.SideOnly;
      import mod.ModMinecraft;
      import mod.common.block.entity.TileEntityAnalyzer;
      import net.minecraft.block.Block;
      import net.minecraft.block.material.Material;
      import net.minecraft.client.renderer.texture.IIconRegister;
      import net.minecraft.creativetab.CreativeTabs;
      import net.minecraft.entity.EntityLivingBase;
      import net.minecraft.entity.item.EntityItem;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.inventory.IInventory;
      import net.minecraft.item.Item;
      import net.minecraft.item.ItemStack;
      import net.minecraft.nbt.NBTTagCompound;
      import net.minecraft.tileentity.TileEntity;
      import net.minecraft.util.IIcon;
      import net.minecraft.util.MathHelper;
      import net.minecraft.world.World;
      
      public class BlockAnalyzer extends Block 
      {
      private IIcon front;
      
      public BlockAnalyzer()
      {
        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
         //N'oubliez pas de remplacer "ModTutoriel"
        // … Mettez les attributs complémentaires que vous voulez
      }
      
      public void registerBlockIcons(IIconRegister iiconRegister)
         {
          this.blockIcon = iiconRegister.registerIcon(ModMinecraft.MODID + ":block2");
          this.front = iiconRegister.registerIcon(ModMinecraft.MODID + ":block1");
      
         }
      
       public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack)
         {
             int direction = MathHelper.floor_double((double)(living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3;
             world.setBlockMetadataWithNotify(x, y, z, direction, 2);
         }
      
        @SideOnly(Side.CLIENT)
         public IIcon getIcon(int side, int metadata)
         {
             if((side == 3 && metadata == 0) || (side == 4 && metadata == 1) || (side == 2 && metadata == 2) || (side == 5 && metadata == 3))
             {
                 return this.front;
             }
      return this.blockIcon;
      
         }
      
      @Override
      public TileEntity createTileEntity(World world, int metadata) //Instancie le TileEntity
          {
              return new TileEntityAnalyzer();
          }
      
          @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(ModMinecraft.instance, 0, world, x, y, z);
                  return true;
              }
          }
      }
      

      BlockRegister

      
      package mod.common.block;
      
      import cpw.mods.fml.common.registry.GameRegistry;
      import mod.ModMinecraft;
      import mod.common.block.entity.TileEntityAnalyzer;
      import mod.common.block.entity.TileEntityBarriere;
      import net.minecraft.block.Block;
      import net.minecraft.block.material.Material;
      import net.minecraft.creativetab.CreativeTabs;
      
      public class BlockRegister 
      {
      
          public static Block BlockBarriere;
          public static Block BlockTronc;
          public static Block BlockFeuille;
          public static Block BlockPousse;
          public static Block BlockAnalyzer;
          public static Block BlockAmbre;
      
          public static void register()
          {
          BlockBarriere = new BlockBarriere(Material.rock).setCreativeTab(CreativeTabs.tabBlock).setBlockTextureName(ModMinecraft.MODID + ":blockBarriere");
              BlockTronc = new BlockTronc().setBlockName("blockTronc").setCreativeTab(CreativeTabs.tabBlock).setHardness(2.0F).setBlockTextureName(ModMinecraft.MODID + ":blockTronc");
              BlockFeuille = new BlockFeuille().setBlockName("blockFeuille").setCreativeTab(CreativeTabs.tabBlock).setHardness(0.1F).setBlockTextureName(ModMinecraft.MODID + ":blockFeuille");
              BlockPousse = new BlockPousse().setBlockName("blockPousse").setHardness(0.5F).setBlockTextureName(ModMinecraft.MODID + ":blockPousse");
              BlockAnalyzer = new BlockAnalyzer().setBlockName("blockAnalyzer").setCreativeTab(CreativeTabs.tabBlock);
              BlockAmbre = new BlockAmbre().setBlockName("blockAmbre").setCreativeTab(CreativeTabs.tabBlock);
      
              GameRegistry.registerBlock(BlockAnalyzer,"block_analyzer");
              GameRegistry.registerBlock(BlockBarriere, "block_barriere");
              GameRegistry.registerBlock(BlockTronc, "block_tronc");
              GameRegistry.registerBlock(BlockFeuille, "block_feuille");
              GameRegistry.registerBlock(BlockPousse, "block_pousse");
              GameRegistry.registerBlock(BlockAmbre, "block_ambre");
      
          }
      }
      

      ContainerAnalyzer

      
      package mod.common.block;
      
      import mod.common.block.entity.TileEntityAnalyzer;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.entity.player.InventoryPlayer;
      import net.minecraft.inventory.Container;
      import net.minecraft.inventory.Slot;
      import net.minecraft.item.ItemStack;
      
      public class ContainerAnalyzer extends Container {
      
      private TileEntityAnalyzer tileAnalyzer;
      
      public ContainerAnalyzer(TileEntityAnalyzer tile, InventoryPlayer inventory)
      {
              this.tileAnalyzer = tile;
              this.addSlotToContainer(new Slot(tile, 0, 117, 31)); //Lancez votre jeu en debug pour calibrer vos slots
              this.addSlotToContainer(new Slot(tile, 2, 61, 31));
              this.addSlotToContainer(new SlotResult(tile, 3, 89, 87)); //Ici c'est un slot que j'ai créer, on le fera après
              this.bindPlayerInventory(inventory); //Les containers ont été vus dans un tutoriel de robin, merci de d'y référer
      }
      
      @Override
      public boolean canInteractWith(EntityPlayer player) {
      return this.tileAnalyzer.isUseableByPlayer(player);
      }
      
      private void bindPlayerInventory(InventoryPlayer inventory)
      {
      int i;
      for (i = 0; i < 3; ++i)
              {
                  for (int j = 0; j < 9; ++j)
                  {
                      this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 17 + j * 18, 125 + i * 18));
                  }
              }
      
              for (i = 0; i < 9; ++i)
              {
                  this.addSlotToContainer(new Slot(inventory, i, 17 + i * 18, 183));
              }
      }
      
      public ItemStack transferStackInSlot(EntityPlayer player, int quantity)
          {
              ItemStack itemstack = null;
              Slot slot = (Slot)this.inventorySlots.get(quantity);
      
              if (slot != null && slot.getHasStack())
              {
                  ItemStack itemstack1 = slot.getStack();
                  itemstack = itemstack1.copy();
      
                  if (quantity < this.tileAnalyzer.getSizeInventory())
                  {
                      if (!this.mergeItemStack(itemstack1, this.tileAnalyzer.getSizeInventory(), this.inventorySlots.size(), true))
                      {
                          return null;
                      }
                  }
                  else if (!this.mergeItemStack(itemstack1, 0, this.tileAnalyzer.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.tileAnalyzer.closeInventory();
          }
      }
      

      GuiAnalyzer

      
      package mod.common.block;
      
      import org.lwjgl.opengl.GL11;
      
      import mod.ModMinecraft;
      import mod.common.block.entity.TileEntityAnalyzer;
      import net.minecraft.client.gui.inventory.GuiContainer;
      import net.minecraft.entity.player.InventoryPlayer;
      import net.minecraft.inventory.IInventory;
      import net.minecraft.util.ResourceLocation;
      import net.minecraft.client.resources.I18n;
      
      public class GuiAnalyzer extends GuiContainer {
      
      private static final ResourceLocation texture = new ResourceLocation(ModMinecraft.MODID,"textures/gui/container/guiAnalyzer.png");
          @SuppressWarnings("unused")
      private TileEntityAnalyzer tileAnalyzer;
          private IInventory playerInv;
      
      public GuiAnalyzer(TileEntityAnalyzer tile, InventoryPlayer inventory) 
      {
      super(new ContainerAnalyzer(tile, inventory));
              this.tileAnalyzer = tile;
              this.playerInv = inventory;
              this.allowUserInput = false;
              this.ySize = 207;
              this.xSize = 195;
      }
      
      @Override
      protected void drawGuiContainerBackgroundLayer(float partialRenderTick, int x, int y) 
      {
      
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
              this.mc.getTextureManager().bindTexture(texture);
              int k = (this.width - this.xSize) / 2;
              int l = (this.height - this.ySize) / 2;
              this.drawTexturedModalRect(k, l, 0, 46, this.xSize, this.ySize);
      
              if(this.tileAnalyzer.isBurning())
              {
              int i = this.tileAnalyzer.getCookProgress();
              this.drawTexturedModalRect(k + 47, l + 46, 0, 2, 100, i);
              }
      }
      
      protected void drawGuiContainerForegroundLayer(int x, int y)
          {
              this.fontRendererObj.drawString(this.playerInv.hasCustomInventoryName() ? this.playerInv.getInventoryName() : I18n.format(this.playerInv.getInventoryName()), 10, this.ySize - 98, 4210752);
          }
      
      }
      

      GuiHandler

      package mod.common.block;
      
      import mod.common.block.entity.TileEntityAnalyzer;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.tileentity.TileEntity;
      import net.minecraft.world.World;
      import cpw.mods.fml.common.network.IGuiHandler;
      
      public class GuiHandler implements IGuiHandler
      {
      @Override
      public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
      switch (ID) {
      
      case 0:
      TileEntity tile = world.getTileEntity(x, y, z);
      if(tile instanceof TileEntityAnalyzer)
      {
      return new ContainerAnalyzer((TileEntityAnalyzer)tile, player.inventory);
      }
      }
      
      return null;
      }
      
      @Override
      public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
      switch (ID) {
      
      case 0:
      TileEntity tile = world.getTileEntity(x, y, z);
      if(tile instanceof TileEntityAnalyzer)
      {
      return new GuiAnalyzer((TileEntityAnalyzer)tile, player.inventory);
      }
      }
      
      return null;
      }
      
      }
      

      SlotResult

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

      Oui ce gif est drôle.

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

        TileEntity et block ?

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

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

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

          La classe blockanalyzer y est , le 3 eme en partant du haut 🙂 Et désolé j’ai oublié le tileentity le voici

          package mod.common.block.entity;
          
          import cpw.mods.fml.relauncher.Side;
          import cpw.mods.fml.relauncher.SideOnly;
          import mod.common.block.AnalyzerRecipes;
          import net.minecraft.entity.player.EntityPlayer;
          import net.minecraft.inventory.IInventory;
          import net.minecraft.item.ItemStack;
          import net.minecraft.nbt.NBTTagCompound;
          import net.minecraft.nbt.NBTTagList;
          import net.minecraft.tileentity.TileEntity;
          
          public class TileEntityAnalyzer extends TileEntity implements IInventory
          {
          
          private ItemStack[] contents = new ItemStack[4]; //0, 1 et 2 sont les inputs et 3 est l'output
          
          private int workingTime = 0; //Temps de cuisson actuel
          private int workingTimeNeeded = 40; //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.Analyzer";
          }
          
          @Override
          public boolean hasCustomInventoryName() {
          return false;
          }
          
          @Override
          public int getInventoryStackLimit() {
          return 64;
          }
          
          @Override
          public boolean isUseableByPlayer(EntityPlayer player) {
          return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
          }
          
          @Override
          public void openInventory() {
          
          }
          
          @Override
          public void closeInventory() {
          
          }
          
          @Override
          public boolean isItemValidForSlot(int slot, ItemStack stack) {
          return slot == 2 ? false : true;
          }
          
          public boolean isBurning()
          {
          return this.workingTime > 0;
          }
          
          private boolean canSmelt()
          {
          if (this.contents[0] == null || this.contents[1] == null) //Si les trois premiers slots sont vides
          {
          return false; //On ne peut pas lancer le processus
          }
          else
          {
          ItemStack itemstack = AnalyzerRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], 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[2] == null) return true; //vérifications du slot d'output
          if (!this.contents[2].isItemEqual(itemstack)) return false; //ici aussi
          int result = contents[2].stackSize + itemstack.stackSize;
          return result <= getInventoryStackLimit() && result <= this.contents[2].getMaxStackSize(); //Et là aussi décidément
          }
          }
          
          @Override
          public void updateEntity() //Méthode exécutée à chaque tick
          {
          if(this.isBurning() && this.canSmelt()) //Si on "cuit" et que notre recette et toujours bonne, on continue
          {
          ++this.workingTime; //incrémentation
          }
          if(this.canSmelt() && !this.isBurning()) //Si la recette est bonne mais qu'elle n'est toujours pas lancée, on la lance
          {
          this.workingTime = 1; //La méthode isBurning() renverra true maintenant (1>0)
          }
          if(this.canSmelt() && this.workingTime == this.workingTimeNeeded) //Si on est arrivé au bout du temps de cuisson et que la recette est toujours bonne
          {
          this.smeltItem(); //on "cuit" les items
          this.workingTime = 0; //et on réinitialise le temps de cuisson
          }
          if(!this.canSmelt()) //Si la recette la recette n'est plus bonne
          {
          this.workingTime= 0; //le temps de cuisson est de 0
          }
          }
          
          public void smeltItem()
          {
          if (this.canSmelt())
          {
          ItemStack itemstack = AnalyzerRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]}); //On récupère l'output de la recette
          if (this.contents[2] == null) //Si il y a rien dans le slot d'output
          {
          this.contents[2] = itemstack.copy(); //On met directement l'ItemStack
          }
          else if (this.contents[2].getItem() == itemstack.getItem()) //Et si l'item que l'on veut est le même que celui qu'il y a déjà
          {
          this.contents[2].stackSize += itemstack.stackSize; // Alors ont incrémente l'ItemStack
          }
          
          –this.contents[0].stackSize; //On décrémente les slots d'input
          –this.contents[1].stackSize;
          
          if (this.contents[0].stackSize <= 0) //Si les slots sont vides, on remet à null le slot
          {
          this.contents[0] = null;
          }
          if (this.contents[1].stackSize <= 0)
          {
          this.contents[1] = null;
          }
          
          }
          }
          
          @SideOnly(Side.CLIENT)
          public int getCookProgress()
          {
          return this.workingTime * 33 / this.workingTimeNeeded; //41 correspond à la hauteur de la barre de progression car notre barre de progression se déroule de haut en bas
          }
          }
          
          

          Oui ce gif est drôle.

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

            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(ModMinecraft.instance, 0, world, x, y, z);
            return true;
            }
            }
            

            La fonction openGui doit être appelée côté client aussi : enlève la condition.

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

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

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

              Si j’enleve la condition mon block ne fonctionne plus lorsque je clic dessus rien ne s’ouvre 😕

              Oui ce gif est drôle.

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

                Ton block ne fonctionne plus ?! c’est à dire ? Il faut enlever cette condition. Regarde mon tutoriel sur “comment créer un item type backpack”, tu verras que j’appelle la méthode côté client ET serveur.

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

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

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

                  Bah en gros si j’enlève la fonction lorsque je fais un click droit sur le block le gui ne s’ouvre plus et pourquoi parler du tutoriel sur comment créer un item type bagpack , moi je suis au tutoriel Créer un block type four … Si je mélange les tutoriels sa va pas marcher 😕

                  Oui ce gif est drôle.

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

                    @‘SCAREX’:

                    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(ModMinecraft.instance, 0, world, x, y, z);
                               return true;
                           }
                       }
                    

                    La fonction openGui doit être appelée côté client aussi : enlève la condition.

                    Heu non. openGui doit être appelé côté serveur, FML envoie un paquet au client.

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

                      Donc je le laisse du coup ^^ ?

                      Oui ce gif est drôle.

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

                        Bon j’ai refais le tutoriel de A à Z et vérifier toutes les lignes de codes j’ai trouver 1 erreur et 1 truc qui me semble louche 🙂

                        En supprimant l’erreur 1 sa na rien changer puis je me suis rappeler de l’erreur boudoutofmachintruc , et j’ai un ```java
                        private ItemStack[] contents = new ItemStack[4];

                        
                        Voila je désespère un peu car en ayant tout re vérifier pour la troisième fois j'ai trouver 1 erreur qui ne règle pas mon soucis et 1 truc bizarre , voila j'attend de plus ample informations..
                        
                        Et aussi dans le container j'ai ceci
                        ```java
                        private void bindPlayerInventory(InventoryPlayer inventory)
                        {
                        int i;
                        for (i = 0; i < 3; ++i)
                               {
                                   for (int j = 0; j < 9; ++j)
                                   {
                                       this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 17 + j * 18, 125 + i * 18));
                                   }
                               }
                        
                               for (i = 0; i < 9; ++i)
                               {
                                   this.addSlotToContainer(new Slot(inventory, i, 17 + i * 18, 183));
                               }
                        }
                        

                        cette ‘fonction’

                        for (i = 0; i < 3; ++i)
                        

                        le 3 représente quoi ? car si il représente les slots d’input sa devrait etre 2 du coup 🙂 Voila merci à ceux qui m’aideront d’avance 🙂

                        Oui ce gif est drôle.

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

                          4 correspond à la taille du tableau, si tu veux 3 éléments, il faudra mettre 3. Pour la boucle : çà doit être la taille du tableau, donc 3 si tu veux 3 slots, car c’est un signe “strictement inférieur à”, donc ta boucle fera les positions 0,1 et 2 puis s’arrêtera car 3 n’est pas inférieur à 3. L’erreur ArrayOutOfBoundsException est une erreur qui apparâit lorsque tu essayes d’accéder à une valeur en dehors du tableau :

                          • position -1 : impossible, pas de valeurs négatives
                          • position 0 : le tableau commence à 0, pas 1 !
                          • position 1
                          • position 2
                          • position 3 : impossible, la taille est de 3.

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

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

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

                            Si je met mon tableau à 3 il m’affiche l’erreur [size=x-small ArrayOutOfBoundsException] 😕
                            Bah alors je vois pas pourquoi ma recette ne fonctionne pas 😞

                            Oui ce gif est drôle.

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

                              @‘Legrandfifou’:

                              Bon j’ai refais le tutoriel de A à Z et vérifier toutes les lignes de codes j’ai trouver 1 erreur et 1 truc qui me semble louche 🙂

                              En supprimant l’erreur 1 sa na rien changer puis je me suis rappeler de l’erreur boudoutofmachintruc , et j’ai un

                              private ItemStack[] contents = new ItemStack[4];
                              

                              , mais j’ai 0 , 1 INPUT et 2 OUTPUT , donc pourquoi je dois mettre 4 si j’en ai 3 ?

                              Voila je désespère un peu car en ayant tout re vérifier pour la troisième fois j’ai trouver 1 erreur qui ne règle pas mon soucis et 1 truc bizarre , voila j’attend de plus ample informations…

                              Et aussi dans le container j’ai ceci

                              private void bindPlayerInventory(InventoryPlayer inventory)
                              {
                              int i;
                              for (i = 0; i < 3; ++i)
                                     {
                                         for (int j = 0; j < 9; ++j)
                                         {
                                             this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 17 + j * 18, 125 + i * 18));
                                         }
                                     }
                              
                                     for (i = 0; i < 9; ++i)
                                     {
                                         this.addSlotToContainer(new Slot(inventory, i, 17 + i * 18, 183));
                                     }
                              }
                              

                              cette ‘fonction’

                              for (i = 0; i < 3; ++i)
                              

                              le 3 représente quoi ? car si il représente les slots d’input sa devrait etre 2 du coup 🙂 Voila merci à ceux qui m’aideront d’avance 🙂

                              Il y a deux boucles l’une dans l’autre, une qui fait varier de 0 à 3 exclut et une de 0 à 9 exclut. Cela correspond aux 27 cases de l’inventaire du joueur. Et l’autre boucle qui va de 0 à 9 exclut correspond aux 9 cases du bas de l’inventaire du joueur (celle utilisable directement en jeu).

                              Donc si tu as toujours des problèmes de ArrayOutOfBoundsException ça ne vient pas de cette fonction. Envoie le constructeur de ton Container.

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

                                J’ai mis toutes les classes dans mon poste , tiens ```java
                                package mod.common.block;

                                import mod.common.block.entity.TileEntityAnalyzer;
                                import net.minecraft.entity.player.EntityPlayer;
                                import net.minecraft.entity.player.InventoryPlayer;
                                import net.minecraft.inventory.Container;
                                import net.minecraft.inventory.Slot;
                                import net.minecraft.item.ItemStack;

                                public class ContainerAnalyzer extends Container {

                                private TileEntityAnalyzer tileBlockAnalyzer;

                                public ContainerAnalyzer(TileEntityAnalyzer tile, InventoryPlayer inventory)
                                {
                                this.tileBlockAnalyzer = tile;
                                this.addSlotToContainer(new Slot(tile, 0, 117, 31)); //Lancez votre jeu en debug pour calibrer vos slots
                                this.addSlotToContainer(new Slot(tile, 2, 61, 31));
                                this.addSlotToContainer(new SlotResult(tile, 3, 89, 87)); //Ici c’est un slot que j’ai créer, on le fera après
                                this.bindPlayerInventory(inventory); //Les containers ont été vus dans un tutoriel de robin, merci de d’y référer
                                }

                                @Override
                                public boolean canInteractWith(EntityPlayer player) {
                                return this.tileBlockAnalyzer.isUseableByPlayer(player);
                                }

                                private void bindPlayerInventory(InventoryPlayer inventory)
                                {
                                int i;
                                for (i = 0; i < 3; ++i)
                                {
                                for (int j = 0; j < 9; ++j)
                                {
                                this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 17 + j * 18, 125 + i * 18));
                                }
                                }

                                for (i = 0; i < 9; ++i)
                                {
                                this.addSlotToContainer(new Slot(inventory, i, 17 + i * 18, 183));
                                }
                                }

                                public ItemStack transferStackInSlot(EntityPlayer player, int quantity)
                                {
                                ItemStack itemstack = null;
                                Slot slot = (Slot)this.inventorySlots.get(quantity);

                                if (slot != null && slot.getHasStack())
                                {
                                ItemStack itemstack1 = slot.getStack();
                                itemstack = itemstack1.copy();

                                if (quantity < this.tileBlockAnalyzer.getSizeInventory())
                                {
                                if (!this.mergeItemStack(itemstack1, this.tileBlockAnalyzer.getSizeInventory(), this.inventorySlots.size(), true))
                                {
                                return null;
                                }
                                }
                                else if (!this.mergeItemStack(itemstack1, 0, this.tileBlockAnalyzer.getSizeInventory(), false))
                                {
                                return null;
                                }

                                if (itemstack1.stackSize == 0)
                                {
                                slot.putStack((ItemStack)null);
                                }
                                else
                                {
                                slot.onSlotChanged();
                                }
                                }

                                return itemstack;
                                }

                                public void onContainerClosed(EntityPlayer player)
                                {
                                super.onContainerClosed(player);
                                this.tileBlockAnalyzer.closeInventory();
                                }
                                }

                                Oui ce gif est drôle.

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

                                  this.addSlotToContainer(new Slot(tile, 0, 117, 31)); //Lancez votre jeu en debug pour calibrer vos slots
                                  this.addSlotToContainer(new Slot(tile, 2, 61, 31));
                                  this.addSlotToContainer(new SlotResult(tile, 3, 89, 87)); //Ici c’est un slot que j’ai créer, on le fera après
                                  0 - 2 - 3.
                                  Tu n’as pas l’impression qu’il y a un problème ici ?

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

                                    Oh bordel je croyais que c’était des coordonnées T_T XYZ et c’est vrai que maintenant je me dit Z c’est l’axe donc WTF , je suis débile srx

                                    Oui ce gif est drôle.

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

                                      Par contre pour la barre de chargement je l’ai aligner et suivi en mettant la hauteur etc mais elle s’affiche un tout petit peu au début mais elle ne se remplit pas entièrement 😕

                                      GuiAnalyzer ```java
                                      @Override
                                      protected void drawGuiContainerBackgroundLayer(float partialRenderTick, int x, int y)
                                      {

                                      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                                      this.mc.getTextureManager().bindTexture(texture);
                                      int k = (this.width - this.xSize) / 2;
                                      int l = (this.height - this.ySize) / 2;
                                      this.drawTexturedModalRect(k, l, 0, 46, this.xSize, this.ySize);

                                      if(this.tileBlockAnalyzer.isBurning())
                                      {
                                      int i = this.tileBlockAnalyzer.getCookProgress();
                                      this.drawTexturedModalRect(k + 59, l + 47, 0, 1, 100, i);

                                      }
                                      }

                                      
                                      TileEntityAnalyzer ```java
                                      @SideOnly(Side.CLIENT)
                                      public int getCookProgress()
                                      {
                                      return this.workingTime * 33 / this.workingTimeNeeded; //33 correspond à la hauteur de la barre de progression car notre barre de progression se déroule de haut en bas
                                      }
                                      

                                      Mais lorsque ma recette se fait , la texture de chargement descend mais elle ne fais pas toutes la barre 😕

                                      Oui ce gif est drôle.

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

                                        Ta texture ressemble à quoi ?

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

                                          nsa38.casimages.com/img/2015/07/09/150709051222791765.png

                                          Oui ce gif est drôle.

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


                                            J’arrivais pas a l’afficher sur le dernier poste j’ai du refaire un nouveau message

                                            Oui ce gif est drôle.

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

                                            MINECRAFT FORGE FRANCE © 2018

                                            Powered by NodeBB