Search in sources :

Example 1 with TileEntitySkinLibrary

use of riskyken.armourersWorkshop.common.tileentities.TileEntitySkinLibrary in project Armourers-Workshop by RiskyKen.

the class MessageClientGuiLoadSaveArmour method onMessage.

@Override
public IMessage onMessage(MessageClientGuiLoadSaveArmour message, MessageContext ctx) {
    EntityPlayerMP player = ctx.getServerHandler().playerEntity;
    if (player == null) {
        return null;
    }
    Container container = player.openContainer;
    if (container != null && container instanceof ContainerArmourLibrary) {
        TileEntitySkinLibrary te = ((ContainerArmourLibrary) container).getTileEntity();
        switch(message.packetType) {
            case CLIENT_SAVE:
                te.sendArmourToClient(message.filename, message.filePath, player);
                break;
            case SERVER_LOAD:
                te.loadArmour(message.filename, message.filePath, player, message.trackFile);
                break;
            case SERVER_SAVE:
                te.saveArmour(message.filename, message.filePath, player, message.publicList);
                break;
            default:
                break;
        }
    }
    return null;
}
Also used : ContainerArmourLibrary(riskyken.armourersWorkshop.common.inventory.ContainerArmourLibrary) TileEntitySkinLibrary(riskyken.armourersWorkshop.common.tileentities.TileEntitySkinLibrary) Container(net.minecraft.inventory.Container) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Example 2 with TileEntitySkinLibrary

use of riskyken.armourersWorkshop.common.tileentities.TileEntitySkinLibrary in project Armourers-Workshop by RiskyKen.

the class SkinUploadHelper method gotSkinPartFromClient.

public static void gotSkinPartFromClient(int skinId, byte packetId, byte[] skinData, EntityPlayerMP player) {
    boolean lastPacket = skinData.length < MAX_PACKET_SIZE;
    byte[] oldSkinData = unfinishedSkins.get(skinId);
    byte[] newSkinData = null;
    if (oldSkinData != null) {
        newSkinData = ArrayUtils.addAll(oldSkinData, skinData);
        unfinishedSkins.remove(skinId);
    } else {
        newSkinData = skinData;
    }
    if (!lastPacket) {
        unfinishedSkins.put(skinId, newSkinData);
    } else {
        Skin skin = ByteBufHelper.convertByteArrayToSkin(newSkinData);
        ModLogger.log("Downloaded skin " + skin + " from client " + player);
        Container container = player.openContainer;
        if (!ConfigHandler.allowClientsToUploadSkins) {
            return;
        }
        if (container != null && container instanceof ContainerArmourLibrary) {
            TileEntitySkinLibrary te = ((ContainerArmourLibrary) container).getTileEntity();
            te.loadArmour(skin, player);
        }
    }
}
Also used : ContainerArmourLibrary(riskyken.armourersWorkshop.common.inventory.ContainerArmourLibrary) TileEntitySkinLibrary(riskyken.armourersWorkshop.common.tileentities.TileEntitySkinLibrary) Container(net.minecraft.inventory.Container) Skin(riskyken.armourersWorkshop.common.skin.data.Skin)

Aggregations

Container (net.minecraft.inventory.Container)2 ContainerArmourLibrary (riskyken.armourersWorkshop.common.inventory.ContainerArmourLibrary)2 TileEntitySkinLibrary (riskyken.armourersWorkshop.common.tileentities.TileEntitySkinLibrary)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)1