Search in sources :

Example 11 with SkinIdentifier

use of riskyken.armourersWorkshop.common.skin.data.SkinIdentifier in project Armourers-Workshop by RiskyKen.

the class CommonSkinCache method sendSkinToClient.

private void sendSkinToClient(Skin skin, SkinRequestMessage requestMessage) {
    SkinIdentifier requestIdentifier = (SkinIdentifier) requestMessage.getSkinIdentifier();
    skin.requestId = requestIdentifier;
    PacketHandler.networkWrapper.sendTo(new MessageServerSendSkinData(requestIdentifier, getFullIdentifier(skin, requestIdentifier), skin), requestMessage.getPlayer());
}
Also used : MessageServerSendSkinData(riskyken.armourersWorkshop.common.network.messages.server.MessageServerSendSkinData) ISkinIdentifier(riskyken.armourersWorkshop.api.common.skin.data.ISkinIdentifier) SkinIdentifier(riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)

Example 12 with SkinIdentifier

use of riskyken.armourersWorkshop.common.skin.data.SkinIdentifier in project Armourers-Workshop by RiskyKen.

the class CommonSkinCache method getFullIdentifier.

public SkinIdentifier getFullIdentifier(Skin skin, ISkinIdentifier skinIdentifier) {
    int localId = skin.lightHash();
    ISkinType skinType = skin.getSkinType();
    ILibraryFile libraryFile = null;
    int globalId = 0;
    try {
        if (cacheLocalFile.containsValue(skin.lightHash())) {
            libraryFile = cacheLocalFile.getBackward(skin.lightHash());
        }
        if (cacheGlobal.containsValue(skin.lightHash())) {
            globalId = cacheGlobal.getBackward(skin.lightHash());
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return new SkinIdentifier(localId, libraryFile, globalId, skinType);
}
Also used : ISkinType(riskyken.armourersWorkshop.api.common.skin.type.ISkinType) ILibraryFile(riskyken.armourersWorkshop.api.common.library.ILibraryFile) ISkinIdentifier(riskyken.armourersWorkshop.api.common.skin.data.ISkinIdentifier) SkinIdentifier(riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)

Example 13 with SkinIdentifier

use of riskyken.armourersWorkshop.common.skin.data.SkinIdentifier in project Armourers-Workshop by RiskyKen.

the class ItemSkin method addTooltipToSkinItem.

public static void addTooltipToSkinItem(ItemStack stack, EntityPlayer player, List tooltip, boolean showAdvancedItemTooltips) {
    String cRed = EnumChatFormatting.RED.toString();
    boolean isEquipmentSkin = stack.getItem() == ModItems.equipmentSkin;
    boolean isEquipmentContainer = stack.getItem() instanceof AbstractModItemArmour;
    if (SkinNBTHelper.stackHasSkinData(stack)) {
        SkinPointer skinData = SkinNBTHelper.getSkinPointerFromStack(stack);
        SkinIdentifier identifier = skinData.getIdentifier();
        if (!isEquipmentSkin & !skinData.lockSkin & !isEquipmentContainer) {
            return;
        }
        if (!isEquipmentSkin) {
            tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.hasSkin"));
        }
        if (ClientSkinCache.INSTANCE.isSkinInCache(skinData)) {
            Skin data = ClientSkinCache.INSTANCE.getSkin(skinData);
            if (stack.getItem() != ModItems.equipmentSkin & !data.getCustomName().trim().isEmpty()) {
                tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinName", data.getCustomName()));
            }
            if (!data.getAuthorName().trim().isEmpty()) {
                tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinAuthor", data.getAuthorName()));
            }
            if (skinData.getIdentifier().getSkinType() != null) {
                String localSkinName = SkinTypeRegistry.INSTANCE.getLocalizedSkinTypeName(skinData.getIdentifier().getSkinType());
                tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinType", localSkinName));
            }
            if (ConfigHandlerClient.showSkinTooltipDebugInfo) {
                if (GuiScreen.isShiftKeyDown()) {
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinIdentifier"));
                    if (identifier.hasLocalId()) {
                        tooltip.add("  " + TranslateUtils.translate("item.armourersworkshop:rollover.skinId", identifier.getSkinLocalId()));
                    }
                    if (identifier.hasLibraryFile()) {
                        tooltip.add("  " + TranslateUtils.translate("item.armourersworkshop:rollover.skinLibraryFile", identifier.getSkinLibraryFile().getFullName()));
                    }
                    if (identifier.hasGlobalId()) {
                        tooltip.add("  " + TranslateUtils.translate("item.armourersworkshop:rollover.skinGlobalId", identifier.getSkinGlobalId()));
                    }
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinTotalCubes", data.getTotalCubes()));
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinNumCubes", data.getTotalOfCubeType(CubeRegistry.INSTANCE.getCubeFormId((byte) 0))));
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinNumCubesGlowing", data.getTotalOfCubeType(CubeRegistry.INSTANCE.getCubeFormId((byte) 1))));
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinNumCubesGlass", data.getTotalOfCubeType(CubeRegistry.INSTANCE.getCubeFormId((byte) 2))));
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinNumCubesGlassGlowing", data.getTotalOfCubeType(CubeRegistry.INSTANCE.getCubeFormId((byte) 3))));
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinPaintData", data.hasPaintData()));
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinMarkerCount", data.getMarkerCount()));
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinDyeCount", skinData.getSkinDye().getNumberOfDyes()));
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinProperties"));
                    ArrayList<String> props = data.getProperties().getPropertiesList();
                    for (int i = 0; i < props.size(); i++) {
                        tooltip.add("  " + props.get(i));
                    }
                } else {
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinHoldShiftForInfo"));
                }
            }
            if (identifier.hasLocalId()) {
                if (identifier.getSkinLocalId() != data.lightHash()) {
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinIdError1"));
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinIdError2"));
                    tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinIdError3", data.requestId, data.lightHash()));
                }
            }
        } else {
            tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skindownloading", identifier.toString()));
            if (identifier.hasLocalId()) {
                tooltip.add("  " + TranslateUtils.translate("item.armourersworkshop:rollover.skinId", identifier.getSkinLocalId()));
            }
            if (identifier.hasLibraryFile()) {
                tooltip.add("  " + TranslateUtils.translate("item.armourersworkshop:rollover.skinLibraryFile", identifier.getSkinLibraryFile().getFullName()));
            }
            if (identifier.hasGlobalId()) {
                tooltip.add("  " + TranslateUtils.translate("item.armourersworkshop:rollover.skinGlobalId", identifier.getSkinGlobalId()));
            }
        }
        String keyName = Keyboard.getKeyName(Keybindings.openCustomArmourGui.getKeyCode());
        if (isEquipmentSkin) {
            tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinOpenWardrobe", keyName));
        }
    } else {
        if (SkinNBTHelper.stackHasLegacySkinData(stack)) {
            tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinOldType"));
        } else {
            if (isEquipmentSkin) {
                tooltip.add(TranslateUtils.translate("item.armourersworkshop:rollover.skinInvalidItem"));
            }
        }
    }
}
Also used : SkinPointer(riskyken.armourersWorkshop.common.skin.data.SkinPointer) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) SkinIdentifier(riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)

Example 14 with SkinIdentifier

use of riskyken.armourersWorkshop.common.skin.data.SkinIdentifier in project Armourers-Workshop by RiskyKen.

the class SkinUploadHelper method uploadSkinToServer.

public static void uploadSkinToServer(Skin skin) {
    if (!ConfigHandler.allowClientsToUploadSkins) {
        return;
    }
    skin.requestId = new SkinIdentifier(skin);
    ModLogger.log("Uploading skin to server: " + skin);
    byte[] skinData = ByteBufHelper.convertSkinToByteArray(skin);
    ArrayList<MessageClientSkinPart> packetQueue = new ArrayList<MessageClientSkinPart>();
    int packetsNeeded = (int) Math.ceil((double) skinData.length / (double) MAX_PACKET_SIZE);
    int bytesLeftToSend = skinData.length;
    int bytesSent = 0;
    for (int i = 0; i < packetsNeeded; i++) {
        boolean lastPacket = i == packetsNeeded - 1;
        byte[] messageData;
        if (lastPacket) {
            messageData = new byte[bytesLeftToSend];
        } else {
            messageData = new byte[MAX_PACKET_SIZE];
        }
        System.arraycopy(skinData, bytesSent, messageData, 0, messageData.length);
        MessageClientSkinPart skinMessage = new MessageClientSkinPart(skin.lightHash(), (byte) i, messageData);
        packetQueue.add(skinMessage);
        bytesLeftToSend -= messageData.length;
        bytesSent += messageData.length;
    }
    for (int i = 0; i < packetQueue.size(); i++) {
        PacketHandler.networkWrapper.sendToServer(packetQueue.get(i));
    }
}
Also used : MessageClientSkinPart(riskyken.armourersWorkshop.common.network.messages.client.MessageClientSkinPart) ArrayList(java.util.ArrayList) SkinIdentifier(riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)

Example 15 with SkinIdentifier

use of riskyken.armourersWorkshop.common.skin.data.SkinIdentifier in project Armourers-Workshop by RiskyKen.

the class MessageServerLibrarySendSkin method toBytes.

@Override
public void toBytes(ByteBuf buf) {
    if (fileName != null) {
        buf.writeBoolean(true);
        ByteBufUtils.writeUTF8String(buf, this.fileName);
    } else {
        buf.writeBoolean(false);
    }
    if (filePath != null) {
        buf.writeBoolean(true);
        ByteBufUtils.writeUTF8String(buf, this.filePath);
    } else {
        buf.writeBoolean(false);
    }
    skin.requestId = new SkinIdentifier(skin);
    ByteBufHelper.writeSkinToByteBuf(buf, skin);
    buf.writeByte(sendType.ordinal());
}
Also used : SkinIdentifier(riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)

Aggregations

SkinIdentifier (riskyken.armourersWorkshop.common.skin.data.SkinIdentifier)21 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)10 ItemStack (net.minecraft.item.ItemStack)8 LibraryFile (riskyken.armourersWorkshop.common.library.LibraryFile)8 SkinPointer (riskyken.armourersWorkshop.common.skin.data.SkinPointer)7 ISkinIdentifier (riskyken.armourersWorkshop.api.common.skin.data.ISkinIdentifier)6 ISkinType (riskyken.armourersWorkshop.api.common.skin.type.ISkinType)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 ILibraryFile (riskyken.armourersWorkshop.api.common.library.ILibraryFile)3 Color (java.awt.Color)2 WrongUsageException (net.minecraft.command.WrongUsageException)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 SkinDye (riskyken.armourersWorkshop.common.skin.data.SkinDye)2 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 GuiButton (net.minecraft.client.gui.GuiButton)1 ScaledResolution (net.minecraft.client.gui.ScaledResolution)1 EntityItem (net.minecraft.entity.item.EntityItem)1 Slot (net.minecraft.inventory.Slot)1