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 | 19 +++++++------- .../geyser/item/GeyserCustomItemData.java | 14 +++++----- .../item/GeyserNonVanillaCustomItemData.java | 26 +++++++++---------- .../CustomItemRegistryPopulator.java | 8 +++--- 5 files changed, 42 insertions(+), 42 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 5bb469abc..916635308 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 @@ public interface CustomItemData { 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 9a1a699c6..778e8e672 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 @@ -50,6 +50,13 @@ public interface NonVanillaCustomItemData extends CustomItemData { */ @NonNegative int javaId(); + /** + * Gets the item's translation string. + * + * @return the item's translation string + */ + @Nullable String translationString(); + /** * Gets the repair materials of the item. * @@ -57,14 +64,6 @@ public interface NonVanillaCustomItemData extends CustomItemData { */ @Nullable Set repairMaterials(); - /** - * 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 chargable, like a bow. * @@ -91,9 +90,9 @@ public interface NonVanillaCustomItemData extends CustomItemData { 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 f1cf50884..08728b091 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 class GeyserCustomItemData implements CustomItemData { 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 class GeyserCustomItemData implements CustomItemData { } @Override - public String translationString() { - return translationString; + public boolean isHat() { + return isHat; } @Override @@ -218,7 +218,7 @@ public class GeyserCustomItemData implements CustomItemData { 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 class GeyserCustomItemData implements CustomItemData { } @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 d727401b2..bcbd16b00 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 @@ import java.util.Set; 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 final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i 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 final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i } @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 final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i 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 final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i 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 final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i 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 141965cbd..6bb29cd39 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 class CustomItemRegistryPopulator { .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 @@ public class CustomItemRegistryPopulator { 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 @@ public class CustomItemRegistryPopulator { } 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 @@ public class CustomItemRegistryPopulator { computeChargeableProperties(itemProperties, componentBuilder, "minecraft:" + tooltype, protocolVersion); } - computeRenderOffsets(isHat, customItemData, componentBuilder); + computeRenderOffsets(customItemData.isHat(), customItemData, componentBuilder); if (customItemData.isFoil()) { itemProperties.putBoolean("foil", true);