Search in sources :

Example 1 with AbstractModItemArmour

use of riskyken.armourersWorkshop.common.items.AbstractModItemArmour 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

Item (net.minecraft.item.Item)1 ItemStack (net.minecraft.item.ItemStack)1 ISkinType (riskyken.armourersWorkshop.api.common.skin.type.ISkinType)1 AbstractModItemArmour (riskyken.armourersWorkshop.common.items.AbstractModItemArmour)1 SkinIdentifier (riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)1 SkinPointer (riskyken.armourersWorkshop.common.skin.data.SkinPointer)1