9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-29 03:49:15 +00:00

fix merge nbt tags on 1.20

This commit is contained in:
XiaoMoMi
2025-03-20 04:28:06 +08:00
parent 81aa965bea
commit f22f04a197
6 changed files with 65 additions and 18 deletions

View File

@@ -213,6 +213,7 @@ public class UniversalItemFactory extends BukkitItemFactory {
@Override
protected void maxStackSize(ItemWrapper<ItemStack> item, Integer maxStackSize) {
throw new UnsupportedOperationException("This feature is only available on 1.20.5+");
}
@Override
@@ -229,7 +230,9 @@ public class UniversalItemFactory extends BukkitItemFactory {
@Override
protected ItemWrapper<ItemStack> merge(ItemWrapper<ItemStack> item1, ItemWrapper<ItemStack> item2) {
Object itemStack = ItemObject.copy(item2.getLiteralObject());
ItemObject.setCustomDataTag(itemStack, ItemObject.getCustomDataTag(item1.getLiteralObject()));
ItemObject.setCustomDataTag(itemStack, TagCompound.clone(ItemObject.getCustomDataTag(item1.getLiteralObject())));
// one more step than vanilla
TagCompound.merge(ItemObject.getCustomDataTag(itemStack), ItemObject.getCustomDataTag(item2.getLiteralObject()), true, true);
return new RTagItemWrapper(new RtagItem(ItemObject.asCraftMirror(itemStack)), item2.count());
}
}

View File

@@ -769,7 +769,8 @@ public class BukkitRecipeManager implements RecipeManager<ItemStack> {
templateHolders.isEmpty() ? null : Ingredient.of(templateHolders),
additionHolders.isEmpty() ? null : Ingredient.of(additionHolders),
new CustomRecipeResult<>(new CloneableConstantItem(recipe.result().isCustom() ? Key.of("!internal:custom") : Key.of(recipe.result().id()), result), recipe.result().count()),
List.of(CustomSmithingTransformRecipe.ItemDataProcessor.MERGE_ALL)
true,
List.of()
);
SmithingTransformRecipe transformRecipe = new SmithingTransformRecipe(key, result,