3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-27 00:23:03 +01:00

Should fix custom items and durability

Dieser Commit ist enthalten in:
Camotoy 2023-05-03 20:17:05 -04:00
Ursprung f3f30625d4
Commit 6e9b272f50
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
3 geänderte Dateien mit 5 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -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); 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()); ComponentItemData componentItemData = new ComponentItemData(customItemName, builder.build());
return new GeyserCustomMappingData(componentItemData, itemDefinition, customItemName, bedrockId); return new GeyserCustomMappingData(componentItemData, itemDefinition, customItemName, bedrockId);
@ -159,7 +159,7 @@ public class CustomItemRegistryPopulator {
return new NonVanillaItemRegistration(componentItemData, item, customItemMapping); 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) { String customItemName, int customItemId) {
NbtMapBuilder builder = NbtMap.builder(); NbtMapBuilder builder = NbtMap.builder();
builder.putString("name", customItemName) builder.putString("name", customItemName)
@ -168,7 +168,7 @@ public class CustomItemRegistryPopulator {
NbtMapBuilder itemProperties = NbtMap.builder(); NbtMapBuilder itemProperties = NbtMap.builder();
NbtMapBuilder componentBuilder = 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; boolean canDestroyInCreative = true;
if (mapping.getToolType() != null) { // This is not using the isTool boolean because it is not just a render type here. if (mapping.getToolType() != null) { // This is not using the isTool boolean because it is not just a render type here.

Datei anzeigen

@ -398,7 +398,7 @@ public class ItemRegistryPopulator {
} }
GeyserCustomMappingData customMapping = CustomItemRegistryPopulator.registerCustomItem( GeyserCustomMappingData customMapping = CustomItemRegistryPopulator.registerCustomItem(
customItemName, mappingItem, customItem, customProtocolId customItemName, javaItem, mappingItem, customItem, customProtocolId
); );
// ComponentItemData - used to register some custom properties // ComponentItemData - used to register some custom properties
componentItemData.add(customMapping.componentItemData()); componentItemData.add(customMapping.componentItemData());

Datei anzeigen

@ -37,12 +37,10 @@ public class GeyserMappingItem {
@JsonProperty("bedrock_data") int bedrockData; @JsonProperty("bedrock_data") int bedrockData;
Integer firstBlockRuntimeId; Integer firstBlockRuntimeId;
Integer lastBlockRuntimeId; Integer lastBlockRuntimeId;
@JsonProperty("stack_size") int stackSize = 64;
@JsonProperty("tool_type") String toolType; @JsonProperty("tool_type") String toolType;
@JsonProperty("tool_tier") String toolTier; @JsonProperty("tool_tier") String toolTier;
@JsonProperty("armor_type") String armorType; @JsonProperty("armor_type") String armorType;
@JsonProperty("protection_value") int protectionValue; @JsonProperty("protection_value") int protectionValue;
@JsonProperty("max_damage") int maxDamage = 0;
@JsonProperty("is_edible") boolean edible = false; @JsonProperty("is_edible") boolean edible = false;
@JsonProperty("is_entity_placer") boolean entityPlacer = false; @JsonProperty("is_entity_placer") boolean entityPlacer = false;
} }