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.
    • G Hors-ligne
      Games2bk
      dernière édition par

      @‘robin4002’:

      Ahh je viens de voir le problème.
      C’est n’est pas ça, ce que tu as fais est bon.
      Le problème est avant, la fonction onBlockActivated de ton bloc n’est jamais appelé car tu n’as pas les bon argument de fonction.
      Regardes dans la classe Block.java tu devrais trouver les bons arguments. De tête int x, int y, int z ont été remplacé par BlockPos pos.
      Il faut ensuite dans la fonction player.openGui remplacer x, y, z par pos.getX(), pos.getY(), pos.getZ()

      Le jeu crash à l’initialization  😢
      Le crash-report :

      –-- Minecraft Crash Report ----
      // There are four lights!
      
      Time: 16/12/17 18:25
      Description: Initializing game
      
      java.lang.NullPointerException: Initializing game
      at com.mod.mod2bk.init.BlockMod.init(BlockMod.java:24)
      at com.mod.mod2bk.mod2bkpri.preInit(mod2bkpri.java:32)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:553)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
      at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
      at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
      at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
      at com.google.common.eventbus.EventBus.post(EventBus.java:275)
      at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)
      at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
      at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
      at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
      at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
      at com.google.common.eventbus.EventBus.post(EventBus.java:275)
      at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
      at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:550)
      at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:249)
      at net.minecraft.client.Minecraft.startGame(Minecraft.java:446)
      at net.minecraft.client.Minecraft.run(Minecraft.java:356)
      at net.minecraft.client.main.Main.main(Main.java:117)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
      at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
      at GradleStart.main(Unknown Source)
      
      A detailed walkthrough of the error, its code path and all known details is as follows:
      ---------------------------------------------------------------------------------------
      
      -- Head --
      Stacktrace:
      at com.mod.mod2bk.init.BlockMod.init(BlockMod.java:24)
      at com.mod.mod2bk.mod2bkpri.preInit(mod2bkpri.java:32)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:553)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
      at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
      at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
      at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
      at com.google.common.eventbus.EventBus.post(EventBus.java:275)
      at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)
      at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
      at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
      at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
      at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
      at com.google.common.eventbus.EventBus.post(EventBus.java:275)
      at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
      at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:550)
      at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:249)
      at net.minecraft.client.Minecraft.startGame(Minecraft.java:446)
      
      -- Initialization --
      Details:
      Stacktrace:
      at net.minecraft.client.Minecraft.run(Minecraft.java:356)
      at net.minecraft.client.main.Main.main(Main.java:117)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
      at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
      at GradleStart.main(Unknown Source)
      
      -- System Details --
      Details:
      Minecraft Version: 1.8
      Operating System: Windows 10 (amd64) version 10.0
      Java Version: 1.8.0_151, Oracle Corporation
      Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
      Memory: 791675320 bytes (755 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
      JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
      IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
      FML: MCP v9.10 FML v8.0.99.99 Minecraft Forge 11.14.4.1577 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
      UCH mcp{9.05} [Minecraft Coder Pack] (minecraft.jar)
      UCH FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8-11.14.4.1577.jar)
      UCH Forge{11.14.4.1577} [Minecraft Forge] (forgeSrc-1.8-11.14.4.1577.jar)
      UCE geneticmaster{1.0.0} [Genetic Master] (bin)
      Loaded coremods (and transformers):
      GL info: ' Vendor: 'ATI Technologies Inc.' Version: '3.3.11672 Compatibility Profile Context' Renderer: 'ATI Radeon HD 4800 Series'
      Launched Version: 1.8
      LWJGL: 2.9.1
      OpenGL: ATI Radeon HD 4800 Series GL version 3.3.11672 Compatibility Profile Context, ATI Technologies Inc.
      GL Caps: Using GL 1.3 multitexturing.
      Using GL 1.3 texture combiners.
      Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
      Shaders are available because OpenGL 2.1 is supported.
      VBOs are available because OpenGL 1.5 is supported.
      
      Using VBOs: No
      Is Modded: Definitely; Client brand changed to 'fml,forge'
      Type: Client (map_client.txt)
      Resource Packs: []
      Current Language: Français (France)
      Profiler Position: N/A (disabled)
      
      1 réponse Dernière réponse Répondre Citer 0
      • G Hors-ligne
        Games2bk
        dernière édition par

        @‘robin4002’:

        Ahh je viens de voir le problème.
        C’est n’est pas ça, ce que tu as fais est bon.
        Le problème est avant, la fonction onBlockActivated de ton bloc n’est jamais appelé car tu n’as pas les bon argument de fonction.
        Regardes dans la classe Block.java tu devrais trouver les bons arguments. De tête int x, int y, int z ont été remplacé par BlockPos pos.
        Il faut ensuite dans la fonction player.openGui remplacer x, y, z par pos.getX(), pos.getY(), pos.getZ()

        Nouvelle piste.
        Déjà, ce que tu as dit est bon(enfin, je suis pas sûr mais tu vas vite savoir pourquoi)
        Je me suis dit “mais tiens, je vais aller voir la classe BlockChest !”
        Et j’ai vu plusieurs choses.
        De 1 : il a un extends BlockContaienr
        De 2 : il n’a pas CreateTileEntity mais CreateNewTileEntity
        De 3 : ça marche quand-même pas  😢 
        Maintenant, j’ai un bloc qui voit à travers les autres blocs (type Cave Block) et qui ouvre toujours rien au clic
        Merci de ton aide et d’une 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

          Pas besoin de BlockContainer avec forge.
          Laisses comme c’était avant au niveau des extends et des fonctions.

          Il faut juste adapter onBlockActivated

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

            J’ai fait tous les code comme prevu tout marche minecraft se lance mais plante pas jusqu’a que quand je clique sur le block en question ca fait l’animation comme quoi je l’ai ouvert avec la main mais la GUI ne s’affiche pas. J’aurai besoin d’aide pour regler se souci svp !

            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,
              Peux-tu envoyer le code de ton gui handler et de ton bloc ?

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

                @robin4002 tien le GUI Hanlder:

                package fr.askipie.funfight;
                
                import cpw.mods.fml.common.network.IGuiHandler;
                import net.minecraft.entity.player.EntityPlayer;
                import net.minecraft.tileentity.TileEntity;
                import net.minecraft.world.World;
                
                public class GuiHandlerFungie implements IGuiHandler
                {
                
                    @Override
                    public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
                    {
                        TileEntity tile = world.getTileEntity(x, y, z);
                        if(tile instanceof TileEntityFungie)
                        {
                            return new GuiCupboard((TileEntityFungie)tile, player.inventory);
                        }
                        return null;
                    }
                
                    @Override
                    public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
                    {
                        TileEntity tile = world.getTileEntity(x, y, z);
                        if(tile instanceof TileEntityFungie)
                        {
                            return new ContainerCupboard((TileEntityFungie)tile, player.inventory);
                        }
                        return null;
                
                    }
                
                }
                

                la classe du bloc:

                package fr.askipie.funfight;
                
                import cpw.mods.fml.common.registry.GameRegistry;
                import net.minecraft.block.Block;
                import net.minecraft.block.material.Material;
                
                public class FFBlocks 
                {
                	public static Block fungieBlock;
                	public static Block telluriumBlock;
                	public static Block vitriolBlock;
                	public static Block crystaliteBlock;
                    public static Block fungieOre;
                    public static Block telluriumOre;
                    public static Block vitriolOre;
                    public static Block crystaliteOre;
                    public static Block fungieSeedsOre;
                    public static Block telluriumSeedsOre;
                    public static Block vitriolSeedsOre;
                    public static Block crystaliteSeedsOre;
                    public static Block borderBlock;
                    public static Block fungieMachine;
                	
                	public static void init()
                	{
                		fungieBlock = new BlocksBasics(Material.rock).setBlockName("fungieBlock").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":fungieBlock").setHardness(2.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone);
                		telluriumBlock = new BlocksBasics(Material.rock).setBlockName("telluriumBlock").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":telluriumBlock").setHardness(2.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone);
                		vitriolBlock = new BlocksBasics(Material.rock).setBlockName("vitriolBlock").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":vitriolBlock").setHardness(2.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone);
                		crystaliteBlock = new BlocksBasics(Material.rock).setBlockName("crystaliteBlock").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":crystaliteBlock").setHardness(2.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone);
                		fungieOre = new BlocksBasics(Material.rock).setBlockName("fungieOre").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":fungieOre").setHardness(2.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone);
                        telluriumOre = new BlocksBasics(Material.rock).setBlockName("telluriumOre").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":telluriumOre").setHardness(2.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone);
                        vitriolOre = new BlocksBasics(Material.rock).setBlockName("vitriolOre").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":vitriolOre").setHardness(2.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone);
                        crystaliteOre = new BlocksBasics(Material.rock).setBlockName("crystaliteOre").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":crystaliteOre").setHardness(2.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone);
                        fungieSeedsOre = new BlocksBasics(Material.ground).setBlockName("fungieSeedsOre").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":fungieSeedsOre").setHardness(0.2F).setResistance(10.0F).setStepSound(Block.soundTypeGrass);
                        telluriumSeedsOre = new BlocksBasics(Material.ground).setBlockName("telluriumSeedsOre").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":telluriumSeedsOre").setHardness(0.2F).setResistance(10.0F).setStepSound(Block.soundTypeGrass);
                        vitriolSeedsOre = new BlocksBasics(Material.ground).setBlockName("vitriolSeedsOre").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":vitriolSeedsOre").setHardness(0.2F).setResistance(10.0F).setStepSound(Block.soundTypeGrass);
                        crystaliteSeedsOre = new BlocksBasics(Material.ground).setBlockName("crystaliteSeedsOre").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":crystaliteSeedsOre").setHardness(0.2F).setResistance(10.0F).setStepSound(Block.soundTypeGrass);
                        borderBlock = new BlocksBasics(Material.glass).setBlockName("borderBlock").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":borderBlock").setHardness(2.0F).setResistance(10.0F).setStepSound(Block.soundTypeCloth);
                        fungieMachine = new GUITutoriel(Material.rock).setBlockName("fungieMachine").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":FungieMachine/machineOFF").setHardness(2.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone);
                	}
                	
                	public static void register()
                	{
                        GameRegistry.registerBlock(fungieBlock, fungieBlock.getUnlocalizedName().substring(5));
                	GameRegistry.registerBlock(telluriumBlock, telluriumBlock.getUnlocalizedName().substring(5));
                	GameRegistry.registerBlock(vitriolBlock, vitriolBlock.getUnlocalizedName().substring(5));
                	GameRegistry.registerBlock(crystaliteBlock, crystaliteBlock.getUnlocalizedName().substring(5));
                        GameRegistry.registerBlock(fungieOre, fungieOre.getUnlocalizedName().substring(5));
                        GameRegistry.registerBlock(telluriumOre, telluriumOre.getUnlocalizedName().substring(5));
                        GameRegistry.registerBlock(vitriolOre, vitriolOre.getUnlocalizedName().substring(5));
                        GameRegistry.registerBlock(crystaliteOre, crystaliteOre.getUnlocalizedName().substring(5));		
                        GameRegistry.registerBlock(fungieSeedsOre, fungieSeedsOre.getUnlocalizedName().substring(5));
                        GameRegistry.registerBlock(telluriumSeedsOre, telluriumSeedsOre.getUnlocalizedName().substring(5));
                        GameRegistry.registerBlock(vitriolSeedsOre, vitriolSeedsOre.getUnlocalizedName().substring(5));
                        GameRegistry.registerBlock(crystaliteSeedsOre, crystaliteSeedsOre.getUnlocalizedName().substring(5));     
                        GameRegistry.registerBlock(borderBlock, borderBlock.getUnlocalizedName().substring(5));
                        GameRegistry.registerBlock(fungieMachine, fungieMachine.getUnlocalizedName().substring(5));
                	}
                
                }
                

                et le block tile entity:

                package fr.askipie.funfight;
                
                import cpw.mods.fml.common.Mod.Instance;
                import cpw.mods.fml.common.network.NetworkRegistry;
                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 TileEntityFungie extends TileEntity implements IInventory
                
                {
                    
                    private ItemStack[] contents = new ItemStack[27];
                    private String customName;
                
                
                
                    @Override
                    public boolean hasCustomInventoryName()
                    {
                        return false;
                    }
                
                
                
                    @Override
                    public void openInventory()
                    {
                        
                    }
                
                    @Override
                    public void closeInventory()
                    {
                        
                    }
                
                    
                    @Override
                public void readFromNBT(NBTTagCompound compound)
                {
                    super.readFromNBT(compound); // exécute ce qui se trouve dans la fonction readFromNBT de la classe mère (lecture de la position du tile entity)
                    if(compound.hasKey("fungieMachine", Constants.NBT.TAG_STRING)) // si un tag custom name de type string existe
                    {
                        this.customName = compound.getString("fungieMachine"); // on le lit
                    }
                
                    NBTTagList nbttaglist = compound.getTagList("Items", Constants.NBT.TAG_COMPOUND); // on obtient la liste de tags nommée Items
                    this.contents = new ItemStack[this.getSizeInventory()]; // on réinitialise le tableau
                    for(int i = 0; i < nbttaglist.tagCount(); ++i) // i varie de 0 à la taille la liste
                    {
                        NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); // on lit le tag nbt
                        int j = nbttagcompound1.getByte("Slot") & 255; // on lit à quel slot se trouve l'item stack
                
                        if(j >= 0 && j < this.contents.length)
                        {
                            this.contents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); // on lit l'item stack qui se trouve dans le tag
                        }
                    }
                }
                
                @Override
                public void writeToNBT(NBTTagCompound compound)
                {
                    super.writeToNBT(compound); // exécute se qui se trouve dans la fonction writeToNBT de la classe mère (écriture de la position du tile entity)
                    if(this.hasCustomInventoryName()) // s'il y a un nom custom
                    {
                        compound.setString("fungieMachine", this.customName); // on le met dans le tag nbt
                    }
                
                    NBTTagList nbttaglist = new NBTTagList(); // on créé une nouvelle liste de tags
                    for(int i = 0; i < this.contents.length; ++i) // i varie de 0 à la taille de notre tableau
                    {
                        if(this.contents[ i] != null) // si l'item stack à l'emplacement i du tableau n'est pas null
                        {
                            NBTTagCompound nbttagcompound1 = new NBTTagCompound(); // on créé un tag nbt
                            nbttagcompound1.setByte("Slot", (byte)i); // on enregistre son emplacement dans le tableau
                            this.contents[ i].writeToNBT(nbttagcompound1); // on écrit l'item dans le tag
                            nbttaglist.appendTag(nbttagcompound1); // on ajoute le tab à la liste
                        }
                    }
                    compound.setTag("Items", nbttaglist); // on enregistre la liste dans le tag nbt
                
                }
                
                @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) // si le contenu dans l'emplacement n'est pas null
                    {
                        ItemStack itemstack;
                
                        if(this.contents[slotIndex].stackSize <= amount) // si la quantité est inférieur où égale à ce qu'on souhaite retirer
                        {
                            itemstack = this.contents[slotIndex]; // la variable itemstack prends la valeur du contenu
                            this.contents[slotIndex] = null; // on retire ce qui est dans la variable contents
                            this.markDirty(); // met à jour le tile entity
                            return itemstack; // renvoie itemstack
                        }
                        else // sinon
                        {
                            itemstack = this.contents[slotIndex].splitStack(amount); // la fonction splitStack(quantité) retire dans this.contents[slotIndex] le contenu et le met dans itemstack
                
                            if(this.contents[slotIndex].stackSize == 0) // au cas où la quantité passe à 0 (ce qui ne devrait pas arriver en temps normal)
                            {
                                this.contents[slotIndex] = null; // on met sur null, ça évite de se retrouver avec des itemstack bugué qui contiennent 0
                            }
                            this.markDirty(); // met à jour le tile entity
                            return itemstack; // renvoie itemstack
                        }
                    }
                    else // sinon si le contenu dans cette emplacement est null
                    {
                        return null; // renvoie null, puisqu'il n'y a rien dans cette emplacement
                    }
                }
                
                @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 String getInventoryName()
                {
                    return this.hasCustomInventoryName() ? this.customName : "tile.cupboard";
                }
                
                public void setCustomName(String customName)
                {
                    this.customName = customName;
                }
                
                @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 boolean isItemValidForSlot(int slotIndex, ItemStack stack)
                {
                    return true;
                }
                
                @Instance("funfight") // attention il doit respecter les majuscules/minuscules
                public static FunFight instance;
                
                {
                
                NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandlerFungie());
                
                }
                
                }
                
                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

                  La classe du bloc ce n’est pas ce que tu as envoyé, c’est la classe qui contient public MonBlock extends Block
                  Dans ton cas ça semble être GUITutoriel et si c’est bien celle classe, tu l’as très mal nommé.

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

                    @robin4002 Ducoup faut que je change quelle classe et quelle ligne ?

                    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

                      Dans les classes que tu as envoyée pas de problème à signaler.

                      Envoie la classe du bloc.

                      ZunF1xZ 2 réponses Dernière réponse Répondre Citer 0
                      • ZunF1xZ Hors-ligne
                        ZunF1x @robin4002
                        dernière édition par

                        @robin4002 tien c’est la classe de tout mes blocs:

                        package fr.askipie.funfight;
                        
                        import cpw.mods.fml.common.registry.GameRegistry;
                        import net.minecraft.block.Block;
                        import net.minecraft.block.material.Material;
                        
                        public class FFBlocks 
                        {
                        	public static Block fungieBlock;
                        	public static Block telluriumBlock;
                        	public static Block vitriolBlock;
                        	public static Block crystaliteBlock;
                            public static Block fungieOre;
                            public static Block telluriumOre;
                            public static Block vitriolOre;
                            public static Block crystaliteOre;
                            public static Block fungieSeedsOre;
                            public static Block telluriumSeedsOre;
                            public static Block vitriolSeedsOre;
                            public static Block crystaliteSeedsOre;
                            public static Block borderBlock;
                            public static Block fungieMachine;
                        	
                        	public static void init()
                        	{
                        		fungieBlock = new BlocksBasics(Material.rock).setBlockName("fungieBlock").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":fungieBlock").setHardness(2.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone);
                        		telluriumBlock = new BlocksBasics(Material.rock).setBlockName("telluriumBlock").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":telluriumBlock").setHardness(2.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone);
                        		vitriolBlock = new BlocksBasics(Material.rock).setBlockName("vitriolBlock").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":vitriolBlock").setHardness(2.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone);
                        		crystaliteBlock = new BlocksBasics(Material.rock).setBlockName("crystaliteBlock").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":crystaliteBlock").setHardness(2.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone);
                        		fungieOre = new BlocksBasics(Material.rock).setBlockName("fungieOre").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":fungieOre").setHardness(2.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone);
                                telluriumOre = new BlocksBasics(Material.rock).setBlockName("telluriumOre").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":telluriumOre").setHardness(2.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone);
                                vitriolOre = new BlocksBasics(Material.rock).setBlockName("vitriolOre").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":vitriolOre").setHardness(2.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone);
                                crystaliteOre = new BlocksBasics(Material.rock).setBlockName("crystaliteOre").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":crystaliteOre").setHardness(2.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone);
                                fungieSeedsOre = new BlocksBasics(Material.ground).setBlockName("fungieSeedsOre").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":fungieSeedsOre").setHardness(0.2F).setResistance(10.0F).setStepSound(Block.soundTypeGrass);
                                telluriumSeedsOre = new BlocksBasics(Material.ground).setBlockName("telluriumSeedsOre").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":telluriumSeedsOre").setHardness(0.2F).setResistance(10.0F).setStepSound(Block.soundTypeGrass);
                                vitriolSeedsOre = new BlocksBasics(Material.ground).setBlockName("vitriolSeedsOre").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":vitriolSeedsOre").setHardness(0.2F).setResistance(10.0F).setStepSound(Block.soundTypeGrass);
                                crystaliteSeedsOre = new BlocksBasics(Material.ground).setBlockName("crystaliteSeedsOre").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":crystaliteSeedsOre").setHardness(0.2F).setResistance(10.0F).setStepSound(Block.soundTypeGrass);
                                borderBlock = new BlocksBasics(Material.glass).setBlockName("borderBlock").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":borderBlock").setHardness(2.0F).setResistance(10.0F).setStepSound(Block.soundTypeCloth);
                                fungieMachine = new GUITutoriel(Material.rock).setBlockName("fungieMachine").setCreativeTab(FunFight.funTab).setBlockTextureName(References.MODID + ":FungieMachine/machineOFF").setHardness(2.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone);
                        	}
                        	
                        	public static void register()
                        	{
                        		GameRegistry.registerBlock(fungieBlock, fungieBlock.getUnlocalizedName().substring(5));
                        		GameRegistry.registerBlock(telluriumBlock, telluriumBlock.getUnlocalizedName().substring(5));
                        		GameRegistry.registerBlock(vitriolBlock, vitriolBlock.getUnlocalizedName().substring(5));
                        		GameRegistry.registerBlock(crystaliteBlock, crystaliteBlock.getUnlocalizedName().substring(5));
                                GameRegistry.registerBlock(fungieOre, fungieOre.getUnlocalizedName().substring(5));
                                GameRegistry.registerBlock(telluriumOre, telluriumOre.getUnlocalizedName().substring(5));
                                GameRegistry.registerBlock(vitriolOre, vitriolOre.getUnlocalizedName().substring(5));
                                GameRegistry.registerBlock(crystaliteOre, crystaliteOre.getUnlocalizedName().substring(5));		
                                GameRegistry.registerBlock(fungieSeedsOre, fungieSeedsOre.getUnlocalizedName().substring(5));
                                GameRegistry.registerBlock(telluriumSeedsOre, telluriumSeedsOre.getUnlocalizedName().substring(5));
                                GameRegistry.registerBlock(vitriolSeedsOre, vitriolSeedsOre.getUnlocalizedName().substring(5));
                                GameRegistry.registerBlock(crystaliteSeedsOre, crystaliteSeedsOre.getUnlocalizedName().substring(5));     
                                GameRegistry.registerBlock(borderBlock, borderBlock.getUnlocalizedName().substring(5));
                                GameRegistry.registerBlock(fungieMachine, fungieMachine.getUnlocalizedName().substring(5));
                        	}
                        
                        }
                        
                        1 réponse Dernière réponse Répondre Citer 0
                        • ZunF1xZ Hors-ligne
                          ZunF1x @robin4002
                          dernière édition par

                          Ce message a été supprimé !
                          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 robin4002

                            Non, ça c’est ta classe ou tu initiales les blocs, tu l’as déjà envoyé …

                            Moi je veux la classe DU bloc en question, celle qui a un extends Block dans son code.

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

                              @robin4002 le guitutoriel ?

                              package fr.askipie.funfight;
                              
                              import net.minecraft.block.Block;
                              import net.minecraft.block.material.Material;
                              import net.minecraft.entity.EntityLivingBase;
                              import net.minecraft.entity.item.EntityItem;
                              import net.minecraft.entity.player.EntityPlayer;
                              import net.minecraft.inventory.IInventory;
                              import net.minecraft.item.ItemStack;
                              import net.minecraft.nbt.NBTTagCompound;
                              import net.minecraft.tileentity.TileEntity;
                              import net.minecraft.world.World;
                              
                              public class GUITutoriel extends Block
                              {
                                  
                                  public GUITutoriel(Material p_i45394_1_)
                                  {
                                      super(p_i45394_1_);
                                  }
                                  
                              
                                  
                                  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(GuiCupboard.class, 0, world, x, y, z);
                                          player.openGui(ContainerCupboard.class, 0, world, x, y, z);
                                          return true;
                              
                                } 
                                      
                              }
                                      
                                      public void breakBlock(World world, int x, int y, int z, Block block, int metadata)
                                      {
                                          TileEntity tileentity = world.getTileEntity(x, y, z);
                                   
                                          if(tileentity instanceof IInventory)
                                          {
                                              IInventory inv = (IInventory)tileentity;
                                              for(int i1 = 0; i1 < inv.getSizeInventory(); ++i1)
                                              {
                                                  ItemStack itemstack = inv.getStackInSlot(i1);
                                   
                                                  if(itemstack != null)
                                                  {
                                                      float f = world.rand.nextFloat() * 0.8F + 0.1F;
                                                      float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
                                                      EntityItem entityitem;
                                   
                                                      for(float f2 = world.rand.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; world.spawnEntityInWorld(entityitem))
                                                      {
                                                          int j1 = world.rand.nextInt(21) + 10;
                                   
                                                          if(j1 > itemstack.stackSize)
                                                          {
                                                              j1 = itemstack.stackSize;
                                                          }
                                   
                                                          itemstack.stackSize -= j1;
                                                          entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
                                                          float f3 = 0.05F;
                                                          entityitem.motionX = (double)((float)world.rand.nextGaussian() * f3);
                                                          entityitem.motionY = (double)((float)world.rand.nextGaussian() * f3 + 0.2F);
                                                          entityitem.motionZ = (double)((float)world.rand.nextGaussian() * f3);
                                   
                                                          if(itemstack.hasTagCompound())
                                                          {
                                                              entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
                                                          }
                                                      }
                                                  }
                                              }
                                              world.func_147453_f(x, y, z, block);
                                          }
                                          super.breakBlock(world, x, y, z, block, metadata);
                                      
                              }
                                      public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack)
                                      {
                                          TileEntity tile = world.getTileEntity(x, y, z);
                                          if(tile instanceof TileEntityFungie)
                                          {
                                              if(stack.hasDisplayName())
                                              {
                                                  ((TileEntityFungie)tile).setCustomName(stack.getDisplayName());
                                              }
                                          }
                              
                              }
                                      
                              }
                              
                              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

                                Oui c’est bien cette classe.

                                Tu aurais dû mettre “Block” dans le nom de la classe comme c’est un bloc et pas du tout un gui.

                                Le problème vient d’ici, tu as mis deux fois la fonction player.openGui et tu as mis n’importe quoi comme premier argument.

                                Il faut mettre l’instance de ton mod (ClassePrincipale.instance).

                                ZunF1xZ 2 réponses Dernière réponse Répondre Citer 0
                                • ZunF1xZ Hors-ligne
                                  ZunF1x @robin4002
                                  dernière édition par ZunF1x

                                  @robin4002 ca capte pas FunFight.instance la classe principal :

                                  package fr.askipie.funfight;
                                  
                                  import cpw.mods.fml.common.Mod;
                                  import cpw.mods.fml.common.Mod.EventHandler;
                                  import cpw.mods.fml.common.SidedProxy;
                                  import cpw.mods.fml.common.event.FMLInitializationEvent;
                                  import cpw.mods.fml.common.event.FMLPostInitializationEvent;
                                  import cpw.mods.fml.common.event.FMLPreInitializationEvent;
                                  import cpw.mods.fml.relauncher.Side;
                                  import cpw.mods.fml.relauncher.SideOnly;
                                  import net.minecraft.creativetab.CreativeTabs;
                                  import net.minecraft.item.Item;
                                  
                                  
                                  @Mod(modid = References.MODID, name = References.MODNAME, version = References.VERSION)
                                  
                                  public class FunFight
                                  {
                                  	
                                  	protected static final String ItemMod = null;
                                  	
                                  	@SidedProxy(clientSide = References.ClientProxy, serverSide = References.ServerProxy)
                                  	public static CommonProxy proxy;
                                  	
                                  	public static CreativeTabs funTab = new CreativeTabs("funTab")
                                      {
                                  		@SideOnly(Side.CLIENT)
                                  		public Item getTabIconItem()
                                  		{
                                  			return FFItems.fungie;
                                  		}
                                      };
                                  	
                                  	@EventHandler
                                  	public void preInit(FMLPreInitializationEvent event)
                                  	{
                                  		Crops.init();
                                  		Crops.register();
                                  		FFBlocks.init();
                                  		FFBlocks.register();
                                  		FFItems.init();
                                  		FFItems.register();
                                  	    FFCraftings.register();
                                  		FFWorldRegister.MainRegistry();
                                  		GUITutoriel.registerBlocks();
                                  		GuiCupboard.getClipboardString();
                                  		GuiCupboard.isCtrlKeyDown();
                                  		GuiCupboard.isShiftKeyDown();
                                  	}
                                  	
                                  	@EventHandler
                                  	public void init(FMLInitializationEvent event)
                                  	{
                                  	    proxy.registerRenders();
                                  	}
                                  	
                                  	@EventHandler
                                  	public void postInit(FMLPostInitializationEvent event)
                                  	{
                                  		
                                  	}
                                  }
                                  
                                  1 réponse Dernière réponse Répondre Citer 0
                                  • ZunF1xZ Hors-ligne
                                    ZunF1x @robin4002
                                    dernière édition par

                                    @robin4002 tu peut regler mon souci ou pas des que je marque FunFight.instance ca marche pas (FunFight est ma classe principale)

                                    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

                                      Car tu n’as pas créé de variable instance dans ta classe principale.

                                      Va voir le tutoriel sur la base du mod pour savoir comment faire : https://www.minecraftforgefrance.fr/topic/526/créer-la-base-de-votre-mod

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

                                        @robin4002 J’ai ajouter

                                        @Instance("FunFight")
                                         public static FunFight instance;
                                        

                                        mais la gui s’ouvre toujours pas 😞

                                        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

                                          Ah oui normal, il te manque les fonctions gérant le tile entity dans la classe de ton bloc.
                                          https://www.minecraftforgefrance.fr/topic/995/ajouter-une-entité-à-votre-bloc-tile-entity

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

                                            @robin4002 sinon est-ce que je pourrai t’envoyer un lien mediafire de mon workspace de mod car je suis pas fort niveau codage je suis perdu sur les codes et tout est-ce que tu peut ???

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

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB