Search in sources :

Example 31 with SkinPointer

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

the class RecipeSkinSword method getCraftingResult.

@Override
public ItemStack getCraftingResult(IInventory inventory) {
    ItemStack skinStack = null;
    ItemStack swordStack = 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.SWORD, item) & !SkinNBTHelper.isSkinLockedOnStack(stack)) {
                if (swordStack != null) {
                    return null;
                }
                swordStack = stack;
            } else {
                return null;
            }
        }
    }
    if (skinStack != null && swordStack != null) {
        ItemStack returnStack = swordStack.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 32 with SkinPointer

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

the class SlotDyeableSkin method onSlotChanged.

@Override
public void onSlotChanged() {
    ItemStack stack = getStack();
    if (stack == null) {
        container.skinRemoved();
    } else {
        SkinPointer sp = SkinNBTHelper.getSkinPointerFromStack(stack);
        if (sp != null) {
            if (stack.getItem() == ModItems.equipmentSkin) {
                container.skinAdded(stack);
            } else {
                if (sp.lockSkin) {
                    container.skinAdded(stack);
                }
            }
        }
    }
    super.onSlotChanged();
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ItemStack(net.minecraft.item.ItemStack)

Example 33 with SkinPointer

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

the class EntityEquipmentData method toBytes.

private void toBytes(ByteBuf buf) {
    buf.writeByte(skinPointerMap.size());
    for (int i = 0; i < skinPointerMap.size(); i++) {
        String skinName = (String) skinPointerMap.keySet().toArray()[i];
        NBTTagCompound compound = new NBTTagCompound();
        SkinPointer skinPointer = (SkinPointer) skinPointerMap.get(skinName);
        skinPointer.writeToCompound(compound);
        ByteBufUtils.writeTag(buf, compound);
        ByteBufUtils.writeUTF8String(buf, skinName);
    }
}
Also used : ISkinPointer(riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 34 with SkinPointer

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

the class ExPropsPlayerSkinData method loadFromItemStack.

private void loadFromItemStack(ItemStack stack, byte slotId) {
    SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(stack);
    addCustomEquipment(skinPointer.getIdentifier().getSkinType(), slotId, skinPointer);
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer)

Example 35 with SkinPointer

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

the class SkinNBTHelper method getSkinPointerFromStack.

public static SkinPointer getSkinPointerFromStack(ItemStack stack) {
    if (!stackHasSkinData(stack)) {
        return null;
    }
    SkinPointer skinData = new SkinPointer();
    skinData.readFromCompound(stack.getTagCompound());
    return skinData;
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer)

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