de04cbced5
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: f29cb801 Separate checkstyle-suppressions file is not required 86f99bbe SPIGOT-7540, PR-946: Add ServerTickManager API d4119585 SPIGOT-6903, PR-945: Add BlockData#getMapColor b7a2ed41 SPIGOT-7530, PR-947: Add Player#removeResourcePack 9dd56255 SPIGOT-7527, PR-944: Add WindCharge#explode() 994a6163 Attempt upgrade of resolver libraries CraftBukkit Changes: b3b43a6ad Add Checkstyle check for unused imports 13fb3358e SPIGOT-7544: Scoreboard#getEntries() doesn't get entries but class names 3dda99c06 SPIGOT-7540, PR-1312: Add ServerTickManager API 2ab4508c0 SPIGOT-6903, PR-1311: Add BlockData#getMapColor 1dbdbbed4 PR-1238: Remove unnecessary sign ticking 659728d2a MC-264285, SPIGOT-7439, PR-1237: Fix unbreakable flint and steel is completely consumed while igniting creeper e37e29ce0 Increase outdated build delay c00438b39 SPIGOT-7530, PR-1313: Add Player#removeResourcePack 492dd80ce SPIGOT-7527, PR-1310: Add WindCharge#explode() e11fbb9d7 Upgrade MySQL driver 9f3a0bd2a Attempt upgrade of resolver libraries 60d16d7ca PR-1306: Centralize Bukkit and Minecraft entity conversion Spigot Changes: 06d602e7 Rebuild patches
148 Zeilen
9.2 KiB
Diff
148 Zeilen
9.2 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 NBT 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 566b588006da2b46ec1727be85560ccd59c42c6f..8f71a60c1d83dfad67ac77ec4464a55c7439d4b3 100644
|
|
--- a/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
|
|
+++ b/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
|
|
@@ -23,8 +23,15 @@ public class SmithingTransformRecipe implements SmithingRecipe {
|
|
final Ingredient base;
|
|
final Ingredient addition;
|
|
final ItemStack result;
|
|
+ final boolean copyNBT; // Paper
|
|
|
|
public SmithingTransformRecipe(Ingredient template, Ingredient base, Ingredient addition, ItemStack result) {
|
|
+ // Paper start
|
|
+ this(template, base, addition, result, true);
|
|
+ }
|
|
+ public SmithingTransformRecipe(Ingredient template, Ingredient base, Ingredient addition, ItemStack result, boolean copyNBT) {
|
|
+ this.copyNBT = copyNBT;
|
|
+ // Paper end
|
|
this.template = template;
|
|
this.base = base;
|
|
this.addition = addition;
|
|
@@ -39,11 +46,13 @@ public class SmithingTransformRecipe implements SmithingRecipe {
|
|
@Override
|
|
public ItemStack assemble(Container inventory, RegistryAccess registryManager) {
|
|
ItemStack itemstack = this.result.copy();
|
|
+ if (this.copyNBT) { // Paper - copy nbt conditionally
|
|
CompoundTag nbttagcompound = inventory.getItem(1).getTag();
|
|
|
|
if (nbttagcompound != null) {
|
|
itemstack.setTag(nbttagcompound.copy());
|
|
}
|
|
+ } // Paper
|
|
|
|
return itemstack;
|
|
}
|
|
@@ -83,7 +92,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.copyNBT); // Paper
|
|
|
|
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 e0b24c140e04a159a7b8aaef64ab94e19fc03dfd..2f26ef211322398e795cbdc75b565fc7922cf4ff 100644
|
|
--- a/src/main/java/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
|
|
+++ b/src/main/java/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
|
|
@@ -29,8 +29,15 @@ public class SmithingTrimRecipe implements SmithingRecipe {
|
|
final Ingredient template;
|
|
final Ingredient base;
|
|
final Ingredient addition;
|
|
+ final boolean copyNbt; // Paper
|
|
|
|
public SmithingTrimRecipe(Ingredient template, Ingredient base, Ingredient addition) {
|
|
+ // Paper start
|
|
+ this(template, base, addition, true);
|
|
+ }
|
|
+ public SmithingTrimRecipe(Ingredient template, Ingredient base, Ingredient addition, boolean copyNbt) {
|
|
+ this.copyNbt = copyNbt;
|
|
+ // Paper end
|
|
this.template = template;
|
|
this.base = base;
|
|
this.addition = addition;
|
|
@@ -56,7 +63,7 @@ public class SmithingTrimRecipe implements SmithingRecipe {
|
|
return ItemStack.EMPTY;
|
|
}
|
|
|
|
- ItemStack itemstack1 = itemstack.copy();
|
|
+ ItemStack itemstack1 = this.copyNbt ? itemstack.copy() : new ItemStack(itemstack.getItem(), itemstack.getCount()); // Paper
|
|
|
|
itemstack1.setCount(1);
|
|
ArmorTrim armortrim = new ArmorTrim((Holder) optional.get(), (Holder) optional1.get());
|
|
@@ -116,7 +123,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.copyNbt); // Paper
|
|
}
|
|
// 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 8c381e2745e7d5b63e72a60c5541b549f0d1b9bf..8b0e3a92e9893af954bc85adb2566502b65a0fa4 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
|
|
+ public CraftSmithingTransformRecipe(NamespacedKey key, ItemStack result, RecipeChoice template, RecipeChoice base, RecipeChoice addition, boolean copyNbt) {
|
|
+ super(key, result, template, base, addition, copyNbt);
|
|
+ }
|
|
+ // Paper end
|
|
|
|
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.willCopyNbt()); // Paper
|
|
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(), true), this.toNMS(this.getBase(), true), this.toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result))));
|
|
+ MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTransformRecipe(this.toNMS(this.getTemplate(), true), this.toNMS(this.getBase(), true), this.toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result), this.willCopyNbt()))); // Paper
|
|
}
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java
|
|
index 87f20a4811d082f217638768417c1c0feb84f741..105c72a674e1a8ca4eb6003841f5d933d3a2c275 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
|
|
+ public CraftSmithingTrimRecipe(NamespacedKey key, RecipeChoice template, RecipeChoice base, RecipeChoice addition, boolean copyNbt) {
|
|
+ super(key, template, base, addition, copyNbt);
|
|
+ }
|
|
+ // Paper end
|
|
|
|
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.willCopyNbt()); // Paper
|
|
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(), true), this.toNMS(this.getBase(), true), this.toNMS(this.getAddition(), true))));
|
|
+ MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.SmithingTrimRecipe(this.toNMS(this.getTemplate(), true), this.toNMS(this.getBase(), true), this.toNMS(this.getAddition(), true), this.willCopyNbt()))); // Paper
|
|
}
|
|
}
|