Files
ParchmentMC/patches/server/0012-Add-Furnace-Recipe-API.patch
Lexi f5430d06d7 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

PaperMC/Paper@42a9c37 Move Adventure patch up
PaperMC/Paper@1d7a6a0 Add missing glow_item_frame walkers
PaperMC/Paper@f9b05cc Expose furnace minecart push property. (#7548)
PaperMC/Paper@9351513 Fix handling message in PlayerHandshakeEvent (#7542)
PaperMC/Paper@6564f70 Fix cancelling ProjectileHitEvent for piercing arrows (#7492)
PaperMC/Paper@196271d Fix save problems on shutdown
PaperMC/Paper@1e12cf8 Add more to the save fixes
PaperMC/Paper@a36d7f6 Updated Upstream (CraftBukkit)
PaperMC/Paper@7b9c30f Fix scoreboard objective name length limit
PaperMC/Paper@d9bf5e7 Add method to set noclip on arrows (#7263)
PaperMC/Paper@c34fb09 Add ghast api (#7554)
PaperMC/Paper@e0b3f3f Adventure 4.10.1
PaperMC/Paper@718fab1 Add CPU name and JVM vendor info in timings (#7490)
PaperMC/Paper@7a21333 Fix setting the view distance to 32 (#7503)
PaperMC/Paper@4423e12 Update docs link in paper.yml (#7562)
PaperMC/Paper@b55ba19 Update README for new docs (#7561)
PaperMC/Paper@657d163 Prevent despawned navigators being readded (#7574)
PaperMC/Paper@d714682 Add more entity api (#7564)
PaperMC/Paper@1790528 More projectile API (#5731)
PaperMC/Paper@ea1efef Remove Patches (#7541)
PaperMC/Paper@aab1f8a Fix swamp hut cat generation deadlock
PaperMC/Paper@dc96bba Ensure the item sent isn't air (#7584)
PaperMC/Paper@bfa33d9 Various improvements to console color formatting (#7560)
PaperMC/Paper@87927e1 Fix CreativeCategory API (#7586)
PaperMC/Paper@ab03538 Fix colors in some console messages
PaperMC/Paper@1358d1e Updated Upstream (CraftBukkit/Spigot) (#7580)
PaperMC/Paper@b65b48f [ci skip] Update gradle wrapper
PaperMC/Paper@1ce3555 [ci-skip] Fix typo in feature request issue template (#7593)
PaperMC/Paper@c8e49cc Add get/set wait time for fish hooks. (#5595)
PaperMC/Paper@a5be178 Use correct toX/Y/Z in player move packet handling
PaperMC/Paper@0ca80c7 Add getComputedBiome API (#5668)
PaperMC/Paper@2d3e8f7 Properly lookup random-ticked precipitation blocks (#7606)
PaperMC/Paper@f35a0ce Remove Java version check once and for all (#7612)
PaperMC/Paper@1c5f8b0 Updated Upstream (Bukkit/CraftBukkit) (#7604)
PaperMC/Paper@f0d0078 Add debug for invalid GameProfiles on skull blocks/items (#7512)
PaperMC/Paper@8788bf7 fix datapacks not being able to modify nether/end (#7588)
PaperMC/Paper@b8c90d2 Added method to check snapshot state of TileStates (#7325)
PaperMC/Paper@8897cea Add enchantWithLevels API (#7615)
PaperMC/Paper@2eeca6f Fix world saving in unloadWorld
PaperMC/Paper@319d5fa Fix state locking for getTopMRUProfiles & getProfileIfCached
PaperMC/Paper@bc68ee0 Remove redundant GameProfileCache diff
PaperMC/Paper@855637f Updated Upstream (CraftBukkit) (#7624)
PaperMC/Paper@5eb61dd Buffer OOB setBlock calls
PaperMC/Paper@7b46444 Properly create profiles with custom name/uuid (#7558)
PaperMC/Paper@a686ff5 Add more missing entity API (#7592)
PaperMC/Paper@993f828 Add TameableDeathMessageEvent (#5392)
PaperMC/Paper@a939d6e Fix generator settings string for flat-type worlds (#7568)
PaperMC/Paper@ab666a4 Deprecating remaining blockkey methods (#7638)
PaperMC/Paper@e7d928a Fix EntityChangeBlockEvent#getBlockData for when sheep eats grass block (#7646)
PaperMC/Paper@e2f743d Fix PalettedContainer synchronization (#7663)
PaperMC/Paper@7fa8870 Updated Upstream (Bukkit/CraftBukkit) (#7672)
PaperMC/Paper@fa68bb1 Fix entity position desync for hanging entities (#7659)
PaperMC/Paper@d3c1023 fix player loottables running when mob loot gamerule is false (#7651)
PaperMC/Paper@7f47b9b Remove KeyedObject interface (#7680)
PaperMC/Paper@7bf9446 Add per player chunk loading limits
PaperMC/Paper@04c7b16 Undeprecate Material#isLegacy (#7679)
PaperMC/Paper@443c506 Fix Nullability Annotations for PrepareItemEnchantEvent (#7681)
PaperMC/Paper@ea2c81e Fix lectern quick move
PaperMC/Paper@87e11bf Cache resource keys instead of trying to create them (#7643)
PaperMC/Paper@820e9ca Update decompiler & param mappings
PaperMC/Paper@92426e3 Update Gradle wrapper
PaperMC/Paper@62dcff3 Update actions
PaperMC/Paper@2914457 Allow seting custom podium location for ender dragon (#7695)
PaperMC/Paper@11e0dcd Fix NBT pieces overriding a block entity during worldgen deadlock (#7692)
PaperMC/Paper@2f16393 Updated Upstream (CraftBukkit)
PaperMC/Paper@4322c05 Use patched spigot decompiler (#7706)
PaperMC/Paper@f8e8d6c Strip enderpearl owners when they are no longer ticked (#7559)
PaperMC/Paper@e42d683 Fix StructureGrowEvent species for RED_MUSHROOM
PaperMC/Paper@a9ee104 Prevent tile entity copies loading chunks
PaperMC/Paper@d4a712d [CI-SKIP] Remove unused import from last patch
PaperMC/Paper@a9f252e Replace third party repos with Paper repo (#7733)
PaperMC/Paper@b8fa41e [ci skip] Remove Mojang repo from test-plugin
PaperMC/Paper@c6e631a Use username instead of display name in PlayerList#getPlayerStats (#7740)
PaperMC/Paper@1cfd363 Updated Upstream (Bukkit/CraftBukkit/Spigot)
PaperMC/Paper@af94364 Fix slime spawners not spawning outside slime chunks (#7741)
PaperMC/Paper@6b9f7a0 Don't fire worldborder events for virtual borders (#7749)
PaperMC/Paper@8bfb1d2 Pass ServerLevel for gamerule callbacks (#7668)
PaperMC/Paper@c66b0f9 Add pre-unbreaking amount to PlayerItemDamageEvent (#7724)
PaperMC/Paper@86fb3d2 Don't send itemmeta for books with the hide option enabled (#7734)
PaperMC/Paper@c642d25 Improve update folder behavior (#7687)
PaperMC/Paper@c7d4c01 Ignore invalid jars inside of the updates folder (Fixes #7751)
PaperMC/Paper@4ecc338 WorldCreator#keepSpawnLoaded (#7673)
PaperMC/Paper@873bfa6 Remove World#refreshChunk deprecation (#7684)
PaperMC/Paper@76ed156 Grant temporary immunity from EAR to moving entities (Fixes #7637) (#7644)
PaperMC/Paper@567fce6 Don't apply previous potion when item is potion (fixes #7756) (#7757)
PaperMC/Paper@c449f6a Build updates
PaperMC/Paper@ef6a1a5 Revert to old createProfile(UUID, String) logic (#7723)
PaperMC/Paper@0f8aa4e Fix NPE for BlockDataMeta#getBlockData (#7670)
PaperMC/Paper@16f224a Trigger bee_nest_destroyed trigger in the correct place (#7436)
PaperMC/Paper@caf4a6f Remove or replace a few dumb deprecations (#7760)
PaperMC/Paper@47f43da Add missing javadoc deprecation msgs for PlayerProfile (#7688)
PaperMC/Paper@fbbc03a Add EntityDyeEvent and CollarColorable interface (#7625)
PaperMC/Paper@5b85ee3 Fire CauldronLevelChange on initial fill (#7678)
PaperMC/Paper@4dc78ae Fix some team color docs and added hasColor (#7602)
PaperMC/Paper@0bf7c95 Fix opening inv in PlayerRecipeBookClickEvent handler (#7552)
PaperMC/Paper@d70ac03 fix powder snow cauldrons not turning to water (#7229)
PaperMC/Paper@ce059b4 Fix V1451 dataconverter stat types
PaperMC/Paper@6f5e6c6 Use setMessage instead of arraycopy
PaperMC/Paper@608482d cleanup filtered sign text (#7777)
PaperMC/Paper@4166632 Updated Upstream (Bukkit/CraftBukkit) (#7776)
PaperMC/Paper@e564110 Couple fixes/improvements to PlayerSetSpawnEvent (#6754)
PaperMC/Paper@e5da93a Deprecate duplicate SoundGroup API (#7509)
PaperMC/Paper@2ab0258 Use mojang item ids for alternative item despawn rate (#6997)
PaperMC/Paper@f6a69de Undeprecate getOfflinePlayer (#7773)
PaperMC/Paper@a117da6 Add PlayerStopUsingItemEvent (#7787)
PaperMC/Paper@f3a8a0b FallingBlock auto expire setting (#7037)
PaperMC/Paper@4219389 Don't tick markers (#7299)
PaperMC/Paper@2515bc4 Improve configurable door difficulty (#6985)
PaperMC/Paper@8c9d98e Clean unused field for Configurable door breaking difficulty (#7793)
PaperMC/Paper@b831784 Only log for passenger / vehicle world mismatch
PaperMC/Paper@7a6163b Add Alternate Current's redstone implementation as an alternative to Vanilla and Eigencraft's. (#7701)
PaperMC/Paper@1a17a83 Move redstone config changes to Eigencraft patch
PaperMC/Paper@87d2eb2 Fix door breaking difficulty defaults for vindicator (#7795)
PaperMC/Paper@e399754 Do not accept invalid client settings
PaperMC/Paper@268476b Fix whitespace error in Alternate Current patch
PaperMC/Paper@18f0f8d Updated Upstream (Bukkit/CraftBukkit/Spigot)
PaperMC/Paper@5928327 Remove unneeded patch (#7806)
PaperMC/Paper@9fd870d Fix cancelling PlayerItemFrameChangeEvent (#7761)
PaperMC/Paper@8d1de8d deprecate old MaterialData api (#7585)
PaperMC/Paper@0116751 List world on tile entity placement exception (#7709)
PaperMC/Paper@73bd35d Updated Upstream (Bukkit/CraftBukkit)
PaperMC/Paper@7045f18 Change link to screamingsandals
PaperMC/Paper@ca62386 Hide ores with deepslate at Y=4 and below (#7792)
PaperMC/Paper@9b492cf Deprecate set/doesBounce from Projectile (#7800)
PaperMC/Paper@ed4e916 [ci-skip] Update repository and API urls (#7835)
PaperMC/Paper@fc1752f Fix more upstream javadocs (#7837)
PaperMC/Paper@123cad5 Remove incorrect parent perm from debugstick.always (#7846)
PaperMC/Paper@d8108b5 team color parameter may be null, causing NPE
PaperMC/Paper@31ccc57 Add support for Proxy Protocol (#7710)
PaperMC/Paper@a90092e Updated Upstream (CraftBukkit/Spigot) (#7848)
PaperMC/Paper@79e07f3 Fix addPassenger for Marker (#7762)
PaperMC/Paper@182a609 Fix duplicate world keys via createWorld (#7614)
PaperMC/Paper@b6a6544 Provide ComponentSerializer services (#7527)
PaperMC/Paper@3f7fbe3 Fix cb's janky level name in WorldCreator (#7851)
PaperMC/Paper@af3b377 Update ForgeFlower (#7857)
PaperMC/Paper@9667181 Fix OfflinePlayer#getBedSpawnLocation (#7861)
PaperMC/Paper@c123915 Fix FurnaceInventory for smokers and blast furnaces (#7249)
PaperMC/Paper@f7382f5 Remove unneeded UOE when copying biome sources (#7629)
PaperMC/Paper@6b035fd Update default vanilla command perms (#7386)
PaperMC/Paper@f210f67 Update the rewriteForIde for new cb package version (#7242)
PaperMC/Paper@3f7111d Fix EntityEquipment and related javadocs (#7380)
PaperMC/Paper@78e6431 Add default kick msg component (#6886)
PaperMC/Paper@04e1b07 Check HAProxyMessage type is PROXY (#7864)
PaperMC/Paper@00c6ae8 Implement Translatable on CreativeCategory (#7587)
PaperMC/Paper@7602dd2 Sanitize Sent BlockEntity NBT (#7010)
PaperMC/Paper@2d17a50 Add translation keys to GameMode enum (#7081)
PaperMC/Paper@c5caee3 Prevent entity loading causing async lookups (#7553)
PaperMC/Paper@71fe3c6 Add numeric string completion suggestions as int suggestions (#6360)
PaperMC/Paper@b1ac25f Respect x-ray permission in World#refreshChunk (#7214)
PaperMC/Paper@1d08ce8 Disable book selector resolving by default
PaperMC/Paper@80d5e71 Updated Upstream (Bukkit)
PaperMC/Paper@2033dba Updated Upstream (CraftBukkit)
PaperMC/Paper@a3ad720 Remove ChatColor usages (#7543)
PaperMC/Paper@8fc0999 Fix some nullability things (#7275)
PaperMC/Paper@fd069dd Remove incorrect throws javadoc in Team (#7869)
PaperMC/Paper@bed5cb2 Limit resolved selectors when enabled
PaperMC/Paper@4d83ed0 [ci skip] Changing the order of the rebase with autosquash command in the contributing.md (#6974)
PaperMC/Paper@071a4a2 throw exception if worlds are created while being ticked (#7653)
PaperMC/Paper@5b6397a Make leave messages for kicks the same as for quitting (#7874)
PaperMC/Paper@5befb55 Updated Upstream (Bukkit/CraftBukkit) (#7875)
PaperMC/Paper@b3deb25 Move some methods to RegionAccessor (#7635)
PaperMC/Paper@d8ef841 [DataConverter] Fix generator options parsing
PaperMC/Paper@4b27254 Fix treasure maps discovered settings (#7627)
PaperMC/Paper@276d830 Fix campfire walker in V1920
PaperMC/Paper@3925a53 Make timings link clickable (#7944)
2022-06-12 18:18:03 -04:00

233 lines
8.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: lexikiq <noellekiq@gmail.com>
Date: Tue, 13 Jul 2021 17:27:45 -0400
Subject: [PATCH] Add Furnace Recipe API
Temporary API to get the result of smelting an item in a (type of) furnace.
Will eventually (hopefully) be replaced by a more extensive Paper PR with support for all recipes.
diff --git a/src/main/java/gg/projecteden/parchment/inventory/CraftRecipeType.java b/src/main/java/gg/projecteden/parchment/inventory/CraftRecipeType.java
new file mode 100644
index 0000000000000000000000000000000000000000..5549da2a0b0790699abff627148a6b15ca37febf
--- /dev/null
+++ b/src/main/java/gg/projecteden/parchment/inventory/CraftRecipeType.java
@@ -0,0 +1,44 @@
+package gg.projecteden.parchment.inventory;
+
+import net.minecraft.world.item.crafting.AbstractCookingRecipe;
+
+public class CraftRecipeType {
+ public static net.minecraft.world.item.crafting.RecipeType asNMS(RecipeType recipeType) {
+ return switch (recipeType) {
+ case CRAFTING -> net.minecraft.world.item.crafting.RecipeType.CRAFTING;
+ case SMELTING -> net.minecraft.world.item.crafting.RecipeType.SMELTING;
+ case BLASTING -> net.minecraft.world.item.crafting.RecipeType.BLASTING;
+ case SMOKING -> net.minecraft.world.item.crafting.RecipeType.SMOKING;
+ case CAMPFIRE_COOKING -> net.minecraft.world.item.crafting.RecipeType.CAMPFIRE_COOKING;
+ case STONECUTTING -> net.minecraft.world.item.crafting.RecipeType.STONECUTTING;
+ case SMITHING -> net.minecraft.world.item.crafting.RecipeType.SMITHING;
+ };
+ }
+
+ public static RecipeType asBukkit(net.minecraft.world.item.crafting.RecipeType recipeType) {
+ if (recipeType == net.minecraft.world.item.crafting.RecipeType.CRAFTING) {
+ return RecipeType.CRAFTING;
+ } else if (recipeType == net.minecraft.world.item.crafting.RecipeType.SMELTING) {
+ return RecipeType.SMELTING;
+ } else if (recipeType == net.minecraft.world.item.crafting.RecipeType.BLASTING) {
+ return RecipeType.BLASTING;
+ } else if (recipeType == net.minecraft.world.item.crafting.RecipeType.SMOKING) {
+ return RecipeType.SMOKING;
+ } else if (recipeType == net.minecraft.world.item.crafting.RecipeType.CAMPFIRE_COOKING) {
+ return RecipeType.CAMPFIRE_COOKING;
+ } else if (recipeType == net.minecraft.world.item.crafting.RecipeType.STONECUTTING) {
+ return RecipeType.STONECUTTING;
+ } else if (recipeType == net.minecraft.world.item.crafting.RecipeType.SMITHING) {
+ return RecipeType.SMITHING;
+ }
+ throw new IllegalArgumentException("Unknown recipe type");
+ }
+
+ public static net.minecraft.world.item.crafting.RecipeType<AbstractCookingRecipe> asCookingRecipe(RecipeType recipeType) {
+ try {
+ return (net.minecraft.world.item.crafting.RecipeType<AbstractCookingRecipe>) asNMS(recipeType);
+ } catch (ClassCastException exc) {
+ throw new IllegalArgumentException("Recipe type must be a cooking recipe");
+ }
+ }
+}
diff --git a/src/main/java/gg/projecteden/parchment/inventory/SingletonContainer.java b/src/main/java/gg/projecteden/parchment/inventory/SingletonContainer.java
new file mode 100644
index 0000000000000000000000000000000000000000..e7114e456f818d7bdd4081620f4b9b9376679145
--- /dev/null
+++ b/src/main/java/gg/projecteden/parchment/inventory/SingletonContainer.java
@@ -0,0 +1,151 @@
+package gg.projecteden.parchment.inventory;
+
+import com.google.common.base.Preconditions;
+import net.minecraft.world.Container;
+import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.item.ItemStack;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.entity.HumanEntity;
+import org.bukkit.inventory.InventoryHolder;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * A container which holds only one item and returns similar values to that of
+ * {@link net.minecraft.world.SimpleContainer SimpleContainer}, meaning it will raise
+ * {@link IndexOutOfBoundsException IndexOutOfBoundsExceptions} and return empty item stacks
+ * where applicable to mirror that class.
+ */
+public class SingletonContainer implements net.minecraft.world.Container {
+
+ private @NotNull ItemStack item;
+ private int maxStackSize = Container.MAX_STACK;
+
+ public SingletonContainer() {
+ this.item = ItemStack.EMPTY;
+ }
+
+ public SingletonContainer(@NotNull ItemStack item) {
+ this.item = Preconditions.checkNotNull(item, "item");
+ }
+
+ public SingletonContainer(org.bukkit.inventory.@NotNull ItemStack item) {
+ this.item = CraftItemStack.asNMSCopy(Preconditions.checkNotNull(item, "item"));
+ }
+
+ public SingletonContainer(@NotNull Material material) {
+ this(new org.bukkit.inventory.ItemStack(Preconditions.checkNotNull(material, "material")));
+ }
+
+ private static void throwIndexException(int index) {
+ throw new IndexOutOfBoundsException("Received slot " + index + ", expected 0");
+ }
+
+ @Override
+ public int getContainerSize() {
+ return 1;
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return item.isEmpty();
+ }
+
+ @Override
+ public ItemStack getItem(int slot) {
+ if (slot < 0) {
+ throwIndexException(slot);
+ }
+ return slot == 0 ? item : ItemStack.EMPTY;
+ }
+
+ @Override
+ public ItemStack removeItem(int slot, int amount) {
+ if (slot < 0) {
+ throwIndexException(slot);
+ }
+ ItemStack itemStack = slot == 0 && !item.isEmpty() ? item.split(amount) : ItemStack.EMPTY;
+ if (!itemStack.isEmpty()) {
+ setChanged();
+ }
+ return itemStack;
+ }
+
+ @Override
+ public ItemStack removeItemNoUpdate(int slot) {
+ if (slot != 0) {
+ throwIndexException(slot);
+ }
+ ItemStack oldItem = item;
+ item = ItemStack.EMPTY;
+ return oldItem.isEmpty() ? ItemStack.EMPTY : oldItem;
+ }
+
+ @Override
+ public void setItem(int slot, ItemStack stack) {
+ if (slot != 0) {
+ throwIndexException(slot);
+ }
+ item = stack;
+ }
+
+ @Override
+ public int getMaxStackSize() {
+ return maxStackSize;
+ }
+
+ @Override
+ public void setMaxStackSize(int size) {
+ maxStackSize = size;
+ }
+
+ @Override
+ public void setChanged() {
+
+ }
+
+ @Override
+ public boolean stillValid(Player player) {
+ return true;
+ }
+
+ @Override
+ public List<ItemStack> getContents() {
+ return Collections.singletonList(item);
+ }
+
+ @Override
+ public void onOpen(CraftHumanEntity who) {
+
+ }
+
+ @Override
+ public void onClose(CraftHumanEntity who) {
+
+ }
+
+ @Override
+ public List<HumanEntity> getViewers() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public InventoryHolder getOwner() {
+ return null;
+ }
+
+ @Override
+ public Location getLocation() {
+ return null;
+ }
+
+ @Override
+ public void clearContent() {
+ item = ItemStack.EMPTY;
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 43244a479a112786539a905a22cb12e3cf55b2dd..72b0a17a52169c0bd6b985e82278fffa73340298 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -2322,4 +2322,11 @@ public class CraftWorld extends CraftRegionAccessor implements World {
return this.adventure$pointers;
}
// Paper end
+
+ // Parchment start
+ @Override
+ public ItemStack smeltItem(ItemStack toSmelt, gg.projecteden.parchment.inventory.RecipeType recipeType) {
+ return world.getRecipeManager().getRecipeFor(gg.projecteden.parchment.inventory.CraftRecipeType.asCookingRecipe(recipeType), new gg.projecteden.parchment.inventory.SingletonContainer(toSmelt), world).map(recipe -> recipe.getResultItem().getBukkitStack()).orElse(null);
+ }
+ // Parchment end
}