use of riskyken.armourersWorkshop.common.network.messages.server.MessageServerLibrarySendSkin 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.network.messages.server.MessageServerLibrarySendSkin in project Armourers-Workshop by RiskyKen.
the class ContainerGlobalSkinLibrary method buttonPressed.
@Override
public void buttonPressed(byte buttonId) {
if (buttonId == 0) {
if (!tileEntity.getWorldObj().isRemote) {
if (!getSlot(37).getHasStack()) {
ItemStack itemStack = getSlot(36).getStack();
SkinPointer skinPointer = SkinNBTHelper.getSkinPointerFromStack(itemStack);
if (skinPointer != null) {
Skin skin = CommonSkinCache.INSTANCE.getSkin(skinPointer);
if (skin != null) {
onSkinUploaded();
MessageServerLibrarySendSkin message = new MessageServerLibrarySendSkin(null, null, skin, SendType.GLOBAL_UPLOAD);
PacketHandler.networkWrapper.sendTo(message, (EntityPlayerMP) player);
}
}
}
}
}
}
Aggregations