Search in sources :

Example 36 with ISkinType

use of riskyken.armourersWorkshop.api.common.skin.type.ISkinType in project Armourers-Workshop by RiskyKen.

the class WardrobeInventoryContainer method readFromNBT.

public void readFromNBT(NBTTagCompound compound) {
    if (compound.hasKey(TAG_WARDROBE_CONTAINER, 10)) {
        NBTTagCompound containerCompound = compound.getCompoundTag(TAG_WARDROBE_CONTAINER);
        Set skinTypes = skinInventorys.keySet();
        for (int i = 0; i < skinInventorys.size(); i++) {
            ISkinType skinType = (ISkinType) skinInventorys.keySet().toArray()[i];
            skinInventorys.get(skinType).readItemsFromNBT(containerCompound);
        }
    } else {
        if (compound.hasKey(TAG_LEGACY_ITEMS)) {
            ItemStack[] legacyItems = new ItemStack[7];
            NBTHelper.readStackArrayFromNBT(compound, TAG_LEGACY_ITEMS, legacyItems);
            getInventoryForSkinType(SkinTypeRegistry.skinHead).setInventorySlotContents(0, legacyItems[0]);
            getInventoryForSkinType(SkinTypeRegistry.skinChest).setInventorySlotContents(0, legacyItems[1]);
            getInventoryForSkinType(SkinTypeRegistry.skinLegs).setInventorySlotContents(0, legacyItems[2]);
            getInventoryForSkinType(SkinTypeRegistry.skinFeet).setInventorySlotContents(0, legacyItems[3]);
            getInventoryForSkinType(SkinTypeRegistry.skinSword).setInventorySlotContents(0, legacyItems[4]);
            getInventoryForSkinType(SkinTypeRegistry.skinBow).setInventorySlotContents(0, legacyItems[5]);
            getInventoryForSkinType(SkinTypeRegistry.skinArrow).setInventorySlotContents(0, legacyItems[6]);
        }
    }
}
Also used : ISkinType(riskyken.armourersWorkshop.api.common.skin.type.ISkinType) Set(java.util.Set) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 37 with ISkinType

use of riskyken.armourersWorkshop.api.common.skin.type.ISkinType in project Armourers-Workshop by RiskyKen.

the class RecipeSkinArmourContainer method isValidArmourForSkin.

private boolean isValidArmourForSkin(ItemStack armourStack, ItemStack skinStack) {
    SkinPointer sp = SkinNBTHelper.getSkinPointerFromStack(skinStack);
    ISkinType skinType = sp.getIdentifier().getSkinType();
    Item armourItem = armourStack.getItem();
    if (armourItem.isValidArmor(armourStack, skinType.getVanillaArmourSlotId(), null)) {
        return true;
    }
    return false;
}
Also used : Item(net.minecraft.item.Item) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ISkinType(riskyken.armourersWorkshop.api.common.skin.type.ISkinType)

Example 38 with ISkinType

use of riskyken.armourersWorkshop.api.common.skin.type.ISkinType 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

ISkinType (riskyken.armourersWorkshop.api.common.skin.type.ISkinType)38 SkinPointer (riskyken.armourersWorkshop.common.skin.data.SkinPointer)6 ItemStack (net.minecraft.item.ItemStack)5 SkinIdentifier (riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 GuiButtonExt (cpw.mods.fml.client.config.GuiButtonExt)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Set (java.util.Set)3 Slot (net.minecraft.inventory.Slot)3 Item (net.minecraft.item.Item)3 ILibraryFile (riskyken.armourersWorkshop.api.common.library.ILibraryFile)3 GuiDropDownList (riskyken.armourersWorkshop.client.gui.controls.GuiDropDownList)3 NewerFileVersionException (riskyken.armourersWorkshop.common.exception.NewerFileVersionException)3 Point (java.awt.Point)2 Minecraft (net.minecraft.client.Minecraft)2 ScaledResolution (net.minecraft.client.gui.ScaledResolution)2 TileEntity (net.minecraft.tileentity.TileEntity)2 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)2 ISkinIdentifier (riskyken.armourersWorkshop.api.common.skin.data.ISkinIdentifier)2