Search in sources :

Example 6 with Skin

use of riskyken.armourersWorkshop.common.skin.data.Skin 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 Skin

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

the class SkinCacheGlobal method doSkinLoading.

public void doSkinLoading() {
    Future<Skin> futureSkin = completionServiceSkinDownloader.poll();
    if (futureSkin != null) {
        try {
            Skin skin = futureSkin.get();
            if (skin != null) {
                synchronized (cacheMapLock) {
                    int globalId = skin.serverId;
                    cacheLocalDatabase.add(skin);
                    cacheMapFileLink.put(globalId, skin.lightHash());
                    CommonSkinCache.INSTANCE.onGlobalSkinLoaded(skin, globalId);
                    synchronized (downloadingSetLock) {
                        downloadingSet.remove(skin.serverId);
                    }
                }
            } else {
                ModLogger.log(Level.ERROR, "Failed to load skin from global database.");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : Skin(riskyken.armourersWorkshop.common.skin.data.Skin)

Example 8 with Skin

use of riskyken.armourersWorkshop.common.skin.data.Skin 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 9 with Skin

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

the class SkinCacheLocalFile method load.

private Skin load(ISkinIdentifier skinIdentifier) {
    Skin skin = SkinIOUtils.loadSkinFromFileName(skinIdentifier.getSkinLibraryFile().getFullName() + SkinIOUtils.SKIN_FILE_EXTENSION);
    addSkinToCache(skin, skinIdentifier.getSkinLibraryFile());
    return skin;
}
Also used : Skin(riskyken.armourersWorkshop.common.skin.data.Skin)

Example 10 with Skin

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

the class GuiGlobalLibraryPanelSkinInfo method draw.

@Override
public void draw(int mouseX, int mouseY, float partialTickTime) {
    if (!visible) {
        return;
    }
    PlushieUser user = null;
    if (skinJson != null && skinJson.has("user_id")) {
        int userId = skinJson.get("user_id").getAsInt();
        user = GlobalSkinLibraryUtils.getUserInfo(userId);
    }
    drawGradientRect(this.x, this.y, this.x + this.width, this.y + height, 0xC0101010, 0xD0101010);
    Skin skin = null;
    if (skinJson != null && skinJson.has("id")) {
        SkinIdentifier identifier = new SkinIdentifier(0, null, skinJson.get("id").getAsInt(), null);
        skin = ClientSkinCache.INSTANCE.getSkin(identifier);
    }
    super.draw(mouseX, mouseY, partialTickTime);
    drawUserbox(x + 5, y + 5, 185, 30, mouseX, mouseY, partialTickTime);
    drawSkinInfo(skin, x + 5, y + 20 + 20, 185, height - 70, mouseX, mouseY, partialTickTime);
    drawPreviewBox(skin, x + 195, y + 5, width - 200, height - 35, mouseX, mouseY, partialTickTime);
}
Also used : Skin(riskyken.armourersWorkshop.common.skin.data.Skin) PlushieUser(riskyken.armourersWorkshop.common.library.global.PlushieUser) SkinIdentifier(riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)

Aggregations

Skin (riskyken.armourersWorkshop.common.skin.data.Skin)69 SkinPointer (riskyken.armourersWorkshop.common.skin.data.SkinPointer)19 ItemStack (net.minecraft.item.ItemStack)11 ISkinPointer (riskyken.armourersWorkshop.api.common.skin.data.ISkinPointer)11 LibraryFile (riskyken.armourersWorkshop.common.library.LibraryFile)10 SkinIdentifier (riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)10 SkinPart (riskyken.armourersWorkshop.common.skin.data.SkinPart)10 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)9 IOException (java.io.IOException)6 ISkinIdentifier (riskyken.armourersWorkshop.api.common.skin.data.ISkinIdentifier)6 AbstractModelSkin (riskyken.armourersWorkshop.client.model.skin.AbstractModelSkin)6 ItemSkin (riskyken.armourersWorkshop.common.items.ItemSkin)6 Color (java.awt.Color)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 DataInputStream (java.io.DataInputStream)4 AbstractClientPlayer (net.minecraft.client.entity.AbstractClientPlayer)4 BakedSkin (riskyken.armourersWorkshop.client.model.bake.ModelBakery.BakedSkin)4 SideOnly (cpw.mods.fml.relauncher.SideOnly)3 BufferedInputStream (java.io.BufferedInputStream)3 ArrayList (java.util.ArrayList)3