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

    Résolu [1.7.10] - Erreur + texture buggé + crash

    1.7.x
    1.7.10
    2
    17
    427
    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.
    • ZunF1x
      ZunF1x dernière édition par

      pour ce qui est de l’erreur la voici:

      erreur:

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

      ligne:

      this.contents.writeToNBT(nbttagcompound1);
      

      classe:

      package fr.askipie.funfight;
      
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.inventory.IInventory;
      import net.minecraft.item.ItemStack;
      import net.minecraft.nbt.NBTTagCompound;
      import net.minecraft.nbt.NBTTagList;
      import net.minecraft.tileentity.TileEntity;
      import net.minecraftforge.common.util.Constants;
      
      public class TileEntityFungieMachine extends TileEntity implements IInventory
      {
          
          private ItemStack[] contents = new ItemStack[4]; //0, 1 et 2 sont les inputs et 3 est l'output
          
          private int workingTime = 0; //Temps de cuisson actuel
          private int workingTimeNeeded = 200; //Temps de cuisson nécessaire
      
          
        
      
          @Override
          public void writeToNBT(NBTTagCompound compound)
          {
              super.writeToNBT(compound);
              NBTTagList nbttaglist = new NBTTagList();
       
              for (int i = 0; i < this.contents.length; ++i) //pour les slots
              {
                  if (this.contents != null)
                  {
                      NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                      nbttagcompound1.setByte("Slot", (byte)i);
                      this.contents.writeToNBT(nbttagcompound1);
                      nbttaglist.appendTag(nbttagcompound1);
                  }
              }
       
              compound.setTag("Items", nbttaglist);
              compound.setShort("workingTime",(short)this.workingTime); //On les enregistrent en short
              compound.setShort("workingTimeNeeded", (short)this.workingTimeNeeded);
          }
          
          @Override
          public void readFromNBT(NBTTagCompound compound)
          {
              super.readFromNBT(compound);
       
              NBTTagList nbttaglist = compound.getTagList("Items", 10);
              this.contents = new ItemStack[this.getSizeInventory()];
       
              for (int i = 0; i < nbttaglist.tagCount(); ++i) //Encore une fois pour les slots
              {
                  NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
                  int j = nbttagcompound1.getByte("Slot") & 255;
       
                  if (j >= 0 && j < this.contents.length)
                  {
                      this.contents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
                  }
              }
       
              this.workingTime = compound.getShort("workingTime"); //On lit nos valeurs
              this.workingTimeNeeded = compound.getShort("workingTimeNeeded");
          }
          
      
      
          @Override
          public int getSizeInventory() { //Tout est dans le nom, retourne la taille de l'inventaire, pour notre bloc c'est quatre
              return this.contents.length;
          }
      
          @Override
          public ItemStack getStackInSlot(int slotIndex) { //Renvoie L'itemStack se trouvant dans le slot passé en argument
              return this.contents[slotIndex];
          }
      
          @Override //Comme dit plus haut, c'est expliqué dans le tutoriel de robin
          public ItemStack decrStackSize(int slotIndex, int amount) {
                  if (this.contents[slotIndex] != null)
                  {
                      ItemStack itemstack;
       
                      if (this.contents[slotIndex].stackSize <= amount)
                      {
                          itemstack = this.contents[slotIndex];
                          this.contents[slotIndex] = null;
                          this.markDirty();
                          return itemstack;
                      }
                      else
                      {
                          itemstack = this.contents[slotIndex].splitStack(amount);
       
                          if (this.contents[slotIndex].stackSize == 0)
                          {
                              this.contents[slotIndex] = null;
                          }
       
                          this.markDirty();
                          return itemstack;
                      }
                  }
                  else
                  {
                      return null;
                  }
          }
       
          @Override
          public ItemStack getStackInSlotOnClosing(int slotIndex) {
              if (this.contents[slotIndex] != null)
              {
                  ItemStack itemstack = this.contents[slotIndex];
                  this.contents[slotIndex] = null;
                  return itemstack;
              }
              else
              {
                  return null;
              }
          }
       
          @Override
          public void setInventorySlotContents(int slotIndex, ItemStack stack) {
              this.contents[slotIndex] = stack;
       
              if (stack != null && stack.stackSize > this.getInventoryStackLimit())
              {
                  stack.stackSize = this.getInventoryStackLimit();
              }
       
              this.markDirty();
          }
       
          @Override
          public String getInventoryName() { //J'ai décider qu'on ne pouvait pas mettre de nom custom
              return "tile.machineTuto";
          }
       
          @Override
          public boolean hasCustomInventoryName() {
              return false;
          }
       
          @Override
          public int getInventoryStackLimit() {
              return 64;
          }
       
          @Override
          public boolean isUseableByPlayer(EntityPlayer player) {
              return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
          }
       
          @Override
          public void openInventory() {
       
          }
       
          @Override
          public void closeInventory() {
       
          }
       
          @Override
          public boolean isItemValidForSlot(int slot, ItemStack stack) {
              return slot == 3 ? false : true;
          }
      
          public boolean isBurning()
          {
              return this.workingTime > 0;
          }
          
          private boolean canSmelt()
          {
              if (this.contents[0] == null || this.contents[1] == null || this.contents[2] == null) //Si les trois premiers slots sont vides
              {
                  return false; //On ne peut pas lancer le processus
              }
              else
              {
                  ItemStack itemstack = FungieMachineRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]}); //Il y a une erreur ici, c'est normal, on y vient après (c'est pour les recettes)
                  if (itemstack == null) return false; //rapport avec les recettes
                  if (this.contents[3] == null) return true; //vérifications du slot d'output
                  if (!this.contents[3].isItemEqual(itemstack)) return false; //ici aussi
                  int result = contents[3].stackSize + itemstack.stackSize;
                  return result <= getInventoryStackLimit() && result <= this.contents[3].getMaxStackSize(); //Et là aussi décidément
              }
          }
          
          public void updateEntity() //Méthode exécutée à chaque tick
          {
              if(this.isBurning() && this.canSmelt()) //Si on "cuit" et que notre recette et toujours bonne, on continue
              {
                  ++this.workingTime; //incrémentation
              }
              if(this.canSmelt() && !this.isBurning()) //Si la recette est bonne mais qu'elle n'est toujours pas lancée, on la lance
              {
                  this.workingTime = 1; //La méthode isBurning() renverra true maintenant (1>0)
              }
              if(this.canSmelt() && this.workingTime == this.workingTimeNeeded) //Si on est arrivé au bout du temps de cuisson et que la recette est toujours bonne
              {
                  this.smeltItem(); //on "cuit" les items
                  this.workingTime = 0; //et on réinitialise le temps de cuisson
              }
              if(!this.canSmelt()) //Si la recette la recette n'est plus bonne
              {
                      this.workingTime= 0; //le temps de cuisson est de 0
              }
          }
          
          public void smeltItem()
          {
              if (this.canSmelt())
              {
                  ItemStack itemstack = FungieMachineRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]}); //On récupère l'output de la recette
                  if (this.contents[3] == null) //Si il y a rien dans le slot d'output
                  {
                      this.contents[3] = itemstack.copy(); //On met directement l'ItemStack
                  }
                  else if (this.contents[3].getItem() == itemstack.getItem()) //Et si l'item que l'on veut est le même que celui qu'il y a déjà
                  {
                      this.contents[3].stackSize += itemstack.stackSize; // Alors ont incrémente l'ItemStack
                  }
       
                  --this.contents[0].stackSize; //On décrémente les slots d'input
                  --this.contents[1].stackSize;
                  --this.contents[2].stackSize;
       
                  if (this.contents[0].stackSize <= 0) //Si les slots sont vides, on remet à null le slot
                  {
                      this.contents[0] = null;
                  }
                  if (this.contents[1].stackSize <= 0)
                  {
                      this.contents[1] = null;
                  }
                  if (this.contents[2].stackSize <= 0)
                  {
                      this.contents[2] = null;
                  }
              }
          }
      
          public void setCustomName(String displayName)
          {
              
          }
      }
      

      pour ce qui est du bug de texture quand je craft un objet ca le craft bien met la barre qui nous indique ou en est le craft reste grise et ne devien pas rouge

      et pour le crash des que l’item est crafter dans la machine je le recupere et ca crash

      crash report:

      ---- Minecraft Crash Report ----
      // I let you down. Sorry :(
      
      Time: 18/02/19 23:37
      Description: Exception in server tick loop
      
      java.lang.Error: Unresolved compilation problem: 
      	Cannot invoke writeToNBT(NBTTagCompound) on the array type ItemStack[]
      
      	at fr.askipie.funfight.TileEntityFungieMachine.writeToNBT(TileEntityFungieMachine.java:34)
      	at net.minecraft.world.chunk.storage.AnvilChunkLoader.writeChunkToNBT(AnvilChunkLoader.java:395)
      	at net.minecraft.world.chunk.storage.AnvilChunkLoader.saveChunk(AnvilChunkLoader.java:204)
      	at net.minecraft.world.gen.ChunkProviderServer.safeSaveChunk(ChunkProviderServer.java:287)
      	at net.minecraft.world.gen.ChunkProviderServer.saveChunks(ChunkProviderServer.java:340)
      	at net.minecraft.world.WorldServer.saveAllChunks(WorldServer.java:863)
      	at net.minecraft.server.MinecraftServer.saveAllWorlds(MinecraftServer.java:370)
      	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:636)
      	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
      	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)
      	at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)
      
      
      A detailed walkthrough of the error, its code path and all known details is as follows:
      ---------------------------------------------------------------------------------------
      
      -- System Details --
      Details:
      	Minecraft Version: 1.7.10
      	Operating System: Windows 8.1 (amd64) version 6.3
      	Java Version: 1.8.0_202, Oracle Corporation
      	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
      	Memory: 936791688 bytes (893 MB) / 1056309248 bytes (1007 MB) up to 1056309248 bytes (1007 MB)
      	JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
      	AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
      	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
      	FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1558 4 mods loaded, 4 mods active
      	States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
      	UCHIJAAAA	mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) 
      	UCHIJAAAA	FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) 
      	UCHIJAAAA	Forge{10.13.4.1558} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) 
      	UCHIJAAAA	funfight{1.0.0} [FunFight] (bin) 
      	GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.
      	Profiler Position: N/A (disabled)
      	Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
      	Player Count: 1 / 8; [EntityPlayerMP['Player953'/175, l='New World', x=-407,06, y=4,00, z=-1879,45]]
      	Type: Integrated Server (map_client.txt)
      	Is Modded: Definitely; Client brand changed to 'fml,forge'
      

      et dans les logs de la console:

      [23:37:19] [Server thread/ERROR]: Encountered an unexpected exception
      java.lang.Error: Unresolved compilation problem: 
      	Cannot invoke writeToNBT(NBTTagCompound) on the array type ItemStack[]
      
      	at fr.askipie.funfight.TileEntityFungieMachine.writeToNBT(TileEntityFungieMachine.java:34) ~[TileEntityFungieMachine.class:?]
      	at net.minecraft.world.chunk.storage.AnvilChunkLoader.writeChunkToNBT(AnvilChunkLoader.java:395) ~[AnvilChunkLoader.class:?]
      	at net.minecraft.world.chunk.storage.AnvilChunkLoader.saveChunk(AnvilChunkLoader.java:204) ~[AnvilChunkLoader.class:?]
      	at net.minecraft.world.gen.ChunkProviderServer.safeSaveChunk(ChunkProviderServer.java:287) ~[ChunkProviderServer.class:?]
      	at net.minecraft.world.gen.ChunkProviderServer.saveChunks(ChunkProviderServer.java:340) ~[ChunkProviderServer.class:?]
      	at net.minecraft.world.WorldServer.saveAllChunks(WorldServer.java:863) ~[WorldServer.class:?]
      	at net.minecraft.server.MinecraftServer.saveAllWorlds(MinecraftServer.java:370) ~[MinecraftServer.class:?]
      	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:636) ~[MinecraftServer.class:?]
      	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) ~[IntegratedServer.class:?]
      	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?]
      	at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?]
      [23:37:19] [Server thread/ERROR]: This crash report has been saved to: C:\Users\atelier\Desktop\FunMod ClientServer\Funmod\eclipse\.\crash-reports\crash-2019-02-18_23.37.19-server.txt
      [23:37:19] [Server thread/INFO]: Stopping server
      [23:37:19] [Server thread/INFO]: Saving players
      [23:37:19] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: ---- Minecraft Crash Report ----
      // Don't do that.
      
      Time: 18/02/19 23:37
      Description: Exception in server tick loop
      
      java.lang.Error: Unresolved compilation problem: 
      	Cannot invoke writeToNBT(NBTTagCompound) on the array type ItemStack[]
      
      	at fr.askipie.funfight.TileEntityFungieMachine.writeToNBT(TileEntityFungieMachine.java:34)
      	at net.minecraft.world.chunk.storage.AnvilChunkLoader.writeChunkToNBT(AnvilChunkLoader.java:395)
      	at net.minecraft.world.chunk.storage.AnvilChunkLoader.saveChunk(AnvilChunkLoader.java:204)
      	at net.minecraft.world.gen.ChunkProviderServer.safeSaveChunk(ChunkProviderServer.java:287)
      	at net.minecraft.world.gen.ChunkProviderServer.saveChunks(ChunkProviderServer.java:340)
      	at net.minecraft.world.WorldServer.saveAllChunks(WorldServer.java:863)
      	at net.minecraft.server.MinecraftServer.saveAllWorlds(MinecraftServer.java:370)
      	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:636)
      	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
      	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)
      	at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)
      
      
      A detailed walkthrough of the error, its code path and all known details is as follows:
      ---------------------------------------------------------------------------------------
      
      -- System Details --
      Details:
      	Minecraft Version: 1.7.10
      	Operating System: Windows 8.1 (amd64) version 6.3
      	Java Version: 1.8.0_202, Oracle Corporation
      	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
      	Memory: 936791688 bytes (893 MB) / 1056309248 bytes (1007 MB) up to 1056309248 bytes (1007 MB)
      	JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
      	AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
      	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
      	FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1558 4 mods loaded, 4 mods active
      	States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
      	UCHIJAAAA	mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) 
      	UCHIJAAAA	FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) 
      	UCHIJAAAA	Forge{10.13.4.1558} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) 
      	UCHIJAAAA	funfight{1.0.0} [FunFight] (bin) 
      	GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.
      	Profiler Position: N/A (disabled)
      	Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
      	Player Count: 1 / 8; [EntityPlayerMP['Player953'/175, l='New World', x=-407,06, y=4,00, z=-1879,45]]
      	Type: Integrated Server (map_client.txt)
      	Is Modded: Definitely; Client brand changed to 'fml,forge'
      [23:37:19] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:393]: #@!@# Game crashed! Crash report saved to: #@!@# .\crash-reports\crash-2019-02-18_23.37.19-server.txt
      [23:37:19] [Client thread/INFO] [FML]: Waiting for the server to terminate/save.
      [23:37:19] [Server thread/INFO]: Saving worlds
      [23:37:19] [Server thread/INFO]: Saving chunks for level 'New World'/Overworld
      [23:37:19] [Server thread/ERROR]: Exception stopping the server
      java.lang.Error: Unresolved compilation problem: 
      	Cannot invoke writeToNBT(NBTTagCompound) on the array type ItemStack[]
      
      	at fr.askipie.funfight.TileEntityFungieMachine.writeToNBT(TileEntityFungieMachine.java:34) ~[TileEntityFungieMachine.class:?]
      	at net.minecraft.world.chunk.storage.AnvilChunkLoader.writeChunkToNBT(AnvilChunkLoader.java:395) ~[AnvilChunkLoader.class:?]
      	at net.minecraft.world.chunk.storage.AnvilChunkLoader.saveChunk(AnvilChunkLoader.java:204) ~[AnvilChunkLoader.class:?]
      	at net.minecraft.world.gen.ChunkProviderServer.safeSaveChunk(ChunkProviderServer.java:287) ~[ChunkProviderServer.class:?]
      	at net.minecraft.world.gen.ChunkProviderServer.saveChunks(ChunkProviderServer.java:340) ~[ChunkProviderServer.class:?]
      	at net.minecraft.world.WorldServer.saveAllChunks(WorldServer.java:863) ~[WorldServer.class:?]
      	at net.minecraft.server.MinecraftServer.saveAllWorlds(MinecraftServer.java:370) ~[MinecraftServer.class:?]
      	at net.minecraft.server.MinecraftServer.stopServer(MinecraftServer.java:405) ~[MinecraftServer.class:?]
      	at net.minecraft.server.integrated.IntegratedServer.stopServer(IntegratedServer.java:266) ~[IntegratedServer.class:?]
      	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:538) [MinecraftServer.class:?]
      	at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?]
      [23:37:19] [Server thread/INFO] [FML]: Applying holder lookups
      [23:37:19] [Server thread/INFO] [FML]: Holder lookups applied
      [23:37:19] [Server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded.
      [23:37:19] [Client thread/INFO] [FML]: Server terminated.
      AL lib: (EE) alc_cleanup: 1 device not closed
      Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
      

      j’espere recevoir une reponse d’ici peu.

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

        yo dans ta fonction writeToNBT de ton tileentity tu essais d’écrire dans les nbt une array d’ItemStack, or ceci n’est pas possible tu dois récupérer chaque éléments de l’array puis les écrire un par un dans la nbttaglist

        pour rappel une array est un tableau, c’est un objet spécial similaire a une liste d’instances d’objet, ensuite tu peux récupérer les éléments a l’aide d’un index donc un chiffre commençant de 0 jusqu’à la (taille de l’array - 1)

        par exemple : int[] arrayOfInt = {0, 52, 86, 05, 2, 53, 100}
        par exemple si je veux récup le nombre 52 alors je dois faire =>arrayOfInt[1] car le nombre 52 se trouve la 2eme position dans l’array, comme on utiliser un index alors on commence de 0 donc le premier élément est a l’index 0 et le second a l’index 1… et ainsi de suite

        dans ton cas tu doit utiliser la variable i de ta boucle for pour récupérer l’élément dans ton array d’ItemStack intitulé contents donc => this.contents[i], ceci te retournera un ItemStack et non une array d’ItemStack contrairement a this.contents (ce qui n’est pas la meme chose)

        ZunF1x 1 réponse Dernière réponse Répondre Citer 0
        • ZunF1x
          ZunF1x @SpyMan dernière édition par

          @SpyMan Ce probleme la est regler maintenant j’aurais besoin pour la textures

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

            c’est a dire ?

            ZunF1x 1 réponse Dernière réponse Répondre Citer 0
            • ZunF1x
              ZunF1x @SpyMan dernière édition par

              des que je fait cuire un truc dans ma machine la texture de la fleche reste grise et ne devient pas rouge sauf que j’ai retrouver le probleme mais maintenant j’ai des erreurs sur le code de la barre de progression pour quelle deviennent rouge

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

                c’est dans la class du gui et c’est la fonction drawTexturedModalRect qui n’a pas les bonnes valeurs

                ZunF1x 1 réponse Dernière réponse Répondre Citer 0
                • ZunF1x
                  ZunF1x @SpyMan dernière édition par

                  bah tien les codage pour me dire les bonnes valeurs:

                  le gui:

                  package fr.askipie.funfight;
                  
                  import org.lwjgl.opengl.GL11;
                  
                  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 fr.askipie.funfight.TileEntityFungieMachine;
                  
                  public class GuiFungieMachine extends GuiContainer
                  {
                      private static final ResourceLocation textures = new ResourceLocation(References.MODID + ":textures/gui/container/fungieMachine.png");
                      private TileEntityFungieMachine tileTuto;
                      private IInventory playerInv;
                  
                   
                      public GuiFungieMachine(TileEntityFungieMachine tile, InventoryPlayer inventory)
                      {
                          super(new ContainerFungieMachine(tile, inventory));
                          this.tileTuto = tile;
                          this.playerInv = inventory;
                          this.allowUserInput = false;
                          this.ySize = 170;
                      }
                      
                      protected void drawGuiContainerForegroundLayer(int x, int y)
                      {
                          String tileName = this.tileTuto.hasCustomInventoryName() ? this.tileTuto.getInventoryName() : I18n.format(this.tileTuto.getInventoryName());
                          this.fontRendererObj.drawString(tileName, (this.xSize - this.fontRendererObj.getStringWidth(tileName)) / 15, 6, 0);
                          String invName = this.playerInv.hasCustomInventoryName() ? this.playerInv.getInventoryName() : I18n.format(this.playerInv.getInventoryName());
                          this.fontRendererObj.drawString(invName, (this.xSize - this.fontRendererObj.getStringWidth(invName)) / 15, this.ySize - 96, 0);
                          
                          if(this.TileEntityFungieMachine.isBurning())   //erreur ici sur TileEntityFungieMachine
                          {
                              int i = this.TileEntityFungieMachine.getCookProgress(); //erreur aussi ici sur TileEntityFungieMachine       
                              this.drawTexturedModalRect(x, y, x, y, width, height);
                          }
                          
                      }
                   
                      @Override
                      protected void drawGuiContainerBackgroundLayer(float partialRenderTick, int x, int y)
                      {
                          GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); // on colorise
                          this.mc.getTextureManager().bindTexture(textures); // affiche la texture
                          int k = (this.width - this.xSize) / 2; // on calcul la coordonnée x du point en haut à gauche
                          int l = (this.height - this.ySize) / 2; // on calcul la coordonnée y du point en haut à gauche
                          this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); // on desine la texture, la fonction à pour argument point x de départ, point y de départ, vecteur u, vecteur v, largeur, hauteur)
                      }
                  }
                  
                  1 réponse Dernière réponse Répondre Citer 0
                  • ZunF1x
                    ZunF1x dernière édition par

                    puis le tile entity:

                    package fr.askipie.funfight;
                    
                    import cpw.mods.fml.relauncher.Side;
                    import cpw.mods.fml.relauncher.SideOnly;
                    import net.minecraft.entity.player.EntityPlayer;
                    import net.minecraft.inventory.IInventory;
                    import net.minecraft.item.ItemStack;
                    import net.minecraft.nbt.NBTTagCompound;
                    import net.minecraft.nbt.NBTTagList;
                    import net.minecraft.tileentity.TileEntity;
                    import net.minecraftforge.common.util.Constants;
                    
                    public class TileEntityFungieMachine extends TileEntity implements IInventory
                    {
                        
                        private ItemStack[] contents = new ItemStack[4]; //0, 1 et 2 sont les inputs et 3 est l'output
                        
                        private int workingTime = 0; //Temps de cuisson actuel
                        private int workingTimeNeeded = 200; //Temps de cuisson nécessaire
                        
                    
                        @Override
                        public void writeToNBT(NBTTagCompound compound)
                        {
                            super.writeToNBT(compound);
                            NBTTagList nbttaglist = new NBTTagList();
                     
                            for (int i = 0; i < this.contents.length; ++i) //pour les slots
                            {
                                if (this.contents != null)
                                {
                                    NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                                    nbttagcompound1.setByte("Slot", (byte)i);
                                    this.contents[i].writeToNBT(nbttagcompound1);
                                    nbttaglist.appendTag(nbttagcompound1);
                                }
                            }
                     
                            compound.setTag("Items", nbttaglist);
                            compound.setShort("workingTime",(short)this.workingTime); //On les enregistrent en short
                            compound.setShort("workingTimeNeeded", (short)this.workingTimeNeeded);
                        }
                        
                        @Override
                        public void readFromNBT(NBTTagCompound compound)
                        {
                            super.readFromNBT(compound);
                     
                            NBTTagList nbttaglist = compound.getTagList("Items", 10);
                            this.contents = new ItemStack[this.getSizeInventory()];
                     
                            for (int i = 0; i < nbttaglist.tagCount(); ++i) //Encore une fois pour les slots
                            {
                                NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
                                int j = nbttagcompound1.getByte("Slot") & 255;
                     
                                if (j >= 0 && j < this.contents.length)
                                {
                                    this.contents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
                                }
                            }
                     
                            this.workingTime = compound.getShort("workingTime"); //On lit nos valeurs
                            this.workingTimeNeeded = compound.getShort("workingTimeNeeded");
                        }
                        
                    
                    
                        @Override
                        public int getSizeInventory() { //Tout est dans le nom, retourne la taille de l'inventaire, pour notre bloc c'est quatre
                            return this.contents.length;
                        }
                    
                        @Override
                        public ItemStack getStackInSlot(int slotIndex) { //Renvoie L'itemStack se trouvant dans le slot passé en argument
                            return this.contents[slotIndex];
                        }
                    
                        @Override //Comme dit plus haut, c'est expliqué dans le tutoriel de robin
                        public ItemStack decrStackSize(int slotIndex, int amount) {
                                if (this.contents[slotIndex] != null)
                                {
                                    ItemStack itemstack;
                     
                                    if (this.contents[slotIndex].stackSize <= amount)
                                    {
                                        itemstack = this.contents[slotIndex];
                                        this.contents[slotIndex] = null;
                                        this.markDirty();
                                        return itemstack;
                                    }
                                    else
                                    {
                                        itemstack = this.contents[slotIndex].splitStack(amount);
                     
                                        if (this.contents[slotIndex].stackSize == 0)
                                        {
                                            this.contents[slotIndex] = null;
                                        }
                     
                                        this.markDirty();
                                        return itemstack;
                                    }
                                }
                                else
                                {
                                    return null;
                                }
                        }
                     
                        @Override
                        public ItemStack getStackInSlotOnClosing(int slotIndex) {
                            if (this.contents[slotIndex] != null)
                            {
                                ItemStack itemstack = this.contents[slotIndex];
                                this.contents[slotIndex] = null;
                                return itemstack;
                            }
                            else
                            {
                                return null;
                            }
                        }
                     
                        @Override
                        public void setInventorySlotContents(int slotIndex, ItemStack stack) {
                            this.contents[slotIndex] = stack;
                     
                            if (stack != null && stack.stackSize > this.getInventoryStackLimit())
                            {
                                stack.stackSize = this.getInventoryStackLimit();
                            }
                     
                            this.markDirty();
                        }
                     
                        @Override
                        public String getInventoryName() { //J'ai décider qu'on ne pouvait pas mettre de nom custom
                            return "tile.machineTuto";
                        }
                     
                        @Override
                        public boolean hasCustomInventoryName() {
                            return false;
                        }
                     
                        @Override
                        public int getInventoryStackLimit() {
                            return 64;
                        }
                     
                        @Override
                        public boolean isUseableByPlayer(EntityPlayer player) {
                            return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
                        }
                     
                        @Override
                        public void openInventory() {
                     
                        }
                     
                        @Override
                        public void closeInventory() {
                     
                        }
                     
                        @Override
                        public boolean isItemValidForSlot(int slot, ItemStack stack) {
                            return slot == 3 ? false : true;
                        }
                    
                        public boolean isBurning()
                        {
                            return this.workingTime > 0;
                        }
                        
                        private boolean canSmelt()
                        {
                            if (this.contents[0] == null || this.contents[1] == null || this.contents[2] == null) //Si les trois premiers slots sont vides
                            {
                                return false; //On ne peut pas lancer le processus
                            }
                            else
                            {
                                ItemStack itemstack = FungieMachineRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]}); //Il y a une erreur ici, c'est normal, on y vient après (c'est pour les recettes)
                                if (itemstack == null) return false; //rapport avec les recettes
                                if (this.contents[3] == null) return true; //vérifications du slot d'output
                                if (!this.contents[3].isItemEqual(itemstack)) return false; //ici aussi
                                int result = contents[3].stackSize + itemstack.stackSize;
                                return result <= getInventoryStackLimit() && result <= this.contents[3].getMaxStackSize(); //Et là aussi décidément
                            }
                        }
                        
                        public void updateEntity() //Méthode exécutée à chaque tick
                        {
                            if(this.isBurning() && this.canSmelt()) //Si on "cuit" et que notre recette et toujours bonne, on continue
                            {
                                ++this.workingTime; //incrémentation
                            }
                            if(this.canSmelt() && !this.isBurning()) //Si la recette est bonne mais qu'elle n'est toujours pas lancée, on la lance
                            {
                                this.workingTime = 1; //La méthode isBurning() renverra true maintenant (1>0)
                            }
                            if(this.canSmelt() && this.workingTime == this.workingTimeNeeded) //Si on est arrivé au bout du temps de cuisson et que la recette est toujours bonne
                            {
                                this.smeltItem(); //on "cuit" les items
                                this.workingTime = 0; //et on réinitialise le temps de cuisson
                            }
                            if(!this.canSmelt()) //Si la recette la recette n'est plus bonne
                            {
                                    this.workingTime= 0; //le temps de cuisson est de 0
                            }
                        }
                        
                        public void smeltItem()
                        {
                            if (this.canSmelt())
                            {
                                ItemStack itemstack = FungieMachineRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]}); //On récupère l'output de la recette
                                if (this.contents[3] == null) //Si il y a rien dans le slot d'output
                                {
                                    this.contents[3] = itemstack.copy(); //On met directement l'ItemStack
                                }
                                else if (this.contents[3].getItem() == itemstack.getItem()) //Et si l'item que l'on veut est le même que celui qu'il y a déjà
                                {
                                    this.contents[3].stackSize += itemstack.stackSize; // Alors ont incrémente l'ItemStack
                                }
                     
                                --this.contents[0].stackSize; //On décrémente les slots d'input
                                --this.contents[1].stackSize;
                                --this.contents[2].stackSize;
                     
                                if (this.contents[0].stackSize <= 0) //Si les slots sont vides, on remet à null le slot
                                {
                                    this.contents[0] = null;
                                }
                                if (this.contents[1].stackSize <= 0)
                                {
                                    this.contents[1] = null;
                                }
                                if (this.contents[2].stackSize <= 0)
                                {
                                    this.contents[2] = null;
                                }
                            }
                        }
                    
                        public void setCustomName(String displayName)
                        {
                            
                        }
                        
                        @SideOnly(Side.CLIENT)
                        public int getCookProgress()
                        {
                            return this.workingTime * 41 / this.workingTimeNeeded; //41 correspond à la hauteur de la barre de progression car notre barre de progression se déroule de haut en bas
                        }  
                    }
                    
                    
                    1 réponse Dernière réponse Répondre Citer 0
                    • SpyMan
                      SpyMan dernière édition par SpyMan

                          
                      * 
                      * 
                      * 
                      * protected void drawGuiContainerForegroundLayer(int x, int y)
                      
                          {
                      
                              String tileName = this.tileTuto.hasCustomInventoryName() ? this.tileTuto.getInventoryName() : I18n.format(this.tileTuto.getInventoryName());
                      
                              this.fontRendererObj.drawString(tileName, (this.xSize - this.fontRendererObj.getStringWidth(tileName)) / 15, 6, 0);
                      
                              String invName = this.playerInv.hasCustomInventoryName() ? this.playerInv.getInventoryName() : I18n.format(this.playerInv.getInventoryName());
                      
                              this.fontRendererObj.drawString(invName, (this.xSize - this.fontRendererObj.getStringWidth(invName)) / 15, this.ySize - 96, 0);
                      
                              
                      
                              if(this.TileEntityFungieMachine.isBurning())   //erreur ici sur TileEntityFungieMachine
                      
                              {
                      
                                  int i = this.TileEntityFungieMachine.getCookProgress(); //erreur aussi ici sur TileEntityFungieMachine       
                      
                                  this.drawTexturedModalRect(x, y, x, y, width, height);
                      
                              }
                      
                              
                      
                          }
                      

                      les bonnes valeurs c’est a toi le les trouver x) deja faut faire le calcul pour trouvé combiens en longeur de la texture doit etre affiche en fonction tu temps ecoulé sur le temps total

                      donc (temps * taille_texture) / temps_max
                      ensuite avec cette valeur tu aura le la taille en longeur du bout de texture
                      rajoute une petite condition pour savoir si le temps et temps_max est bien > 0 et le tour est joué

                      ZunF1x 1 réponse Dernière réponse Répondre Citer 0
                      • ZunF1x
                        ZunF1x @SpyMan dernière édition par

                        @SpyMan ouai mais j’arrive pas je suis pas fort au codage moi

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

                          c’est pas du code c’est des maths simple ca x)
                          et on ne dit pas codage mais programmation
                          le codage en informatique c’est autre chose

                          ZunF1x 1 réponse Dernière réponse Répondre Citer 0
                          • ZunF1x
                            ZunF1x @SpyMan dernière édition par

                            @SpyMan ouai mais faut les mettre ou les valeurs temps * taille_texture / temps_max ?

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

                              tu creé une variable pour stocké le resultat ce de calcul, ensuite les valeurs a mettre dans le calcul doivent se trouver dans ton tileentity

                              ZunF1x 1 réponse Dernière réponse Répondre Citer 0
                              • ZunF1x
                                ZunF1x @SpyMan dernière édition par

                                oui mais comment ?

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

                                  ok alors on va faire un truc, tu range le mod minecraft sur un coins de ton bureau et tu lis ce tuto qui va te permettre de comprendre un certains nombre de choses : https://openclassrooms.com/fr/courses/26832-apprenez-a-programmer-en-java
                                  une fois le tuto lu tu saura comment faire des calcules basiques et tu aura toutes la bases en java pour continuer ton mod tranquille sans coincé tout les 2 lignes de code x)

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

                                    Ce message a été supprimé !
                                    1 réponse Dernière réponse Répondre Citer 0
                                    • ZunF1x
                                      ZunF1x dernière édition par

                                      tu peut pas juste me faire les 2 lignes je te dit la longueur des la barre est 36 largeur 17 et voila la gui:

                                      fungieMachine.png

                                      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