diff --git a/api/src/main/java/com/lunarclient/apollo/common/icon/CustomModelData.java b/api/src/main/java/com/lunarclient/apollo/common/icon/CustomModelData.java new file mode 100644 index 00000000..87293405 --- /dev/null +++ b/api/src/main/java/com/lunarclient/apollo/common/icon/CustomModelData.java @@ -0,0 +1,79 @@ +/* + * This file is part of Apollo, licensed under the MIT License. + * + * Copyright (c) 2026 Moonsworth + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package com.lunarclient.apollo.common.icon; + +import java.util.Collections; +import java.util.List; +import lombok.Builder; +import lombok.Getter; + +/** + * Represents the custom model data attached to an {@link ItemStackIcon}. + * + *

Mirrors the Minecraft 1.21.4 {@code CustomModelData} item component, which + * replaced the single integer value with four parallel lists.

+ * + * @since 1.2.7 + */ +@Getter +@Builder +public final class CustomModelData { + + /** + * Returns the custom model data {@link Float} values. + * + * @return the custom model data floats + * @since 1.2.7 + */ + @Builder.Default + List floats = Collections.emptyList(); + + /** + * Returns the custom model data {@link Boolean} flags. + * + * @return the custom model data flags + * @since 1.2.7 + */ + @Builder.Default + List flags = Collections.emptyList(); + + /** + * Returns the custom model data {@link String} values. + * + * @return the custom model data strings + * @since 1.2.7 + */ + @Builder.Default + List strings = Collections.emptyList(); + + /** + * Returns the custom model data color {@link Integer} values. + * + * @return the custom model data colors + * @since 1.2.7 + */ + @Builder.Default + List colors = Collections.emptyList(); + +} diff --git a/api/src/main/java/com/lunarclient/apollo/common/icon/ItemStackIcon.java b/api/src/main/java/com/lunarclient/apollo/common/icon/ItemStackIcon.java index 2df8cb7f..3913eee7 100644 --- a/api/src/main/java/com/lunarclient/apollo/common/icon/ItemStackIcon.java +++ b/api/src/main/java/com/lunarclient/apollo/common/icon/ItemStackIcon.java @@ -57,10 +57,20 @@ public final class ItemStackIcon extends Icon { * Returns the icon {@link Integer} custom model data. * * @return the icon custom model data + * @deprecated for removal since 1.2.7, use {@link ItemStackIcon#customModelDataObject} instead. * @since 1.0.7 */ + @Deprecated int customModelData; + /** + * Returns the icon {@link CustomModelData} object. + * + * @return the icon custom model data object + * @since 1.2.7 + */ + @Nullable CustomModelData customModelDataObject; + /** * Returns the icon {@link Profile}. * diff --git a/common/src/main/java/com/lunarclient/apollo/network/NetworkTypes.java b/common/src/main/java/com/lunarclient/apollo/network/NetworkTypes.java index 1bc39264..00cb3c65 100644 --- a/common/src/main/java/com/lunarclient/apollo/network/NetworkTypes.java +++ b/common/src/main/java/com/lunarclient/apollo/network/NetworkTypes.java @@ -28,6 +28,7 @@ import com.lunarclient.apollo.common.cuboid.Cuboid2D; import com.lunarclient.apollo.common.cuboid.Cuboid3D; import com.lunarclient.apollo.common.icon.AdvancedResourceLocationIcon; +import com.lunarclient.apollo.common.icon.CustomModelData; import com.lunarclient.apollo.common.icon.Icon; import com.lunarclient.apollo.common.icon.ItemStackIcon; import com.lunarclient.apollo.common.icon.ResourceLocationIcon; @@ -577,6 +578,11 @@ public static com.lunarclient.apollo.common.v1.ItemStackIcon toProtobuf(ItemStac .setItemId(icon.getItemId()) .setCustomModelData(icon.getCustomModelData()); + CustomModelData customModelData = icon.getCustomModelDataObject(); + if (customModelData != null) { + builder.setCustomModelDataObject(NetworkTypes.toProtobuf(customModelData)); + } + if (icon.getItemName() != null) { builder.setItemName(icon.getItemName()); } @@ -602,6 +608,10 @@ public static ItemStackIcon fromProtobuf(com.lunarclient.apollo.common.v1.ItemSt .itemId(icon.getItemId()) .customModelData(icon.getCustomModelData()); + if (icon.hasCustomModelDataObject()) { + builder.customModelDataObject(NetworkTypes.fromProtobuf(icon.getCustomModelDataObject())); + } + if (icon.hasProfile()) { builder.profile(NetworkTypes.fromProtobuf(icon.getProfile())); } @@ -609,6 +619,40 @@ public static ItemStackIcon fromProtobuf(com.lunarclient.apollo.common.v1.ItemSt return builder.build(); } + /** + * Converts a {@link CustomModelData} object to a + * {@link com.lunarclient.apollo.common.v1.CustomModelData} proto message. + * + * @param object the custom model data + * @return the proto custom model data message + * @since 1.2.7 + */ + public static com.lunarclient.apollo.common.v1.CustomModelData toProtobuf(CustomModelData object) { + return com.lunarclient.apollo.common.v1.CustomModelData.newBuilder() + .addAllFloats(object.getFloats()) + .addAllFlags(object.getFlags()) + .addAllStrings(object.getStrings()) + .addAllColors(object.getColors()) + .build(); + } + + /** + * Converts a {@link com.lunarclient.apollo.common.v1.CustomModelData} + * proto message to a {@link CustomModelData} object. + * + * @param message the custom model data message + * @return the custom model data object + * @since 1.2.7 + */ + public static CustomModelData fromProtobuf(com.lunarclient.apollo.common.v1.CustomModelData message) { + return CustomModelData.builder() + .floats(message.getFloatsList()) + .flags(message.getFlagsList()) + .strings(message.getStringsList()) + .colors(message.getColorsList()) + .build(); + } + /** * Converts a {@link Profile} object to a * {@link com.lunarclient.apollo.common.v1.Profile} proto message. diff --git a/docs/developers/lightweight/json/object-util.mdx b/docs/developers/lightweight/json/object-util.mdx index f60dbbfd..91d086f2 100644 --- a/docs/developers/lightweight/json/object-util.mdx +++ b/docs/developers/lightweight/json/object-util.mdx @@ -88,11 +88,11 @@ public static JsonObject createBlockLocationObject(@NotNull Location location) { Icon-related methods ```java -public static JsonObject createItemStackIconObject(@Nullable String itemName, int itemId, int customModelData) { - return JsonUtil.createItemStackIconObject(itemName, itemId, customModelData, null); +public static JsonObject createItemStackIconObject(@Nullable String itemName, int itemId) { + return JsonUtil.createItemStackIconObject(itemName, itemId, null, null); } -public static JsonObject createItemStackIconObject(@Nullable String itemName, int itemId, int customModelData, @Nullable JsonObject profile) { +public static JsonObject createItemStackIconObject(@Nullable String itemName, int itemId, @Nullable JsonObject customModelData, @Nullable JsonObject profile) { JsonObject itemIconObject = new JsonObject(); if (itemName != null) { itemIconObject.addProperty("item_name", itemName); @@ -100,7 +100,9 @@ public static JsonObject createItemStackIconObject(@Nullable String itemName, in itemIconObject.addProperty("item_id", itemId); } - itemIconObject.addProperty("custom_model_data", customModelData); + if (customModelData != null) { + itemIconObject.add("custom_model_data_object", customModelData); + } if (profile != null) { itemIconObject.add("profile", profile); @@ -111,6 +113,28 @@ public static JsonObject createItemStackIconObject(@Nullable String itemName, in return iconObject; } +public static JsonObject createCustomModelDataObject(List floats, List flags, List strings, List colors) { + JsonObject customModelDataObject = new JsonObject(); + + JsonArray floatsArray = new JsonArray(); + floats.forEach(floatsArray::add); + customModelDataObject.add("floats", floatsArray); + + JsonArray flagsArray = new JsonArray(); + flags.forEach(flagsArray::add); + customModelDataObject.add("flags", flagsArray); + + JsonArray stringsArray = new JsonArray(); + strings.forEach(stringsArray::add); + customModelDataObject.add("strings", stringsArray); + + JsonArray colorsArray = new JsonArray(); + colors.forEach(colorsArray::add); + customModelDataObject.add("colors", colorsArray); + + return customModelDataObject; +} + public static JsonObject createProfileObject(@Nullable UUID id, @NotNull String texture, @NotNull String signature) { JsonObject profileObject = new JsonObject(); if (id != null) { diff --git a/docs/developers/lightweight/protobuf.mdx b/docs/developers/lightweight/protobuf.mdx index c1129b9d..0d43206e 100644 --- a/docs/developers/lightweight/protobuf.mdx +++ b/docs/developers/lightweight/protobuf.mdx @@ -26,7 +26,7 @@ Available fields for each message, including their types, are available on the B com.lunarclient apollo-protos - 0.1.6 + 0.1.7 ``` @@ -41,7 +41,7 @@ Available fields for each message, including their types, are available on the B } dependencies { - api 'com.lunarclient:apollo-protos:0.1.6' + api 'com.lunarclient:apollo-protos:0.1.7' } ``` @@ -55,7 +55,7 @@ Available fields for each message, including their types, are available on the B } dependencies { - api("com.lunarclient:apollo-protos:0.1.6") + api("com.lunarclient:apollo-protos:0.1.7") } ``` diff --git a/docs/developers/lightweight/protobuf/object-util.mdx b/docs/developers/lightweight/protobuf/object-util.mdx index 7f5817b7..a7d410f1 100644 --- a/docs/developers/lightweight/protobuf/object-util.mdx +++ b/docs/developers/lightweight/protobuf/object-util.mdx @@ -97,19 +97,22 @@ public static Location toBukkitPlayerLocation(JsonObject message) { Icon-related methods ```java -public static ItemStackIcon createItemStackIconProto(@Nullable String itemName, int itemId, int customModelData) { - return ProtobufUtil.createItemStackIconProto(itemName, itemId, customModelData, null); +public static ItemStackIcon createItemStackIconProto(@Nullable String itemName, int itemId) { + return ProtobufUtil.createItemStackIconProto(itemName, itemId, null, null); } -public static ItemStackIcon createItemStackIconProto(@Nullable String itemName, int itemId, int customModelData, @Nullable Profile profile) { +public static ItemStackIcon createItemStackIconProto(@Nullable String itemName, int itemId, @Nullable CustomModelData customModelData, @Nullable Profile profile) { ItemStackIcon.Builder iconBuilder = ItemStackIcon.newBuilder() - .setItemId(itemId) - .setCustomModelData(customModelData); + .setItemId(itemId); if (itemName != null) { iconBuilder.setItemName(itemName); } + if (customModelData != null) { + iconBuilder.setCustomModelDataObject(customModelData); + } + if (profile != null) { iconBuilder.setProfile(profile); } @@ -117,6 +120,15 @@ public static ItemStackIcon createItemStackIconProto(@Nullable String itemName, return iconBuilder.build(); } +public static CustomModelData createCustomModelDataProto(List floats, List flags, List strings, List colors) { + return CustomModelData.newBuilder() + .addAllFloats(floats) + .addAllFlags(flags) + .addAllStrings(strings) + .addAllColors(colors) + .build(); +} + public static Profile createProfileProto(@Nullable UUID id, String texture, String signature) { Profile.Builder builder = Profile.newBuilder() .setTexture(texture) diff --git a/docs/developers/modules/cooldown.mdx b/docs/developers/modules/cooldown.mdx index 6c695fea..55fe092d 100644 --- a/docs/developers/modules/cooldown.mdx +++ b/docs/developers/modules/cooldown.mdx @@ -216,7 +216,7 @@ public void displayCooldownItemExample(Player viewer) { .setName("enderpearl-cooldown") .setDuration(ProtobufUtil.createDurationProto(Duration.ofSeconds(15))) .setIcon(Icon.newBuilder() - .setItemStack(ProtobufUtil.createItemStackIconProto("ENDER_PEARL", 0, 0)) + .setItemStack(ProtobufUtil.createItemStackIconProto("ENDER_PEARL", 0)) .build()) .build(); @@ -232,7 +232,7 @@ public void displayCooldownWithStyleExample(Player viewer) { .setName("book-cooldown") .setDuration(ProtobufUtil.createDurationProto(Duration.ofSeconds(30))) .setIcon(Icon.newBuilder() - .setItemStack(ProtobufUtil.createItemStackIconProto("BOOK", 0, 0)) + .setItemStack(ProtobufUtil.createItemStackIconProto("BOOK", 0)) .build()) .setStyle(CooldownStyle.newBuilder() .setCircleStartColor(ProtobufUtil.createColorProto(new Color(255, 85, 85))) // ApolloColors.RED @@ -255,7 +255,7 @@ public void displayCooldownWithPlayerTextureExample(Player viewer) { .setDuration(ProtobufUtil.createDurationProto(Duration.ofSeconds(15))) .setIcon(Icon.newBuilder() .setItemStack(ProtobufUtil.createItemStackIconProto( - "PLAYER_HEAD", 0, 0, + "PLAYER_HEAD", 0, null, ProtobufUtil.createProfileProto( UUID.fromString("f17627d8-1a97-487b-92ea-c04f413394bd"), "e3RleHR1cmVzOntTS0lOOnt1cmw6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWQ4MjUwNWJjZjNiYTU5YzJiZTdlMmQzNmY0ZTJiZGE4MzZmMmZkMTk0YjYyMTJhMmExYzRiNGEyYTQ3MWUifX19", @@ -322,7 +322,7 @@ public void displayCooldownItemExample(Player viewer) { message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.cooldown.v1.DisplayCooldownMessage"); message.addProperty("name", "enderpearl-cooldown"); message.addProperty("duration", JsonUtil.createDurationObject(Duration.ofSeconds(15))); - message.add("icon", JsonUtil.createItemStackIconObject("ENDER_PEARL", 0, 0)); + message.add("icon", JsonUtil.createItemStackIconObject("ENDER_PEARL", 0)); JsonPacketUtil.sendPacket(viewer, message); } @@ -336,7 +336,7 @@ public void displayCooldownWithStyleExample(Player viewer) { message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.cooldown.v1.DisplayCooldownMessage"); message.addProperty("name", "book-cooldown"); message.addProperty("duration", JsonUtil.createDurationObject(Duration.ofSeconds(30))); - message.add("icon", JsonUtil.createItemStackIconObject("BOOK", 0, 0)); + message.add("icon", JsonUtil.createItemStackIconObject("BOOK", 0)); JsonObject style = new JsonObject(); style.add("circle_start_color", JsonUtil.createColorObject(new Color(255, 85, 85))); // ApolloColors.RED @@ -358,7 +358,7 @@ public void displayCooldownWithPlayerTextureExample(Player viewer) { message.addProperty("name", "player-head-cooldown"); message.addProperty("duration", JsonUtil.createDurationObject(Duration.ofSeconds(15))); message.add("icon", JsonUtil.createItemStackIconObject( - "PLAYER_HEAD", 0, 0, + "PLAYER_HEAD", 0, null, JsonUtil.createProfileObject( UUID.fromString("f17627d8-1a97-487b-92ea-c04f413394bd"), "e3RleHR1cmVzOntTS0lOOnt1cmw6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWQ4MjUwNWJjZjNiYTU5YzJiZTdlMmQzNmY0ZTJiZGE4MzZmMmZkMTk0YjYyMTJhMmExYzRiNGEyYTQ3MWUifX19", diff --git a/docs/developers/utilities/icons.mdx b/docs/developers/utilities/icons.mdx index 1b1b488a..28eba917 100644 --- a/docs/developers/utilities/icons.mdx +++ b/docs/developers/utilities/icons.mdx @@ -35,12 +35,12 @@ public final class ItemStackIcon extends Icon { int itemId; /** - * Returns the icon {@link Integer} custom model data. + * Returns the icon {@link CustomModelData} object. * - * @return the icon custom model data - * @since 1.0.7 + * @return the icon custom model data object + * @since 1.2.7 */ - int customModelData; + @Nullable CustomModelData customModelDataObject; /** * Returns the icon {@link Profile}. @@ -53,6 +53,48 @@ public final class ItemStackIcon extends Icon { } ``` +## `CustomModelData` Builder + +The `CustomModelData` builder mirrors the Minecraft 1.21.4+ custom model data object. + +```java +public final class CustomModelData { + + /** + * Returns the custom model data {@link Float} values. + * + * @return the custom model data floats + * @since 1.2.7 + */ + List floats; + + /** + * Returns the custom model data {@link Boolean} flags. + * + * @return the custom model data flags + * @since 1.2.7 + */ + List flags; + + /** + * Returns the custom model data {@link String} values. + * + * @return the custom model data strings + * @since 1.2.7 + */ + List strings; + + /** + * Returns the custom model data color {@link Integer} values. + * + * @return the custom model data colors + * @since 1.2.7 + */ + List colors; + +} +``` + ### Sample Code ```java diff --git a/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/module/CooldownJsonExample.java b/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/module/CooldownJsonExample.java index 2b853532..22a04409 100644 --- a/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/module/CooldownJsonExample.java +++ b/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/module/CooldownJsonExample.java @@ -40,7 +40,7 @@ public void displayCooldownItemExample(Player viewer) { message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.cooldown.v1.DisplayCooldownMessage"); message.addProperty("name", "enderpearl-cooldown"); message.addProperty("duration", JsonUtil.createDurationObject(Duration.ofSeconds(15))); - message.add("icon", JsonUtil.createItemStackIconObject("ENDER_PEARL", 0, 0)); + message.add("icon", JsonUtil.createItemStackIconObject("ENDER_PEARL", 0)); JsonPacketUtil.sendPacket(viewer, message); } @@ -51,7 +51,7 @@ public void displayCooldownWithStyleExample(Player viewer) { message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.cooldown.v1.DisplayCooldownMessage"); message.addProperty("name", "book-cooldown"); message.addProperty("duration", JsonUtil.createDurationObject(Duration.ofSeconds(30))); - message.add("icon", JsonUtil.createItemStackIconObject("BOOK", 0, 0)); + message.add("icon", JsonUtil.createItemStackIconObject("BOOK", 0)); JsonObject style = new JsonObject(); style.add("circle_start_color", JsonUtil.createColorObject(new Color(255, 85, 85))); // ApolloColors.RED @@ -70,7 +70,7 @@ public void displayCooldownWithPlayerTextureExample(Player viewer) { message.addProperty("name", "player-head-cooldown"); message.addProperty("duration", JsonUtil.createDurationObject(Duration.ofSeconds(15))); message.add("icon", JsonUtil.createItemStackIconObject( - "PLAYER_HEAD", 0, 0, + "PLAYER_HEAD", 0, null, JsonUtil.createProfileObject( UUID.fromString("f17627d8-1a97-487b-92ea-c04f413394bd"), "e3RleHR1cmVzOntTS0lOOnt1cmw6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWQ4MjUwNWJjZjNiYTU5YzJiZTdlMmQzNmY0ZTJiZGE4MzZmMmZkMTk0YjYyMTJhMmExYzRiNGEyYTQ3MWUifX19", diff --git a/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/util/JsonUtil.java b/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/util/JsonUtil.java index 694ce2f4..07d452ed 100644 --- a/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/util/JsonUtil.java +++ b/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/util/JsonUtil.java @@ -23,10 +23,12 @@ */ package com.lunarclient.apollo.example.json.util; +import com.google.gson.JsonArray; import com.google.gson.JsonObject; import java.awt.Color; import java.time.Duration; import java.time.Instant; +import java.util.List; import java.util.Map; import java.util.UUID; import org.bukkit.Bukkit; @@ -139,11 +141,11 @@ public static Location toBukkitPlayerLocation(JsonObject message) { return location; } - public static JsonObject createItemStackIconObject(@Nullable String itemName, int itemId, int customModelData) { - return JsonUtil.createItemStackIconObject(itemName, itemId, customModelData, null); + public static JsonObject createItemStackIconObject(@Nullable String itemName, int itemId) { + return JsonUtil.createItemStackIconObject(itemName, itemId, null, null); } - public static JsonObject createItemStackIconObject(@Nullable String itemName, int itemId, int customModelData, @Nullable JsonObject profile) { + public static JsonObject createItemStackIconObject(@Nullable String itemName, int itemId, @Nullable JsonObject customModelData, @Nullable JsonObject profile) { JsonObject itemIconObject = new JsonObject(); if (itemName != null) { itemIconObject.addProperty("item_name", itemName); @@ -151,7 +153,9 @@ public static JsonObject createItemStackIconObject(@Nullable String itemName, in itemIconObject.addProperty("item_id", itemId); } - itemIconObject.addProperty("custom_model_data", customModelData); + if (customModelData != null) { + itemIconObject.add("custom_model_data_object", customModelData); + } if (profile != null) { itemIconObject.add("profile", profile); @@ -162,6 +166,28 @@ public static JsonObject createItemStackIconObject(@Nullable String itemName, in return iconObject; } + public static JsonObject createCustomModelDataObject(List floats, List flags, List strings, List colors) { + JsonObject customModelDataObject = new JsonObject(); + + JsonArray floatsArray = new JsonArray(); + floats.forEach(floatsArray::add); + customModelDataObject.add("floats", floatsArray); + + JsonArray flagsArray = new JsonArray(); + flags.forEach(flagsArray::add); + customModelDataObject.add("flags", flagsArray); + + JsonArray stringsArray = new JsonArray(); + strings.forEach(stringsArray::add); + customModelDataObject.add("strings", stringsArray); + + JsonArray colorsArray = new JsonArray(); + colors.forEach(colorsArray::add); + customModelDataObject.add("colors", colorsArray); + + return customModelDataObject; + } + public static JsonObject createProfileObject(@Nullable UUID id, @NotNull String texture, @NotNull String signature) { JsonObject profileObject = new JsonObject(); if (id != null) { diff --git a/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/module/CooldownProtoExample.java b/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/module/CooldownProtoExample.java index cdcbec81..116ffc4e 100644 --- a/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/module/CooldownProtoExample.java +++ b/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/module/CooldownProtoExample.java @@ -44,7 +44,7 @@ public void displayCooldownItemExample(Player viewer) { .setName("enderpearl-cooldown") .setDuration(ProtobufUtil.createDurationProto(Duration.ofSeconds(15))) .setIcon(Icon.newBuilder() - .setItemStack(ProtobufUtil.createItemStackIconProto("ENDER_PEARL", 0, 0)) + .setItemStack(ProtobufUtil.createItemStackIconProto("ENDER_PEARL", 0)) .build()) .build(); @@ -57,7 +57,7 @@ public void displayCooldownWithStyleExample(Player viewer) { .setName("book-cooldown") .setDuration(ProtobufUtil.createDurationProto(Duration.ofSeconds(30))) .setIcon(Icon.newBuilder() - .setItemStack(ProtobufUtil.createItemStackIconProto("BOOK", 0, 0)) + .setItemStack(ProtobufUtil.createItemStackIconProto("BOOK", 0)) .build()) .setStyle(CooldownStyle.newBuilder() .setCircleStartColor(ProtobufUtil.createColorProto(new Color(255, 85, 85))) // ApolloColors.RED @@ -77,7 +77,7 @@ public void displayCooldownWithPlayerTextureExample(Player viewer) { .setDuration(ProtobufUtil.createDurationProto(Duration.ofSeconds(15))) .setIcon(Icon.newBuilder() .setItemStack(ProtobufUtil.createItemStackIconProto( - "PLAYER_HEAD", 0, 0, + "PLAYER_HEAD", 0, null, ProtobufUtil.createProfileProto( UUID.fromString("f17627d8-1a97-487b-92ea-c04f413394bd"), "e3RleHR1cmVzOntTS0lOOnt1cmw6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWQ4MjUwNWJjZjNiYTU5YzJiZTdlMmQzNmY0ZTJiZGE4MzZmMmZkMTk0YjYyMTJhMmExYzRiNGEyYTQ3MWUifX19", diff --git a/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/util/ProtobufUtil.java b/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/util/ProtobufUtil.java index 373fb9fa..40c2c31c 100644 --- a/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/util/ProtobufUtil.java +++ b/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/util/ProtobufUtil.java @@ -27,6 +27,7 @@ import com.lunarclient.apollo.common.v1.AdvancedResourceLocationIcon; import com.lunarclient.apollo.common.v1.BlockLocation; import com.lunarclient.apollo.common.v1.Cuboid2D; +import com.lunarclient.apollo.common.v1.CustomModelData; import com.lunarclient.apollo.common.v1.EntityId; import com.lunarclient.apollo.common.v1.ItemStackIcon; import com.lunarclient.apollo.common.v1.Profile; @@ -35,6 +36,7 @@ import com.lunarclient.apollo.common.v1.Uuid; import java.awt.Color; import java.time.Duration; +import java.util.List; import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -115,19 +117,22 @@ public static Location toBukkitLocation(com.lunarclient.apollo.common.v1.PlayerL return location; } - public static ItemStackIcon createItemStackIconProto(@Nullable String itemName, int itemId, int customModelData) { - return ProtobufUtil.createItemStackIconProto(itemName, itemId, customModelData, null); + public static ItemStackIcon createItemStackIconProto(@Nullable String itemName, int itemId) { + return ProtobufUtil.createItemStackIconProto(itemName, itemId, null, null); } - public static ItemStackIcon createItemStackIconProto(@Nullable String itemName, int itemId, int customModelData, @Nullable Profile profile) { + public static ItemStackIcon createItemStackIconProto(@Nullable String itemName, int itemId, @Nullable CustomModelData customModelData, @Nullable Profile profile) { ItemStackIcon.Builder iconBuilder = ItemStackIcon.newBuilder() - .setItemId(itemId) - .setCustomModelData(customModelData); + .setItemId(itemId); if (itemName != null) { iconBuilder.setItemName(itemName); } + if (customModelData != null) { + iconBuilder.setCustomModelDataObject(customModelData); + } + if (profile != null) { iconBuilder.setProfile(profile); } @@ -135,6 +140,15 @@ public static ItemStackIcon createItemStackIconProto(@Nullable String itemName, return iconBuilder.build(); } + public static CustomModelData createCustomModelDataProto(List floats, List flags, List strings, List colors) { + return CustomModelData.newBuilder() + .addAllFloats(floats) + .addAllFlags(flags) + .addAllStrings(strings) + .addAllColors(colors) + .build(); + } + public static Profile createProfileProto(@Nullable UUID id, String texture, String signature) { Profile.Builder builder = Profile.newBuilder() .setTexture(texture) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index cb68d5c4..f2b33187 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -11,7 +11,7 @@ geantyref = "1.3.11" idea = "1.1.7" jetbrains = "24.0.1" lombok = "1.18.38" -protobuf = "0.1.6" +protobuf = "0.1.7" gson = "2.10.1" shadow = "9.4.1" spotless = "8.4.0"