Navigation

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    SOLVED Ajouter un slot à l'inventaire du joueur

    1.8.x
    1.8.9
    2
    7
    1376
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Ama
      Ama last edited by

      Bonjoir à tous !

      Je viens mendier votre aide pour ajouter un slot à l’inventaire du joueur, voilà un long moment que je parcours les internets, ainsi que le fofo pour trouver réponse à ma question.

      Je sais que je dois passer par un IExtendEntityProperties, seulement je suis en 1.8.9, donc logiquement les cabapilities ? Mais je trouve rien de concret à ce niveau là non plus.

      Je sais aussi que je dois refaire le container, slot et gui, c’est évident ^^

      Si quelqu’un à un tel système en 1.8.9 de fonctionnel et voudrait bien m’éclairer la lanterne je suis preneur ! (Et pourquoi pas en faire un tuto !)

      Merci de votre aide !

      1 Reply Last reply Reply Quote 0
      • Ama
        Ama last edited by

        Aucune, idée de comment je pourrais procéder ? :’(

        1 Reply Last reply Reply Quote 0
        • robin4002
          robin4002 Administrateurs Rédacteurs Moddeurs confirmés last edited by

          Salut,
          Pour les capacities : https://www.minecraftforgefrance.fr/showthread.php?tid=3028
          Avec l’event OpenContainerEvent il y a peut-être moyen d’ajouter les slots sans modifier le container.
          Par contre le gui il faudra bien le remplacer ou le redessiner avec GuiScreenEvent.DrawScreenEvent

          1 Reply Last reply Reply Quote 0
          • Ama
            Ama last edited by

            OpenContainerEvent N’existe pas en 1.8.9

            1 Reply Last reply Reply Quote 0
            • robin4002
              robin4002 Administrateurs Rédacteurs Moddeurs confirmés last edited by

              C’est PlayerOpenContainerEvent visiblement.

              1 Reply Last reply Reply Quote 0
              • Ama
                Ama last edited by

                J’ai essayé un code, sans doute pas du tout bon pour ajouter un slot, mais du coup, j’ai un OutOfBoundException à cause de la taille d’origine de l’inventaire

                @SubscribeEvent
                public void onOpenContainer(PlayerOpenContainerEvent event)
                {
                Container container = event.entityPlayer.inventoryContainer; 
                InventoryPlayer playerInventory = event.entityPlayer.inventory;
                InventoryCustomPlayer inventoryCustom = ExtendedPlayer.get(event.entityPlayer).inventory;
                Slot slotCustom = new SlotCustom(inventoryCustom, 0, 80,8);
                
                if(container instanceof ContainerPlayer && container != null)
                {
                ItemStack[] temp = new ItemStack[playerInventory.mainInventory.length + 10]; // censé augmenter la taille de l'inventaire de base
                
                  for (int i = 0; i < playerInventory.mainInventory.length; i++){
                     temp* = playerInventory.mainInventory*;
                  }
                  playerInventory.mainInventory = temp;
                
                container.inventorySlots.add(temp.length, slotCustom);
                }
                }
                
                1 Reply Last reply Reply Quote 0
                • robin4002
                  robin4002 Administrateurs Rédacteurs Moddeurs confirmés last edited by

                  Plutôt comme ça :

                  @SubscribeEvent
                  public void onOpenContainer(PlayerOpenContainerEvent event)
                  {
                  Container container = event.entityPlayer.openContainer;
                  InventoryPlayer playerInventory = event.entityPlayer.inventory;
                  InventoryCustomPlayer inventoryCustom = ExtendedPlayer.get(event.entityPlayer).inventory;
                  
                  if(container instanceof ContainerPlayer)
                  {
                  for(int i = playerInventory.getSizeInventory(); i < playerInventory.getSizeInventory() + inventoryCustom.getSizeInventory(); i++)
                  {
                  Slot s = new Slot(inventoryCustom, i, posX, posY); // à remplacer
                  s.slotNumber = container.inventorySlots.size();
                  container.inventorySlots.add(s);
                  container.inventoryItemStacks.add((ItemStack)null);
                  }
                  }
                  }
                  
                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  • First post
                    Last post
                  Design by Woryk
                  Contact / Mentions Légales / Faire un don

                  MINECRAFT FORGE FRANCE © 2018

                  Powered by NodeBB