Search in sources :

Example 21 with SkinIdentifier

use of riskyken.armourersWorkshop.common.skin.data.SkinIdentifier in project Armourers-Workshop by RiskyKen.

the class RecipeSkinUpdate method getCraftingResult.

@Override
public ItemStack getCraftingResult(InventoryCrafting invCrafting) {
    ItemStack oldSkinStack = null;
    for (int slotId = 0; slotId < invCrafting.getSizeInventory(); slotId++) {
        ItemStack stack = invCrafting.getStackInSlot(slotId);
        if (stack != null) {
            Item item = stack.getItem();
            if (SkinNBTHelper.stackHasLegacySkinData(stack)) {
                if (oldSkinStack != null) {
                    return null;
                }
                oldSkinStack = stack;
            } else {
                return null;
            }
        }
    }
    if (oldSkinStack != null) {
        int skinId = SkinNBTHelper.getLegacyIdFromStack(oldSkinStack);
        ISkinType skinType = SkinTypeRegistry.INSTANCE.getSkinTypeFromLegacyId(oldSkinStack.getItemDamage());
        SkinPointer skinPointer = new SkinPointer(new SkinIdentifier(skinId, null, 0, skinType), false);
        if (oldSkinStack.getItem() instanceof AbstractModItemArmour) {
            return SkinNBTHelper.makeArmouerContainerStack(skinPointer);
        } else {
            return SkinNBTHelper.makeEquipmentSkinStack(skinPointer);
        }
    } else {
        return null;
    }
}
Also used : Item(net.minecraft.item.Item) ISkinType(riskyken.armourersWorkshop.api.common.skin.type.ISkinType) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ItemStack(net.minecraft.item.ItemStack) SkinIdentifier(riskyken.armourersWorkshop.common.skin.data.SkinIdentifier) AbstractModItemArmour(riskyken.armourersWorkshop.common.items.AbstractModItemArmour)

Aggregations

SkinIdentifier (riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)21 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)10 ItemStack (net.minecraft.item.ItemStack)8 LibraryFile (riskyken.armourersWorkshop.common.library.LibraryFile)8 SkinPointer (riskyken.armourersWorkshop.common.skin.data.SkinPointer)7 ISkinIdentifier (riskyken.armourersWorkshop.api.common.skin.data.ISkinIdentifier)6 ISkinType (riskyken.armourersWorkshop.api.common.skin.type.ISkinType)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 ILibraryFile (riskyken.armourersWorkshop.api.common.library.ILibraryFile)3 Color (java.awt.Color)2 WrongUsageException (net.minecraft.command.WrongUsageException)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 SkinDye (riskyken.armourersWorkshop.common.skin.data.SkinDye)2 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 GuiButton (net.minecraft.client.gui.GuiButton)1 ScaledResolution (net.minecraft.client.gui.ScaledResolution)1 EntityItem (net.minecraft.entity.item.EntityItem)1 Slot (net.minecraft.inventory.Slot)1