From 2ecfc259c4e91ded20b83b222b0d418f191dd4e2 Mon Sep 17 00:00:00 2001 From: DoctaEnkoda Date: Sun, 12 Jan 2025 12:40:23 -0800 Subject: [PATCH] Added the ability to add combustible items --- build-data/purpur.at | 1 + ...the-ability-to-add-combustible-items.patch | 60 ----------------- ...the-ability-to-add-combustible-items.patch | 65 ------------------- .../main/java/org/bukkit/Bukkit.java.patch | 23 ++++++- .../main/java/org/bukkit/Server.java.patch | 19 +++++- .../inventory/AbstractFurnaceMenu.java.patch | 17 +++++ .../bukkit/craftbukkit/CraftServer.java.patch | 23 +++++++ 7 files changed, 81 insertions(+), 127 deletions(-) delete mode 100644 patches/api/0030-Added-the-ability-to-add-combustible-items.patch delete mode 100644 patches/server/0200-Added-the-ability-to-add-combustible-items.patch create mode 100644 purpur-server/minecraft-patches/sources/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch diff --git a/build-data/purpur.at b/build-data/purpur.at index 2b1143631..37b66526b 100644 --- a/build-data/purpur.at +++ b/build-data/purpur.at @@ -5,4 +5,5 @@ public net.minecraft.world.entity.Entity updateInWaterStateAndDoWaterCurrentPush public net.minecraft.world.entity.LivingEntity canGlide()Z public net.minecraft.world.entity.monster.Shulker MAX_SCALE public net.minecraft.world.entity.player.Player canGlide()Z +public net.minecraft.world.level.block.entity.FuelValues values public-f net.minecraft.world.entity.EntityType dimensions diff --git a/patches/api/0030-Added-the-ability-to-add-combustible-items.patch b/patches/api/0030-Added-the-ability-to-add-combustible-items.patch deleted file mode 100644 index 10b834d4c..000000000 --- a/patches/api/0030-Added-the-ability-to-add-combustible-items.patch +++ /dev/null @@ -1,60 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: DoctaEnkoda -Date: Mon, 9 Aug 2021 13:22:03 +0200 -Subject: [PATCH] Added the ability to add combustible items - - -diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java -index cd6c712a2ad92f73c7ce8f4ada8b810fcba00ba3..79528ad4408eac53754ccc810445970e263a1a32 100644 ---- a/src/main/java/org/bukkit/Bukkit.java -+++ b/src/main/java/org/bukkit/Bukkit.java -@@ -2987,5 +2987,24 @@ public final class Bukkit { - public static boolean isLagging() { - return server.isLagging(); - } -+ -+ /** -+ * Add an Item as fuel for furnaces -+ * -+ * @param material The material that will be the fuel -+ * @param burnTime The time (in ticks) this item will burn for -+ */ -+ public static void addFuel(@NotNull Material material, int burnTime) { -+ server.addFuel(material, burnTime); -+ } -+ -+ /** -+ * Remove an item as fuel for furnaces -+ * -+ * @param material The material that will no longer be a fuel -+ */ -+ public static void removeFuel(@NotNull Material material) { -+ server.removeFuel(material); -+ } - // Purpur end - } -diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index 788702d1c5be00a78a0438e267fe5fca9985e4ce..c1523229138d5d07569c8e564cf27b8276cca153 100644 ---- a/src/main/java/org/bukkit/Server.java -+++ b/src/main/java/org/bukkit/Server.java -@@ -2634,5 +2634,20 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi - * @return True if lagging - */ - boolean isLagging(); -+ -+ /** -+ * Add an Item as fuel for furnaces -+ * -+ * @param material The material that will be the fuel -+ * @param burnTime The time (in ticks) this item will burn for -+ */ -+ public void addFuel(@NotNull Material material, int burnTime); -+ -+ /** -+ * Remove an item as fuel for furnaces -+ * -+ * @param material The material that will no longer be a fuel -+ */ -+ public void removeFuel(@NotNull Material material); - // Purpur end - } diff --git a/patches/server/0200-Added-the-ability-to-add-combustible-items.patch b/patches/server/0200-Added-the-ability-to-add-combustible-items.patch deleted file mode 100644 index 842b947e4..000000000 --- a/patches/server/0200-Added-the-ability-to-add-combustible-items.patch +++ /dev/null @@ -1,65 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: DoctaEnkoda -Date: Mon, 9 Aug 2021 13:22:20 +0200 -Subject: [PATCH] Added the ability to add combustible items - - -diff --git a/net/minecraft/world/inventory/AbstractFurnaceMenu.java b/net/minecraft/world/inventory/AbstractFurnaceMenu.java -index 1240df9368855f836412b06cf564926a18bfe90d..248e2fb41df3cb1efc64921074a51a02419d8fbb 100644 ---- a/net/minecraft/world/inventory/AbstractFurnaceMenu.java -+++ b/net/minecraft/world/inventory/AbstractFurnaceMenu.java -@@ -114,7 +114,13 @@ public abstract class AbstractFurnaceMenu extends RecipeBookMenu { - } else if (slot != 1 && slot != 0) { - if (this.canSmelt(itemstack1)) { - if (!this.moveItemStackTo(itemstack1, 0, 1, false)) { -- return ItemStack.EMPTY; -+ // Purpur start - Added the ability to add combustible items -+ if (this.isFuel(itemstack1)) { -+ if (!this.moveItemStackTo(itemstack1, 1, 2, false)) { -+ return ItemStack.EMPTY; -+ } -+ } -+ // Purpur end - Added the ability to add combustible items - } - } else if (this.isFuel(itemstack1)) { - if (!this.moveItemStackTo(itemstack1, 1, 2, false)) { -diff --git a/net/minecraft/world/level/block/entity/FuelValues.java b/net/minecraft/world/level/block/entity/FuelValues.java -index 61ef08ac941b1e8988d001241780d3a1582f7a2d..6ceb938d6f6a4f2bc5b786c7af7bd291f7486340 100644 ---- a/net/minecraft/world/level/block/entity/FuelValues.java -+++ b/net/minecraft/world/level/block/entity/FuelValues.java -@@ -17,7 +17,7 @@ import net.minecraft.world.level.ItemLike; - import net.minecraft.world.level.block.Blocks; - - public class FuelValues { -- private final Object2IntSortedMap values; -+ public final Object2IntSortedMap values; // Purpur - private -> public - Added the ability to add combustible items - - FuelValues(Object2IntSortedMap fuelValues) { - this.values = fuelValues; -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 3b5225c3ba8e10df45df2fbf2305f8542b2f1f39..9aa6744ab3a19e1ecf32b4aa059b7f4c555f03ff 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -1629,6 +1629,22 @@ public final class CraftServer implements Server { - return true; - } - -+ // Purpur start - Added the ability to add combustible items -+ @Override -+ public void addFuel(org.bukkit.Material material, int burnTime) { -+ Preconditions.checkArgument(burnTime > 0, "BurnTime must be greater than 0"); -+ -+ net.minecraft.world.item.ItemStack itemStack = net.minecraft.world.item.ItemStack.fromBukkitCopy(new ItemStack(material)); -+ MinecraftServer.getServer().fuelValues().values.put(itemStack.getItem(), burnTime); -+ } -+ -+ @Override -+ public void removeFuel(org.bukkit.Material material) { -+ net.minecraft.world.item.ItemStack itemStack = net.minecraft.world.item.ItemStack.fromBukkitCopy(new ItemStack(material)); -+ MinecraftServer.getServer().fuelValues().values.keySet().removeIf(itemStack::is); -+ } -+ // Purpur end - Added the ability to add combustible items -+ - @Override - public List getRecipesFor(ItemStack result) { - Preconditions.checkArgument(result != null, "ItemStack cannot be null"); diff --git a/purpur-api/paper-patches/files/src/main/java/org/bukkit/Bukkit.java.patch b/purpur-api/paper-patches/files/src/main/java/org/bukkit/Bukkit.java.patch index 967abc8bc..f5430a56d 100644 --- a/purpur-api/paper-patches/files/src/main/java/org/bukkit/Bukkit.java.patch +++ b/purpur-api/paper-patches/files/src/main/java/org/bukkit/Bukkit.java.patch @@ -1,6 +1,6 @@ --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java -@@ -2968,4 +_,26 @@ +@@ -2968,4 +_,47 @@ public static Server.Spigot spigot() { return server.spigot(); } @@ -26,4 +26,25 @@ + return server.isLagging(); + } + // Purpur end - Lagging threshold ++ ++ // Purpur start - Added the ability to add combustible items ++ /** ++ * Add an Item as fuel for furnaces ++ * ++ * @param material The material that will be the fuel ++ * @param burnTime The time (in ticks) this item will burn for ++ */ ++ public static void addFuel(@NotNull Material material, int burnTime) { ++ server.addFuel(material, burnTime); ++ } ++ ++ /** ++ * Remove an item as fuel for furnaces ++ * ++ * @param material The material that will no longer be a fuel ++ */ ++ public static void removeFuel(@NotNull Material material) { ++ server.removeFuel(material); ++ } ++ // Purpur end - Added the ability to add combustible items } diff --git a/purpur-api/paper-patches/files/src/main/java/org/bukkit/Server.java.patch b/purpur-api/paper-patches/files/src/main/java/org/bukkit/Server.java.patch index 005059697..a771e76a1 100644 --- a/purpur-api/paper-patches/files/src/main/java/org/bukkit/Server.java.patch +++ b/purpur-api/paper-patches/files/src/main/java/org/bukkit/Server.java.patch @@ -1,6 +1,6 @@ --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -2607,4 +_,22 @@ +@@ -2607,4 +_,39 @@ */ void allowPausing(@NotNull org.bukkit.plugin.Plugin plugin, boolean value); // Paper end - API to check if the server is sleeping @@ -22,4 +22,21 @@ + */ + boolean isLagging(); + // Purpur end - Lagging threshold ++ ++ // Purpur start - Added the ability to add combustible items ++ /** ++ * Add an Item as fuel for furnaces ++ * ++ * @param material The material that will be the fuel ++ * @param burnTime The time (in ticks) this item will burn for ++ */ ++ public void addFuel(@NotNull Material material, int burnTime); ++ ++ /** ++ * Remove an item as fuel for furnaces ++ * ++ * @param material The material that will no longer be a fuel ++ */ ++ public void removeFuel(@NotNull Material material); ++ // Purpur end - Added the ability to add combustible items } diff --git a/purpur-server/minecraft-patches/sources/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch b/purpur-server/minecraft-patches/sources/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch new file mode 100644 index 000000000..1626289f6 --- /dev/null +++ b/purpur-server/minecraft-patches/sources/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch @@ -0,0 +1,17 @@ +--- a/net/minecraft/world/inventory/AbstractFurnaceMenu.java ++++ b/net/minecraft/world/inventory/AbstractFurnaceMenu.java +@@ -121,7 +_,13 @@ + } else if (index != 1 && index != 0) { + if (this.canSmelt(item)) { + if (!this.moveItemStackTo(item, 0, 1, false)) { +- return ItemStack.EMPTY; ++ // Purpur start - Added the ability to add combustible items ++ if (this.isFuel(item)) { ++ if (!this.moveItemStackTo(item, 1, 2, false)) { ++ return ItemStack.EMPTY; ++ } ++ } ++ // Purpur end - Added the ability to add combustible items + } + } else if (this.isFuel(item)) { + if (!this.moveItemStackTo(item, 1, 2, false)) { diff --git a/purpur-server/paper-patches/files/src/main/java/org/bukkit/craftbukkit/CraftServer.java.patch b/purpur-server/paper-patches/files/src/main/java/org/bukkit/craftbukkit/CraftServer.java.patch index b40374f1b..a6f0d6dd7 100644 --- a/purpur-server/paper-patches/files/src/main/java/org/bukkit/craftbukkit/CraftServer.java.patch +++ b/purpur-server/paper-patches/files/src/main/java/org/bukkit/craftbukkit/CraftServer.java.patch @@ -24,6 +24,29 @@ this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*"); this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions"); +@@ -1645,6 +_,22 @@ + return true; + } + ++ // Purpur start - Added the ability to add combustible items ++ @Override ++ public void addFuel(org.bukkit.Material material, int burnTime) { ++ Preconditions.checkArgument(burnTime > 0, "BurnTime must be greater than 0"); ++ ++ net.minecraft.world.item.ItemStack itemStack = net.minecraft.world.item.ItemStack.fromBukkitCopy(new ItemStack(material)); ++ MinecraftServer.getServer().fuelValues().values.put(itemStack.getItem(), burnTime); ++ } ++ ++ @Override ++ public void removeFuel(org.bukkit.Material material) { ++ net.minecraft.world.item.ItemStack itemStack = net.minecraft.world.item.ItemStack.fromBukkitCopy(new ItemStack(material)); ++ MinecraftServer.getServer().fuelValues().values.keySet().removeIf(itemStack::is); ++ } ++ // Purpur end - Added the ability to add combustible items ++ + @Override + public List getRecipesFor(ItemStack result) { + Preconditions.checkArgument(result != null, "ItemStack cannot be null"); @@ -3049,6 +_,18 @@ return CraftServer.this.console.paperConfigurations.createLegacyObject(CraftServer.this.console); }