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

      il suffit de tester que getStackInSlot(0) != null et que Block.getBlockFromItem(getStackInSlot(0)) != null.
      Ensuite tu utilises Block.getBlockFromItem(getStackInSlot(0)) pour ton setBlock

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

        @‘robin4002’:

        il suffit de tester que getStackInSlot(0) != null et que Block.getBlockFromItem(getStackInSlot(0)) != null.
        Ensuite tu utilises Block.getBlockFromItem(getStackInSlot(0)) pour ton setBlock

        salut,
        je te remercie je vais tester ça.

        a +

        https://www.youtube.com/channel/UC74HKvv67kvm8and7xkQfbg

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

          Super tutoriel !
          Une simple question : à quoi sert la fonction “world.func_147453_f(x, y, z, block)” dans le onBreak() du Block ?

          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

            elle sert à signalé que le bloc a changé.

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

              Merci ! Et une autre remarque , dans le onBlockActivated() , tu ouvres le gui quand isRemote vaut false , ce n’est pas le contraire ?

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

                Non c’est bien si il est false, car le serveur va ouvrir le Container du gui puis enverra un packet au client pour lui dire d’ouvrir le gui.

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

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

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

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

                  Euh… J’aimerais savoir comment on fait pour créer une sorte de nouvelle table de craft ? Pour m’aider, j’ai un peu observé le pré-code qu’ils utilisent sur MCreator mais bon…

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

                    https://www.minecraftforgefrance.fr/showthread.php?tid=3556
                    Un peu de recherche ne fait pas de mal.

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

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

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

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

                      O.K, merci, je suis désolé de demander comme ça, hein mais je ne trouvais pas dans le sommaire et j’oublie tt le temps de chercher un article particulier sur le site

                      EDIT : J’ai lu l’article et les commentaires mais j’avoue que ça m’intéresserait plus en 1.7.10 comme tuto complet si tu en as un

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

                        N’empêche que c’est vrai que ça serait bien de l’ajouter au sommaire ^^ mais c’est pas moi qui le gère.

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

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

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

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

                          Faut regarder du côté des TileEntities 🙂

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

                            O.k merci mais ou précisément ?

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

                              Salut,
                              J’ai une petite erreur au niveau de la TileEntity
                              http://prntscr.com/d6eakw

                              Cordialement, FanatikForce

                              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

                                Cette fonction doit être mise dans la classe du bloc et non dans le tile entity.

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

                                  J’ai un problème quant je mes un hopper au dessus de mon block, le contenue du hopper disparaît bien mais il apparaît pas tous dans mon block et quant mon block est full il disparaisse comme même du hopper.

                                  PS le block a un seul emplacement qui peut contenir qu’un item.

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

                                    Pourrais-tu montrer la classe de ton TileEntity ?

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

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

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

                                    1 réponse Dernière réponse Répondre Citer 0
                                    • Adsl HoubaA Hors-ligne
                                      Adsl Houba
                                      dernière édition par

                                      Merci pour le tuto !!

                                      J’ai un petit soucis,

                                      Si je passe le getInventoryStackLimit() à 1 pour avoir un seul item, quand on utilise le shift + click sur un stack de plusieurs items, ils disparaissent (à l’exception de celui qui rentre dans le slot)

                                      La fonction transferStackInSlot n’est pas commenté, du coup je suis un peu perdu 😕

                                      Les sources :
                                      https://github.com/mandonnaud/houbmod/blob/master/src/main/java/fr/adslhouba/houbmod/common/ContainerCupboard.java
                                      https://github.com/mandonnaud/houbmod/blob/master/src/main/java/fr/adslhouba/houbmod/common/block/cc/TileEntityEnclumeCPO.java

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

                                        Bonjour.

                                        J’ai suivi ce tutoriel à la lettre et j’ai voulu tester si ça marcher bien et quand je clique sur mon block… BOOM… MineCraft Crash !!! et je sais pas pourquoi…

                                        Voici mes code :

                                        Classe Principale :

                                        package mod.plantsandfoodpack.common;
                                        
                                        import net.minecraft.block.Block;
                                        import net.minecraft.block.Block.SoundType;
                                        import net.minecraft.block.material.Material;
                                        import net.minecraft.creativetab.CreativeTabs;
                                        import net.minecraft.init.Blocks;
                                        import net.minecraft.init.Items;
                                        import net.minecraft.item.Item;
                                        import net.minecraft.item.ItemFood;
                                        import net.minecraft.item.ItemSeeds;
                                        import net.minecraft.item.ItemStack;
                                        import mod.plantsandfoodpack.proxy.CommonProxy;
                                        import cpw.mods.fml.common.Mod;
                                        import cpw.mods.fml.common.Mod.EventHandler;
                                        import cpw.mods.fml.common.Mod.Instance;
                                        import cpw.mods.fml.common.SidedProxy;
                                        import cpw.mods.fml.common.event.FMLInitializationEvent;
                                        import cpw.mods.fml.common.event.FMLPostInitializationEvent;
                                        import cpw.mods.fml.common.event.FMLPreInitializationEvent;
                                        import cpw.mods.fml.common.network.NetworkRegistry;
                                        import cpw.mods.fml.common.registry.GameRegistry;
                                        
                                        @Mod(modid= "plantsandfoodpack", name="Plants & Food Pack Mod", version ="1.0.0")
                                        
                                        public class ModPlantsandFoodPack{
                                        
                                        public static final String MODID = "plantsandfoodpack";
                                        
                                        @Instance(MODID)
                                        public static ModPlantsandFoodPack instance;
                                        
                                        @SidedProxy(clientSide = "mod.plantsandfoodpack.proxy.ClientProxy", serverSide ="mod.plantsandfoodpack.proxy.CommonProxy")
                                        public static CommonProxy proxy;
                                        
                                        public static Item flour, itemTomato, itemTomatoSeeds, itemLettuceSeeds, itemLettuceLeaf;
                                        public static Block blockSugar, blockTomatoCrop, blockLettuceCrop, blockKitchenCupboard;
                                        
                                        @EventHandler
                                        public void preInit(FMLPreInitializationEvent event){
                                        
                                        blockSugar = new BlockSugar(Material.sand).setBlockName("sugarBlock").setBlockTextureName(MODID + ":sugar_block").setCreativeTab(CreativeTabs.tabBlock).setStepSound(Block.soundTypeSand);
                                        blockTomatoCrop = new BlockTomatoCrop().setBlockName("tomatoCrop").setBlockTextureName(MODID + ":tomato_crop");
                                        blockLettuceCrop = new BlockLettuceCrop().setBlockName("lettuceCrop").setBlockTextureName(MODID + ":lettuce_crop");
                                        blockKitchenCupboard = new BlockKitchenCupboard(Material.wood).setBlockName("kitchenCupboard");
                                        
                                        flour = new ItemFlour().setUnlocalizedName("flour").setTextureName(MODID + ":flour").setCreativeTab(CreativeTabs.tabMaterials);
                                        itemTomato = new ItemTomato(3, 2.5F, false).setUnlocalizedName("tomato").setTextureName(MODID + ":tomato").setCreativeTab(CreativeTabs.tabFood);
                                        itemTomatoSeeds = new ItemSeeds(this.blockTomatoCrop, Blocks.farmland).setUnlocalizedName("tomatoSeed").setTextureName(MODID + ":tomato_seeds").setCreativeTab(CreativeTabs.tabMaterials);
                                        itemLettuceLeaf = new ItemFood(2, 1.5F, false).setUnlocalizedName("lettuceLeaf").setTextureName(MODID + ":lettuce_leaf").setCreativeTab(CreativeTabs.tabFood);
                                        itemLettuceSeeds = new ItemSeeds(this.blockLettuceCrop, Blocks.farmland).setUnlocalizedName("lettuceSeeds").setTextureName(MODID + ":lettuce_seeds").setCreativeTab(CreativeTabs.tabMaterials);
                                        
                                        GameRegistry.registerBlock(blockSugar, "sugar_block");
                                        GameRegistry.registerBlock(blockTomatoCrop, "tomatoCrop");
                                        GameRegistry.registerBlock(blockLettuceCrop, "lettuceCrop");
                                        GameRegistry.registerBlock(blockKitchenCupboard, "kitchenCupboard");
                                        
                                        GameRegistry.registerItem(flour, "flour");
                                        GameRegistry.registerItem(itemTomato, "tomato");
                                        GameRegistry.registerItem(itemTomatoSeeds, "tomato_seeds");
                                        GameRegistry.registerItem(itemLettuceLeaf, "lettuce_leaf");
                                        GameRegistry.registerItem(itemLettuceSeeds, "lettuce_seeds");
                                        
                                        }
                                        
                                        @EventHandler
                                        public void Init(FMLInitializationEvent event){
                                        
                                        GameRegistry.addRecipe(new ItemStack(flour, 1), new Object[] {"*", '*', Items.wheat});
                                        GameRegistry.addRecipe(new ItemStack(blockSugar, 1), new Object[] {"###", "###", "###", '#', Items.sugar});
                                        GameRegistry.addRecipe(new ItemStack(blockKitchenCupboard, 1), new Object[] {"WWW", "W W", "WWW", 'W', Blocks.log});
                                        
                                        GameRegistry.registerTileEntity(TileEntityKitchenCupboard.class, MODID + ":kitchenCupboard");
                                        proxy.registerRender();
                                        
                                        NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandlerPlantsAndFoodPack());
                                        }
                                        
                                        @EventHandler
                                        public void postInit(FMLPostInitializationEvent event){
                                        
                                        }
                                        }
                                        
                                        

                                        Classe du Block :

                                        package mod.plantsandfoodpack.common;
                                        
                                        import mod.plantsandfoodpack.proxy.ClientProxy;
                                        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.tileentity.TileEntityChest;
                                        import net.minecraft.util.MathHelper;
                                        import net.minecraft.world.World;
                                        import net.minecraftforge.common.util.ForgeDirection;
                                        
                                        public class BlockKitchenCupboard extends Block{
                                        
                                        protected BlockKitchenCupboard(Material p_i45394_1_) {
                                        super(p_i45394_1_);
                                        }
                                        
                                        @Override
                                        public boolean hasTileEntity(int metadata) {
                                        
                                        return true;
                                        }
                                        
                                        @Override
                                        public TileEntity createTileEntity(World world, int metadata) {
                                        
                                        return new TileEntityKitchenCupboard ();
                                        }
                                        
                                        public void breakBlock(World world, int x, int y, int z, Block block, int metadata)
                                           {
                                               TileEntity tileentity = world.getTileEntity(x, y, z);
                                        
                                               if (tileentity instanceof IInventory)
                                               {
                                                IInventory inv = (IInventory)tileentity;
                                                   for (int i1 = 0; i1 < inv.getSizeInventory(); ++i1)
                                                   {
                                                       ItemStack itemstack = inv.getStackInSlot(i1);
                                        
                                                       if (itemstack != null)
                                                       {
                                                           float f = world.rand.nextFloat() * 0.8F + 0.1F;
                                                           float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
                                                           EntityItem entityitem;
                                        
                                                           for (float f2 = world.rand.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; world.spawnEntityInWorld(entityitem))
                                                           {
                                                               int j1 = world.rand.nextInt(21) + 10;
                                        
                                                               if (j1 > itemstack.stackSize)
                                                               {
                                                                   j1 = itemstack.stackSize;
                                                               }
                                        
                                                               itemstack.stackSize -= j1;
                                                               entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
                                                               float f3 = 0.05F;
                                                               entityitem.motionX = (double)((float)world.rand.nextGaussian() * f3);
                                                               entityitem.motionY = (double)((float)world.rand.nextGaussian() * f3 + 0.2F);
                                                               entityitem.motionZ = (double)((float)world.rand.nextGaussian() * f3);
                                        
                                                               if (itemstack.hasTagCompound())
                                                               {
                                                                   entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
                                                               }
                                                           }
                                                       }
                                                   }
                                        
                                                   world.func_147453_f(x, y, z, block);
                                               }
                                        
                                               super.breakBlock(world, x, y, z, block, metadata);
                                           }
                                        
                                        public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
                                           {
                                        if(world.isRemote)
                                              {
                                                  return true;
                                              }
                                              else
                                              {
                                                  player.openGui(ModPlantsandFoodPack.instance, 0, world, x, y, z);
                                                  return true;
                                              }
                                           }
                                        
                                        public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack){
                                        if(stack.getItemDamage() == 0)
                                        {
                                        TileEntity tile = world.getTileEntity(x, y, z);
                                        if(tile instanceof TileEntityKitchenCupboard)
                                        {
                                        int direction = MathHelper.floor_double((double)(living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3;
                                        ((TileEntityKitchenCupboard)tile).setDirection((byte)direction);
                                        if(stack.hasDisplayName())
                                        {
                                        ((TileEntityKitchenCupboard)tile).setCustomName(stack.getDisplayName());
                                        }
                                        }
                                        }
                                        }
                                        
                                        @Override
                                        public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis)
                                        {
                                        if((axis == ForgeDirection.UP || axis == ForgeDirection.DOWN) && !world.isRemote && world.getBlockMetadata(x, y, z) == 0)
                                        {
                                        TileEntity tile = world.getTileEntity(x, y, z);
                                        if(tile instanceof TileEntityKitchenCupboard)
                                        {
                                        TileEntityKitchenCupboard tileKitchenCupboard = (TileEntityKitchenCupboard)tile;
                                        byte direction = tileKitchenCupboard.getDirection();
                                        direction++;
                                        if(direction > 3)
                                        {
                                        direction = 0;
                                        }
                                        tileKitchenCupboard.setDirection(direction);
                                        return true;
                                        }
                                        }
                                        return false;
                                        }
                                        
                                        public ForgeDirection[] getValidRotation(World world, int x, int y, int z)
                                        {
                                        return world.getBlockMetadata(x, y, z) == 0 ? new ForgeDirection[] {ForgeDirection.UP, ForgeDirection.DOWN,} : ForgeDirection.VALID_DIRECTIONS;
                                        }
                                        
                                        public boolean isOpaqueCube(){
                                        return false;
                                        }
                                        
                                        public boolean renderAsNormalBlock(){
                                        return false;
                                        }
                                        
                                        public int getRenderType(){
                                        return ClientProxy.tesrRenderId;
                                        }
                                        
                                        }
                                        
                                        

                                        Classe du Tile Entity :

                                        package mod.plantsandfoodpack.common;
                                        
                                        import net.minecraft.entity.player.EntityPlayer;
                                        import net.minecraft.inventory.IInventory;
                                        import net.minecraft.item.ItemStack;
                                        import net.minecraft.nbt.NBTTagCompound;
                                        import net.minecraft.nbt.NBTTagList;
                                        import net.minecraft.network.NetworkManager;
                                        import net.minecraft.network.Packet;
                                        import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
                                        import net.minecraft.tileentity.TileEntity;
                                        import net.minecraftforge.common.util.Constants;
                                        
                                        public class TileEntityKitchenCupboard extends TileEntity implements IInventory {
                                        
                                        private byte direction;
                                        private ItemStack[] contents = new ItemStack[18];
                                        private String customName;
                                        
                                        @Override
                                        public void readFromNBT(NBTTagCompound compound)
                                        {
                                        super.readFromNBT(compound);
                                        this.direction = compound.getByte("Direction");
                                        
                                               if (compound.hasKey("CustomName", Constants.NBT.TAG_STRING))
                                               {
                                                   this.customName = compound.getString("CustomName");
                                               }
                                        
                                               NBTTagList nbttaglist = compound.getTagList("Items", Constants.NBT.TAG_COMPOUND);
                                               this.contents = new ItemStack[this.getSizeInventory()];
                                        
                                               for (int i = 0; i < nbttaglist.tagCount(); ++i)
                                               {
                                                   NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
                                                   int j = nbttagcompound1.getByte("Slot") & 255;
                                        
                                                   if (j >= 0 && j < this.contents.length)
                                                   {
                                                       this.contents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
                                                   }
                                               }
                                        }
                                        
                                        public void writeToNBT(NBTTagCompound compound)
                                        {
                                        super.writeToNBT(compound);
                                        compound.setByte("Direction", this.direction);
                                        if (this.hasCustomInventoryName())
                                               {
                                                   compound.setString("CustomName", this.customName);
                                               }
                                        
                                        NBTTagList nbttaglist = new NBTTagList();
                                        
                                               for (int i = 0; i < this.contents.length; ++i)
                                               {
                                                   if (this.contents* != null)
                                                   {
                                                       NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                                                       nbttagcompound1.setByte("Slot", (byte)i);
                                                       this.contents*.writeToNBT(nbttagcompound1);
                                                       nbttaglist.appendTag(nbttagcompound1);
                                                   }
                                               }
                                        
                                               compound.setTag("Items", nbttaglist);
                                        
                                        }
                                        
                                        public byte getDirection()
                                        {
                                        return direction;
                                        }
                                        
                                        public void setDirection(byte direction)
                                        {
                                        this.direction = direction;
                                        this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
                                        }
                                        
                                        public Packet getDescriptionPacket()
                                        {
                                        NBTTagCompound nbttagcompound = new NBTTagCompound();
                                        this.writeToNBT(nbttagcompound);
                                        return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbttagcompound);
                                        }
                                        
                                        public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)
                                        {
                                        this.readFromNBT(pkt.func_148857_g());
                                        this.worldObj.markBlockRangeForRenderUpdate(this.xCoord, this.yCoord, this.zCoord, this.xCoord, this.yCoord, this.zCoord);
                                        }
                                        
                                        @Override
                                        public int getSizeInventory() {
                                        return this.contents.length;
                                        }
                                        
                                           @Override
                                          public ItemStack getStackInSlot(int slotIndex)
                                          {
                                              return this.contents[slotIndex];
                                          }
                                        
                                        @Override
                                        public ItemStack decrStackSize(int slotIndex, int amount)
                                           {
                                               if (this.contents[slotIndex] != null)
                                               {
                                                   ItemStack itemstack;
                                        
                                                   if (this.contents[slotIndex].stackSize <= amount)
                                                   {
                                                       itemstack = this.contents[slotIndex];
                                                       this.contents[slotIndex] = null;
                                                       this.markDirty();
                                                       return itemstack;
                                                   }
                                                   else
                                                   {
                                                       itemstack = this.contents[slotIndex].splitStack(amount);
                                        
                                                       if (this.contents[slotIndex].stackSize == 0)
                                                       {
                                                           this.contents[slotIndex] = null;
                                                       }
                                        
                                                       this.markDirty();
                                                       return itemstack;
                                                   }
                                               }
                                               else
                                               {
                                                   return null;
                                               }
                                           }
                                        
                                        @Override
                                        public ItemStack getStackInSlotOnClosing(int slotIndex)
                                           {
                                               if (this.contents[slotIndex] != null)
                                               {
                                                   ItemStack itemstack = this.contents[slotIndex];
                                                   this.contents[slotIndex] = null;
                                                   return itemstack;
                                               }
                                               else
                                               {
                                                   return null;
                                               }
                                           }
                                        
                                        @Override
                                        public void setInventorySlotContents(int slotIndex, ItemStack stack) {
                                        this.contents[slotIndex] = stack;
                                        
                                               if (stack != null && stack.stackSize > this.getInventoryStackLimit())
                                               {
                                                   stack.stackSize = this.getInventoryStackLimit();
                                               }
                                        
                                               this.markDirty();
                                        }
                                        
                                        @Override
                                        public String getInventoryName() {
                                        return this.hasCustomInventoryName() ? this.customName : "tile.kitchenCupboard";
                                        }
                                        
                                        @Override
                                        public boolean hasCustomInventoryName() {
                                        return this.customName != null && !this.customName.isEmpty();
                                        }
                                        
                                        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 void openInventory() {
                                        
                                        }
                                        
                                        @Override
                                        public void closeInventory() {
                                        
                                        }
                                        
                                        @Override
                                        public boolean isItemValidForSlot(int slotIndex, ItemStack stack) {
                                        return true;
                                        }
                                        
                                        }
                                        
                                        

                                        Classe du GuiHandler :

                                        package mod.plantsandfoodpack.common;
                                        
                                        import mod.plantsandfoodpack.client.GuiKitchenCupboard;
                                        import net.minecraft.entity.player.EntityPlayer;
                                        import net.minecraft.tileentity.TileEntity;
                                        import net.minecraft.world.World;
                                        import cpw.mods.fml.common.network.IGuiHandler;
                                        
                                        public class GuiHandlerPlantsAndFoodPack 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 TileEntityKitchenCupboard)
                                        {
                                        return new ContainerKitchenCupboard((TileEntityKitchenCupboard)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 TileEntityKitchenCupboard)
                                        {
                                        return new GuiKitchenCupboard((TileEntityKitchenCupboard)tile, player.inventory);
                                        }
                                        return null;
                                        }
                                        
                                        }
                                        
                                        

                                        Classe du Container :

                                        package mod.plantsandfoodpack.common;
                                        
                                        import net.minecraft.entity.player.EntityPlayer;
                                        import net.minecraft.entity.player.InventoryPlayer;
                                        import net.minecraft.init.Blocks;
                                        import net.minecraft.inventory.Container;
                                        import net.minecraft.inventory.Slot;
                                        import net.minecraft.item.Item;
                                        import net.minecraft.item.ItemStack;
                                        
                                        public class ContainerKitchenCupboard extends Container
                                        {
                                        private final TileEntityKitchenCupboard tileKitchenCupboard;
                                        
                                        public ContainerKitchenCupboard(TileEntityKitchenCupboard tile, InventoryPlayer inventory)
                                        {
                                        this.tileKitchenCupboard = tile;
                                        tile.openInventory();
                                        for (int i = 0; i < 3; ++i)
                                               {
                                                   for (int j = 0; j < 9; ++j)
                                                   {
                                                       this.addSlotToContainer(new Slot(tile, j + i * 9, 8 + j * 18, 18 + i * 18));
                                                   }
                                               }
                                        this.bindPlayerInventory(inventory);
                                        
                                        }
                                        
                                        private void bindPlayerInventory(InventoryPlayer inventory)
                                        {
                                        int i;
                                        for (i = 0; i < 3; ++i)
                                               {
                                                   for (int j = 0; j < 9; ++j)
                                                   {
                                                       this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 85 + i * 18 -18));
                                                   }
                                               }
                                        
                                               for (i = 0; i < 9; ++i)
                                               {
                                                   this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 143));
                                               }
                                        }
                                        
                                        public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int slotIndex)
                                           {
                                               ItemStack itemstack = null;
                                               Slot slot = (Slot)this.inventorySlots.get(slotIndex);
                                        
                                               if (slot != null && slot.getHasStack())
                                               {
                                                   ItemStack itemstack1 = slot.getStack();
                                                   itemstack = itemstack1.copy();
                                        
                                                   if (slotIndex < this.tileKitchenCupboard.getSizeInventory())
                                                   {
                                                       if (!this.mergeItemStack(itemstack1, this.tileKitchenCupboard.getSizeInventory(), this.inventorySlots.size(), true))
                                                       {
                                                           return null;
                                                       }
                                                   }
                                                   else if (!this.mergeItemStack(itemstack1, 0, this.tileKitchenCupboard.getSizeInventory(), false))
                                                   {
                                                       return null;
                                                   }
                                        
                                                   if (itemstack1.stackSize == 0)
                                                   {
                                                       slot.putStack((ItemStack)null);
                                                   }
                                                   else
                                                   {
                                                       slot.onSlotChanged();
                                                   }
                                               }
                                        
                                               return itemstack;
                                           }
                                        
                                        @Override
                                        public boolean canInteractWith(EntityPlayer player)
                                        {
                                        return this.tileKitchenCupboard.isUseableByPlayer(player);
                                        }
                                        
                                        public void onContainerClosed(EntityPlayer player)
                                           {
                                               super.onContainerClosed(player);
                                               this.tileKitchenCupboard.closeInventory();
                                           }
                                        
                                        }
                                        
                                        

                                        Classe du Gui :

                                        package mod.plantsandfoodpack.client;
                                        
                                        import java.awt.Container;
                                        
                                        import mod.plantsandfoodpack.common.ContainerKitchenCupboard;
                                        import mod.plantsandfoodpack.common.TileEntityKitchenCupboard;
                                        import net.minecraft.client.gui.inventory.GuiContainer;
                                        import net.minecraft.entity.player.InventoryPlayer;
                                        
                                        public class GuiKitchenCupboard extends GuiContainer {
                                        
                                        public GuiKitchenCupboard(TileEntityKitchenCupboard tile, InventoryPlayer inventory) {
                                        super(new ContainerKitchenCupboard(tile, inventory));
                                        }
                                        
                                        @Override
                                        protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
                                        
                                        }
                                        
                                        }
                                        
                                        

                                        Au passage, j’aimera savoir comment je pourrais faire pour que sur mon Gui, il y est 3 rangées de 6 slots ?

                                        Merci d’avance !

                                        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

                                          Il manque l’essentiel : le rapport de crash.

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

                                            Voilà !!

                                            [19:07:59] [Server thread/INFO]: themoney158 a rejoint la partie
                                            [19:08:15] [Server thread/ERROR]: Encountered an unexpected exception
                                            net.minecraft.util.ReportedException: Ticking memory connection
                                            at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:198) ~[NetworkSystem.class:?]
                                            at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) ~[MinecraftServer.class:?]
                                            at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) ~[MinecraftServer.class:?]
                                            at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) ~[IntegratedServer.class:?]
                                            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?]
                                            at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?]
                                            Caused by: java.lang.ArrayIndexOutOfBoundsException: 18
                                            at mod.plantsandfoodpack.common.TileEntityKitchenCupboard.getStackInSlot(TileEntityKitchenCupboard.java:104) ~[TileEntityKitchenCupboard.class:?]
                                            at net.minecraft.inventory.Slot.getStack(Slot.java:88) ~[Slot.class:?]
                                            at net.minecraft.inventory.Container.getInventory(Container.java:67) ~[Container.class:?]
                                            at net.minecraft.inventory.Container.addCraftingToCrafters(Container.java:53) ~[Container.class:?]
                                            at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:88) ~[FMLNetworkHandler.class:?]
                                            at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501) ~[EntityPlayer.class:?]
                                            at mod.plantsandfoodpack.common.BlockKitchenCupboard.onBlockActivated(BlockKitchenCupboard.java:92) ~[BlockKitchenCupboard.class:?]
                                            at net.minecraft.server.management.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:409) ~[ItemInWorldManager.class:?]
                                            at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:593) ~[NetHandlerPlayServer.class:?]
                                            at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74) ~[C08PacketPlayerBlockPlacement.class:?]
                                            at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122) ~[C08PacketPlayerBlockPlacement.class:?]
                                            at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) ~[NetworkManager.class:?]
                                            at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) ~[NetworkSystem.class:?]
                                            … 5 more
                                            [19:08:16] [Server thread/ERROR]: This crash report has been saved to: C:\Users\nathan\Desktop\Mod Minecraft 1.7.2\eclipse\.\crash-reports\crash-2017-05-09_19.08.16-server.txt
                                            [19:08:16] [Server thread/INFO]: Stopping server
                                            [19:08:16] [Server thread/INFO]: Saving players
                                            [19:08:16] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: –-- Minecraft Crash Report ----
                                            // I feel sad now :(
                                            
                                            Time: 09/05/17 19:08
                                            Description: Ticking memory connection
                                            
                                            java.lang.ArrayIndexOutOfBoundsException: 18
                                            at mod.plantsandfoodpack.common.TileEntityKitchenCupboard.getStackInSlot(TileEntityKitchenCupboard.java:104)
                                            at net.minecraft.inventory.Slot.getStack(Slot.java:88)
                                            at net.minecraft.inventory.Container.getInventory(Container.java:67)
                                            at net.minecraft.inventory.Container.addCraftingToCrafters(Container.java:53)
                                            at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:88)
                                            at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501)
                                            at mod.plantsandfoodpack.common.BlockKitchenCupboard.onBlockActivated(BlockKitchenCupboard.java:92)
                                            at net.minecraft.server.management.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:409)
                                            at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:593)
                                            at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74)
                                            at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122)
                                            at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241)
                                            at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)
                                            at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726)
                                            at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)
                                            at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
                                            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)
                                            at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)
                                            
                                            A detailed walkthrough of the error, its code path and all known details is as follows:
                                            ---------------------------------------------------------------------------------------
                                            
                                            -- Head --
                                            Stacktrace:
                                            at mod.plantsandfoodpack.common.TileEntityKitchenCupboard.getStackInSlot(TileEntityKitchenCupboard.java:104)
                                            at net.minecraft.inventory.Slot.getStack(Slot.java:88)
                                            at net.minecraft.inventory.Container.getInventory(Container.java:67)
                                            at net.minecraft.inventory.Container.addCraftingToCrafters(Container.java:53)
                                            at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:88)
                                            at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501)
                                            at mod.plantsandfoodpack.common.BlockKitchenCupboard.onBlockActivated(BlockKitchenCupboard.java:92)
                                            at net.minecraft.server.management.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:409)
                                            at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:593)
                                            at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74)
                                            at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122)
                                            at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241)
                                            
                                            -- Ticking connection --
                                            Details:
                                            Connection: net.minecraft.network.NetworkManager@493d80f4
                                            Stacktrace:
                                            at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)
                                            at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726)
                                            at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)
                                            at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
                                            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)
                                            at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)
                                            
                                            -- System Details --
                                            Details:
                                            Minecraft Version: 1.7.10
                                            Operating System: Windows 7 (amd64) version 6.1
                                            Java Version: 1.8.0_121, Oracle Corporation
                                            Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
                                            Memory: 835496320 bytes (796 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
                                            JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
                                            AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
                                            IntCache: cache: 15, tcache: 0, allocated: 13, tallocated: 95
                                            FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1558 4 mods loaded, 4 mods active
                                            States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
                                            UCHIJAAAA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) 
                                            UCHIJAAAA FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) 
                                            UCHIJAAAA Forge{10.13.4.1558} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) 
                                            UCHIJAAAA plantsandfoodpack{1.0.0} [Plants & Food Pack Mod] (bin) 
                                            GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.
                                            Profiler Position: N/A (disabled)
                                            Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
                                            Player Count: 1 / 8; [EntityPlayerMP['themoney158'/337, l='TEST 1', x=5,83, y=68,00, z=309,36]]
                                            Type: Integrated Server (map_client.txt)
                                            Is Modded: Definitely; Client brand changed to 'fml,forge'
                                            [19:08:16] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:393]: #@!@# Game crashed! Crash report saved to: #@!@# .\crash-reports\crash-2017-05-09_19.08.16-server.txt
                                            [19:08:16] [Client thread/INFO] [FML]: Waiting for the server to terminate/save.
                                            [19:08:16] [Server thread/INFO]: Saving worlds
                                            [19:08:16] [Server thread/INFO]: Saving chunks for level 'TEST 1'/Overworld
                                            [19:08:16] [Server thread/INFO]: Saving chunks for level 'TEST 1'/Nether
                                            [19:08:16] [Server thread/INFO]: Saving chunks for level 'TEST 1'/The End
                                            [19:08:16] [Server thread/INFO] [FML]: Unloading dimension 0
                                            [19:08:16] [Server thread/INFO] [FML]: Unloading dimension -1
                                            [19:08:16] [Server thread/INFO] [FML]: Unloading dimension 1
                                            [19:08:16] [Server thread/INFO] [FML]: Applying holder lookups
                                            [19:08:16] [Server thread/INFO] [FML]: Holder lookups applied
                                            [19:08:16] [Server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded.
                                            [19:08:16] [Client thread/INFO] [FML]: Server terminated.
                                            AL lib: (EE) alc_cleanup: 1 device not closed
                                            Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
                                            

                                            Merci D’avance !

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

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB