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

      c’est bon j’ai réussi 
      dans la classe principale on a :

      ​%(#555555)[[font=Arial, tahoma, sans-serif]proxy.registerGuiHandler(this.instance, new GuiHandler());]
      

      et dans le CommonProxy :

      ​    public void registerGuiHandler(Robotic instance, GuiHandler guiHandler)
      
          {
              // TODO Auto-generated method stub
              NetworkRegistry.INSTANCE.registerGuiHandler(Robotic.modid, new GuiHandler());
          }
      

      En tout cas merci de votre aide a tous

      Tout probleme a sa solution, s'il n'y a pas de solution c'est qu'il n'y a pas de problemes

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

        Tu peux directement mettre le “NetworkRegistry.INSTANCE.registerGuiHandler(Robotic.modid, new GuiHandler());” dans ta fonction init.

        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
        • Bowser338B Hors-ligne
          Bowser338
          dernière édition par

          Ok bon a savoir merci en tout cas

          Tout probleme a sa solution, s'il n'y a pas de solution c'est qu'il n'y a pas de problemes

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

            Plop!

            Hum, je sais pas si le tuto est entièrement compatible 1.7.10 mais moi de mon côté j’ai quelques erreurs:

            Méthode readFromNBT(NBTTagCompound) du TileEntity:
            “The method getTagList(String, int) in the type NBTTagCompound is not applicable for the arguments (String)”
            “The method tagAt(int) is undefined for the type NBTTagList”

            Méthodes decrStackSize(int, int) et setInventorySlotContents(int, ItemStack) du TileEntity:
            “The method onInventoryChanged() is undefined for the type TileEntityBigChest”

            Méthode drawGuiContainerForegroundLayer(int, int) du GUI:
            “fontRenderer cannot be resolved or is not a field”
            “The method isInvNameLocalized() is undefined for the type IInventory”
            “The method getString(String) is undefined for the type I18n”

            Vàla, en espérant qu’il y ait une solution 😕

            Mes mods :

            • Cookie Ore (1.7.10)

            Mod en cours : **E…

            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

              Non, il n’est pas fait pour la 1.7.
              Regarde ici :
              https://github.com/FFMT/Privatizer/tree/master/privatizer_src/fr/mcnanotech/privatizer/common
              TileEntityPrivateChest et ContainerPrivateChest devrait t’aider.

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

                Merci pour cette réponse rapide ^^
                Je vais y jeter un coup d’oeil.
                Est-ce que le tuto sera mis à jour pour la 1.7 ou bien il passera directement en 1.8?  😄

                EDIT: Au fait, “massive” work 😛

                Mes mods :

                • Cookie Ore (1.7.10)

                Mod en cours : **E…

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

                  Je ne sais pas, ça dépendra de mon temps.

                  Ah oui en effet, mais maintenant c’est trop tard pour changer le nom du commit ^^

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

                    Salut, comment rajouter un bouton sur le gui ? Et faire que quand on clique dessus ca fait quelque chose ?

                    Developpeur d'Hogsmod, un mod implémentant le Monde d'Harry Potter dans Minecraft!

                    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

                      C’est le même principe que pour ajouter des boutons dans un menu de Minecraft. Tu peux aussi regarder le gui de l’enclume (GuiRepair)
                      Attention si les actions que tu veux faire doit être fait côté serveur, il faut utiliser un paquet.

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

                        Je veux faire que si dans le slot 1 on a un objet precis alors ca le supprime et ca mets un autre item dans un autre slot

                        Developpeur d'Hogsmod, un mod implémentant le Monde d'Harry Potter dans Minecraft!

                        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 n’es pas obliger de passer par un bouton pour ça, tu peux passer par la fonction update() du tile entity. Mais si tu veux vraiment le faire depuis un bouton, il te faudra un paquet.

                          Dans mod privatizer depuis un bloc avec un gui et un container on peut modifier le mot de passe d’un bloc via une zone de texte et un bouton confirmer.
                          La déclaration du bouton : https://github.com/FFMT/Privatizer/blob/master/privatizer_src/fr/mcnanotech/privatizer/client/GuiPrivateEditor.java#L47-L49

                          Et l’action du bouton : https://github.com/FFMT/Privatizer/blob/master/privatizer_src/fr/mcnanotech/privatizer/client/GuiPrivateEditor.java#L105-L112

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

                            J’ai réussis a mettre le bouton et tout, mais je ne trouves pas comment faire que ça check les slots, et que ça te donne la potions et que ça supprime les ingrédients… Tu peux m’aider ?

                            Developpeur d'Hogsmod, un mod implémentant le Monde d'Harry Potter dans Minecraft!

                            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

                              Envoie ton code et explique précisément ce que tu cherche à faire.

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

                                Alors, j’ai créer un GUI pour mon block Chaudron, ce GUI va servir pour faire des potions, dans ce GUI j’ai 7 slots pour mettre des ingrédients, et 2 autres, 1 pour mettre une fiole vide, l’autre un sceau d’eau. J’ai aussi un bouton créer pour lancer le craft.

                                Je voudrais que quand il y a un certains items dans les 7 slots et qu’il y a une fiole et un sceau alors ca supprime tout ca et dans un autre slot ca te mettes une potion.

                                Mes codes:

                                package com.harrypotter.sosoh.common.gui;
                                
                                import org.lwjgl.opengl.GL11;
                                
                                import com.harrypotter.sosoh.common.ModHarryPotter;
                                import com.harrypotter.sosoh.common.blocks.TileEntityChaudron;
                                import com.harrypotter.sosoh.common.gui.container.ContainerChaudron;
                                
                                import cpw.mods.fml.common.FMLCommonHandler;
                                import net.minecraft.client.gui.GuiButton;
                                import net.minecraft.client.gui.inventory.GuiContainer;
                                import net.minecraft.client.resources.I18n;
                                import net.minecraft.entity.player.EntityPlayer;
                                import net.minecraft.entity.player.InventoryPlayer;
                                import net.minecraft.inventory.IInventory;
                                import net.minecraft.inventory.Slot;
                                import net.minecraft.server.MinecraftServer;
                                import net.minecraft.util.ResourceLocation;
                                import net.minecraft.world.World;
                                
                                public class GuiChaudron extends GuiContainer
                                {
                                
                                public static ResourceLocation texture = new ResourceLocation("modharrypotter", "textures/gui/container/GuiChaudron.png");
                                private TileEntityChaudron chaudron;
                                private IInventory playerInventory;
                                private ContainerChaudron containerChaudron;
                                private GuiButton confirmButton;
                                
                                public GuiChaudron(InventoryPlayer inventory, TileEntityChaudron tileEntity)
                                {
                                super(new ContainerChaudron(inventory, tileEntity));
                                this.chaudron = tileEntity;
                                this.playerInventory = inventory;
                                this.ySize = 230;
                                
                                }
                                
                                   protected void drawGuiContainerForegroundLayer(int par1, int par2)
                                   {
                                       this.fontRendererObj.drawString(this.playerInventory.hasCustomInventoryName() ? this.playerInventory.getInventoryName() : I18n.format(this.playerInventory.getInventoryName()), 8, 129, 0);
                                       this.fontRendererObj.drawString(this.chaudron.hasCustomInventoryName() ? this.chaudron.getInventoryName() : I18n.format(this.chaudron.getInventoryName()), 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);
                                }
                                
                                public void initGui()
                                   {
                                       super.initGui();
                                       int x = (this.width - this.xSize) / 2;
                                       int j = (this.height - this.ySize) / 2;
                                       this.confirmButton = new GuiButton(0, x + 120, j + 100, 45, 20, "Créer");
                                       this.buttonList.add(confirmButton);
                                   }
                                
                                protected void actionPerformed(GuiButton guiButton)
                                   {
                                       if(guiButton.id == 0)
                                       {
                                
                                       }
                                   }
                                
                                }
                                
                                package com.harrypotter.sosoh.common.gui.container;
                                
                                import com.harrypotter.sosoh.common.blocks.TileEntityChaudron;
                                
                                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 ContainerChaudron extends Container
                                {
                                private TileEntityChaudron tileEntity;
                                
                                public ContainerChaudron(InventoryPlayer playerInventory, TileEntityChaudron teChaudron)
                                {
                                this.tileEntity = teChaudron;
                                
                                this.addSlotToContainer(new Slot(teChaudron, 1, 26, 18));
                                this.addSlotToContainer(new Slot(teChaudron, 2, 62, 18));
                                this.addSlotToContainer(new Slot(teChaudron, 3, 98, 18));
                                this.addSlotToContainer(new Slot(teChaudron, 4, 134, 18));
                                
                                this.addSlotToContainer(new Slot(teChaudron, 5, 44, 36));
                                this.addSlotToContainer(new Slot(teChaudron, 6, 80, 36));
                                this.addSlotToContainer(new Slot(teChaudron, 7, 116, 36));
                                
                                //Sceau et Fiole
                                
                                this.addSlotToContainer(new Slot(teChaudron, 20, 8, 90));
                                this.addSlotToContainer(new Slot(teChaudron, 21, 26, 90));
                                
                                //Potions
                                
                                this.addSlotToContainer(new Slot(teChaudron, 22, 278, 90));
                                
                                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;
                                }
                                }
                                

                                Mon init dans ma classe principale:

                                @EventHandler
                                public void init(FMLInitializationEvent event)
                                {
                                proxy.registerRender();
                                
                                //Potions
                                
                                network = NetworkRegistry.INSTANCE.newSimpleChannel("HarryPotterMod");
                                NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
                                
                                SomnolenceEffect.loadEffects();
                                SomnolenceEffect.register();
                                
                                //Events
                                MinecraftForge.EVENT_BUS.register(new com.harrypotter.sosoh.common.EventHandlerHarryPotter());
                                }
                                
                                package com.harrypotter.sosoh.common.gui.handler;
                                
                                import net.minecraft.entity.player.EntityPlayer;
                                import net.minecraft.tileentity.TileEntity;
                                import net.minecraft.world.World;
                                
                                import com.harrypotter.sosoh.common.blocks.TileEntityChaudron;
                                import com.harrypotter.sosoh.common.gui.GuiChaudron;
                                import com.harrypotter.sosoh.common.gui.container.ContainerChaudron;
                                
                                import cpw.mods.fml.common.network.IGuiHandler;
                                
                                public class GuiHandler implements IGuiHandler {
                                
                                @Override
                                public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
                                
                                TileEntity te = world.getTileEntity(x, y, z);
                                
                                if(te instanceof TileEntityChaudron)
                                {
                                return new ContainerChaudron(player.inventory, (TileEntityChaudron)te);
                                }
                                return null;
                                }
                                
                                @Override
                                public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
                                
                                TileEntity te = world.getTileEntity(x, y, z);
                                if(te instanceof TileEntityChaudron)
                                {
                                return new GuiChaudron(player.inventory, (TileEntityChaudron)te);
                                }
                                return null;
                                }
                                
                                }
                                
                                package com.harrypotter.sosoh.common.blocks;
                                
                                import net.minecraft.entity.player.EntityPlayer;
                                import net.minecraft.inventory.IInventory;
                                import net.minecraft.item.ItemStack;
                                import net.minecraft.nbt.NBTTagCompound;
                                import net.minecraft.nbt.NBTTagList;
                                import net.minecraft.network.NetworkManager;
                                import net.minecraft.network.Packet;
                                import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
                                import net.minecraft.tileentity.TileEntity;
                                
                                public class TileEntityChaudron extends TileEntity implements IInventory{
                                
                                   private byte direction;
                                   private ItemStack[] inventory = new ItemStack[72];
                                private String customName;
                                
                                   @Override
                                   public void readFromNBT(NBTTagCompound nbttag)
                                   {
                                    super.readFromNBT(nbttag);
                                       this.direction = nbttag.getByte("Direction");
                                       NBTTagList nbttaglist = nbttag.getTagList("Items", blockMetadata);
                                       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.getCompoundTagAt(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);
                                       nbttag.setByte("Direction", this.direction);
                                
                                       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.hasCustomInventoryName())
                                       {
                                           nbttag.setString("CustomName", this.customName);
                                       }
                                   }
                                
                                   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 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.updateContainingBlockInfo();
                                               return itemstack;
                                           }
                                           else
                                           {
                                               itemstack = this.inventory[slotId].splitStack(quantity);
                                
                                               if (this.inventory[slotId].stackSize == 0)
                                               {
                                                   this.inventory[slotId] = null;
                                               }
                                
                                               this.updateContainingBlockInfo();
                                               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.updateContainingBlockInfo();
                                }
                                
                                @Override
                                public String getInventoryName()
                                {
                                return this.hasCustomInventoryName() ? this.customName : "container.chaudron";
                                }
                                
                                @Override
                                public boolean hasCustomInventoryName()
                                {
                                return this.customName != null && this.customName.length() > 0;
                                }
                                
                                public void setCustomGuiName(String name)
                                {
                                   this.customName = name;
                                   }
                                
                                @Override
                                public int getInventoryStackLimit() {
                                return 1;
                                }
                                
                                @Override
                                public boolean isUseableByPlayer(EntityPlayer player)
                                {
                                return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;
                                }
                                
                                @Override
                                public void openInventory() {
                                
                                }
                                
                                @Override
                                public void closeInventory() {
                                
                                }
                                
                                @Override
                                public boolean isItemValidForSlot(int slotId, ItemStack stack)
                                {
                                return true;
                                }
                                }
                                
                                package com.harrypotter.sosoh.common.blocks;
                                
                                import java.util.Random;
                                
                                import com.harrypotter.sosoh.common.ModHarryPotter;
                                import com.harrypotter.sosoh.proxy.ClientProxy;
                                
                                import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
                                import net.minecraft.block.Block;
                                import net.minecraft.block.material.Material;
                                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.Item;
                                import net.minecraft.item.ItemStack;
                                import net.minecraft.nbt.NBTTagCompound;
                                import net.minecraft.tileentity.TileEntity;
                                import net.minecraft.world.IBlockAccess;
                                import net.minecraft.world.World;
                                
                                public class BlockChaudron extends Block{
                                
                                public BlockChaudron(Material Material) {
                                super(Material);
                                this.setCreativeTab(ModHarryPotter.creativetabsHPP);
                                this.setHardness(3.5F);
                                }
                                
                                   @Override
                                   public TileEntity createTileEntity(World world, int metadata)
                                   {
                                       return new TileEntityChaudron();
                                   }
                                
                                   @Override
                                   public boolean hasTileEntity(int metadata)
                                   {
                                       return true;
                                   }
                                
                                   @Override
                                   public Item getItemDropped(int metadata, Random random, int fortune) {
                                       return Item.getItemFromBlock(ModHarryPotter.blockChaudron);
                                   }
                                
                                   public boolean isOpaqueCube()
                                   {
                                       return false;
                                   }
                                
                                   public boolean renderAsNormalBlock()
                                   {
                                       return false;
                                   }
                                
                                   public int getRenderType()
                                   {
                                    return ClientProxy.blockChaudronRenderId;
                                   }
                                
                                   public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)
                                   {
                                       this.setBlockBounds(0.1F, 0.0F, 0.1F, 0.9F, 0.8F, 0.9F);
                                   }
                                
                                   public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
                                {
                                FMLNetworkHandler.openGui(player, ModHarryPotter.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.getTileEntity(x, y, z);
                                if(te != null && stack.getItemDamage() == 3 && te instanceof TileEntityChaudron && stack.hasDisplayName())
                                {
                                ((TileEntityChaudron)te).setCustomGuiName(stack.getDisplayName());
                                }
                                }
                                
                                   public void breakBlock(World world, int x, int y, int z, Block side, int metadata)
                                   {
                                    dropContainerItem(world, x, y, z);
                                       super.breakBlock(world, x, y, z, side, metadata);
                                   }
                                
                                   protected void dropContainerItem(World world, int x, int y, int z)
                                   {
                                    TileEntityChaudron chaudron = (TileEntityChaudron)world.getTileEntity(x, y, z);
                                
                                       if (chaudron != null)
                                       {
                                           for (int slotId = 0; slotId < chaudron.getSizeInventory(); slotId++)
                                           {
                                               ItemStack stack = chaudron.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.getItem(), 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());
                                                       }
                                                   }
                                               }
                                           }
                                       }
                                   }
                                }
                                

                                Developpeur d'Hogsmod, un mod implémentant le Monde d'Harry Potter dans Minecraft!

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

                                  Dans ton paquet, depuis le joueur tu peux avoir l’instance du container (player.openContainer) et grâce au container tu peux avoir l’instance de l’entité de bloc. Ensuite avec l’entité de bloc c’est facile de supprimer / ajouter des items.

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

                                    Ok donc je fais que quand je cliques sur le bouton ca envoies un paquet et quand le serveur recoit se paquet alors ca check tout ca et si c’est bon ca donne l’objet et supprime les autres et sinon ca fait rien … C’est ca?

                                    Developpeur d'Hogsmod, un mod implémentant le Monde d'Harry Potter dans Minecraft!

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

                                      Ok donc je fais que quand je cliques sur le bouton ca envoies un paquet et quand le serveur recoit se paquet alors ca check tout ca et si c’est bon ca donne l’objet et supprime les autres et sinon ca fait rien … C’est ca?

                                      Developpeur d'Hogsmod, un mod implémentant le Monde d'Harry Potter dans Minecraft!

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

                                        Oui c’est ça.

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

                                          Est ce possible de faire une case la ou on peut rien mettre (le joueur) comme la sortie d’un item dans le four, et une endroit la ou peut mettre que un type d’objet comme le fuel mais la c’est pas du fuel (ici une fiole)?

                                          Developpeur d'Hogsmod, un mod implémentant le Monde d'Harry Potter dans Minecraft!

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

                                            Oui, regarde dans le tile entity du four, il y a la fonction isItemValidForSlot, c’est elle qui gère ça.

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

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB