Search in sources :

Example 6 with ItemSkin

use of riskyken.armourersWorkshop.common.items.ItemSkin in project Armourers-Workshop by RiskyKen.

the class ContainerArmourer method transferStackInSlot.

@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotID) {
    Slot slot = getSlot(slotID);
    if (slot != null && slot.getHasStack()) {
        ItemStack stack = slot.getStack();
        ItemStack result = stack.copy();
        if (slotID < 2) {
            if (!this.mergeItemStack(stack, 11, 38, false)) {
                if (!this.mergeItemStack(stack, 2, 11, false)) {
                    return null;
                }
            }
        } else {
            if ((stack.getItem() instanceof ItemSkinTemplate & stack.getItemDamage() == 0) | stack.getItem() instanceof ItemSkin | stack.getItem() instanceof ItemArmourContainerItem) {
                if (!this.mergeItemStack(stack, 0, 1, false)) {
                    return null;
                }
            } else {
                return null;
            }
        }
        if (stack.stackSize == 0) {
            slot.putStack(null);
        } else {
            slot.onSlotChanged();
        }
        slot.onPickupFromSlot(player, stack);
        return result;
    }
    return null;
}
Also used : ItemSkinTemplate(riskyken.armourersWorkshop.common.items.ItemSkinTemplate) Slot(net.minecraft.inventory.Slot) ItemSkin(riskyken.armourersWorkshop.common.items.ItemSkin) ItemStack(net.minecraft.item.ItemStack) ItemArmourContainerItem(riskyken.armourersWorkshop.common.items.ItemArmourContainerItem)

Example 7 with ItemSkin

use of riskyken.armourersWorkshop.common.items.ItemSkin in project Armourers-Workshop by RiskyKen.

the class ContainerSkinWardrobe method transferStackInSlot.

@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotId) {
    Slot slot = getSlot(slotId);
    if (slot != null && slot.getHasStack()) {
        ItemStack stack = slot.getStack();
        ItemStack result = stack.copy();
        if (slotId < skinSlots) {
            // Moving item to main inv
            if (!this.mergeItemStack(stack, skinSlots + 9, skinSlots + 36, false)) {
                // Moving item to hotbar
                if (!this.mergeItemStack(stack, skinSlots, skinSlots + 9, false)) {
                    return null;
                }
            }
        } else {
            if (stack.getItem() instanceof ItemSkin & SkinNBTHelper.stackHasSkinData(stack)) {
                boolean slotted = false;
                for (int i = 0; i < skinSlots; i++) {
                    Slot targetSlot = getSlot(i);
                    if (targetSlot.isItemValid(stack)) {
                        if (this.mergeItemStack(stack, i, i + 1, false)) {
                            slotted = true;
                            break;
                        }
                    }
                }
                if (!slotted) {
                    return null;
                }
            } else {
                return null;
            }
        }
        if (stack.stackSize == 0) {
            slot.putStack(null);
        } else {
            slot.onSlotChanged();
        }
        slot.onPickupFromSlot(player, stack);
        return result;
    }
    return null;
}
Also used : Slot(net.minecraft.inventory.Slot) ItemSkin(riskyken.armourersWorkshop.common.items.ItemSkin) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemStack (net.minecraft.item.ItemStack)7 ItemSkin (riskyken.armourersWorkshop.common.items.ItemSkin)7 Slot (net.minecraft.inventory.Slot)4 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)3 SkinPointer (riskyken.armourersWorkshop.common.skin.data.SkinPointer)3 ItemSkinTemplate (riskyken.armourersWorkshop.common.items.ItemSkinTemplate)2 LibraryFile (riskyken.armourersWorkshop.common.library.LibraryFile)2 MessageServerLibrarySendSkin (riskyken.armourersWorkshop.common.network.messages.server.MessageServerLibrarySendSkin)2 ItemArmourContainerItem (riskyken.armourersWorkshop.common.items.ItemArmourContainerItem)1 SkinProperties (riskyken.armourersWorkshop.common.skin.data.SkinProperties)1