• Récent
  • Mots-clés
  • Populaire
  • Utilisateurs
  • Groupes
  • S'inscrire
  • Se connecter
  • S'inscrire
  • Se connecter
  • Recherche
  • Récent
  • Mots-clés
  • Populaire
  • Utilisateurs
  • Groupes

Résolu Petit soucis inventaire.

1.8.x
1.8
4
8
1.3k
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.
  • Gabs
    Gabs dernière édition par 17 juin 2016, 12:20

    Bonjour,

    Je rencontre un petit soucis avec ma “hotbar” de mon inventaire.
    Je explique: Quand je ramasse un item par terre il se place dans ma hotbar et quand je veux placer cet item dans mon inventaire et au moment ou je clique sur l’item il se drop par terre .
    Je vous donne ma classe Countainer et ma classe Slot:

    Countainer:

    package net.armacraft.GUI;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.entity.player.InventoryPlayer;
    import net.minecraft.init.Items;
    import net.minecraft.inventory.Container;
    import net.minecraft.inventory.Slot;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    import net.minecraft.nbt.NBTTagCompound;
    public class ContainerArma extends Container
    {
        public InventaireArma inv;
        public ContainerArma(InventoryPlayer playerInv, InventaireArma inv)
        {
        this.inv = inv;
            this.addSlotToContainer(new SlotInvArmaArmor(playerInv, 36, 3, 81, 45));
            this.addSlotToContainer(new SlotInvArmaArmor(playerInv, 37, 2, 110, 45));
            this.addSlotToContainer(new SlotInvArmaArmor(playerInv, 38, 1, 137, 45));
            this.addSlotToContainer(new SlotInvArmaArmor(playerInv, 39, 0, 166, 45));
            this.addSlotToContainer(new SlotInvArmaGun(playerInv, 0, 215, 45));
            //Pistol
            this.addSlotToContainer(new SlotInvArmaGun(playerInv, 2, 215, 77));
            //Shlass
            this.addSlotToContainer(new SlotInvArmaGun(playerInv, 8, 215, 109));
            this.addSlotToContainer(new SlotInvArmaHotbar(playerInv, 3, 81, 200));// slot qui pose problème.
            this.addSlotToContainer(new SlotInvArmaHotbar(playerInv, 4, 109, 200));//slot qui pose problème.
            this.addSlotToContainer(new SlotInvArmaHotbar(playerInv, 5, 137, 200));//slot qui pose problème.
            this.addSlotToContainer(new SlotInvArmaHotbar(playerInv, 6, 165, 200));//slot qui pose problème.
            this.addSlotToContainer(new SlotInvArmaHotbar(playerInv, 7, 193, 200));//slot qui pose problème.
            int slot = 9;
            for(int i=1; i<7; i++) {
                int y = 55 + (i*18);
                for(int i1=1; i1<7; i1++) {
                    int x = 60 + (i1*18);
                    if(slot <= 35) {
                        this.addSlotToContainer(new Slot(playerInv, slot, x, y));
                        slot++;
                    }
                }
            }
        }
        @Override
        public boolean canInteractWith(EntityPlayer player)
        {
            return true;
        }
        @Override
        public ItemStack transferStackInSlot(EntityPlayer player, int index)
        {
            return null;
        }
        /**
         * Used to save content
         */
        @Override
        public void onContainerClosed(EntityPlayer player)
        {
            super.onContainerClosed(player);
        }
    }

    Slot:

    package net.armacraft.GUI;
    import net.minecraft.init.Items;
    import net.minecraft.inventory.IInventory;
    import net.minecraft.inventory.Slot;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    public class SlotInvArmaHotbar extends Slot {
        public SlotInvArmaHotbar(IInventory inv, int index, int x, int y) {
            super(inv, index, x, y);
        }
        /**
         * Method used to prevent backpack-ception (backpacks inside backpacks)
         */
        @Override
        public boolean isItemValid(ItemStack stack) {
        return true;
        }
    }

    Merci d’avance 🙂

    1 réponse Dernière réponse Répondre Citer 0
    • robin4002
      robin4002 Moddeurs confirmés Rédacteurs Administrateurs dernière édition par 17 juin 2016, 13:04

      Salut,
      Le problème vient surement du fait que ta fonction transferStackInSlot retourne null.

      1 réponse Dernière réponse Répondre Citer 0
      • AymericRed
        AymericRed dernière édition par 17 juin 2016, 13:13

        @‘robin4002’:

        Salut,
        Le problème vient surement du fait que ta fonction transferStackInSlot retourne null.

        Non car beaucoup de mes containers return null (fonction compliquée et pour l’instant la flemme de comprendre Mojang) et j’ai aucun problème.
        Regarde plutôt du côté des ids des slots, que ceux dans le for ne gênent pas les autres. EDIT : Après avoir regardé ça ne devrait pas.

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

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

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

        1 réponse Dernière réponse Répondre Citer 0
        • robin4002
          robin4002 Moddeurs confirmés Rédacteurs Administrateurs dernière édition par 17 juin 2016, 13:15

          Ah oui possible, transferStackInSlot ne sert que le pour le shift + clic

          1 réponse Dernière réponse Répondre Citer 0
          • Gabs
            Gabs dernière édition par 17 juin 2016, 13:41

            Bah c’est bizarre je met ça dans mon countainer:

            ```java
            public ContainerArma(InventoryPlayer playerInv, InventaireArma inv)
                {
                    this.inv = inv;

            this.addSlotToContainer(new SlotInvArmaArmor(inv, 0, 81, 13));
                    this.addSlotToContainer(new Slot(inv, 1, 109, 13));
                    this.addSlotToContainer(new Slot(inv, 2, 137, 13));

            this.addSlotToContainer(new Slot(inv, 3, 166, 13));
                    this.addSlotToContainer(new Slot(inv, 4, 189, 13));
                    this.addSlotToContainer(new Slot(inv, 5, 212, 13));
                    this.addSlotToContainer(new Slot(inv, 6, 234, 13));

            this.addSlotToContainer(new Slot(inv, 7, 200, 38));

            this.addSlotToContainer(new Slot(inv, 8, 163, 57));
                    this.addSlotToContainer(new Slot(inv, 9, 181, 57));
                    this.addSlotToContainer(new Slot(inv, 10, 200, 57));
                    this.addSlotToContainer(new Slot(inv, 11, 219, 57));
                    this.addSlotToContainer(new Slot(inv, 12, 237, 57));

            this.addSlotToContainer(new Slot(inv, 13, 200, 77));

            this.addSlotToContainer(new Slot(inv, 14, 163, 96));
                    this.addSlotToContainer(new Slot(inv, 15, 181, 96));
                    this.addSlotToContainer(new Slot(inv, 16, 200, 96));
                    this.addSlotToContainer(new Slot(inv, 17, 219, 96));
                    this.addSlotToContainer(new Slot(inv, 18, 237, 96));

            this.addSlotToContainer(new Slot(inv, 19, 200, 116));

            this.addSlotToContainer(new Slot(inv, 20, 163, 134));
                    this.addSlotToContainer(new Slot(inv, 21, 181, 134));
                    this.addSlotToContainer(new Slot(inv, 22, 200, 134));
                    this.addSlotToContainer(new Slot(inv, 23, 219, 134));
                    this.addSlotToContainer(new Slot(inv, 24, 237, 134));

            this.addSlotToContainer(new Slot(inv, 25, 75, 134));
                    this.addSlotToContainer(new Slot(inv, 26, 92, 134));
                    this.addSlotToContainer(new Slot(inv, 27, 109, 134));
                    this.addSlotToContainer(new Slot(inv, 28, 126, 134));
                    this.addSlotToContainer(new Slot(inv, 29, 143, 134));

            for(int i = 0; i < 9; i++)
                    {
                        this.addSlotToContainer(new Slot(playerInv, i, 45 + i * 18, 169));
                    }
                }

            
            J'ai aucun soucis et quand je met le code que je vous est mis plus bah la hotbar bug..
            1 réponse Dernière réponse Répondre Citer 0
            • BrokenSwing
              BrokenSwing Moddeurs confirmés Rédacteurs dernière édition par 17 juin 2016, 13:45

              C’est bête mais souvent dans mes GUI quand je cliquais sur l’item il se dropait mais la réponse était que je cliquais là où s’affiche le nombre d’item dans le stack (en gros en bas à droite du slot) ce qui avait pour action de drop l’item, mécanique du jeu que je ne connaissais pas (bon après il y a sûrement qu’à moi que ça arrive). Je tenais à le dire au cas où c’était ça … Sinon je vois que tu ajoute les slots de ton container à l’inventaire du joueur et non pas à ton inventaire arma, je sais pas si c’est normal (ça doit l’être) et je crois qu’il y a un problème d’id au niveau des slots, par exemple où est le slot avec l’id 1 ?

              EDIT : Tu as changé ton code 😢 Du coup même remarque au niveau des inventaires, es-tu sûr que tu ajoute les slots sur le bon inventaire ?

              1 réponse Dernière réponse Répondre Citer 0
              • robin4002
                robin4002 Moddeurs confirmés Rédacteurs Administrateurs dernière édition par 17 juin 2016, 14:00

                Sinon laisse le code comme ça, ça ne change pas grand chose.

                1 réponse Dernière réponse Répondre Citer 0
                • Gabs
                  Gabs dernière édition par 17 juin 2016, 15:29

                  Problème résolu il fallait juste monté un peu les slots…

                  1 réponse Dernière réponse Répondre Citer 0
                  • 1 / 1
                  1 sur 8
                  • Premier message
                    1/8
                    Dernier message
                  Design by Woryk
                  Contact / Mentions Légales

                  MINECRAFT FORGE FRANCE © 2018

                  Powered by NodeBB