Jump to content

[1.6.2]Weird Dupe Bug on Shift Click


Vemahk20

Recommended Posts

Ok, so i have my container working mostly, only when a item/block is shift clicked out of the 6 slots of the repair station, that item is doubled and then put in my inv... Its probably just a stupid mistake but ive looked the program over a few times and i can't seem to find it. Any help would be nice, here's my container code

 

package RS;

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 ContainerRStation extends Container {

        protected TileEntityRStation tileEntity;

        public ContainerRStation (InventoryPlayer inventoryPlayer, TileEntityRStation te){
                tileEntity = te;

                addSlotToContainer(new Slot(tileEntity, 0,25,34));
                addSlotToContainer(new Slot(tileEntity, 1,43,34));
                addSlotToContainer(new Slot(tileEntity, 2,61,34));
                addSlotToContainer(new Slot(tileEntity, 3,79,34));
                addSlotToContainer(new Slot(tileEntity, 4,117,34));
                addSlotToContainer(new Slot(tileEntity, 5,135,34));
                bindPlayerInventory(inventoryPlayer);
        }

        @Override
        public boolean canInteractWith(EntityPlayer player) {
                return tileEntity.isUseableByPlayer(player);
        }


        protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) {
                for (int i = 0; i < 3; i++) {
                        for (int j = 0; j < 9; j++) {
                                addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9,
                                                8 + j * 18, 84 + i * 18));
                        }
                }

                for (int i = 0; i < 9; i++) {
                        addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142));
                }
        }

        @Override
        public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
                ItemStack stack = null;
                Slot slotObject = (Slot) inventorySlots.get(slot);

                if (slotObject != null && slotObject.getHasStack()) {
                        ItemStack stackInSlot = slotObject.getStack();
                        stack = stackInSlot.copy();

                        if (slot < 6) {
                                if (!this.mergeItemStack(stackInSlot, 0, 42, true)) {
                                        return null;
                                }
                        
                        else if (!this.mergeItemStack(stackInSlot, 0, 6, false)) {
                                return null;
                        }

                        if (stackInSlot.stackSize == 0) {
                                slotObject.putStack(null);
                        } else {
                                slotObject.onSlotChanged();
                        }

                        if (stackInSlot.stackSize == stack.stackSize) {
                                return null;
                        }
                        slotObject.onPickupFromSlot(player, stackInSlot);
                }
                return stack;
        }
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.