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());
}
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);
}
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"));
}
}
}
}
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));
}
}
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());
}
Aggregations