MFF

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

    Ajouter un gui et un container à un bloc

    Planifier Épinglé Verrouillé Déplacé Les interfaces (GUI) et les container
    1.7.x
    129 Messages 21 Publieurs 31.6k Vues 8 Watching
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • _ Hors-ligne
      ___Freezer___
      dernière édition par

      Non 😕

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

        Je ne vois pas comment c’est possible o_O

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

          Bizarrre, montres la classe de ton block avec le system.out et le @Override, voir si ils sont bien placés.

          Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

          AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

          Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
          Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

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

            http://www.noelshack.com/2017-29-1-1500281971-capture3.png

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

              Et le “test” apparaît vraiment aucune fois dans la console quand tu cliques droit sur ton bloc ?

              Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

              AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

              Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
              Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

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

                Non, il n’y a rien

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

                  Dans ta classe principale, à la déclaration de ton block, tu fais un new BlocksMod, alors que depuis le début tu nous montres ta classe BlockFour, donc erreur très bête.

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

                    Ok merci c’est bon mais après l’avoir ouvert mon jeu  crash et maintenant, je ne peux plus lancer mon monde.

                    Crash report :

                    [16:35:37] [Server thread/INFO]: Starting integrated minecraft server version 1.7.10
                    [16:35:37] [Server thread/INFO]: Generating keypair
                    [16:35:37] [Server thread/INFO] [FML]: Injecting existing block and item data into this server instance
                    [16:35:37] [Server thread/INFO] [FML]: Applying holder lookups
                    [16:35:37] [Server thread/INFO] [FML]: Holder lookups applied
                    [16:35:37] [Server thread/INFO] [FML]: Loading dimension 0 (New World) (net.minecraft.server.integrated.IntegratedServer@6034c282)
                    [16:35:37] [Server thread/INFO] [FML]: Loading dimension 1 (New World) (net.minecraft.server.integrated.IntegratedServer@6034c282)
                    [16:35:37] [Server thread/INFO] [FML]: Loading dimension -1 (New World) (net.minecraft.server.integrated.IntegratedServer@6034c282)
                    [16:35:37] [Server thread/INFO]: Preparing start region for level 0
                    [16:35:38] [Server thread/INFO]: Changing view distance to 12, from 10
                    [16:35:38] [Server thread/ERROR]: Encountered an unexpected exception
                    net.minecraft.util.ReportedException: Ticking block entity
                    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:709) ~[MinecraftServer.class:?]
                    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) ~[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:?]
                    Caused by: java.lang.NullPointerException
                    at Package1.common.FourTotal.BlockFourRecipes.isSameKey(BlockFourRecipes.java:73) ~[BlockFourRecipes.class:?]
                    at Package1.common.FourTotal.BlockFourRecipes.getSmeltingResult(BlockFourRecipes.java:63) ~[BlockFourRecipes.class:?]
                    at Package1.common.FourTotal.TileEntityFour.smeltItem(TileEntityFour.java:213) ~[TileEntityFour.class:?]
                    at Package1.common.FourTotal.TileEntityFour.updateEntity(TileEntityFour.java:200) ~[TileEntityFour.class:?]
                    at net.minecraft.world.World.updateEntities(World.java:2160) ~[World.class:?]
                    at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:515) ~[WorldServer.class:?]
                    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:703) ~[MinecraftServer.class:?]
                    … 4 more
                    [16:35:38] [Server thread/ERROR]: This crash report has been saved to: D:\BUREAU\FREEZER-regroupement de dossiers\Codage\Mods\Forge 1.7.10\eclipse\.\crash-reports\crash-2017-07-17_16.35.38-server.txt
                    [16:35:38] [Server thread/INFO]: Stopping server
                    [16:35:38] [Server thread/INFO]: Saving players
                    [16:35:38] [Server thread/INFO]: Saving worlds
                    [16:35:38] [Server thread/INFO]: Saving chunks for level 'New World'/Overworld
                    [16:35:38] [Server thread/INFO]: Saving chunks for level 'New World'/Nether
                    [16:35:38] [Server thread/INFO]: Saving chunks for level 'New World'/The End
                    [16:35:38] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: –-- Minecraft Crash Report ----
                    // On the bright side, I bought you a teddy bear!
                    
                    Time: 17/07/17 16:35
                    Description: Ticking block entity
                    
                    java.lang.NullPointerException: Ticking block entity
                    at Package1.common.FourTotal.BlockFourRecipes.isSameKey(BlockFourRecipes.java:73)
                    at Package1.common.FourTotal.BlockFourRecipes.getSmeltingResult(BlockFourRecipes.java:63)
                    at Package1.common.FourTotal.TileEntityFour.smeltItem(TileEntityFour.java:213)
                    at Package1.common.FourTotal.TileEntityFour.updateEntity(TileEntityFour.java:200)
                    at net.minecraft.world.World.updateEntities(World.java:2160)
                    at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:515)
                    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:703)
                    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)
                    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:
                    ---------------------------------------------------------------------------------------
                    
                    -- Head --
                    Stacktrace:
                    at Package1.common.FourTotal.BlockFourRecipes.isSameKey(BlockFourRecipes.java:73)
                    at Package1.common.FourTotal.BlockFourRecipes.getSmeltingResult(BlockFourRecipes.java:63)
                    at Package1.common.FourTotal.TileEntityFour.smeltItem(TileEntityFour.java:213)
                    at Package1.common.FourTotal.TileEntityFour.updateEntity(TileEntityFour.java:200)
                    
                    -- Block entity being ticked --
                    Details:
                    Name: compleatcraft:FourTileEntity // Package1.common.FourTotal.TileEntityFour
                    Block type: ID #177 (tile.BlockFour // Package1.common.FourTotal.BlockFour)
                    Block data value: 0 / 0x0 / 0b0000
                    Block location: World: (-206,67,152), Chunk: (at 2,4,8 in -13,9; contains blocks -208,0,144 to -193,255,159), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
                    Actual block type: ID #177 (tile.BlockFour // Package1.common.FourTotal.BlockFour)
                    Actual block data value: 0 / 0x0 / 0b0000
                    Stacktrace:
                    at net.minecraft.world.World.updateEntities(World.java:2160)
                    at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:515)
                    
                    -- Affected level --
                    Details:
                    Level name: New World
                    All players: 0 total; []
                    Chunk stats: ServerChunkCache: 625 Drop: 0
                    Level seed: -8957039999929459700
                    Level generator: ID 00 - default, ver 1\. Features enabled: true
                    Level generator options:
                    Level spawn location: World: (-196,64,148), Chunk: (at 12,4,4 in -13,9; contains blocks -208,0,144 to -193,255,159), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
                    Level time: 221841 game time, 18584 day time
                    Level dimension: 0
                    Level storage version: 0x04ABD - Anvil
                    Level weather: Rain time: 21306 (now: true), thunder time: 153946 (now: false)
                    Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
                    Stacktrace:
                    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:703)
                    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)
                    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)
                    
                    -- System Details --
                    Details:
                    Minecraft Version: 1.7.10
                    Operating System: Windows 10 (amd64) version 10.0
                    Java Version: 1.8.0_131, Oracle Corporation
                    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
                    Memory: 919065176 bytes (876 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 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: 12, tallocated: 94
                    FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1614 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.1614-1.7.10.jar)
                    UCHIJAAAA Forge{10.13.4.1614} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar)
                    UCHIJAAAA compleatcraft{1.0.0} [Compleat Craft] (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: 0 / 8; []
                    Type: Integrated Server (map_client.txt)
                    Is Modded: Definitely; Client brand changed to 'fml,forge'
                    [16:35:38] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:393]: #@!@# Game crashed! Crash report saved to: #@!@# .\crash-reports\crash-2017-07-17_16.35.38-server.txt
                    [16:35:38] [Client thread/INFO] [FML]: Waiting for the server to terminate/save.
                    [16:35:39] [Server thread/INFO] [FML]: Unloading dimension 0
                    [16:35:39] [Server thread/INFO] [FML]: Unloading dimension -1
                    [16:35:39] [Server thread/INFO] [FML]: Unloading dimension 1
                    [16:35:39] [Server thread/INFO] [FML]: Applying holder lookups
                    [16:35:39] [Server thread/INFO] [FML]: Holder lookups applied
                    [16:35:39] [Server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded.
                    [16:35:39] [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
                    
                    
                    1 réponse Dernière réponse Répondre Citer 0
                    • DeletedD Hors-ligne
                      Deleted
                      dernière édition par

                      BlockFourRecipes.java:73 ?

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

                        pour l’erreur 1 :
                        http://www.noelshack.com/2017-29-1-1500302613-capture.png

                        pour l’erreur 2 :
                        http://www.noelshack.com/2017-29-1-1500302621-capture1.png

                        pour l’erreur 3 :
                        http://www.noelshack.com/2017-29-1-1500302625-capture2.png

                        et pour l’erreur 4 :
                        http://www.noelshack.com/2017-29-1-1500302627-capture3.png

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

                          File ta classe entièrement, on gagnera en efficacité/compréhension.
                          Tu devrais sûrement rajouter un null-check de stackList*, avant d’appeler dessus un .getItem()

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

                            BlockFourRecipes :

                            package Package1.common.FourTotal;
                            
                            import java.util.HashMap;
                            import java.util.Iterator;
                            import java.util.Map;
                            import java.util.Map.Entry;
                            
                            import net.minecraft.block.Block;
                            import net.minecraft.init.Blocks;
                            import net.minecraft.init.Items;
                            import net.minecraft.item.Item;
                            import net.minecraft.item.ItemStack;
                            
                            public class BlockFourRecipes {
                            
                            private static final BlockFourRecipes smeltingBase = new BlockFourRecipes();
                            private Map smeltingList = new HashMap();
                            
                            public BlockFourRecipes()
                            {
                            this.addRecipe(Items.apple, Items.apple, Items.arrow, new ItemStack(Blocks.diamond_block));
                            }
                            
                            public void addRecipe(ItemStack stack1, ItemStack stack2, ItemStack stack3, ItemStack stack4)
                            {
                            ItemStack[] stackList = new ItemStack[]{stack1, stack2, stack3};
                            this.smeltingList.put(stackList, stack4);
                            }
                            
                                   public void addRecipe(Item item1, Item item2, Item item3, ItemStack stack) //1er cas
                            {
                            this.addRecipe(new ItemStack(item1), new ItemStack(item2), new ItemStack(item3), stack);
                            }
                            
                            public void addRecipe(Block block1, Item item2, Item item3, ItemStack stack) //2nd cas
                            {
                            this.addRecipe(Item.getItemFromBlock(block1), item2, item3, stack);
                            }
                            
                            public void addRecipe(Block block1, Block block2, Item item3, ItemStack stack) //3ème cas
                            {
                            this.addRecipe(Item.getItemFromBlock(block1), Item.getItemFromBlock(block2), item3, stack);
                            }
                            
                            public void addRecipe(Block block1, Block block2, Block block3, ItemStack stack) //4ème cas
                            {
                            this.addRecipe(Item.getItemFromBlock(block1), Item.getItemFromBlock(block2), Item.getItemFromBlock(block3), stack);
                            }
                            
                            public ItemStack getSmeltingResult(ItemStack[] stack)
                            {
                                Iterator iterator = this.smeltingList.entrySet().iterator();
                                Entry entry;
                            
                                do
                                {
                                    if (!iterator.hasNext())
                                    {
                                        return null;
                                    }
                                      entry = (Entry)iterator.next();
                                  }
                                  while (!this.isSameKey(stack, (ItemStack[])entry.getKey()));
                            
                                  return (ItemStack)entry.getValue();
                             }
                            
                            private boolean isSameKey(ItemStack[] stackList, ItemStack[] stackList2)
                            {
                            boolean isSame = false;
                            for(int i=0; i<=2; i++)
                            {
                            if(stackList*.getItem() == stackList2*.getItem())
                            {
                            isSame = true;
                            }
                            else
                            {
                            return false;
                            }
                            }
                            return isSame;
                            }
                            
                            public Map getSmeltingList()
                            {
                                  return this.smeltingList;
                               }
                            
                            public static BlockFourRecipes smelting()
                            {
                            return smeltingBase;
                            }
                            }
                            
                            

                            TileEntityFour:

                            package Package1.common.FourTotal;
                            
                            import cpw.mods.fml.relauncher.Side;
                            import cpw.mods.fml.relauncher.SideOnly;
                            import net.minecraft.entity.player.EntityPlayer;
                            import net.minecraft.inventory.IInventory;
                            import net.minecraft.item.ItemStack;
                            import net.minecraft.nbt.NBTTagCompound;
                            import net.minecraft.nbt.NBTTagList;
                            import net.minecraft.tileentity.TileEntity;
                            
                            public class TileEntityFour extends TileEntity implements IInventory{
                            
                            private ItemStack[] contents = new ItemStack[4];
                            private int workingTime = 0;
                            private int workingTimeNeeded = 200;
                            
                            @Override
                               public void writeToNBT(NBTTagCompound compound)
                               {
                                   super.writeToNBT(compound);
                                   NBTTagList nbttaglist = new NBTTagList();
                            
                                   for (int i = 0; i < this.contents.length; ++i) //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() {
                            return this.contents.length;
                            }
                            
                            @Override
                            public ItemStack getStackInSlot(int slotIndex) {
                            return this.contents[slotIndex];
                            }
                            
                            @Override
                            public ItemStack decrStackSize(int slotIndex, int amount) {
                            if (this.contents[slotIndex] != null)
                                   {
                                       ItemStack itemstack;
                            
                                       if (this.contents[slotIndex].stackSize <= amount)
                                       {
                                           itemstack = this.contents[slotIndex];
                                           this.contents[slotIndex] = null;
                                           this.markDirty();
                                           return itemstack;
                                       }
                                       else
                                       {
                                           itemstack = this.contents[slotIndex].splitStack(amount);
                            
                                           if (this.contents[slotIndex].stackSize == 0)
                                           {
                                               this.contents[slotIndex] = null;
                                           }
                            
                                           this.markDirty();
                                           return itemstack;
                                       }
                                   }
                                   else
                                   {
                                       return null;
                                   }
                            }
                            
                            @Override
                            public ItemStack getStackInSlotOnClosing(int slotIndex) {
                            if (this.contents[slotIndex] != null)
                                   {
                                       ItemStack itemstack = this.contents[slotIndex];
                                       this.contents[slotIndex] = null;
                                       return itemstack;
                                   }
                                   else
                                   {
                                       return null;
                                   }
                            }
                            
                            @Override
                            public void setInventorySlotContents(int slotIndex, ItemStack stack) {
                            this.contents[slotIndex] = stack;
                            
                                   if (stack != null && stack.stackSize > this.getInventoryStackLimit())
                                   {
                                       stack.stackSize = this.getInventoryStackLimit();
                                   }
                            
                                   this.markDirty();
                            }
                            
                            @Override
                            public String getInventoryName() {
                            return "tile.BlockFour";
                            }
                            
                            @Override
                            public boolean hasCustomInventoryName() {
                            return false;
                            }
                            
                            @Override
                            public int getInventoryStackLimit() {
                            return 64;
                            }
                            
                            @Override
                            public boolean isUseableByPlayer(EntityPlayer player) {
                            return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
                            }
                            
                            @Override
                            public void openInventory() {
                            
                            }
                            
                            @Override
                            public void closeInventory() {
                            
                            }
                            
                            @Override
                            public boolean isItemValidForSlot(int slot, ItemStack stack) {
                            return slot == 3 ? false : true;
                            }
                            
                            public boolean isBurning()
                               {
                                   return this.workingTime > 0;
                               }
                            
                            private boolean canSmelt()
                               {
                                   if (this.contents[0] == null || this.contents[1] == null || this.contents[2] == null)
                                   {
                                       return true;
                                   }
                                   else
                                   {
                                       ItemStack itemstack = BlockFourRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]}); //Il y a une erreur ici, c'est normal, on y vient après (c'est pour les recettes)
                                       if (itemstack == null) return false;
                                       if (this.contents[3] == null) return true;
                                       if (!this.contents[3].isItemEqual(itemstack)) return false;
                                       int result = contents[3].stackSize + itemstack.stackSize;
                                       return result <= getInventoryStackLimit() && result <= this.contents[3].getMaxStackSize();
                                   }
                               }
                            
                            public void updateEntity()
                               {
                                if(this.isBurning() && this.canSmelt())
                                {
                                ++this.workingTime;
                                }
                                if(this.canSmelt() && !this.isBurning())
                                {
                                this.workingTime = 1;
                                }
                                if(this.canSmelt() && this.workingTime == this.workingTimeNeeded)
                                {
                                this.smeltItem();
                                this.workingTime = 0;
                                }
                                   if(!this.canSmelt())
                                   {
                                          this.workingTime= 0;
                                   }
                               }
                            
                            public void smeltItem()
                               {
                                   if (this.canSmelt())
                                   {
                                       ItemStack itemstack = BlockFourRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]});
                                        if (this.contents[3] == null)
                                        {
                                             this.contents[3] = itemstack.copy();
                                        }
                                        else if (this.contents[3].getItem() == itemstack.getItem())
                                        {
                                             this.contents[3].stackSize += itemstack.stackSize;
                                        }
                            
                                        –this.contents[0].stackSize;
                                        –this.contents[1].stackSize;
                                        –this.contents[2].stackSize;
                            
                                        if (this.contents[0].stackSize <= 0)
                                        {
                                            this.contents[0] = null;
                                        }
                                        if (this.contents[1].stackSize <= 0)
                                        {
                                            this.contents[1] = null;
                                        }
                                        if (this.contents[2].stackSize <= 0)
                                        {
                                            this.contents[2] = null;
                                        }
                                   }
                               }
                            @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
                            • _ Hors-ligne
                              ___Freezer___
                              dernière édition par

                              ???

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

                                Salut juste j’ai un problème j’ai suivi ce tuto (mon mc est en 1.8) en éspérant pouvoir réussir mais j’ai rencontré des erreurs.
                                J’ai réussi à régler la plupart mais… yen a une qui me bloque.
                                au niveau de la classe du container j’ai une erreur. :@

                                Voici mon container et merci de votre réponse.

                                package com.mod.mod2bk.init;
                                
                                import java.util.List;
                                
                                import Blocks.TileEntityGeneticMachine;
                                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.world.World;
                                
                                public class ContainerGeneticMachine extends Container
                                {
                                
                                   private final TileEntityGeneticMachine tileGM;
                                
                                   public ContainerGeneticMachine(TileEntityGeneticMachine tile, InventoryPlayer inventory)
                                   {
                                       this.tileGM = tile;
                                
                                       tile.openInventory(); // c'est à ce niveau là que ya l'erreur.
                                
                                      for(int i = 0; i < 3; ++i)
                                      {
                                          for(int j = 0; j < 9; ++j)
                                          {
                                              this.addSlotToContainer(new Slot(tile, j + i * 9, 8 + j * 18, 18 + i * 18));
                                
                                          }
                                      }
                                      this.bindPlayerInventory(inventory);
                                   }
                                
                                   @Override
                                   public boolean canInteractWith(EntityPlayer playerIn)
                                   {
                                       return false;
                                   }
                                }
                                
                                1 réponse Dernière réponse Répondre Citer 0
                                • robin4002R Hors-ligne
                                  robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                                  dernière édition par

                                  Salut,
                                  La fonction a été renommée, il devrait en avoir une autre avec un nom similaire.

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

                                    @‘robin4002’:

                                    Salut,
                                    La fonction a été renommée, il devrait en avoir une autre avec un nom similaire.

                                    La fonction est toujours existante mais il me demande de rajouter des paramètres entre parenthèses(EntityPlayer)
                                    J’ai essayé de faire un```java
                                    EntityPlayer player = new EntityPlayer();

                                    Et après ça tourne en boucle comme ça…
                                    1 réponse Dernière réponse Répondre Citer 0
                                    • robin4002R Hors-ligne
                                      robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                                      dernière édition par

                                      Mets inventory.player

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

                                        Mon jeu est en 1.8…
                                        Et super, quand je clic droit sur le bloc, il se passe rien…
                                        Ma classe du bloc (Le bloc est GeneticMachine et la classe est geneticGMachine)

                                        package Blocks;
                                        
                                        import com.mod.mod2bk.mod2bkpri;
                                        
                                        import net.minecraft.block.Block;
                                        import net.minecraft.block.BlockPistonBase;
                                        import net.minecraft.block.material.Material;
                                        import net.minecraft.block.state.IBlockState;
                                        import net.minecraft.entity.EntityLivingBase;
                                        import net.minecraft.entity.player.EntityPlayer;
                                        import net.minecraft.inventory.IInventory;
                                        import net.minecraft.inventory.InventoryHelper;
                                        import net.minecraft.item.ItemStack;
                                        import net.minecraft.tileentity.TileEntity;
                                        import net.minecraft.tileentity.TileEntityDispenser;
                                        import net.minecraft.util.BlockPos;
                                        import net.minecraft.util.ChatComponentText;
                                        import net.minecraft.util.EnumFacing;
                                        import net.minecraft.world.World;
                                        import net.minecraftforge.fml.common.network.internal.FMLNetworkHandler;
                                        
                                        public class geneticGMachine extends Block
                                        {
                                        
                                            public geneticGMachine(Material materialIn)
                                            {
                                                super(materialIn);
                                            }
                                        
                                            @Override
                                            public boolean hasTileEntity(IBlockState state)
                                            {
                                                return true;
                                            }
                                        
                                            @Override
                                            public TileEntity createTileEntity(World world, IBlockState state)
                                            {
                                                return new TileEntityGeneticMachine();
                                            }
                                        
                                            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(mod2bkpri.instance, 0, world, x, y, z);
                                        
                                                   return true;
                                               }
                                        
                                           }
                                        
                                            public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
                                            {
                                                TileEntity tileentity = worldIn.getTileEntity(pos);
                                        
                                                if (tileentity instanceof IInventory)
                                                {
                                                    InventoryHelper.dropInventoryItems(worldIn, pos, (IInventory)tileentity);
                                                    worldIn.updateComparatorOutputLevel(pos, this);
                                                }
                                        
                                                super.breakBlock(worldIn, pos, state);
                                            }
                                        
                                            public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
                                            {
                                        
                                                if (stack.hasDisplayName())
                                                {
                                                    TileEntity tileentity = worldIn.getTileEntity(pos);
                                        
                                                    if (tileentity instanceof TileEntityGeneticMachine)
                                                    {
                                                        ((TileEntityGeneticMachine)tileentity).setCustomName(stack.getDisplayName());
                                                    }
                                                }
                                            }
                                        
                                        }
                                        

                                        Ma classe du TileEntity (TileEntityGeneticMachine)

                                        package Blocks;
                                        
                                        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.network.NetworkManager;
                                        import net.minecraft.network.Packet;
                                        import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
                                        import net.minecraft.tileentity.TileEntity;
                                        import net.minecraft.util.IChatComponent;
                                        
                                        public class TileEntityGeneticMachine extends TileEntity implements IInventory
                                        {
                                        
                                            private ItemStack[] contents = new ItemStack[27];
                                            private String customName;    
                                        
                                            private int number;
                                        
                                            @Override
                                            public void readFromNBT(NBTTagCompound compound)
                                            {
                                                super.readFromNBT(compound);
                                                this.number = compound.getInteger("Number");
                                            }
                                        
                                            @Override
                                            public void writeToNBT(NBTTagCompound compound)
                                            {
                                                super.writeToNBT(compound);
                                                compound.setInteger("Number", this.number);
                                            }
                                        
                                            public int getNumber()
                                            {
                                                return number;
                                            }
                                        
                                            public void setNumber(int number)
                                            {
                                                this.number = number;
                                            }
                                        
                                            @Override
                                            public Packet getDescriptionPacket() {
                                        
                                                NBTTagCompound nbttagcompound = new NBTTagCompound();
                                        
                                                this.writeToNBT(nbttagcompound);
                                        
                                                return new S35PacketUpdateTileEntity(this.pos, 0, nbttagcompound);
                                        
                                            }
                                        
                                            @Override
                                            public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
                                        
                                                super.onDataPacket(net, pkt);
                                        
                                                this.readFromNBT(pkt.getNbtCompound());
                                        
                                            }
                                        
                                            public void readFromNBT1(NBTTagCompound compound)
                                            {
                                                super.readFromNBT(compound);
                                                NBTTagList nbttaglist = compound.getTagList("Items", 10);
                                                this.contents = new ItemStack[this.getSizeInventory()];
                                        
                                                if (compound.hasKey("CustomName", 8))
                                                {
                                                    this.customName = compound.getString("CustomName");
                                                }
                                        
                                                for (int i = 0; i < nbttaglist.tagCount(); ++i)
                                                {
                                                    NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
                                                    int j = nbttagcompound1.getByte("Slot") & 255;
                                        
                                                    if (j >= 0 && j < this.contents.length)
                                                    {
                                                        this.contents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
                                                    }
                                                }
                                            }
                                        
                                            public void writeToNBT1(NBTTagCompound compound)
                                            {
                                                super.writeToNBT(compound);
                                                NBTTagList nbttaglist = new NBTTagList();
                                        
                                                for (int i = 0; i < this.contents.length; ++i)
                                                {
                                                    if (this.contents* != null)
                                                    {
                                                        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                                                        nbttagcompound1.setByte("Slot", (byte)i);
                                                        this.contents*.writeToNBT(nbttagcompound1);
                                                        nbttaglist.appendTag(nbttagcompound1);
                                                    }
                                                }
                                        
                                                compound.setTag("Items", nbttaglist);
                                        
                                                if (this.hasCustomName())
                                                {
                                                    compound.setString("CustomName", this.customName);
                                                }
                                            }
                                        
                                            @Override
                                            public String getName()
                                            {
                                                return this.hasCustomName() ? this.customName : "tile.geneticmachine";
                                            }
                                        
                                            public void setCustomName(String customName)    
                                           {
                                               this.customName = customName;
                                           }
                                        
                                            @Override
                                            public boolean hasCustomName()
                                            {
                                                return false;
                                            }
                                        
                                            @Override
                                            public IChatComponent getDisplayName()
                                            {
                                                return null;
                                            }
                                        
                                            @Override
                                            public int getSizeInventory()
                                            {
                                                return this.contents.length;
                                            }
                                        
                                            @Override
                                            public ItemStack getStackInSlot(int index)
                                            {
                                                return this.contents[index];
                                            }
                                        
                                            @Override
                                        
                                            public ItemStack decrStackSize(int slotIndex, int amount)
                                            {
                                        
                                                if(this.contents[slotIndex] != null) 
                                                {
                                        
                                                    ItemStack itemstack;
                                        
                                                    if(this.contents[slotIndex].stackSize <= amount) 
                                                    {
                                        
                                                        itemstack = this.contents[slotIndex]; 
                                        
                                                        this.contents[slotIndex] = null; 
                                        
                                                        this.markDirty();
                                        
                                                        return itemstack; 
                                                    }
                                                    else
                                                    {
                                                        itemstack = this.contents[slotIndex].splitStack(amount); 
                                        
                                                        if(this.contents[slotIndex].stackSize == 0) 
                                                        {
                                        
                                                            this.contents[slotIndex] = null; 
                                                        }
                                        
                                                        this.markDirty(); 
                                        
                                                        return itemstack;
                                        
                                                    }
                                        
                                                }
                                                else 
                                                {
                                                    return null; 
                                                }
                                            }
                                        
                                            @Override
                                           public ItemStack getStackInSlotOnClosing(int slotIndex)
                                           {
                                               if(this.contents[slotIndex] != null)
                                        
                                               {
                                        
                                                   ItemStack itemstack = this.contents[slotIndex];
                                        
                                                   this.contents[slotIndex] = null;
                                        
                                                   return itemstack;
                                               }
                                               else
                                               {
                                        
                                                   return null;
                                               }
                                           }
                                        
                                            @Override
                                           public void setInventorySlotContents(int slotIndex, ItemStack stack)
                                           {
                                        
                                               this.contents[slotIndex] = stack; // met l'item stack dans le tableau
                                        
                                               if(stack != null && stack.stackSize > this.getInventoryStackLimit()) // si la taille de l'item stack dépasse la limite maximum de l'inventaire
                                        
                                               {
                                        
                                                   stack.stackSize = this.getInventoryStackLimit(); // on le remet sur la limite
                                        
                                               }
                                        
                                               this.markDirty(); // met à jour le tile entity
                                        
                                           }
                                        
                                            @Override
                                            public int getInventoryStackLimit()
                                            {
                                                return 64;
                                            }
                                        
                                            public boolean isUseableByPlayer(EntityPlayer player)
                                            {
                                                return this.worldObj.getTileEntity(this.pos) != this ? false : player.getDistanceSq((double)this.pos.getX() + 0.5D, (double)this.pos.getY() + 0.5D, (double)this.pos.getZ() + 0.5D) <= 64.0D;
                                            }
                                        
                                            @Override
                                            public void openInventory(EntityPlayer player)
                                            {
                                        
                                            }
                                        
                                            @Override
                                            public void closeInventory(EntityPlayer player)
                                            {
                                        
                                            }
                                        
                                            @Override
                                            public boolean isItemValidForSlot(int index, ItemStack stack)
                                            {
                                                return true;
                                            }
                                        
                                            @Override
                                            public int getField(int id)
                                            {
                                                return 0;
                                            }
                                        
                                            @Override
                                            public void setField(int id, int value)
                                            {
                                        
                                            }
                                        
                                            @Override
                                            public int getFieldCount()
                                            {
                                                return 0;
                                            }
                                        
                                            @Override
                                            public void clear()
                                            {
                                        
                                            }
                                        }
                                        

                                        Le GuiHandler :

                                        package com.mod.mod2bk;
                                        
                                        import com.mod.mod2bk.init.ContainerGeneticMachine;
                                        
                                        import Blocks.TileEntityGeneticMachine;
                                        import net.minecraft.entity.player.EntityPlayer;
                                        import net.minecraft.tileentity.TileEntity;
                                        import net.minecraft.util.BlockPos;
                                        import net.minecraft.world.World;
                                        import net.minecraftforge.fml.common.network.IGuiHandler;
                                        import net.minecraft.*;
                                        
                                        public class GuiHandlerGeneticMaster implements IGuiHandler
                                        {
                                        
                                            @Override
                                            public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
                                            {
                                                BlockPos pos = new BlockPos(x, y, z);
                                                TileEntity tile = world.getTileEntity(pos);
                                        
                                               if(tile instanceof TileEntityGeneticMachine)
                                        
                                               {
                                        
                                                   return new ContainerGeneticMachine((TileEntityGeneticMachine)tile, player.inventory);
                                        
                                               }
                                        
                                               return null;
                                            }
                                        
                                            @Override
                                            public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
                                            {
                                                BlockPos pos = new BlockPos(x, y, z);
                                                TileEntity tile = world.getTileEntity(pos);
                                        
                                               if(tile instanceof TileEntityGeneticMachine)
                                               {
                                                   return new GuiGeneticMachine((TileEntityGeneticMachine)tile, player.inventory);
                                               }
                                               return null;
                                            }
                                        }
                                        

                                        La classe du container (ContainerGeneticMachine)

                                        package com.mod.mod2bk.init;
                                        
                                        import java.util.List;
                                        
                                        import Blocks.TileEntityGeneticMachine;
                                        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;
                                        import net.minecraft.world.World;
                                        
                                        public class ContainerGeneticMachine extends Container
                                        {
                                        
                                            private final TileEntityGeneticMachine tileGM;
                                        
                                            public ContainerGeneticMachine(TileEntityGeneticMachine tile, InventoryPlayer inventory)
                                            {
                                        
                                                this.tileGM = tile;
                                        
                                                tile.openInventory(inventory.player);
                                        
                                               for(int i = 0; i < 3; ++i)
                                               {
                                                   for(int j = 0; j < 9; ++j)
                                                   {
                                                       this.addSlotToContainer(new Slot(tile, j + i * 9, 8 + j * 18, 18 + i * 18));
                                                   }
                                               }
                                        
                                               this.bindPlayerInventory(inventory);
                                            }
                                        
                                            private void bindPlayerInventory(InventoryPlayer inventory)
                                           {
                                        
                                               int i;
                                        
                                               for(i = 0; i < 3; ++i)
                                               {
                                        
                                                   for(int j = 0; j < 9; ++j)
                                                   {
                                                       this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 86 + i * 18));
                                                   }
                                        
                                               }
                                        
                                               for(i = 0; i < 9; ++i)
                                               {
                                                   this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 144));
                                               }
                                        
                                           }
                                        
                                            public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex)    
                                           {
                                               ItemStack itemstack = null;
                                        
                                               Slot slot = (Slot)this.inventorySlots.get(slotIndex);
                                        
                                               if(slot != null && slot.getHasStack())
                                               {
                                                   ItemStack itemstack1 = slot.getStack();
                                        
                                                   itemstack = itemstack1.copy();
                                        
                                                   if(slotIndex < this.tileGM.getSizeInventory())
                                                   {
                                        
                                                       if(!this.mergeItemStack(itemstack1, this.tileGM.getSizeInventory(), this.inventorySlots.size(), true))
                                                       {
                                                           return null;
                                                       }
                                                   }
                                        
                                                   else if(!this.mergeItemStack(itemstack1, 0, this.tileGM.getSizeInventory(), false))
                                                   {
                                                       return null;
                                                   }
                                        
                                                   if(itemstack1.stackSize == 0)
                                                   {
                                                       slot.putStack((ItemStack)null);
                                                   }
                                                   else
                                                   {
                                                       slot.onSlotChanged();
                                                   }
                                               }
                                               return itemstack;
                                           }
                                            @Override
                                            public boolean canInteractWith(EntityPlayer player)
                                           {
                                               return this.tileGM.isUseableByPlayer(player);
                                           }
                                        }
                                        

                                        Et le Gui(GuiGeneticMachine)

                                        package com.mod.mod2bk;
                                        
                                        import org.lwjgl.opengl.GL11;
                                        
                                        import com.mod.mod2bk.init.ContainerGeneticMachine;
                                        
                                        import Blocks.TileEntityGeneticMachine;
                                        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;
                                        
                                        public class GuiGeneticMachine extends GuiContainer
                                        {
                                        
                                            private static final ResourceLocation textures = new ResourceLocation(Reference.MOD_ID, "textures/gui/container/geneticmachine.png");
                                        
                                            private TileEntityGeneticMachine tileGM;
                                        
                                            private IInventory playerInv;
                                        
                                            public GuiGeneticMachine(TileEntityGeneticMachine tile, InventoryPlayer inventory)
                                            {
                                                super(new ContainerGeneticMachine(tile, inventory));
                                        
                                                this.tileGM = tile;
                                                this.playerInv = inventory;
                                                this.allowUserInput = false;
                                                this.ySize = 170;
                                            }
                                        
                                            @Override
                                           protected void drawGuiContainerBackgroundLayer(float partialRenderTick, int x, int y)
                                           {
                                        
                                               GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                                        
                                               this.mc.getTextureManager().bindTexture(textures);
                                        
                                               int k = (this.width - this.xSize) / 2;
                                        
                                               int l = (this.height - this.ySize) / 2;
                                               this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
                                           }
                                        
                                            protected void drawGuiContainerForegroundLayer(int x, int y)
                                           {
                                        
                                               String tileName = this.tileGM.hasCustomName() ? this.tileGM.getName() : I18n.format(this.tileGM.getName());
                                        
                                               this.fontRendererObj.drawString(tileName, (this.xSize - this.fontRendererObj.getStringWidth(tileName)) / 2, 6, 0);
                                        
                                               String invName = this.playerInv.hasCustomName() ? this.playerInv.getName() : I18n.format(this.playerInv.getName());
                                        
                                               this.fontRendererObj.drawString(invName, (this.xSize - this.fontRendererObj.getStringWidth(invName)) / 2, this.ySize - 96, 0);
                                           }
                                        
                                        }
                                        

                                        Voilà et merci de la réponse

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

                                          Ton gui handler est bien enregistré ?

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

                                            @‘robin4002’:

                                            Ton gui handler est bien enregistré ?

                                            Oui, dans la fonction init

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

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB