Search in sources :

Example 1 with ISkinIdentifier

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

the class ClientSkinCache method getPartCount.

public int getPartCount() {
    int count = 0;
    synchronized (skinIDMap) {
        Object[] keySet = skinIDMap.getKeySet().toArray();
        for (int i = 0; i < keySet.length; i++) {
            ISkinIdentifier key = (ISkinIdentifier) keySet[i];
            Skin skin = skinIDMap.getQuiet(key);
            count += skin.getPartCount();
        }
    }
    return count;
}
Also used : ISkinIdentifier(riskyken.armourersWorkshop.api.common.skin.data.ISkinIdentifier) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) BakedSkin(riskyken.armourersWorkshop.client.model.bake.ModelBakery.BakedSkin)

Example 2 with ISkinIdentifier

use of riskyken.armourersWorkshop.api.common.skin.data.ISkinIdentifier 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 3 with ISkinIdentifier

use of riskyken.armourersWorkshop.api.common.skin.data.ISkinIdentifier 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 4 with ISkinIdentifier

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

the class CommonSkinCache method processMessage.

private void processMessage(SkinRequestMessage queueMessage) {
    ISkinIdentifier identifier = queueMessage.getSkinIdentifier();
    EntityPlayerMP player = queueMessage.getPlayer();
    if (identifier.hasLocalId()) {
        sendLocalDatabaseSkinToClient(queueMessage);
    } else if (identifier.hasLibraryFile()) {
        sendLocalFileSkinToClient(queueMessage);
    } else if (identifier.hasGlobalId()) {
        sendGlobalDatabaseSkinToClient(queueMessage);
    } else {
        ModLogger.log(Level.ERROR, "Player " + player.getCommandSenderName() + " requested a skin with no vaid ID:" + identifier.toString());
    }
}
Also used : ISkinIdentifier(riskyken.armourersWorkshop.api.common.skin.data.ISkinIdentifier) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Example 5 with ISkinIdentifier

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

the class CommonSkinCache method getFullIdentifier.

public SkinIdentifier getFullIdentifier(Skin skin, ISkinIdentifier skinIdentifier) {
    int localId = skin.lightHash();
    ISkinType skinType = skin.getSkinType();
    ILibraryFile libraryFile = null;
    int globalId = 0;
    try {
        if (cacheLocalFile.containsValue(skin.lightHash())) {
            libraryFile = cacheLocalFile.getBackward(skin.lightHash());
        }
        if (cacheGlobal.containsValue(skin.lightHash())) {
            globalId = cacheGlobal.getBackward(skin.lightHash());
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return new SkinIdentifier(localId, libraryFile, globalId, skinType);
}
Also used : ISkinType(riskyken.armourersWorkshop.api.common.skin.type.ISkinType) ILibraryFile(riskyken.armourersWorkshop.api.common.library.ILibraryFile) ISkinIdentifier(riskyken.armourersWorkshop.api.common.skin.data.ISkinIdentifier) SkinIdentifier(riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)

Aggregations

ISkinIdentifier (riskyken.armourersWorkshop.api.common.skin.data.ISkinIdentifier)7 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)5 BakedSkin (riskyken.armourersWorkshop.client.model.bake.ModelBakery.BakedSkin)3 SkinIdentifier (riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)3 ILibraryFile (riskyken.armourersWorkshop.api.common.library.ILibraryFile)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 ISkinType (riskyken.armourersWorkshop.api.common.skin.type.ISkinType)1