From 72da5a576b8207966aa6c2bd38f31a3793255364 Mon Sep 17 00:00:00 2001 From: Eclipse Date: Sat, 11 May 2024 10:08:21 +0000 Subject: [PATCH] Move translation string back to non vanilla and move hat to vanilla --- .../api/item/custom/CustomItemData.java | 17 ++++++------ .../item/custom/NonVanillaCustomItemData.java | 17 ++++++------ .../geyser/item/GeyserCustomItemData.java | 14 +++++----- .../item/GeyserNonVanillaCustomItemData.java | 26 +++++++++---------- .../CustomItemRegistryPopulator.java | 8 +++--- 5 files changed, 41 insertions(+), 41 deletions(-) diff --git a/api/src/main/java/org/geysermc/geyser/api/item/custom/CustomItemData.java b/api/src/main/java/org/geysermc/geyser/api/item/custom/CustomItemData.java index 5bb469abc89..91663530804 100644 --- a/api/src/main/java/org/geysermc/geyser/api/item/custom/CustomItemData.java +++ b/api/src/main/java/org/geysermc/geyser/api/item/custom/CustomItemData.java @@ -158,13 +158,6 @@ public interface CustomItemData { */ @Nullable String toolTier(); - /** - * Gets the item's translation string. - * - * @return the item's translation string - */ - @Nullable String translationString(); - /** * Gets the armor type of the item. * @@ -179,6 +172,14 @@ public interface CustomItemData { */ int protectionValue(); + /** + * Gets if the item is a hat. This is used to determine if the item should be rendered on the player's head, and + * normally allow the player to equip it. This is not meant for armor. + * + * @return if the item is a hat + */ + boolean isHat(); + /** * Gets if the item is a foil. This is used to determine if the item should be rendered with an enchantment glint effect. * @@ -255,7 +256,7 @@ interface Builder { Builder protectionValue(int protectionValue); - Builder translationString(@Nullable String translationString); + Builder hat(boolean isHat); Builder foil(boolean isFoil); diff --git a/api/src/main/java/org/geysermc/geyser/api/item/custom/NonVanillaCustomItemData.java b/api/src/main/java/org/geysermc/geyser/api/item/custom/NonVanillaCustomItemData.java index 9a1a699c674..778e8e6724d 100644 --- a/api/src/main/java/org/geysermc/geyser/api/item/custom/NonVanillaCustomItemData.java +++ b/api/src/main/java/org/geysermc/geyser/api/item/custom/NonVanillaCustomItemData.java @@ -51,19 +51,18 @@ public interface NonVanillaCustomItemData extends CustomItemData { @NonNegative int javaId(); /** - * Gets the repair materials of the item. + * Gets the item's translation string. * - * @return the repair materials of the item + * @return the item's translation string */ - @Nullable Set repairMaterials(); + @Nullable String translationString(); /** - * Gets if the item is a hat. This is used to determine if the item should be rendered on the player's head, and - * normally allow the player to equip it. This is not meant for armor. + * Gets the repair materials of the item. * - * @return if the item is a hat + * @return the repair materials of the item */ - boolean isHat(); + @Nullable Set repairMaterials(); /** * Gets if the item is chargable, like a bow. @@ -91,9 +90,9 @@ interface Builder extends CustomItemData.Builder { Builder javaId(@NonNegative int javaId); - Builder repairMaterials(@Nullable Set repairMaterials); + Builder translationString(@Nullable String translationString); - Builder hat(boolean isHat); + Builder repairMaterials(@Nullable Set repairMaterials); Builder chargeable(boolean isChargeable); diff --git a/core/src/main/java/org/geysermc/geyser/item/GeyserCustomItemData.java b/core/src/main/java/org/geysermc/geyser/item/GeyserCustomItemData.java index f1cf5088423..08728b09152 100644 --- a/core/src/main/java/org/geysermc/geyser/item/GeyserCustomItemData.java +++ b/core/src/main/java/org/geysermc/geyser/item/GeyserCustomItemData.java @@ -57,9 +57,9 @@ public class GeyserCustomItemData implements CustomItemData { private final int attackDamage; private final String toolType; private final String toolTier; - private final String translationString; private final String armorType; private final int protectionValue; + private final boolean isHat; private final boolean isFoil; private final boolean isEdible; private final boolean canAlwaysEat; @@ -81,9 +81,9 @@ public GeyserCustomItemData(Builder builder) { this.attackDamage = builder.attackDamage; this.toolType = builder.toolType; this.toolTier = builder.toolTier; - this.translationString = builder.translationString; this.armorType = builder.armorType; this.protectionValue = builder.protectionValue; + this.isHat = builder.hat; this.isFoil = builder.foil; this.isEdible = builder.edible; this.canAlwaysEat = builder.canAlwaysEat; @@ -180,8 +180,8 @@ public int protectionValue() { } @Override - public String translationString() { - return translationString; + public boolean isHat() { + return isHat; } @Override @@ -218,7 +218,7 @@ public static class Builder implements CustomItemData.Builder { private String toolTier = null; private String armorType = null; private int protectionValue = 0; - private String translationString; + private boolean hat = false; private boolean foil = false; private boolean edible = false; private boolean canAlwaysEat = false; @@ -332,8 +332,8 @@ public Builder protectionValue(int protectionValue) { } @Override - public Builder translationString(@Nullable String translationString) { - this.translationString = translationString; + public Builder hat(boolean isHat) { + this.hat = isHat; return this; } diff --git a/core/src/main/java/org/geysermc/geyser/item/GeyserNonVanillaCustomItemData.java b/core/src/main/java/org/geysermc/geyser/item/GeyserNonVanillaCustomItemData.java index d727401b23d..bcbd16b00b0 100644 --- a/core/src/main/java/org/geysermc/geyser/item/GeyserNonVanillaCustomItemData.java +++ b/core/src/main/java/org/geysermc/geyser/item/GeyserNonVanillaCustomItemData.java @@ -40,8 +40,8 @@ public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData implements NonVanillaCustomItemData { private final String identifier; private final int javaId; + private final String translationString; private final Set repairMaterials; - private final boolean isHat; private final boolean isChargeable; private final String block; @@ -50,8 +50,8 @@ public GeyserNonVanillaCustomItemData(Builder builder) { this.identifier = builder.identifier; this.javaId = builder.javaId; + this.translationString = builder.translationString; this.repairMaterials = builder.repairMaterials; - this.isHat = builder.hat; this.isChargeable = builder.chargeable; this.block = builder.block; } @@ -67,13 +67,13 @@ public int javaId() { } @Override - public Set repairMaterials() { - return repairMaterials; + public String translationString() { + return translationString; } @Override - public boolean isHat() { - return isHat; + public Set repairMaterials() { + return repairMaterials; } @Override @@ -89,8 +89,8 @@ public String block() { public static class Builder extends GeyserCustomItemData.Builder implements NonVanillaCustomItemData.Builder { private String identifier = null; private int javaId = -1; + private String translationString; private Set repairMaterials; - private boolean hat = false; private boolean chargeable = false; private String block = null; @@ -152,6 +152,12 @@ public Builder javaId(int javaId) { return this; } + @Override + public Builder translationString(@Nullable String translationString) { + this.translationString = translationString; + return this; + } + @Override public Builder repairMaterials(@Nullable Set repairMaterials) { this.repairMaterials = repairMaterials; @@ -168,12 +174,6 @@ public Builder creativeGroup(@Nullable String creativeGroup) { return (Builder) super.creativeGroup(creativeGroup); } - @Override - public Builder hat(boolean isHat) { - this.hat = isHat; - return this; - } - @Override public Builder chargeable(boolean isChargeable) { this.chargeable = isChargeable; diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/CustomItemRegistryPopulator.java b/core/src/main/java/org/geysermc/geyser/registry/populator/CustomItemRegistryPopulator.java index 141965cbd2a..6bb29cd39d2 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/CustomItemRegistryPopulator.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/CustomItemRegistryPopulator.java @@ -153,7 +153,7 @@ public boolean isValidRepairItem(Item other) { .build(); NbtMapBuilder builder = createComponentNbt(customItemData, customItemData.identifier(), customItemId, - customItemData.isHat(), customItemData.displayHandheld(), protocolVersion); + customItemData.displayHandheld(), protocolVersion); ComponentItemData componentItemData = new ComponentItemData(customIdentifier, builder.build()); return new NonVanillaItemRegistration(componentItemData, item, customItemMapping); @@ -226,7 +226,7 @@ private static NbtMapBuilder createComponentNbt(CustomItemData customItemData, I computeThrowableProperties(componentBuilder); } - computeRenderOffsets(false, customItemData, componentBuilder); + computeRenderOffsets(customItemData.isHat(), customItemData, componentBuilder); componentBuilder.putCompound("item_properties", itemProperties.build()); builder.putCompound("components", componentBuilder.build()); @@ -235,7 +235,7 @@ private static NbtMapBuilder createComponentNbt(CustomItemData customItemData, I } private static NbtMapBuilder createComponentNbt(NonVanillaCustomItemData customItemData, String customItemName, - int customItemId, boolean isHat, boolean displayHandheld, int protocolVersion) { + int customItemId, boolean displayHandheld, int protocolVersion) { NbtMapBuilder builder = NbtMap.builder(); builder.putString("name", customItemName) .putInt("id", customItemId); @@ -269,7 +269,7 @@ private static NbtMapBuilder createComponentNbt(NonVanillaCustomItemData customI computeChargeableProperties(itemProperties, componentBuilder, "minecraft:" + tooltype, protocolVersion); } - computeRenderOffsets(isHat, customItemData, componentBuilder); + computeRenderOffsets(customItemData.isHat(), customItemData, componentBuilder); if (customItemData.isFoil()) { itemProperties.putBoolean("foil", true);