use of riskyken.armourersWorkshop.common.skin.data.SkinIdentifier 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);
}
use of riskyken.armourersWorkshop.common.skin.data.SkinIdentifier in project Armourers-Workshop by RiskyKen.
the class SkinIdentifierSerializer method readFromCompound.
public static SkinIdentifier readFromCompound(NBTTagCompound compound) {
int localId = 0;
ILibraryFile libraryFile = null;
int globalId = 0;
ISkinType skinType = null;
NBTTagCompound idDataCompound = compound.getCompoundTag(TAG_SKIN_ID_DATA);
localId = idDataCompound.getInteger(TAG_SKIN_LOCAL_ID);
if (idDataCompound.hasKey(TAG_SKIN_LIBRARY_FILE, NBT.TAG_STRING)) {
libraryFile = new LibraryFile(idDataCompound.getString(TAG_SKIN_LIBRARY_FILE));
}
globalId = idDataCompound.getInteger(TAG_SKIN_GLOBAL_ID);
skinType = SkinTypeRegistry.INSTANCE.getSkinTypeFromRegistryName(idDataCompound.getString(TAG_SKIN_TYPE));
if (compound.hasKey(TAG_SKIN_OLD_ID, NBT.TAG_INT)) {
localId = compound.getInteger(TAG_SKIN_OLD_ID);
}
if (compound.hasKey(TAG_SKIN_TYPE, NBT.TAG_STRING)) {
skinType = SkinTypeRegistry.INSTANCE.getSkinTypeFromRegistryName(compound.getString(TAG_SKIN_TYPE));
}
return new SkinIdentifier(localId, libraryFile, globalId, skinType);
}
use of riskyken.armourersWorkshop.common.skin.data.SkinIdentifier in project Armourers-Workshop by RiskyKen.
the class EntitySkinHandler method giveRandomSkin.
public void giveRandomSkin(ExPropsEntityEquipmentData entityEquipmentData) {
if (entityEquipmentData == null) {
return;
}
if (ConfigHandler.enitiySpawnWithSkinsChance <= 0) {
return;
}
ArrayList<ISkinType> skinTypes = entityEquipmentData.getSkinInventory().getSkinTypes();
for (int i = 0; i < skinTypes.size(); i++) {
int rnd = entityEquipmentData.getEntity().worldObj.rand.nextInt(99) + 1;
if (rnd >= ConfigHandler.enitiySpawnWithSkinsChance) {
continue;
}
ISkinType skinType = skinTypes.get(i);
LibraryFile libraryFile = getRandomSkinOfType(skinType);
if (libraryFile == null) {
continue;
}
SkinIdentifier identifier = new SkinIdentifier(0, libraryFile, 0, skinType);
ItemStack skinStack = SkinNBTHelper.makeEquipmentSkinStack(new SkinPointer(identifier));
if (skinStack == null) {
continue;
}
entityEquipmentData.getSkinInventory().setInventorySlotContents(i, skinStack);
}
}
use of riskyken.armourersWorkshop.common.skin.data.SkinIdentifier in project Armourers-Workshop by RiskyKen.
the class TileEntitySkinLibrary method loadArmour.
/**
* Loads an armour file from the disk and adds it to an items NBT data.
* @param filePath
* @param filename The name of the file to load.
* @param player The player that pressed the load button.
*/
public void loadArmour(String fileName, String filePath, EntityPlayerMP player, boolean trackFile) {
ItemStack stackInput = getStackInSlot(0);
ItemStack stackOutput = getStackInSlot(1);
if (!isCreativeLibrary()) {
if (stackInput == null) {
return;
}
}
if (stackOutput != null) {
return;
}
if (!isCreativeLibrary()) {
if (!(stackInput.getItem() instanceof ISkinHolder)) {
return;
}
}
Skin skin = null;
String fullFileName = fileName;
skin = SkinIOUtils.loadSkinFromFileName(filePath + fileName + SkinIOUtils.SKIN_FILE_EXTENSION);
if (skin == null) {
return;
}
LibraryFile libraryFile = new LibraryFile(fileName, filePath, skin.getSkinType());
SkinIdentifier identifier = null;
if (trackFile) {
identifier = new SkinIdentifier(0, libraryFile, 0, skin.getSkinType());
} else {
identifier = new SkinIdentifier(skin.lightHash(), null, 0, skin.getSkinType());
}
// TODO Set master using trackFile
CommonSkinCache.INSTANCE.addEquipmentDataToCache(skin, libraryFile);
ModLogger.log("Loaded file form lib: " + libraryFile.toString());
ItemStack stackArmour = SkinNBTHelper.makeEquipmentSkinStack(skin, identifier);
if (stackArmour == null) {
return;
}
if (!isCreativeLibrary()) {
this.decrStackSize(0, 1);
}
this.setInventorySlotContents(1, stackArmour);
}
use of riskyken.armourersWorkshop.common.skin.data.SkinIdentifier in project Armourers-Workshop by RiskyKen.
the class ClientSkinCache method receivedModelFromBakery.
public void receivedModelFromBakery(BakedSkin bakedSkin) {
SkinIdentifier identifierRequested = bakedSkin.getSkinIdentifierRequested();
synchronized (requestedSkinIDs) {
synchronized (skinIDMap) {
if (skinIDMap.containsKey(identifierRequested)) {
// We already have this skin, remove the old one before adding the new one.
Skin oldSkin = skinIDMap.get(identifierRequested);
skinIDMap.remove(identifierRequested);
oldSkin.cleanUpDisplayLists();
ModLogger.log("removing skin");
}
if (requestedSkinIDs.contains(identifierRequested)) {
skinIDMap.put(identifierRequested, bakedSkin.getSkin());
requestedSkinIDs.remove(identifierRequested);
} else {
// We did not request this skin.
skinIDMap.put(bakedSkin.getSkinIdentifierUpdated(), bakedSkin.getSkin());
ModLogger.log(Level.WARN, "Got an unknown skin - Identifier: " + bakedSkin.getSkinIdentifierUpdated().toString());
}
}
}
}
Aggregations