Search in sources :

Example 11 with SkinPointer

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

the class ExPropsEntityEquipmentData method setInventorySlotContents.

@Override
public void setInventorySlotContents(IInventory inventory, int slotId, ItemStack stack) {
    if (entity.worldObj.isRemote) {
        return;
    }
    if (stack == null) {
        ISkinType skinType = getSkinTypeForSlot(slotId);
        equipmentData.removeEquipment(skinType, 0);
    } else {
        SkinPointer skinData = SkinNBTHelper.getSkinPointerFromStack(stack);
        equipmentData.addEquipment(skinData.getIdentifier().getSkinType(), 0, skinData);
    }
    sendEquipmentDataToPlayerToAllPlayersAround();
}
Also used : ISkinType(riskyken.armourersWorkshop.api.common.skin.type.ISkinType) SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer)

Example 12 with SkinPointer

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

the class TileEntitySkinLibrary method sendArmourToClient.

public void sendArmourToClient(String filename, String filePath, EntityPlayerMP player) {
    if (!ConfigHandler.allowClientsToDownloadSkins) {
        return;
    }
    ItemStack stackInput = getStackInSlot(0);
    ItemStack stackOutput = getStackInSlot(1);
    if (stackInput == null) {
        return;
    }
    if (stackOutput != null) {
        return;
    }
    if (!(stackInput.getItem() instanceof ItemSkin)) {
        return;
    }
    if (!SkinNBTHelper.stackHasSkinData(stackInput)) {
        return;
    }
    SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(stackInput);
    Skin skin = CommonSkinCache.INSTANCE.getSkin(skinPointer);
    if (skin == null) {
        return;
    }
    LibraryFile file = new LibraryFile(filename, filePath, skin.getSkinType());
    // if the file was overwritten remove it's old id link
    CommonSkinCache.INSTANCE.clearFileNameIdLink(file);
    // ModLogger.log(file.getFullName());
    MessageServerLibrarySendSkin message = new MessageServerLibrarySendSkin(filename, filePath, skin, SendType.LIBRARY_SAVE);
    PacketHandler.networkWrapper.sendTo(message, player);
    this.decrStackSize(0, 1);
    this.setInventorySlotContents(1, stackInput);
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ItemSkin(riskyken.armourersWorkshop.common.items.ItemSkin) ItemSkin(riskyken.armourersWorkshop.common.items.ItemSkin) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) MessageServerLibrarySendSkin(riskyken.armourersWorkshop.common.network.messages.server.MessageServerLibrarySendSkin) MessageServerLibrarySendSkin(riskyken.armourersWorkshop.common.network.messages.server.MessageServerLibrarySendSkin) LibraryFile(riskyken.armourersWorkshop.common.library.LibraryFile) ItemStack(net.minecraft.item.ItemStack)

Example 13 with SkinPointer

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

the class SkinNBTHelper method getSkinIdFromStack.

public static int getSkinIdFromStack(ItemStack stack) {
    if (!stackHasSkinData(stack)) {
        return -1;
    }
    SkinPointer skinData = new SkinPointer();
    skinData.readFromCompound(stack.getTagCompound());
    return skinData.getIdentifier().getSkinLocalId();
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer)

Example 14 with SkinPointer

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

the class SkinNBTHelper method getSkinTypeFromStack.

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

Example 15 with SkinPointer

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

the class SkinNBTHelper method removeSkinDataFromStack.

public static void removeSkinDataFromStack(ItemStack stack, boolean overrideLock) {
    if (!stackHasSkinData(stack)) {
        return;
    }
    SkinPointer skinData = getSkinPointerFromStack(stack);
    if (skinData.lockSkin) {
        if (!overrideLock) {
            return;
        }
    }
    NBTTagCompound itemCompound = stack.getTagCompound();
    if (itemCompound.hasKey(SkinPointer.TAG_SKIN_DATA)) {
        itemCompound.removeTag(SkinPointer.TAG_SKIN_DATA);
    }
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

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