use of riskyken.armourersWorkshop.common.skin.data.SkinPointer in project Armourers-Workshop by RiskyKen.
the class ExPropsEntityEquipmentData method setInventorySlotContents.
@Override
public void setInventorySlotContents(IInventory inventory, int slotId, ItemStack stack) {
if (entity.worldObj.isRemote) {
return;
}
if (stack == null) {
ISkinType skinType = getSkinTypeForSlot(slotId);
equipmentData.removeEquipment(skinType, 0);
} else {
SkinPointer skinData = SkinNBTHelper.getSkinPointerFromStack(stack);
equipmentData.addEquipment(skinData.getIdentifier().getSkinType(), 0, skinData);
}
sendEquipmentDataToPlayerToAllPlayersAround();
}
use of riskyken.armourersWorkshop.common.skin.data.SkinPointer in project Armourers-Workshop by RiskyKen.
the class TileEntitySkinLibrary method sendArmourToClient.
public void sendArmourToClient(String filename, String filePath, EntityPlayerMP player) {
if (!ConfigHandler.allowClientsToDownloadSkins) {
return;
}
ItemStack stackInput = getStackInSlot(0);
ItemStack stackOutput = getStackInSlot(1);
if (stackInput == null) {
return;
}
if (stackOutput != null) {
return;
}
if (!(stackInput.getItem() instanceof ItemSkin)) {
return;
}
if (!SkinNBTHelper.stackHasSkinData(stackInput)) {
return;
}
SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(stackInput);
Skin skin = CommonSkinCache.INSTANCE.getSkin(skinPointer);
if (skin == null) {
return;
}
LibraryFile file = new LibraryFile(filename, filePath, skin.getSkinType());
// if the file was overwritten remove it's old id link
CommonSkinCache.INSTANCE.clearFileNameIdLink(file);
// ModLogger.log(file.getFullName());
MessageServerLibrarySendSkin message = new MessageServerLibrarySendSkin(filename, filePath, skin, SendType.LIBRARY_SAVE);
PacketHandler.networkWrapper.sendTo(message, player);
this.decrStackSize(0, 1);
this.setInventorySlotContents(1, stackInput);
}
use of riskyken.armourersWorkshop.common.skin.data.SkinPointer in project Armourers-Workshop by RiskyKen.
the class SkinNBTHelper method getSkinIdFromStack.
public static int getSkinIdFromStack(ItemStack stack) {
if (!stackHasSkinData(stack)) {
return -1;
}
SkinPointer skinData = new SkinPointer();
skinData.readFromCompound(stack.getTagCompound());
return skinData.getIdentifier().getSkinLocalId();
}
use of riskyken.armourersWorkshop.common.skin.data.SkinPointer in project Armourers-Workshop by RiskyKen.
the class SkinNBTHelper method getSkinTypeFromStack.
public static ISkinType getSkinTypeFromStack(ItemStack stack) {
if (!stackHasSkinData(stack)) {
return null;
}
SkinPointer skinData = new SkinPointer();
skinData.readFromCompound(stack.getTagCompound());
return skinData.getIdentifier().getSkinType();
}
use of riskyken.armourersWorkshop.common.skin.data.SkinPointer in project Armourers-Workshop by RiskyKen.
the class SkinNBTHelper method removeSkinDataFromStack.
public static void removeSkinDataFromStack(ItemStack stack, boolean overrideLock) {
if (!stackHasSkinData(stack)) {
return;
}
SkinPointer skinData = getSkinPointerFromStack(stack);
if (skinData.lockSkin) {
if (!overrideLock) {
return;
}
}
NBTTagCompound itemCompound = stack.getTagCompound();
if (itemCompound.hasKey(SkinPointer.TAG_SKIN_DATA)) {
itemCompound.removeTag(SkinPointer.TAG_SKIN_DATA);
}
}
Aggregations