Search in sources :

Example 6 with SkinIdentifier

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

the class SkinCacheGlobal method get.

public Skin get(SkinRequestMessage requestMessage, boolean softLoad) {
    ISkinIdentifier identifier = requestMessage.getSkinIdentifier();
    int globalId = identifier.getSkinGlobalId();
    synchronized (cacheMapLock) {
        if (!cacheMapFileLink.containsKey(globalId)) {
            downloadSkin(identifier);
            return null;
        }
        if (cacheMapFileLink.containsKey(globalId)) {
            int id = cacheMapFileLink.get(globalId);
            SkinIdentifier newIdentifier = new SkinIdentifier(id, null, globalId, identifier.getSkinType());
            Skin skin = cacheLocalDatabase.get(newIdentifier, false);
            if (skin != null) {
                return skin;
            } else {
                ModLogger.log(Level.WARN, "Somehow failed to load a skin that we should have. ID was " + id);
            }
        } else {
            if (requestMessage.getPlayer() != null) {
                ModLogger.log(Level.ERROR, "Skin [" + identifier.toString() + "] was requested by " + requestMessage.getPlayer().getCommandSenderName() + " but was not found.");
            } else {
                ModLogger.log(Level.ERROR, "Skin [" + identifier.toString() + "] was requested but was not found.");
            }
        }
    }
    return null;
}
Also used : ISkinIdentifier(riskyken.armourersWorkshop.api.common.skin.data.ISkinIdentifier) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) ISkinIdentifier(riskyken.armourersWorkshop.api.common.skin.data.ISkinIdentifier) SkinIdentifier(riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)

Example 7 with SkinIdentifier

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

the class SkinCacheLocalFile method get.

public Skin get(SkinRequestMessage requestMessage, boolean softLoad) {
    ISkinIdentifier identifier = requestMessage.getSkinIdentifier();
    ILibraryFile libraryFile = identifier.getSkinLibraryFile();
    synchronized (cacheMapLock) {
        if (!cacheMapFileLink.containsKey(libraryFile)) {
            if (softLoad) {
                synchronized (skinLoadQueueLock) {
                    skinLoadQueue.add(requestMessage);
                }
                return null;
            } else {
                load(identifier);
            }
        }
        if (cacheMapFileLink.containsKey(libraryFile)) {
            int id = cacheMapFileLink.get(libraryFile);
            SkinIdentifier newIdentifier = new SkinIdentifier(id, requestMessage.getSkinIdentifier().getSkinLibraryFile(), 0, requestMessage.getSkinIdentifier().getSkinType());
            Skin skin = cacheLocalDatabase.get(newIdentifier, false);
            if (skin != null) {
                return skin;
            } else {
                ModLogger.log(Level.WARN, "Somehow failed to load a skin that we should have. ID was " + id);
            }
        } else {
            if (requestMessage.getPlayer() != null) {
                ModLogger.log(Level.ERROR, "Skin [" + libraryFile.getFullName() + "] was requested by " + requestMessage.getPlayer().getCommandSenderName() + " but was not found.");
            } else {
                ModLogger.log(Level.ERROR, "Skin [" + libraryFile.getFullName() + "] was requested but was not found.");
            }
        }
    }
    return null;
}
Also used : ISkinIdentifier(riskyken.armourersWorkshop.api.common.skin.data.ISkinIdentifier) ILibraryFile(riskyken.armourersWorkshop.api.common.library.ILibraryFile) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) ISkinIdentifier(riskyken.armourersWorkshop.api.common.skin.data.ISkinIdentifier) SkinIdentifier(riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)

Example 8 with SkinIdentifier

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

the class SkinNBTHelper method makeArmouerContainerStack.

public static ItemStack makeArmouerContainerStack(Skin skin) {
    ItemStack stack = new ItemStack(ModItems.armourContainer[skin.getSkinType().getVanillaArmourSlotId()], 1);
    stack.setTagCompound(new NBTTagCompound());
    addSkinDataToStack(stack, new SkinIdentifier(skin), false, null);
    return stack;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) SkinIdentifier(riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)

Example 9 with SkinIdentifier

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

the class SkinNBTHelper method makeEquipmentSkinStack.

public static ItemStack makeEquipmentSkinStack(Skin skin) {
    ItemStack stack = new ItemStack(ModItems.equipmentSkin, 1);
    stack.setTagCompound(new NBTTagCompound());
    addSkinDataToStack(stack, new SkinIdentifier(skin), false, null);
    return stack;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) SkinIdentifier(riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)

Example 10 with SkinIdentifier

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

the class SkinNBTHelper method makeEquipmentSkinStack.

public static ItemStack makeEquipmentSkinStack(Skin skin, ISkinDye skinDye) {
    ItemStack stack = new ItemStack(ModItems.equipmentSkin, 1);
    stack.setTagCompound(new NBTTagCompound());
    addSkinDataToStack(stack, new SkinIdentifier(skin), false, skinDye);
    return stack;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) SkinIdentifier(riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)

Aggregations

SkinIdentifier (riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)21 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)10 ItemStack (net.minecraft.item.ItemStack)8 LibraryFile (riskyken.armourersWorkshop.common.library.LibraryFile)8 SkinPointer (riskyken.armourersWorkshop.common.skin.data.SkinPointer)7 ISkinIdentifier (riskyken.armourersWorkshop.api.common.skin.data.ISkinIdentifier)6 ISkinType (riskyken.armourersWorkshop.api.common.skin.type.ISkinType)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 ILibraryFile (riskyken.armourersWorkshop.api.common.library.ILibraryFile)3 Color (java.awt.Color)2 WrongUsageException (net.minecraft.command.WrongUsageException)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 SkinDye (riskyken.armourersWorkshop.common.skin.data.SkinDye)2 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 GuiButton (net.minecraft.client.gui.GuiButton)1 ScaledResolution (net.minecraft.client.gui.ScaledResolution)1 EntityItem (net.minecraft.entity.item.EntityItem)1 Slot (net.minecraft.inventory.Slot)1