mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 11:27:35 +01:00
3b9db2b194
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: bb4e97c6 Add support for Java 23 bc6874dd Bump asm to 9.7.1 50e8a00b PR-1064: Add specific getTopInventory methods for InventoryView derivatives 758b0a0f SPIGOT-7911: Fix Location#isWorldLoaded() for re-loaded worlds 133a64a7 Improve Registry#getOrThrow messages be0f5957 PR-1058: Add tests for Minecraft registry <-> Bukkit fields d1b31df2 PR-1062: Clarify BeaconView documentation 3fab4384 PR-1060: Cache Material to BlockType and ItemType conversion 967a7301 SPIGOT-7906: Increase YAML nesting limit to 100 6ecf033d SPIGOT-7899: Smithing recipes don't require inputs CraftBukkit Changes: 0a7bd6c81 PR-1493: Improve reroute performance and add some tests 54941524c Add support for Java 23 f4d957fff SPIGOT-7915: Fix World#getKeepSpawnInMemory() using Spawn Radius rather than Spawn Chunk Radius ded183674 Fix HIDE_ENCHANTS flag in items without enchantments 308785a0a Bump asm to 9.7.1 and re-add ClassReader to ClassWriter 72ce823cd PR-1487: Add specific getTopInventory methods for InventoryView derivatives 11a5e840c SPIGOT-7907, PR-1484: Improve merchant recipe item matching behavior to more closely align with older versions 45b66f7e4 SPIGOT-7909: Always set HIDE_ENCHANTS flag to item if flag is set 963459791 Increase outdated build delay fc5b2d75f SPIGOT-7910: Fix launching breeze wind charge from API and improve dispenser launch API c7d6428f2 SPIGOT-7856, PR-1483: End platform not dropping items after replacing blocks 2a5572b52 SPIGOT-7780, PR-1482: Cannot edit chunks during unload event 527041ab5 SPIGOT-7902, PR-1477: Fix CraftMetaPotion#hasCustomEffects() does not check if customEffects (List) is empty 5529a1769 Implement base methods for tags 30fbdbaaf Improve Registry#getOrThrow messages 6b71a7322 PR-1475: Add tests for Minecraft registry <-> Bukkit fields 5f24c255c SPIGOT-7908: Mark junit-platform-suite-engine as test scope e4c92ef65 PR-1473: Change tests to use suites, to run tests in different environments and feature flags d25e1e722 PR-1481: Fix BeaconView#set[X]Effect(null) d69a05362 PR-1480: Fix PerMaterialTest#isEdible test running for legacy materials bb3284a89 PR-1479: Use custom #isBlock method in legacy init instead of the one in Material, since it relies on legacy being init 98c57cbbe SPIGOT-7904: Fix NPE for PlayerItemBreakEvent f35bae9ec Fix missing hasJukeboxPlayable 8a6f8b6d8 SPIGOT-7881: CTRL+Pick Block saves position data into item 7913b3be7 SPIGOT-7899: Smithing recipes don't require inputs
144 lines
10 KiB
Diff
144 lines
10 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
Date: Sun, 26 Sep 2021 12:57:28 -0700
|
|
Subject: [PATCH] Option to prevent data components copy in smithing recipes
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java b/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
|
|
index 83b77e170f2945e9b40f302c4cf65efb1628c84a..d64a1c1e146d5d9aa940a37dbee16889c9bab783 100644
|
|
--- a/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
|
|
+++ b/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
|
|
@@ -22,8 +22,15 @@ public class SmithingTransformRecipe implements SmithingRecipe {
|
|
final Ingredient base;
|
|
final Ingredient addition;
|
|
final ItemStack result;
|
|
+ final boolean copyDataComponents; // Paper - Option to prevent data components copy
|
|
|
|
public SmithingTransformRecipe(Ingredient template, Ingredient base, Ingredient addition, ItemStack result) {
|
|
+ // Paper start - Option to prevent data components copy
|
|
+ this(template, base, addition, result, true);
|
|
+ }
|
|
+ public SmithingTransformRecipe(Ingredient template, Ingredient base, Ingredient addition, ItemStack result, boolean copyDataComponents) {
|
|
+ this.copyDataComponents = copyDataComponents;
|
|
+ // Paper end - Option to prevent data components copy
|
|
this.template = template;
|
|
this.base = base;
|
|
this.addition = addition;
|
|
@@ -37,7 +44,9 @@ public class SmithingTransformRecipe implements SmithingRecipe {
|
|
public ItemStack assemble(SmithingRecipeInput input, HolderLookup.Provider lookup) {
|
|
ItemStack itemstack = input.base().transmuteCopy(this.result.getItem(), this.result.getCount());
|
|
|
|
+ if (this.copyDataComponents) { // Paper - Option to prevent data components copy
|
|
itemstack.applyComponents(this.result.getComponentsPatch());
|
|
+ } // Paper - Option to prevent data components copy
|
|
return itemstack;
|
|
}
|
|
|
|
@@ -76,7 +85,7 @@ public class SmithingTransformRecipe implements SmithingRecipe {
|
|
public Recipe toBukkitRecipe(NamespacedKey id) {
|
|
CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
|
|
|
- CraftSmithingTransformRecipe recipe = new CraftSmithingTransformRecipe(id, result, CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition));
|
|
+ CraftSmithingTransformRecipe recipe = new CraftSmithingTransformRecipe(id, result, CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition), this.copyDataComponents); // Paper - Option to prevent data components copy
|
|
|
|
return recipe;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/item/crafting/SmithingTrimRecipe.java b/src/main/java/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
|
|
index 4ea43872f9da72ed959dd0709f959402d01d5fe0..f6f10da21a752e927409ea16076701c4ec403a0e 100644
|
|
--- a/src/main/java/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
|
|
+++ b/src/main/java/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
|
|
@@ -30,8 +30,15 @@ public class SmithingTrimRecipe implements SmithingRecipe {
|
|
final Ingredient template;
|
|
final Ingredient base;
|
|
final Ingredient addition;
|
|
+ final boolean copyDataComponents; // Paper - Option to prevent data components copy
|
|
|
|
public SmithingTrimRecipe(Ingredient template, Ingredient base, Ingredient addition) {
|
|
+ // Paper start - Option to prevent data components copy
|
|
+ this(template, base, addition, true);
|
|
+ }
|
|
+ public SmithingTrimRecipe(Ingredient template, Ingredient base, Ingredient addition, boolean copyDataComponents) {
|
|
+ this.copyDataComponents = copyDataComponents;
|
|
+ // Paper end - Option to prevent data components copy
|
|
this.template = template;
|
|
this.base = base;
|
|
this.addition = addition;
|
|
@@ -55,7 +62,7 @@ public class SmithingTrimRecipe implements SmithingRecipe {
|
|
return ItemStack.EMPTY;
|
|
}
|
|
|
|
- ItemStack itemstack1 = itemstack.copyWithCount(1);
|
|
+ ItemStack itemstack1 = this.copyDataComponents ? itemstack.copyWithCount(1) : new ItemStack(itemstack.getItem(), 1); // Paper - Option to prevent data components copy
|
|
|
|
itemstack1.set(DataComponents.TRIM, new ArmorTrim((Holder) optional.get(), (Holder) optional1.get()));
|
|
return itemstack1;
|
|
@@ -106,7 +113,7 @@ public class SmithingTrimRecipe implements SmithingRecipe {
|
|
// CraftBukkit start
|
|
@Override
|
|
public Recipe toBukkitRecipe(NamespacedKey id) {
|
|
- return new CraftSmithingTrimRecipe(id, CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition));
|
|
+ return new CraftSmithingTrimRecipe(id, CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition), this.copyDataComponents); // Paper - Option to prevent data components copy
|
|
}
|
|
// CraftBukkit end
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java
|
|
index 09f86aec08ec958b8e3015020e9ae213db27d85c..37b39a2c696a59b0f52324cc222b83c0c9f341e6 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java
|
|
@@ -12,12 +12,17 @@ public class CraftSmithingTransformRecipe extends SmithingTransformRecipe implem
|
|
public CraftSmithingTransformRecipe(NamespacedKey key, ItemStack result, RecipeChoice template, RecipeChoice base, RecipeChoice addition) {
|
|
super(key, result, template, base, addition);
|
|
}
|
|
+ // Paper start - Option to prevent data components copy
|
|
+ public CraftSmithingTransformRecipe(NamespacedKey key, ItemStack result, RecipeChoice template, RecipeChoice base, RecipeChoice addition, boolean copyDataComponents) {
|
|
+ super(key, result, template, base, addition, copyDataComponents);
|
|
+ }
|
|
+ // Paper end - Option to prevent data components copy
|
|
|
|
public static CraftSmithingTransformRecipe fromBukkitRecipe(SmithingTransformRecipe recipe) {
|
|
if (recipe instanceof CraftSmithingTransformRecipe) {
|
|
return (CraftSmithingTransformRecipe) recipe;
|
|
}
|
|
- CraftSmithingTransformRecipe ret = new CraftSmithingTransformRecipe(recipe.getKey(), recipe.getResult(), recipe.getTemplate(), recipe.getBase(), recipe.getAddition());
|
|
+ CraftSmithingTransformRecipe ret = new CraftSmithingTransformRecipe(recipe.getKey(), recipe.getResult(), recipe.getTemplate(), recipe.getBase(), recipe.getAddition(), recipe.willCopyDataComponents()); // Paper - Option to prevent data components copy
|
|
return ret;
|
|
}
|
|
|
|
@@ -25,6 +30,6 @@ public class CraftSmithingTransformRecipe extends SmithingTransformRecipe implem
|
|
public void addToCraftingManager() {
|
|
ItemStack result = this.getResult();
|
|
|
|
- MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTransformRecipe(this.toNMS(this.getTemplate(), false), this.toNMS(this.getBase(), false), this.toNMS(this.getAddition(), false), CraftItemStack.asNMSCopy(result))));
|
|
+ MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTransformRecipe(this.toNMS(this.getTemplate(), false), this.toNMS(this.getBase(), false), this.toNMS(this.getAddition(), false), CraftItemStack.asNMSCopy(result), this.willCopyDataComponents()))); // Paper - Option to prevent data components copy
|
|
}
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java
|
|
index 8245b728d341a64f25357edbd2c3c447b6c0a0cf..389fa313f811279091cace76faaabf8bdb0fc94c 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java
|
|
@@ -12,17 +12,22 @@ public class CraftSmithingTrimRecipe extends SmithingTrimRecipe implements Craft
|
|
public CraftSmithingTrimRecipe(NamespacedKey key, RecipeChoice template, RecipeChoice base, RecipeChoice addition) {
|
|
super(key, template, base, addition);
|
|
}
|
|
+ // Paper start - Option to prevent data components copy
|
|
+ public CraftSmithingTrimRecipe(NamespacedKey key, RecipeChoice template, RecipeChoice base, RecipeChoice addition, boolean copyDataComponents) {
|
|
+ super(key, template, base, addition, copyDataComponents);
|
|
+ }
|
|
+ // Paper end - Option to prevent data components copy
|
|
|
|
public static CraftSmithingTrimRecipe fromBukkitRecipe(SmithingTrimRecipe recipe) {
|
|
if (recipe instanceof CraftSmithingTrimRecipe) {
|
|
return (CraftSmithingTrimRecipe) recipe;
|
|
}
|
|
- CraftSmithingTrimRecipe ret = new CraftSmithingTrimRecipe(recipe.getKey(), recipe.getTemplate(), recipe.getBase(), recipe.getAddition());
|
|
+ CraftSmithingTrimRecipe ret = new CraftSmithingTrimRecipe(recipe.getKey(), recipe.getTemplate(), recipe.getBase(), recipe.getAddition(), recipe.willCopyDataComponents()); // Paper - Option to prevent data components copy
|
|
return ret;
|
|
}
|
|
|
|
@Override
|
|
public void addToCraftingManager() {
|
|
- MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTrimRecipe(this.toNMS(this.getTemplate(), false), this.toNMS(this.getBase(), false), this.toNMS(this.getAddition(), false))));
|
|
+ MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTrimRecipe(this.toNMS(this.getTemplate(), false), this.toNMS(this.getBase(), false), this.toNMS(this.getAddition(), false), this.willCopyDataComponents()))); // Paper - Option to prevent data components copy
|
|
}
|
|
}
|