[1.12.2] problème avec mon GUI



  • @robin4002

    ses pas du au:

    public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
         ItemStack itemstack = ItemStack.EMPTY;
         Slot slot = (Slot) this.inventorySlots.get(index);
    
         if ((slot != null) && (slot.getHasStack())) {
           ItemStack itemstack1 = slot.getStack();
           itemstack = itemstack1.copy();
    
           if (index < 9) {
             if (!mergeItemStack(itemstack1, 18, this.inventorySlots.size(), true)) {
               return ItemStack.EMPTY;
             }
           } else if (!mergeItemStack(itemstack1, 0, 18, false)) {
             return ItemStack.EMPTY;
           }
    
           if (itemstack1.isEmpty()) {
             slot.putStack(ItemStack.EMPTY);
           } else {
             slot.onSlotChanged();
           }
         }
    
         return itemstack;
       }
    

    ????


  • Administrateurs

    Si c'est bien cette fonction qui gère le shift clic.



  • @robin4002
    je comprent pas pourquoi il bug quand je shift click sa crash



  • @robin4002 tu ses a peut prêt dout sa peut être ?


  • Administrateurs

    Tu peux envoyer le rapport de crash ?



  • @robin4002 il en na pas


  • Administrateurs

    Si cela crash il y a forcément quelque chose dans les logs.



  • @robin4002
    2019-01-16 21-58-41.zip

    de meme je peut même pas mètre d'objet a l'interrieur

     package fr.thexrayfr.familygame.container;
     
     import fr.thexrayfr.familygame.tile.TileEntityBarrel;
     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 ContainerBarrel extends Container
     {
       private final TileEntityBarrel tileTuto;
       
       public ContainerBarrel(TileEntityBarrel tile, InventoryPlayer inventory)
       {
    
         this.tileTuto = tile;
         tile.openInventory(inventory.player);
    
         for (int i = 0; i < 6; i++)
         {
           for (int j = 0; j < 3; j++)
           {
             addSlotToContainer(new Slot(tile, j + i * 3, 62 + j * 18, 18 + i * 18));
           }
         }
         bindPlayerInventory(inventory);
       }
     
       private void bindPlayerInventory(InventoryPlayer inventory)
       {
         for (int i = 0; i < 3; i++)
         {
           for (int j = 0; j < 9; j++)
           {
             addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 138 + i * 18));
           }
         }
    
         for (int i = 0; i < 9; i++)
         {
           addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 196));
         }
       }
    
       public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
         ItemStack itemstack = ItemStack.EMPTY;
         Slot slot = (Slot) this.inventorySlots.get(index);
    
         if ((slot != null) && (slot.getHasStack())) {
           ItemStack itemstack1 = slot.getStack();
           itemstack = itemstack1.copy();
    
           if (index < 9) {
             if (!mergeItemStack(itemstack1, 18, this.inventorySlots.size(), true)) {
               return ItemStack.EMPTY;
             }
           } else if (!mergeItemStack(itemstack1, 0, 18, false)) {
             return ItemStack.EMPTY;
           }
    
           if (itemstack1.isEmpty()) {
             slot.putStack(ItemStack.EMPTY);
           } else {
             slot.onSlotChanged();
           }
         }
    
         return itemstack;
       }
     
       public boolean canInteractWith(EntityPlayer player)
       {
         return this.tileTuto.isUsableByPlayer(player);
       }
       
     
       public void onContainerClosed(EntityPlayer player)
       {
         super.onContainerClosed(player);
         this.tileTuto.closeInventory(player);
       }
     }
    


  • dans le TileEntity

     package fr.thexrayfr.familygame.tile;
    
     import net.minecraft.inventory.ItemStackHelper;
     import net.minecraft.nbt.NBTTagCompound;
     
     public class TileEntityBarrel extends TileEntityStorage
     {
         @Override
       public int getSizeInventory()
       {
         return 18;
       }
    
         @Override
       public void readFromNBT(NBTTagCompound compound)
       {
         super.readFromNBT(compound);
         ItemStackHelper.loadAllItems(compound, this.stacks);
       }
    
         @Override
       public NBTTagCompound writeToNBT(NBTTagCompound compound)
       {
         ItemStackHelper.saveAllItems(compound, this.stacks);
         return super.writeToNBT(compound);
       }
    
     }
    

    Dans le contenair

     package fr.thexrayfr.familygame.container;
     
     import fr.thexrayfr.familygame.tile.TileEntityBarrel;
     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 ContainerBarrel extends Container
     {
       private final TileEntityBarrel tileTuto;
       
       public ContainerBarrel(TileEntityBarrel tile, InventoryPlayer inventory)
       {
    
         this.tileTuto = tile;
         tile.openInventory(inventory.player);
    
         for (int i = 0; i < 6; ++i)
         {
           for (int j = 0; j < 3; ++j)
           {
             this.addSlotToContainer(new Slot(tile, j + i * 3, 62 + j * 18, 18 + i * 18));
           }
         }
         this.bindPlayerInventory(inventory);
       }
     
       private void bindPlayerInventory(InventoryPlayer inventory)
       {
         int i;
         for (i = 0; i < 3; ++i)
         {
           for (int j = 0; j < 9; ++j)
           {
             this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 138 + i * 18));
           }
         }
    
         for (i = 0; i < 9; ++i)
         {
           this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 196));
         }
       }
    
       @Override
       public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
         ItemStack itemstack = ItemStack.EMPTY;
         Slot slot = (Slot) this.inventorySlots.get(index);
    
         if (slot != null && slot.getHasStack()) {
           ItemStack itemstack1 = slot.getStack();
           itemstack = itemstack1.copy();
    
           if (index < 9) {
             if (!this.mergeItemStack(itemstack1, 18, this.inventorySlots.size(), true)) {
               return ItemStack.EMPTY;
             }
           } else if (!this.mergeItemStack(itemstack1, 0, 18, false)) {
             return ItemStack.EMPTY;
           }
    
           if (itemstack1.isEmpty())
           {
             slot.putStack(ItemStack.EMPTY);
           }
           else
           {
             slot.onSlotChanged();
           }
         }
    
         return itemstack;
       }
    
       @Override
       public boolean canInteractWith(EntityPlayer player)
       {
         return this.tileTuto.isUsableByPlayer(player);
       }
    
       @Override
       public void onContainerClosed(EntityPlayer player)
       {
         super.onContainerClosed(player);
         this.tileTuto.closeInventory(player);
       }
     }
    

    se que j'ai changer ses les ++i et ++j qui étai i++ et j++ donc je les ais inversser


Log in to reply