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