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.
    • 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
                              • robin4002R Hors-ligne
                                robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                                dernière édition par

                                Je n’ai plus aucune workspace 1.7.10 sur mon ordinateur, donc ça va être compliqué.

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

                                  @robin4002 ouai mais c’est deja compilé ya plus qu’a lancer avec eclipse et ca vat marcher normalement !

                                  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

                                    Alors non, pour déboguer quelque chose il faut les sources, donc ce n’est pas déjà compilé.

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

                                      @robin4002 alors tu veux bien j’ai que 12 ans alors pour coder c’est pas tres bien !
                                      @robin4002 meme si ya tout dans dossier du mod ?

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

                                        @robin4002 tien essaye si ca marche pas c’est pas grave je me debrouillerai:

                                        Workspace

                                        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 mais de toute façon la 1.7.10 ne m’intéresse pas, cette version est obsolète, je ne dev plus sur cette version.
                                          Ça ne sert à rien d’insister.

                                          Suis le tutoriel sur les tile entity, il te manque que 2 fonctions dans la classe du bloc et ça devrait fonctionner.

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

                                            Quand j’ouvre ma gui en cliquant sur le bloc mon jeu crash j’aurai besoin d’aide car je ne sais pas pourquoi:

                                            la classe du bloc en question

                                            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_);
                                                }
                                                
                                             
                                                @Override
                                                public boolean hasTileEntity(int metadata)
                                                {
                                                    return true;
                                                }
                                                
                                                @Override
                                                public TileEntity createTileEntity(World world, int metadata)
                                                {
                                                    if(metadata == 0)
                                                    {
                                                    return new TileEntityFungie();
                                                    }
                                                    else if(metadata == 1)
                                                    {
                                                        return new TileEntityFungie();
                                                    }
                                                    else if(metadata == 2)
                                                    {
                                                        return new TileEntityFungie();
                                                    }
                                                    return null;
                                                }
                                             
                                            
                                            
                                                
                                                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(FunFight.instance, 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());
                                                            }
                                                        }
                                            
                                            }
                                                    
                                            }
                                            

                                            la classe du tileEntity :

                                            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());
                                            
                                            }
                                            
                                            }
                                            
                                            

                                            Sa me soule ca marche jamais avec moi je suis vraiment nul serieux!!!

                                            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