From e5f037e45f760d06763c705e199841303d59ee3e Mon Sep 17 00:00:00 2001 From: Eclipse Date: Sun, 21 Jul 2024 14:03:27 +0000 Subject: [PATCH] Move tool type and tool tier back to non vanilla items --- .../api/item/custom/CustomItemData.java | 18 --------- .../item/custom/NonVanillaCustomItemData.java | 24 +++++++++--- .../geyser/item/GeyserCustomItemData.java | 28 -------------- .../item/GeyserNonVanillaCustomItemData.java | 38 ++++++++++++++----- .../mappings/versions/MappingsReader_v1.java | 8 ---- .../CustomItemRegistryPopulator.java | 2 - 6 files changed, 46 insertions(+), 72 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 7dd0725e7..a55de0092 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 @@ -144,20 +144,6 @@ public interface CustomItemData { */ int attackDamage(); - /** - * Gets the tool type of the item. - * - * @return the tool type of the item - */ - @Nullable String toolType(); - - /** - * Gets the tool tier of the item. - * - * @return the tool tier of the item - */ - @Nullable String toolTier(); - /** * Gets the armor type of the item. * @@ -237,10 +223,6 @@ public interface CustomItemData { Builder attackDamage(int attackDamage); - Builder toolType(@Nullable String toolType); - - Builder toolTier(@Nullable String toolTier); - Builder armorType(@Nullable String armorType); Builder protectionValue(int protectionValue); 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 7cb3e629e..98b4694c2 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 @@ -43,6 +43,20 @@ public interface NonVanillaCustomItemData extends CustomItemData { */ @NonNull String identifier(); + /** + * Gets the tool type of the item. + * + * @return the tool type of the item + */ + @Nullable String toolType(); + + /** + * Gets the tool tier of the item. + * + * @return the tool tier of the item + */ + @Nullable String toolTier(); + /** * Gets the java item id of the item. * @@ -136,12 +150,6 @@ public interface NonVanillaCustomItemData extends CustomItemData { @Override Builder attackDamage(int attackDamage); - @Override - Builder toolType(@Nullable String toolType); - - @Override - Builder toolTier(@Nullable String toolTier); - @Override Builder armorType(@Nullable String armorType); @@ -172,6 +180,10 @@ public interface NonVanillaCustomItemData extends CustomItemData { Builder javaId(@NonNegative int javaId); + Builder toolType(@Nullable String toolType); + + Builder toolTier(@Nullable String toolTier); + Builder translationString(@Nullable String translationString); Builder repairMaterials(@Nullable Set repairMaterials); 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 08728b091..406dc3234 100644 --- a/core/src/main/java/org/geysermc/geyser/item/GeyserCustomItemData.java +++ b/core/src/main/java/org/geysermc/geyser/item/GeyserCustomItemData.java @@ -55,8 +55,6 @@ public class GeyserCustomItemData implements CustomItemData { private final int stackSize; private final int maxDamage; private final int attackDamage; - private final String toolType; - private final String toolTier; private final String armorType; private final int protectionValue; private final boolean isHat; @@ -79,8 +77,6 @@ public class GeyserCustomItemData implements CustomItemData { this.stackSize = builder.stackSize; this.maxDamage = builder.maxDamage; this.attackDamage = builder.attackDamage; - this.toolType = builder.toolType; - this.toolTier = builder.toolTier; this.armorType = builder.armorType; this.protectionValue = builder.protectionValue; this.isHat = builder.hat; @@ -159,16 +155,6 @@ public class GeyserCustomItemData implements CustomItemData { return attackDamage; } - @Override - public String toolType() { - return toolType; - } - - @Override - public String toolTier() { - return toolTier; - } - @Override public @Nullable String armorType() { return armorType; @@ -214,8 +200,6 @@ public class GeyserCustomItemData implements CustomItemData { private int stackSize = 0; private int maxDamage = -1; private int attackDamage = 0; - private String toolType = null; - private String toolTier = null; private String armorType = null; private int protectionValue = 0; private boolean hat = false; @@ -307,18 +291,6 @@ public class GeyserCustomItemData implements CustomItemData { return this; } - @Override - public Builder toolType(@Nullable String toolType) { - this.toolType = toolType; - return this; - } - - @Override - public Builder toolTier(@Nullable String toolTier) { - this.toolTier = toolTier; - return this; - } - @Override public Builder armorType(@Nullable String armorType) { this.armorType = armorType; 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 63b1c693e..c5ac4f68e 100644 --- a/core/src/main/java/org/geysermc/geyser/item/GeyserNonVanillaCustomItemData.java +++ b/core/src/main/java/org/geysermc/geyser/item/GeyserNonVanillaCustomItemData.java @@ -40,6 +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 toolType; + private final String toolTier; private final String translationString; private final Set repairMaterials; private final boolean isChargeable; @@ -50,6 +52,8 @@ public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i this.identifier = builder.identifier; this.javaId = builder.javaId; + this.toolType = builder.toolType; + this.toolTier = builder.toolTier; this.translationString = builder.translationString; this.repairMaterials = builder.repairMaterials; this.isChargeable = builder.chargeable; @@ -66,6 +70,16 @@ public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i return javaId; } + @Override + public String toolType() { + return toolType; + } + + @Override + public String toolTier() { + return toolTier; + } + @Override public String translationString() { return translationString; @@ -89,6 +103,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 toolType = null; + private String toolTier = null; private String translationString; private Set repairMaterials; private boolean chargeable = false; @@ -165,16 +181,6 @@ public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i return (Builder) super.attackDamage(attackDamage); } - @Override - public Builder toolType(@Nullable String toolType) { - return (Builder) super.toolType(toolType); - } - - @Override - public Builder toolTier(@Nullable String toolTier) { - return (Builder) super.toolTier(toolTier); - } - @Override public Builder armorType(@Nullable String armorType) { return (Builder) super.armorType(armorType); @@ -217,6 +223,18 @@ public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i return this; } + @Override + public Builder toolType(@Nullable String toolType) { + this.toolType = toolType; + return this; + } + + @Override + public Builder toolTier(@Nullable String toolTier) { + this.toolTier = toolTier; + return this; + } + @Override public Builder translationString(@Nullable String translationString) { this.translationString = translationString; diff --git a/core/src/main/java/org/geysermc/geyser/registry/mappings/versions/MappingsReader_v1.java b/core/src/main/java/org/geysermc/geyser/registry/mappings/versions/MappingsReader_v1.java index 5d6bf4e32..509af0417 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/mappings/versions/MappingsReader_v1.java +++ b/core/src/main/java/org/geysermc/geyser/registry/mappings/versions/MappingsReader_v1.java @@ -225,14 +225,6 @@ public class MappingsReader_v1 extends MappingsReader { customItemData.maxDamage(node.get("attack_damage").asInt()); } - if (node.has("tool_type")) { - customItemData.toolType(node.get("tool_type").asText()); - } - - if (node.has("tool_tier")) { - customItemData.toolTier(node.get("tool_tier").asText()); - } - if (node.has("armor_type")) { customItemData.armorType(node.get("armor_type").asText()); } 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 8d22562c4..8bb28673f 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 @@ -176,8 +176,6 @@ public class CustomItemRegistryPopulator { String toolType = null; if (mapping.getToolType() != null) { toolType = mapping.getToolType(); - } else if (customItemData.toolType() != null) { - toolType = customItemData.toolType(); } if (toolType != null) {