MFF

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

    Créer un gui et un container sur un bloc (type coffre)

    Planifier Épinglé Verrouillé Déplacé Les interfaces (GUI) et les container
    1.6.x
    136 Messages 24 Publieurs 55.9k Vues 5 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.
    • PatatoufetP Hors-ligne
      Patatoufet
      dernière édition par

      @‘isador34’:

      comment modifier ce code pour que ça ouvre un container mais pas sur un bloc, en appuyant sur la touche P par exemple

      http://www.minecraftforgefrance.fr/showthread.php?tid=545

      1 réponse Dernière réponse Répondre Citer 0
      • isadorI Hors-ligne
        isador Moddeurs confirmés Modérateurs
        dernière édition par

        merci ❤

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

          Petite question, comment faire pour par exemple reproduire une enclume? qui n’a pas de TileEntity, je veux dire, pour le GUIhandler, comment cela se passe?

          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

            Tu peux utiliser les id dans le openGui oui alors tu compares avec le bloc.

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

              j’avais fait ça:

              
              int block = world.getBlockId(x, y, z);
              if(block == Import.Rubanvil.blockID)
              {
              return new ContainerRubanvil(player.inventory, world, x, y, z, player);
              }
              
              
              
              int block = world.getBlockId(x, y, z);
              if(block == Import.Rubanvil.blockID)
              {
              return new GuiRubanvil(player.inventory, world, x, y, z);
              }
              
              

              Mais si cela te semble bon c’est que mon erreur vient d’autre part, et que je vais devoir fouiller

              1 réponse Dernière réponse Répondre Citer 0
              • Superloup10S Hors-ligne
                Superloup10 Modérateurs
                dernière édition par

                Personnellement, je fais comme ceci: GuiHandler.java

                Si vous souhaitez me faire un don, il vous suffit de cliquer sur le bouton situé en dessous.

                Je suis un membre apprécié et joueur, j'ai déjà obtenu 17 points de réputation.

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

                  le soucis c’est que ya pas de TileEntity pour une enclume 😕

                  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 n’utilise pas le tile entity mais l’id.

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

                      oui mais il switch sur le tileentity non?

                      1 réponse Dernière réponse Répondre Citer 0
                      • Superloup10S Hors-ligne
                        Superloup10 Modérateurs
                        dernière édition par

                        Si tu regardes bien, ContainerPedia et GuiPedia ne prennent pas en compte le tileEntity.

                        Si vous souhaitez me faire un don, il vous suffit de cliquer sur le bouton situé en dessous.

                        Je suis un membre apprécié et joueur, j'ai déjà obtenu 17 points de réputation.

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

                          autant pour moi, merci, je vais regarder avec ça 😄

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

                            Bonsoir, je voudrais savoir si l’on pouvait ouvrir un GUI avec un clic droit sur un item et avoir des boutons sur le menu menu. Merci 🙂

                            Mes mods :

                            >! GGButtonMod : http://minecraftforgefrance.fr/showthread.php?tid=1280
                            CraftYourMenu : http://minecraftforgefrance.fr/showth…

                            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

                              Le menu menu ? Je connais que le menu menu menu moi 😛
                              Oui c’est possible, je l’ai fait sur le sabre de nanotech mod. Après si plus ou moins compliqué selon ce que tu veux faire. Un simple gui avec des boutons, il faut juste des paquets pour envoyer les informations aux serveurs après, et tu sauvegarde tout dans le nbt tag de l’item stack. Par contre un gui et un container avec des slots sur un item (en gros un sac), j’ai pas encore tenté, ça m’a l’air plus complet.
                              Il faudrait un tutoriel à part pour traiter ça, je vais voir pour en faire un lorsque je vais reprendre les tutoriels (j’ai d’autres priorités pour l’instant).

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

                                Merci de ta reponse robin 🙂 Donc aloes en faite je résume :
                                Quand on fait un clique droit sur un item, un gui s’ouvre au joueur qui a cliqué avec l’item, dans ce gui, il y aura différents boutons simples, lors d’un clique sur l’un d’eux, un son sera joué à la position du joueur, et le gui ser fermera. Merci d’avance 🙂

                                Mes mods :

                                >! GGButtonMod : http://minecraftforgefrance.fr/showthread.php?tid=1280
                                CraftYourMenu : http://minecraftforgefrance.fr/showth…

                                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

                                  Suffit juste d’ouvrir le gui lorsque le joueur fait un clic droit :

                                  
                                  @Override
                                  public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
                                  {
                                  player.openGui(ClassePrincipale.instance, id, world, (int)player.posX, (int)player.posY, (int)player.posZ);
                                  return stack;
                                  }
                                  

                                  Ensuite dans le gui handler, il faut faire une condition avec l’id.
                                  Côté serveur, tu n’as rien à faire. Côté client, ouvre le gui.
                                  Ensuite pour les boutons, si tu veux que seul le joueur entende le son, il faut le jouer directement comme les sons du clic des boutons. Sinon faut envoyer un paquet au serveur, et le serveur va renvoyer à tout les clients via la fonction playSound du serveur.

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

                                    Petit probleme :
                                    TileEntityTutorial2
                                    TileEntityTutorial

                                    A quoi corresponde ces deux tileentity?

                                    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

                                      Heu tu parle de quoi ? Il n’y a pas un seul TileEntityTutorial ni de TileEntityTutorial2 dans ce tutoriel.

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

                                        Bon j’ai un probleme 😛 j’ai suivis a la lettre le tuto mais en jeu quand je clique droit rien ne se passe alors que j’ai aucune erreur dans mes fichiers

                                        Classe Gui :

                                        
                                        package craftz;
                                        
                                        import net.minecraft.client.gui.inventory.GuiContainer;
                                        import net.minecraft.client.resources.I18n;
                                        import net.minecraft.entity.player.InventoryPlayer;
                                        import net.minecraft.inventory.IInventory;
                                        import net.minecraft.util.ResourceLocation;
                                        
                                        import org.lwjgl.opengl.GL11;
                                        
                                        public class GuiBigChest extends GuiContainer
                                        {
                                        public static ResourceLocation texture = new ResourceLocation("craftz", "textures/gui/container/bigChest.png");
                                        private TileEntityBigChest bigChest;
                                        private IInventory playerInventory;
                                        public GuiBigChest(InventoryPlayer inventory, TileEntityBigChest tileEntity)
                                        {
                                        super(new ContainerBigChest(inventory, tileEntity));
                                        this.bigChest = tileEntity;
                                        this.playerInventory = inventory;
                                        this.ySize = 230;
                                        }
                                        
                                        protected void drawGuiContainerForegroundLayer(int par1, int par2)
                                        {
                                        this.fontRenderer.drawString(this.playerInventory.isInvNameLocalized() ? this.playerInventory.getInvName() : I18n.getString(this.playerInventory.getInvName()), 8, 129, 0);
                                        this.fontRenderer.drawString(this.bigChest.isInvNameLocalized() ? this.bigChest.getInvName() : I18n.getString(this.bigChest.getInvName()), 8, 7, 0);
                                        }
                                        
                                        @Override
                                        protected void drawGuiContainerBackgroundLayer(float f, int i, int j)
                                        {
                                        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                                        this.mc.getTextureManager().bindTexture(texture);
                                        int x = (this.width - this.xSize) / 2;
                                        int y = (this.height - this.ySize) / 2;
                                        this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize);
                                        }
                                        }
                                        
                                        

                                        block coffre:

                                        
                                        package craftz;
                                        
                                        import java.util.List;
                                        
                                        import net.minecraft.block.BlockContainer;
                                        import net.minecraft.block.material.Material;
                                        import net.minecraft.client.renderer.texture.IconRegister;
                                        import net.minecraft.creativetab.CreativeTabs;
                                        import net.minecraft.entity.EntityLivingBase;
                                        import net.minecraft.entity.item.EntityItem;
                                        import net.minecraft.entity.player.EntityPlayer;
                                        import net.minecraft.item.ItemStack;
                                        import net.minecraft.nbt.NBTTagCompound;
                                        import net.minecraft.tileentity.TileEntity;
                                        import net.minecraft.tileentity.TileEntityChest;
                                        import net.minecraft.util.Icon;
                                        import net.minecraft.util.MathHelper;
                                        import net.minecraft.world.IBlockAccess;
                                        import net.minecraft.world.World;
                                        import cpw.mods.fml.common.network.FMLNetworkHandler;
                                        import cpw.mods.fml.relauncher.Side;
                                        import cpw.mods.fml.relauncher.SideOnly;
                                        
                                        public class BlockCoffre extends BlockContainer
                                        {
                                        
                                        protected BlockCoffre(int par1, Material par2Material) {
                                        super(par1, par2Material);
                                        }
                                        public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
                                        {
                                        if(world.getBlockMetadata(x, y, z) == 3)
                                        {
                                        FMLNetworkHandler.openGui(player, ModCatnos.instance, 0, world, x, y, z);
                                        return true;
                                        }
                                        return false;
                                        }
                                        public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack)
                                        {
                                        TileEntity te = world.getBlockTileEntity(x, y, z);
                                        if(te != null && stack.getItemDamage() == 3 && te instanceof TileEntityBigChest && stack.hasDisplayName())
                                        {
                                        ((TileEntityBigChest)te).setCustomGuiName(stack.getDisplayName());
                                        }
                                        }
                                        public void breakBlock(World world, int x, int y, int z, int side, int metadata)
                                        {
                                        if(metadata == 3)
                                        {
                                        dropContainerItem(world, x, y, z);
                                        }
                                        super.breakBlock(world, x, y, z, side, metadata);
                                        }
                                        @Override
                                        public TileEntity createNewTileEntity(World world) {
                                        // TODO Auto-generated method stub
                                        return null;
                                        }
                                        protected void dropContainerItem(World world, int x, int y, int z)
                                        {
                                        TileEntityBigChest bigchest = (TileEntityBigChest)world.getBlockTileEntity(x, y, z);
                                        
                                        if (bigchest != null)
                                        {
                                        for (int slotId = 0; slotId < bigchest.getSizeInventory(); slotId++)
                                        {
                                        ItemStack stack = bigchest.getStackInSlot(slotId);
                                        
                                        if (stack != 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; stack.stackSize > 0; world.spawnEntityInWorld(entityitem))
                                        {
                                        int k1 = world.rand.nextInt(21) + 10;
                                        
                                        if (k1 > stack.stackSize)
                                        {
                                        k1 = stack.stackSize;
                                        }
                                        
                                        stack.stackSize -= k1;
                                        entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(stack.itemID, k1, stack.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 (stack.hasTagCompound())
                                        {
                                        entityitem.getEntityItem().setTagCompound((NBTTagCompound)stack.getTagCompound().copy());
                                        }
                                        }
                                        }
                                        }
                                        }
                                        }
                                        }
                                        
                                        

                                        COntainer:

                                        
                                        package craftz;
                                        
                                        import net.minecraft.entity.player.EntityPlayer;
                                        import net.minecraft.entity.player.InventoryPlayer;
                                        import net.minecraft.inventory.Container;
                                        import net.minecraft.inventory.Slot;
                                        import net.minecraft.item.ItemStack;
                                        
                                        public class ContainerBigChest extends Container
                                        {
                                        private TileEntityBigChest tileEntity;
                                        
                                        public ContainerBigChest(InventoryPlayer playerInventory, TileEntityBigChest teChest)
                                        {
                                        this.tileEntity = teChest;
                                        
                                        for(int i = 0; i < 6; i++)
                                        {
                                        for(int j = 0; j < 9; j++)
                                        {
                                        this.addSlotToContainer(new Slot(teChest, j + i * 9, 8 + j * 18, 18 + i * 18));
                                        }
                                        }
                                        this.bindPlayerInventory(playerInventory);
                                        }
                                        
                                        private void bindPlayerInventory(InventoryPlayer playerInventory)
                                        {
                                        int i;
                                        for(i = 0; i < 3; i++)
                                        {
                                        for(int j = 0; j < 9; j++)
                                        {
                                        this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 103 + i * 18 + 37));
                                        }
                                        }
                                        
                                        for(i = 0; i < 9; i++)
                                        {
                                        this.addSlotToContainer(new Slot(playerInventory, i, 8 + i * 18, 161 + 37));
                                        }
                                        }
                                        
                                        @Override
                                        public boolean canInteractWith(EntityPlayer player)
                                        {
                                        return tileEntity.isUseableByPlayer(player);
                                        }
                                        
                                        public ItemStack transferStackInSlot(EntityPlayer player, int slotId)
                                        {
                                        ItemStack itemstack = null;
                                        Slot slot = (Slot)this.inventorySlots.get(slotId);
                                        
                                        if(slot != null && slot.getHasStack())
                                        {
                                        ItemStack itemstack1 = slot.getStack();
                                        itemstack = itemstack1.copy();
                                        
                                        if(slotId < 9)
                                        {
                                        if(!this.mergeItemStack(itemstack1, 9, this.inventorySlots.size(), true))
                                        {
                                        return null;
                                        }
                                        }
                                        else if(!this.mergeItemStack(itemstack1, 0, 9, false))
                                        {
                                        return null;
                                        }
                                        
                                        if(itemstack1.stackSize == 0)
                                        {
                                        slot.putStack((ItemStack)null);
                                        }
                                        else
                                        {
                                        slot.onSlotChanged();
                                        }
                                        }
                                        return itemstack;
                                        }
                                        }
                                        
                                        

                                        GUi handler

                                        
                                        package craftz;
                                        
                                        import cpw.mods.fml.common.network.IGuiHandler;
                                        import net.minecraft.entity.player.EntityPlayer;
                                        import net.minecraft.tileentity.TileEntity;
                                        import net.minecraft.world.World;
                                        
                                        public class GuiHandlerTutorial implements IGuiHandler
                                        
                                        {
                                        
                                        @Override
                                        public Object getServerGuiElement(int ID, EntityPlayer player, World world,
                                        int x, int y, int z) {
                                        TileEntity te = world.getBlockTileEntity(x, y, z);
                                        if(te instanceof TileEntityBigChest)
                                        {
                                        return new ContainerBigChest(player.inventory, (TileEntityBigChest)te);
                                        }
                                        return null;
                                        }
                                        
                                        @Override
                                        public Object getClientGuiElement(int ID, EntityPlayer player, World world,
                                        int x, int y, int z) {
                                        
                                        TileEntity te = world.getBlockTileEntity(x, y, z);
                                        if(te instanceof TileEntityBigChest)
                                        {
                                        return new GuiBigChest(player.inventory, (TileEntityBigChest)te);
                                        }
                                        return null;
                                        }
                                        }
                                        
                                        

                                        et Tile ENtity

                                        
                                        package craftz;
                                        
                                        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.minecraft.entity.player.EntityPlayer;
                                        import net.minecraft.inventory.IInventory;
                                        import net.minecraft.item.ItemStack;
                                        import net.minecraft.nbt.NBTTagCompound;
                                        import net.minecraft.nbt.NBTTagList;
                                        import net.minecraft.tileentity.TileEntity;
                                        
                                        public class TileEntityBigChest extends TileEntity implements IInventory
                                        {
                                        private ItemStack[] inventory = new ItemStack[72];
                                        private String customName;
                                        
                                        public void readFromNBT(NBTTagCompound nbttag)
                                        {
                                        super.readFromNBT(nbttag);
                                        NBTTagList nbttaglist = nbttag.getTagList("Items");
                                        this.inventory = new ItemStack[this.getSizeInventory()];
                                        
                                        if (nbttag.hasKey("CustomName"))
                                        {
                                        this.customName = nbttag.getString("CustomName");
                                        }
                                        
                                        for (int i = 0; i < nbttaglist.tagCount(); i++)
                                        {
                                        NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i);
                                        int j = nbttagcompound1.getByte("Slot");
                                        
                                        if (j >= 0 && j < this.inventory.length)
                                        {
                                        this.inventory[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
                                        }
                                        }
                                        }
                                        
                                        public void writeToNBT(NBTTagCompound nbttag)
                                        {
                                        super.writeToNBT(nbttag);
                                        NBTTagList nbttaglist = new NBTTagList();
                                        
                                        for (int i = 0; i < this.inventory.length; i++)
                                        {
                                        if (this.inventory* != null)
                                        {
                                        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                                        nbttagcompound1.setByte("Slot", (byte)i);
                                        this.inventory*.writeToNBT(nbttagcompound1);
                                        nbttaglist.appendTag(nbttagcompound1);
                                        }
                                        }
                                        
                                        nbttag.setTag("Items", nbttaglist);
                                        
                                        if (this.isInvNameLocalized())
                                        {
                                        nbttag.setString("CustomName", this.customName);
                                        }
                                        }
                                        @Override
                                        public int getSizeInventory()
                                        {
                                        return inventory.length;
                                        }
                                        @Override
                                        public ItemStack getStackInSlot(int slotId)
                                        {
                                        return inventory[slotId];
                                        }
                                        @Override
                                        public ItemStack decrStackSize(int slotId, int quantity)
                                        {
                                        if (this.inventory[slotId] != null)
                                        {
                                        ItemStack itemstack;
                                        
                                        if (this.inventory[slotId].stackSize <= quantity)
                                        {
                                        itemstack = this.inventory[slotId];
                                        this.inventory[slotId] = null;
                                        this.onInventoryChanged();
                                        return itemstack;
                                        }
                                        else
                                        {
                                        itemstack = this.inventory[slotId].splitStack(quantity);
                                        
                                        if (this.inventory[slotId].stackSize == 0)
                                        {
                                        this.inventory[slotId] = null;
                                        }
                                        
                                        this.onInventoryChanged();
                                        return itemstack;
                                        }
                                        }
                                        else
                                        {
                                        return null;
                                        }
                                        }
                                        
                                        @Override
                                        public ItemStack getStackInSlotOnClosing(int slotId)
                                        {
                                        if (this.inventory[slotId] != null)
                                        {
                                        ItemStack itemstack = this.inventory[slotId];
                                        this.inventory[slotId] = null;
                                        return itemstack;
                                        }
                                        else
                                        {
                                        return null;
                                        }
                                        }
                                        
                                        @Override
                                        public void setInventorySlotContents(int slotId, ItemStack stack)
                                        {
                                        this.inventory[slotId] = stack;
                                        
                                        if (stack != null && stack.stackSize > this.getInventoryStackLimit())
                                        {
                                        stack.stackSize = this.getInventoryStackLimit();
                                        }
                                        
                                        this.onInventoryChanged();
                                        }
                                        @Override
                                        public String getInvName()
                                        {
                                        return this.isInvNameLocalized() ? this.customName : "container.bigchest";
                                        }
                                        
                                        @Override
                                        public boolean isInvNameLocalized()
                                        {
                                        return this.customName != null && this.customName.length() > 0;
                                        }
                                        
                                        public void setCustomGuiName(String name)
                                        {
                                        this.customName = name;
                                        }
                                        @Override
                                        public int getInventoryStackLimit()
                                        {
                                        return 64;
                                        }
                                        @Override
                                        public boolean isUseableByPlayer(EntityPlayer player)
                                        {
                                        return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;
                                        }
                                        @Override
                                        public void openChest()
                                        {
                                        
                                        }
                                        
                                        @Override
                                        public void closeChest()
                                        {
                                        
                                        }
                                        @Override
                                        public boolean isItemValidForSlot(int slotId, ItemStack stack)
                                        {
                                        return true;
                                        }
                                        
                                        }
                                        
                                        

                                        Merci superloup

                                        1 réponse Dernière réponse Répondre Citer 0
                                        • Superloup10S Hors-ligne
                                          Superloup10 Modérateurs
                                          dernière édition par

                                          Il y a des balises exprès pour le code java [java][/java] sans les *.

                                          Si vous souhaitez me faire un don, il vous suffit de cliquer sur le bouton situé en dessous.

                                          Je suis un membre apprécié et joueur, j'ai déjà obtenu 17 points de réputation.

                                          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 vois deux problèmes dans le bloc.
                                            1. Ta fonction createTileEntity retourne null, cela devrait être :

                                            @Override
                                            public TileEntity createNewTileEntity(World world) {
                                            return new TileEntityBigChest();
                                            }
                                            

                                            Autre problème, j’ai dit que dans le cas du tutoriel je créé le container sur le metadata 3, dans ton cas tu n’as pas de métadata donc :

                                            public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
                                            {
                                            if(world.getBlockMetadata(x, y, z) == 3)
                                            {
                                            FMLNetworkHandler.openGui(player, ModCatnos.instance, 0, world, x, y, z);
                                            return true;
                                            }
                                            return false;
                                            }
                                            public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack)
                                            {
                                            TileEntity te = world.getBlockTileEntity(x, y, z);
                                            if(te != null && stack.getItemDamage() == 3 && te instanceof TileEntityBigChest && stack.hasDisplayName())
                                            {
                                            ((TileEntityBigChest)te).setCustomGuiName(stack.getDisplayName());
                                            }
                                            }
                                            public void breakBlock(World world, int x, int y, int z, int side, int metadata)
                                            {
                                            if(metadata == 3)
                                            {
                                            dropContainerItem(world, x, y, z);
                                            }
                                            super.breakBlock(world, x, y, z, side, metadata);
                                            }
                                            

                                            Devrait être :

                                            public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
                                            {
                                            FMLNetworkHandler.openGui(player, ModCatnos.instance, 0, world, x, y, z);
                                            return true;
                                            }
                                            public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack)
                                            {
                                            TileEntity te = world.getBlockTileEntity(x, y, z);
                                            if(te instanceof TileEntityBigChest && stack.hasDisplayName())
                                            {
                                            ((TileEntityBigChest)te).setCustomGuiName(stack.getDisplayName());
                                            }
                                            }
                                            public void breakBlock(World world, int x, int y, int z, int side, int metadata)
                                            {
                                            dropContainerItem(world, x, y, z);
                                            super.breakBlock(world, x, y, z, side, metadata);
                                            }
                                            
                                            1 réponse Dernière réponse Répondre Citer 0
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 6
                                            • 7
                                            • 2 / 7
                                            • Premier message
                                              Dernier message
                                            Design by Woryk
                                            ContactMentions Légales

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB