Search in sources :

Example 61 with SkinPointer

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

the class RecipeSkinBow method getCraftingResult.

@Override
public ItemStack getCraftingResult(IInventory inventory) {
    ItemStack skinStack = null;
    ItemStack bowStack = null;
    for (int slotId = 0; slotId < inventory.getSizeInventory(); slotId++) {
        ItemStack stack = inventory.getStackInSlot(slotId);
        if (stack != null) {
            Item item = stack.getItem();
            if (isValidSkinForType(stack)) {
                if (skinStack != null) {
                    return null;
                }
                skinStack = stack;
            } else if (EntityEquipmentDataManager.INSTANCE.isRenderItem(ItemOverrideType.BOW, item) & !SkinNBTHelper.isSkinLockedOnStack(stack)) {
                if (bowStack != null) {
                    return null;
                }
                bowStack = stack;
            } else {
                return null;
            }
        }
    }
    if (skinStack != null && bowStack != null) {
        ItemStack returnStack = bowStack.copy();
        SkinPointer skinData = SkinNBTHelper.getSkinPointerFromStack(skinStack);
        SkinNBTHelper.addSkinDataToStack(returnStack, skinData.getIdentifier(), skinData.getSkinDye(), true);
        return returnStack;
    } else {
        return null;
    }
}
Also used : Item(net.minecraft.item.Item) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ItemStack(net.minecraft.item.ItemStack)

Example 62 with SkinPointer

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

the class RecipeSkinDye method getCraftingResult.

@Override
public ItemStack getCraftingResult(InventoryCrafting invCrafting) {
    ItemStack skinStack = null;
    ItemStack dyeStack = null;
    for (int slotId = 0; slotId < invCrafting.getSizeInventory(); slotId++) {
        ItemStack stack = invCrafting.getStackInSlot(slotId);
        if (stack != null) {
            Item item = stack.getItem();
            if (item == ModItems.dyeBottle) {
                if (dyeStack != null) {
                    return null;
                }
                if (PaintingHelper.getToolHasPaint(stack)) {
                    dyeStack = stack;
                } else {
                    return null;
                }
            } else if (item == ModItems.equipmentSkin) {
                if (skinStack != null) {
                    return null;
                }
                SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(stack);
                if (skinPointer != null) {
                    if (skinPointer.getSkinDye().getNumberOfDyes() < SkinDye.MAX_SKIN_DYES) {
                        skinStack = stack;
                    } else {
                        return null;
                    }
                } else {
                    return null;
                }
            }
        }
    }
    if (skinStack != null && dyeStack != null) {
        ItemStack returnStack = skinStack.copy();
        byte[] rgbt = PaintingHelper.getToolPaintData(dyeStack);
        SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(returnStack);
        ISkinDye dye = skinPointer.getSkinDye();
        dye.addDye(rgbt);
        SkinNBTHelper.addSkinDataToStack(returnStack, skinPointer);
        return returnStack;
    }
    return null;
}
Also used : Item(net.minecraft.item.Item) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ISkinDye(riskyken.armourersWorkshop.api.common.skin.data.ISkinDye) ItemStack(net.minecraft.item.ItemStack)

Example 63 with SkinPointer

use of riskyken.armourersWorkshop.common.skin.data.SkinPointer 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)

Example 64 with SkinPointer

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

the class RecipeSkinArmour method getCraftingResult.

@Override
public ItemStack getCraftingResult(IInventory inventory) {
    ItemStack skinStack = null;
    ItemStack armourStack = null;
    for (int slotId = 0; slotId < inventory.getSizeInventory(); slotId++) {
        ItemStack stack = inventory.getStackInSlot(slotId);
        if (stack != null) {
            Item item = stack.getItem();
            if (isValidSkinForType(stack)) {
                if (skinStack != null) {
                    return null;
                }
                skinStack = stack;
            } else if (isValidArmour(stack) & !SkinNBTHelper.isSkinLockedOnStack(stack)) {
                if (armourStack != null) {
                    return null;
                }
                armourStack = stack;
            } else {
                return null;
            }
        }
    }
    if (skinStack != null && armourStack != null) {
        if (!isValidArmourForSkin(armourStack, skinStack)) {
            return null;
        }
        ItemStack returnStack = armourStack.copy();
        SkinPointer skinData = SkinNBTHelper.getSkinPointerFromStack(skinStack);
        SkinNBTHelper.addSkinDataToStack(returnStack, skinData.getIdentifier(), skinData.getSkinDye(), true);
        return returnStack;
    } else {
        return null;
    }
}
Also used : Item(net.minecraft.item.Item) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ItemStack(net.minecraft.item.ItemStack)

Aggregations

SkinPointer (riskyken.armourersWorkshop.common.skin.data.SkinPointer)64 ItemStack (net.minecraft.item.ItemStack)28 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)19 ISkinPointer (riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer)15 Item (net.minecraft.item.Item)13 ISkinDye (riskyken.armourersWorkshop.api.common.skin.data.ISkinDye)8 LibraryFile (riskyken.armourersWorkshop.common.library.LibraryFile)7 SkinIdentifier (riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)7 ISkinType (riskyken.armourersWorkshop.api.common.skin.type.ISkinType)6 AbstractClientPlayer (net.minecraft.client.entity.AbstractClientPlayer)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 ItemSkin (riskyken.armourersWorkshop.common.items.ItemSkin)4 Minecraft (net.minecraft.client.Minecraft)3 ScaledResolution (net.minecraft.client.gui.ScaledResolution)3 ItemBlock (net.minecraft.item.ItemBlock)3 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)3 AbstractModelSkin (riskyken.armourersWorkshop.client.model.skin.AbstractModelSkin)3 MessageServerLibrarySendSkin (riskyken.armourersWorkshop.common.network.messages.server.MessageServerLibrarySendSkin)3 SkinDye (riskyken.armourersWorkshop.common.skin.data.SkinDye)3 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)2