use of riskyken.armourersWorkshop.common.skin.ISkinHolder 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.ISkinHolder in project Armourers-Workshop by RiskyKen.
the class TileEntitySkinLibrary method loadArmour.
public void loadArmour(Skin skin, EntityPlayerMP player) {
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;
}
}
ItemStack inputItem = SkinNBTHelper.makeEquipmentSkinStack(skin);
if (inputItem == null) {
return;
}
CommonSkinCache.INSTANCE.addEquipmentDataToCache(skin, (LibraryFile) null);
this.decrStackSize(0, 1);
this.setInventorySlotContents(1, inputItem);
}
use of riskyken.armourersWorkshop.common.skin.ISkinHolder in project Armourers-Workshop by RiskyKen.
the class TileEntityArmourer method saveArmourItem.
/**
* Get blocks in the world and saved them onto an items NBT data.
* @param player The player that pressed the save button.
* @param name Custom name for the item.
*/
public void saveArmourItem(EntityPlayerMP player, String customName, String tags) {
if (getWorldObj().isRemote) {
return;
}
ItemStack stackInput = getStackInSlot(0);
ItemStack stackOutput = getStackInSlot(1);
if (stackInput == null) {
return;
}
if (stackOutput != null) {
return;
}
if (!(stackInput.getItem() instanceof ISkinHolder)) {
return;
}
ISkinHolder inputItem = (ISkinHolder) stackInput.getItem();
Skin armourItemData = null;
SkinProperties skinProps = new SkinProperties();
skinProps.setProperty(Skin.KEY_AUTHOR_NAME, player.getCommandSenderName());
if (player.getGameProfile() != null && player.getGameProfile().getId() != null) {
skinProps.setProperty(Skin.KEY_AUTHOR_UUID, player.getGameProfile().getId().toString());
}
skinProps.setProperty(Skin.KEY_CUSTOM_NAME, customName);
for (int i = 0; i < skinType.getProperties().size(); i++) {
SkinProperty skinProp = (SkinProperty) skinType.getProperties().get(i);
skinProp.setValue(skinProps, skinProp.getValue(this.skinProps));
}
try {
armourItemData = ArmourerWorldHelper.saveSkinFromWorld(worldObj, skinProps, skinType, paintData, xCoord, yCoord + HEIGHT_OFFSET, zCoord, direction);
} catch (SkinSaveException e) {
switch(e.getType()) {
case NO_DATA:
player.addChatMessage(new ChatComponentText(e.getMessage()));
break;
case MARKER_ERROR:
player.addChatMessage(new ChatComponentText(e.getMessage()));
break;
case MISSING_PARTS:
player.addChatMessage(new ChatComponentText(e.getMessage()));
break;
case BED_AND_SEAT:
player.addChatMessage(new ChatComponentText(e.getMessage()));
break;
case INVALID_MULTIBLOCK:
player.addChatMessage(new ChatComponentText(e.getMessage()));
break;
}
}
if (armourItemData == null) {
return;
}
CommonSkinCache.INSTANCE.addEquipmentDataToCache(armourItemData, (LibraryFile) null);
stackOutput = inputItem.makeStackForEquipment(armourItemData);
if (stackOutput == null) {
return;
}
this.decrStackSize(0, 1);
setInventorySlotContents(1, stackOutput);
}
Aggregations