Search in sources :

Example 26 with SkinPointer

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

the class ContainerGlobalSkinLibrary method buttonPressed.

@Override
public void buttonPressed(byte buttonId) {
    if (buttonId == 0) {
        if (!tileEntity.getWorldObj().isRemote) {
            if (!getSlot(37).getHasStack()) {
                ItemStack itemStack = getSlot(36).getStack();
                SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(itemStack);
                if (skinPointer != null) {
                    Skin skin = CommonSkinCache.INSTANCE.getSkin(skinPointer);
                    if (skin != null) {
                        onSkinUploaded();
                        MessageServerLibrarySendSkin message = new MessageServerLibrarySendSkin(null, null, skin, SendType.GLOBAL_UPLOAD);
                        PacketHandler.networkWrapper.sendTo(message, (EntityPlayerMP) player);
                    }
                }
            }
        }
    }
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) MessageServerLibrarySendSkin(riskyken.armourersWorkshop.common.network.messages.server.MessageServerLibrarySendSkin) MessageServerLibrarySendSkin(riskyken.armourersWorkshop.common.network.messages.server.MessageServerLibrarySendSkin) ItemStack(net.minecraft.item.ItemStack)

Example 27 with SkinPointer

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

the class AbstractModItemArmour method getArmorModel.

@Override
@SideOnly(Side.CLIENT)
public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack stack, int armorSlot) {
    if (!SkinNBTHelper.stackHasSkinData(stack)) {
        return null;
    }
    SkinPointer skinData = SkinNBTHelper.getSkinPointerFromStack(stack);
    AbstractModelSkin targetModel = null;
    SkinModelRenderer emr = SkinModelRenderer.INSTANCE;
    Skin data = emr.getCustomArmourItemData(skinData);
    if (data == null) {
        return null;
    }
    targetModel = emr.getModelForEquipmentType(data.getSkinType());
    if (targetModel == null) {
        return null;
    }
    targetModel.npcSkinData = data;
    targetModel.npcDyeData = skinData.getSkinDye();
    return targetModel;
}
Also used : SkinModelRenderer(riskyken.armourersWorkshop.client.render.SkinModelRenderer) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) AbstractModelSkin(riskyken.armourersWorkshop.client.model.skin.AbstractModelSkin) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) AbstractModelSkin(riskyken.armourersWorkshop.client.model.skin.AbstractModelSkin) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 28 with SkinPointer

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

the class RecipeSkinArmour 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 29 with SkinPointer

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

the class RecipeSkinCopy method getCraftingResult.

@Override
public ItemStack getCraftingResult(IInventory inventory) {
    ItemStack skinStack = null;
    ItemStack blackStack = null;
    for (int slotId = 0; slotId < inventory.getSizeInventory(); slotId++) {
        ItemStack stack = inventory.getStackInSlot(slotId);
        if (stack != null) {
            Item item = stack.getItem();
            if (item == ModItems.equipmentSkin && SkinNBTHelper.stackHasSkinData(stack)) {
                if (skinStack != null) {
                    return null;
                }
                skinStack = stack;
            } else if (item == ModItems.equipmentSkinTemplate & !SkinNBTHelper.stackHasSkinData(stack)) {
                if (blackStack != null) {
                    return null;
                }
                blackStack = stack;
            } else {
                return null;
            }
        }
    }
    if (skinStack != null && blackStack != null) {
        ItemStack returnStack = new ItemStack(ModItems.equipmentSkin, 1);
        SkinPointer skinData = SkinNBTHelper.getSkinPointerFromStack(skinStack);
        SkinNBTHelper.addSkinDataToStack(returnStack, skinData.getIdentifier(), false, new SkinDye(skinData.getSkinDye()));
        return returnStack;
    }
    return null;
}
Also used : Item(net.minecraft.item.Item) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) SkinDye(riskyken.armourersWorkshop.common.skin.data.SkinDye) ItemStack(net.minecraft.item.ItemStack)

Example 30 with SkinPointer

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

the class RecipeSkinPickaxe 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.PICKAXE, 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)

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