From 6e9b272f50f77ba9d6a3b4b3c825e327ea588efc Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Wed, 3 May 2023 20:17:05 -0400 Subject: [PATCH] Should fix custom items and durability --- .../registry/populator/CustomItemRegistryPopulator.java | 8 ++++---- .../geyser/registry/populator/ItemRegistryPopulator.java | 2 +- .../geysermc/geyser/registry/type/GeyserMappingItem.java | 2 -- 3 files changed, 5 insertions(+), 7 deletions(-) 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 cd7a0d491..3c037988f 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 @@ -98,10 +98,10 @@ public class CustomItemRegistryPopulator { } } - public static GeyserCustomMappingData registerCustomItem(String customItemName, GeyserMappingItem javaItem, CustomItemData customItemData, int bedrockId) { + public static GeyserCustomMappingData registerCustomItem(String customItemName, Item javaItem, GeyserMappingItem mapping, CustomItemData customItemData, int bedrockId) { ItemDefinition itemDefinition = new SimpleItemDefinition(customItemName, bedrockId, true); - NbtMapBuilder builder = createComponentNbt(customItemData, javaItem, customItemName, bedrockId); + NbtMapBuilder builder = createComponentNbt(customItemData, javaItem, mapping, customItemName, bedrockId); ComponentItemData componentItemData = new ComponentItemData(customItemName, builder.build()); return new GeyserCustomMappingData(componentItemData, itemDefinition, customItemName, bedrockId); @@ -159,7 +159,7 @@ public class CustomItemRegistryPopulator { return new NonVanillaItemRegistration(componentItemData, item, customItemMapping); } - private static NbtMapBuilder createComponentNbt(CustomItemData customItemData, GeyserMappingItem mapping, + private static NbtMapBuilder createComponentNbt(CustomItemData customItemData, Item javaItem, GeyserMappingItem mapping, String customItemName, int customItemId) { NbtMapBuilder builder = NbtMap.builder(); builder.putString("name", customItemName) @@ -168,7 +168,7 @@ public class CustomItemRegistryPopulator { NbtMapBuilder itemProperties = NbtMap.builder(); NbtMapBuilder componentBuilder = NbtMap.builder(); - setupBasicItemInfo(mapping.getMaxDamage(), mapping.getStackSize(), mapping.getToolType() != null || customItemData.displayHandheld(), customItemData, itemProperties, componentBuilder); + setupBasicItemInfo(javaItem.maxDamage(), javaItem.maxStackSize(), mapping.getToolType() != null || customItemData.displayHandheld(), customItemData, itemProperties, componentBuilder); boolean canDestroyInCreative = true; if (mapping.getToolType() != null) { // This is not using the isTool boolean because it is not just a render type here. diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/ItemRegistryPopulator.java b/core/src/main/java/org/geysermc/geyser/registry/populator/ItemRegistryPopulator.java index 08eb343d9..ebe1e4152 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/ItemRegistryPopulator.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/ItemRegistryPopulator.java @@ -398,7 +398,7 @@ public class ItemRegistryPopulator { } GeyserCustomMappingData customMapping = CustomItemRegistryPopulator.registerCustomItem( - customItemName, mappingItem, customItem, customProtocolId + customItemName, javaItem, mappingItem, customItem, customProtocolId ); // ComponentItemData - used to register some custom properties componentItemData.add(customMapping.componentItemData()); diff --git a/core/src/main/java/org/geysermc/geyser/registry/type/GeyserMappingItem.java b/core/src/main/java/org/geysermc/geyser/registry/type/GeyserMappingItem.java index 6576ea144..f1cd762b5 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/type/GeyserMappingItem.java +++ b/core/src/main/java/org/geysermc/geyser/registry/type/GeyserMappingItem.java @@ -37,12 +37,10 @@ public class GeyserMappingItem { @JsonProperty("bedrock_data") int bedrockData; Integer firstBlockRuntimeId; Integer lastBlockRuntimeId; - @JsonProperty("stack_size") int stackSize = 64; @JsonProperty("tool_type") String toolType; @JsonProperty("tool_tier") String toolTier; @JsonProperty("armor_type") String armorType; @JsonProperty("protection_value") int protectionValue; - @JsonProperty("max_damage") int maxDamage = 0; @JsonProperty("is_edible") boolean edible = false; @JsonProperty("is_entity_placer") boolean entityPlacer = false; }