Search in sources :

Example 1 with MessageServerLibrarySendSkin

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);
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) ItemSkin(riskyken.armourersWorkshop.common.items.ItemSkin) ItemSkin(riskyken.armourersWorkshop.common.items.ItemSkin) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) MessageServerLibrarySendSkin(riskyken.armourersWorkshop.common.network.messages.server.MessageServerLibrarySendSkin) MessageServerLibrarySendSkin(riskyken.armourersWorkshop.common.network.messages.server.MessageServerLibrarySendSkin) LibraryFile(riskyken.armourersWorkshop.common.library.LibraryFile) ItemStack(net.minecraft.item.ItemStack)

Example 2 with MessageServerLibrarySendSkin

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);
                    }
                }
            }
        }
    }
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) MessageServerLibrarySendSkin(riskyken.armourersWorkshop.common.network.messages.server.MessageServerLibrarySendSkin) MessageServerLibrarySendSkin(riskyken.armourersWorkshop.common.network.messages.server.MessageServerLibrarySendSkin) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemStack (net.minecraft.item.ItemStack)2 MessageServerLibrarySendSkin (riskyken.armourersWorkshop.common.network.messages.server.MessageServerLibrarySendSkin)2 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)2 SkinPointer (riskyken.armourersWorkshop.common.skin.data.SkinPointer)2 ItemSkin (riskyken.armourersWorkshop.common.items.ItemSkin)1 LibraryFile (riskyken.armourersWorkshop.common.library.LibraryFile)1