mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-05 10:20:53 +01:00
c0936a71bd
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: 01aa02eb PR-858: Add LivingEntity#playHurtAnimation() 9421320f PR-884: Refinements to new ban API for improved compatibility and correctness 37a60b45 SPIGOT-6455, SPIGOT-7030, PR-750: Improve ban API 4eeb174b All smithing inventories are now the new smithing inventory f2bb168e PR-880: Add methods to get/set FallingBlock CancelDrop e7a807fa PR-879: Add Player#sendHealthUpdate() 692b8e96 SPIGOT-7370: Remove float value conversion in plugin.yml 2d033390 SPIGOT-7403: Add direct API for waxed signs 16a08373 PR-876: Add missing Raider API and 'no action ticks' CraftBukkit Changes: b60a95c8c PR-1189: Add LivingEntity#playHurtAnimation() 95c335c63 PR-1226: Fix VehicleEnterEvent not being called for certain entities 0a0fc3bee PR-1227: Refinements to new ban API for improved compatibility and correctness 0d0b1e5dc Revert bad change to PathfinderGoalSit causing all cats to sit 648196070 SPIGOT-6455, SPIGOT-7030, PR-1054: Improve ban API 31fe848d6 All smithing inventories are now the new smithing inventory 9a919a143 SPIGOT-7416: SmithItemEvent not firing in Smithing Table 9f64f0d22 PR-1221: Add methods to get/set FallingBlock CancelDrop 3be9ac171 PR-1220: Add Player#sendHealthUpdate() c1279f775 PR-1209: Clean up various patches c432e4397 Fix Raider#setCelebrating() implementation 504d96665 SPIGOT-7403: Add direct API for waxed signs c68c1f1b3 PR-1216: Add missing Raider API and 'no action ticks' 85b89c3dd Increase outdated build delay Spigot Changes: 9ebce8af Rebuild patches 64b565e6 Rebuild patches
148 lines
9.3 KiB
Diff
148 lines
9.3 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 2b3718f9fc68c286e8abdde4a960e19b97302531..7819a914bbbe4f0e2a4407e4c99b14732d4d89c5 100644
|
|
--- a/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
|
|
+++ b/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
|
|
@@ -25,8 +25,15 @@ public class SmithingTransformRecipe implements SmithingRecipe {
|
|
final Ingredient base;
|
|
final Ingredient addition;
|
|
final ItemStack result;
|
|
+ final boolean copyNBT; // Paper
|
|
|
|
public SmithingTransformRecipe(ResourceLocation id, Ingredient template, Ingredient base, Ingredient addition, ItemStack result) {
|
|
+ // Paper start
|
|
+ this(id, template, base, addition, result, true);
|
|
+ }
|
|
+ public SmithingTransformRecipe(ResourceLocation id, Ingredient template, Ingredient base, Ingredient addition, ItemStack result, boolean copyNBT) {
|
|
+ this.copyNBT = copyNBT;
|
|
+ // Paper end
|
|
this.id = id;
|
|
this.template = template;
|
|
this.base = base;
|
|
@@ -42,11 +49,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;
|
|
}
|
|
@@ -91,7 +100,7 @@ public class SmithingTransformRecipe implements SmithingRecipe {
|
|
public Recipe toBukkitRecipe() {
|
|
CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
|
|
|
- CraftSmithingTransformRecipe recipe = new CraftSmithingTransformRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition));
|
|
+ CraftSmithingTransformRecipe recipe = new CraftSmithingTransformRecipe(CraftNamespacedKey.fromMinecraft(this.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 c28b0d7a97e8463f7fe15bbf0f3485f2559efd4a..5b0cee067b5c69d2d4c51b8c8d2489744b843043 100644
|
|
--- a/src/main/java/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
|
|
+++ b/src/main/java/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
|
|
@@ -31,8 +31,15 @@ public class SmithingTrimRecipe implements SmithingRecipe {
|
|
final Ingredient template;
|
|
final Ingredient base;
|
|
final Ingredient addition;
|
|
+ final boolean copyNbt; // Paper
|
|
|
|
public SmithingTrimRecipe(ResourceLocation id, Ingredient template, Ingredient base, Ingredient addition) {
|
|
+ // Paper start
|
|
+ this(id, template, base, addition, true);
|
|
+ }
|
|
+ public SmithingTrimRecipe(ResourceLocation id, Ingredient template, Ingredient base, Ingredient addition, boolean copyNbt) {
|
|
+ this.copyNbt = copyNbt;
|
|
+ // Paper end
|
|
this.id = id;
|
|
this.template = template;
|
|
this.base = base;
|
|
@@ -59,7 +66,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());
|
|
@@ -124,7 +131,7 @@ public class SmithingTrimRecipe implements SmithingRecipe {
|
|
// CraftBukkit start
|
|
@Override
|
|
public Recipe toBukkitRecipe() {
|
|
- return new CraftSmithingTrimRecipe(CraftNamespacedKey.fromMinecraft(this.id), CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition));
|
|
+ return new CraftSmithingTrimRecipe(CraftNamespacedKey.fromMinecraft(this.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 872baa62d5c893141af88727f5f93911cebf8cdc..248d742b173d7b5fae655e656cd87146e2a483c1 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java
|
|
@@ -11,12 +11,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;
|
|
}
|
|
|
|
@@ -24,6 +29,6 @@ public class CraftSmithingTransformRecipe extends SmithingTransformRecipe implem
|
|
public void addToCraftingManager() {
|
|
ItemStack result = this.getResult();
|
|
|
|
- MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.SmithingTransformRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getTemplate(), true), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result)));
|
|
+ MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.SmithingTransformRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getTemplate(), true), toNMS(this.getBase(), true), 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 6ef43f58d8fb6bbe9e2a58fc0bb62fb0c935d7f9..610e6fa88e5d835027ba19d1bd3ff31cc42d2687 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java
|
|
@@ -11,17 +11,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 net.minecraft.world.item.crafting.SmithingTrimRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getTemplate(), true), toNMS(this.getBase(), true), toNMS(this.getAddition(), true)));
|
|
+ MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.SmithingTrimRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getTemplate(), true), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), this.willCopyNbt())); // Paper
|
|
}
|
|
}
|