<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Inventaire personnalisé]]></title><description><![CDATA[<p dir="auto">J’ai plusieurs problèmes avec mon inventaire personnalisé:</p>
<p dir="auto">1. Quand on clique sur un items pour le déplacer, il est directement remis à sa place donc impossible de déplacer les items et si on fais clique molette et qu’on met un objet dans un autre slot et puis qu’on clique dessus, il disparait<br />
2. Quand j’arrive à mettre un item dans un de mes slots perso, quand je ferme l’inventaire il est droppé</p>
<p dir="auto">Je crois qu’il faut utiliser les nbttag et/ou les paquets mais je ne sais pas comment m’y prendre.</p>
<p dir="auto">GUI handler:</p>
<pre><code class="java">public class GuiHandlerMod implements IGuiHandler
{

    @Override
    public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
    {
        if(ID == 1)
        {
            return new ContainerInventory(player);
        }
        return null;
    }

    @Override
    public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
    {
        if(ID == 1)
        {
            return new GuiInventory(player);
        }
        return null;
    }
}
</code></pre>
<p dir="auto">Container Inventory:</p>
<pre><code class="java">public class ContainerInventory extends Container implements IInventory
{
    public ItemStack[] content = new ItemStack[6];
    private final EntityPlayer player;

    public ContainerInventory(EntityPlayer p)
    {
        player = p;
        this.addSlotToContainer(new Slot(this, 0, 180, 93));
        this.addSlotToContainer(new Slot(this, 1, 198, 93));

        this.addSlotToContainer(new Slot(this, 2, 180, 124));
        this.addSlotToContainer(new Slot(this, 3, 198, 124));
        this.addSlotToContainer(new Slot(this, 4, 180, 142));
        this.addSlotToContainer(new Slot(this, 5, 198, 142));

        this.bindPlayerInventory(player.inventory);
    }

    private void bindPlayerInventory(InventoryPlayer inventory)
   {
       int i;
       for(i = 0; i &lt; 3; ++i)
       {
           for(int j = 0; j &lt; 9; ++j)
           {
               this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
           }
       }

       for(i = 0; i &lt; 9; ++i)
       {
           this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 142));
       }
   }

    @Override
    public boolean canInteractWith(EntityPlayer player)
    {
        return true;
    }

    @Override
    public int getSizeInventory()
    {
        return 42;
    }

    @Override
    public ItemStack getStackInSlot(int index)
    {
        return this.content[index];
    }

    @Override
    public ItemStack decrStackSize(int index, int amount)
    {
        ItemStack stack = getStackInSlot(index);
        if (stack != null) {
            if (stack.stackSize &gt; amount) {
                stack = stack.splitStack(amount);
                if (stack.stackSize == 0) this.content[index] = null;
            } else {
                this.content[index] = null;
            }
        }
        return stack;
    }

    @Override
    public ItemStack getStackInSlotOnClosing(int index)
    {
        ItemStack stack = getStackInSlot(index);
        if (stack != null) this.content[index] = null;
        return stack;
    }

    @Override
    public void setInventorySlotContents(int index, ItemStack stack)
    {
        this.content[index] = stack;
    }

    @Override
    public String getInventoryName()
    {
        return "container.inventory";
    }

    @Override
    public boolean hasCustomInventoryName()
    {
        return false;
    }

    @Override
    public int getInventoryStackLimit()
    {
        return 64;
    }

    @Override
    public void markDirty()
    {}

    @Override
    public boolean isUseableByPlayer(EntityPlayer p_70300_1_)
    {
        return true;
    }

    @Override
    public void openInventory()
    {}

    @Override
    public void closeInventory()
    {}

    @Override
    public boolean isItemValidForSlot(int slot, ItemStack stack)
    {
        return true;
    }

    public ItemStack transferStackInSlot(EntityPlayer player, int id)
    {
        ItemStack itemstack = null;
        Slot slot = (Slot)this.inventorySlots.get(id);

        if (slot != null &amp;&amp; slot.getHasStack())
        {
            ItemStack itemstack1 = slot.getStack();
            itemstack = itemstack1.copy();

            if (id == 0)
            {
                if (!this.mergeItemStack(itemstack1, 9, 45, true))
                {
                    return null;
                }

                slot.onSlotChange(itemstack1, itemstack);
            }
            else if (id &gt;= 1 &amp;&amp; id &lt; 5)
            {
                if (!this.mergeItemStack(itemstack1, 9, 45, false))
                {
                    return null;
                }
            }
            else if (id &gt;= 5 &amp;&amp; id &lt; 9)
            {
                if (!this.mergeItemStack(itemstack1, 9, 45, false))
                {
                    return null;
                }
            }
            else if (itemstack.getItem() instanceof ItemArmor &amp;&amp; !((Slot)this.inventorySlots.get(5 + ((ItemArmor)itemstack.getItem()).armorType)).getHasStack())
            {
                int j = 5 + ((ItemArmor)itemstack.getItem()).armorType;

                if (!this.mergeItemStack(itemstack1, j, j + 1, false))
                {
                    return null;
                }
            }
            else if (id &gt;= 9 &amp;&amp; id &lt; 36)
            {
                if (!this.mergeItemStack(itemstack1, 36, 45, false))
                {
                    return null;
                }
            }
            else if (id &gt;= 36 &amp;&amp; id &lt; 45)
            {
                if (!this.mergeItemStack(itemstack1, 9, 36, false))
                {
                    return null;
                }
            }
            else if (!this.mergeItemStack(itemstack1, 9, 45, false))
            {
                return null;
            }

            if (itemstack1.stackSize == 0)
            {
                slot.putStack((ItemStack)null);
            }
            else
            {
                slot.onSlotChanged();
            }

            if (itemstack1.stackSize == itemstack.stackSize)
            {
                return null;
            }

            slot.onPickupFromSlot(player, itemstack1);
        }

        return itemstack;
    }
}
</code></pre>
<p dir="auto">GuiInventory:</p>
<pre><code class="java">public class GuiInventory extends GuiContainer
{
   private static final ResourceLocation textures = new ResourceLocation(Reference.MOD_ID, "textures/gui/container/brawlcraft_inventory.png");
   private IInventory playerInv;

   public GuiInventory(EntityPlayer player)
   {
       super(new ContainerInventory(player));
       this.playerInv = player.inventory;
       this.allowUserInput = false;
       this.xSize = 228;
       this.ySize = 166;
   }

   @Override
   protected void drawGuiContainerBackgroundLayer(float partialRenderTick, int x, int y)
   {
      GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
      this.mc.getTextureManager().bindTexture(textures);
      int k = (this.width - this.xSize) / 2;
      int l = (this.height - this.ySize) / 2;
      this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
   }

   protected void drawGuiContainerForegroundLayer(int x, int y)
   {
      String tileName = "container.inventory";
      this.fontRendererObj.drawString(tileName, (this.xSize - this.fontRendererObj.getStringWidth(tileName)) / 2, 6, 0x00ff00);
      String tileName2 = "weapons";
      this.fontRendererObj.drawString(tileName, (this.xSize - this.fontRendererObj.getStringWidth(tileName)) / 2, 6, 0x00ff00);
      String tileName3 = "gadgets";
      this.fontRendererObj.drawString(tileName, (this.xSize - this.fontRendererObj.getStringWidth(tileName)) / 2, 6, 0x00ff00);
   }
}
</code></pre>
<p dir="auto">Merci d’avance <img src="https://www.minecraftforgefrance.fr/images/Minecraft_Forge_France/smilies/v3/smile.png" alt="" class=" img-fluid img-markdown" /></p>
]]></description><link>https://www.minecraftforgefrance.fr/topic/3721/inventaire-personnalisé</link><generator>RSS for Node</generator><lastBuildDate>Tue, 11 Aug 2026 20:40:59 GMT</lastBuildDate><atom:link href="https://www.minecraftforgefrance.fr/topic/3721.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 02 Oct 2016 10:53:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Inventaire personnalisé on Sun, 02 Oct 2016 18:35:57 GMT]]></title><description><![CDATA[<p dir="auto">Bien c’est l’inventaire de base mais avec 6 slots en plus, 2 réservés à des trucs extends weapons et 4 extends gadgets</p>
<p dir="auto">Minantcraft <img src="https://www.minecraftforgefrance.fr/assets/plugins/nodebb-plugin-emoji/emoji/android/1f609.png?v=3a52b347b9a" class="not-responsive emoji emoji-android emoji--wink" style="height:23px;width:auto;vertical-align:middle" title=";)" alt="😉" /></p>
]]></description><link>https://www.minecraftforgefrance.fr/post/48191</link><guid isPermaLink="true">https://www.minecraftforgefrance.fr/post/48191</guid><dc:creator><![CDATA[Minantcraft]]></dc:creator><pubDate>Sun, 02 Oct 2016 18:35:57 GMT</pubDate></item><item><title><![CDATA[Reply to Inventaire personnalisé on Sun, 02 Oct 2016 18:32:35 GMT]]></title><description><![CDATA[<p dir="auto">Essaie de détailler ce que tu veux faire pour chaque slot pour ensuite le traduire en code</p>
]]></description><link>https://www.minecraftforgefrance.fr/post/48190</link><guid isPermaLink="true">https://www.minecraftforgefrance.fr/post/48190</guid><dc:creator><![CDATA[SCAREX]]></dc:creator><pubDate>Sun, 02 Oct 2016 18:32:35 GMT</pubDate></item><item><title><![CDATA[Reply to Inventaire personnalisé on Sun, 02 Oct 2016 18:31:38 GMT]]></title><description><![CDATA[<p dir="auto">Oui je l’ai rajouter mais ça faisait la même chose avant</p>
<p dir="auto">Envoyé de mon SM-G360F en utilisant Tapatalk</p>
]]></description><link>https://www.minecraftforgefrance.fr/post/48189</link><guid isPermaLink="true">https://www.minecraftforgefrance.fr/post/48189</guid><dc:creator><![CDATA[Minantcraft]]></dc:creator><pubDate>Sun, 02 Oct 2016 18:31:38 GMT</pubDate></item><item><title><![CDATA[Reply to Inventaire personnalisé on Sun, 02 Oct 2016 17:40:41 GMT]]></title><description><![CDATA[<p dir="auto">Le problème vient de ta fonction transferStackInslot, ce que tu fais de tes items n’est pas très claire</p>
]]></description><link>https://www.minecraftforgefrance.fr/post/48186</link><guid isPermaLink="true">https://www.minecraftforgefrance.fr/post/48186</guid><dc:creator><![CDATA[SCAREX]]></dc:creator><pubDate>Sun, 02 Oct 2016 17:40:41 GMT</pubDate></item></channel></rss>