Fix crash relating to bad recipes in furnace-like tile entities

This commit is contained in:
Jake Potrebic 2023-03-19 20:36:22 -07:00
parent 71e08c0a8d
commit b436c07ec7

View file

@ -176,11 +176,11 @@
+ ItemStack itemstack = (ItemStack) nonnulllist.get(0);
+ ItemStack itemstack1 = ((AbstractCookingRecipe) recipeholder.value()).assemble(singlerecipeinput, iregistrycustom);
+ ItemStack itemstack2 = (ItemStack) nonnulllist.get(2);
+
+ // CraftBukkit start - fire FurnaceSmeltEvent
+ CraftItemStack source = CraftItemStack.asCraftMirror(itemstack);
+ org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1);
+
+ FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(CraftBlock.at(world, blockposition), source, result, (org.bukkit.inventory.CookingRecipe<?>) recipeholder.toBukkitRecipe()); // Paper - Add recipe to cook events
+ world.getCraftServer().getPluginManager().callEvent(furnaceSmeltEvent);
+
@ -276,7 +276,7 @@
}
}
@@ -378,41 +481,55 @@
@@ -378,41 +481,56 @@
}
public List<RecipeHolder<?>> getRecipesToAwardAndPopExperience(ServerLevel world, Vec3 pos) {
@ -294,6 +294,7 @@
- world.recipeAccess().byKey((ResourceKey) entry.getKey()).ifPresent((recipeholder) -> {
+ worldserver.recipeAccess().byKey(entry.getKey()).ifPresent((recipeholder) -> { // CraftBukkit - decompile error
+ if (!(recipeholder.value() instanceof AbstractCookingRecipe)) return; // Paper - don't process non-cooking recipes
list.add(recipeholder);
- AbstractFurnaceBlockEntity.createExperience(world, pos, entry.getIntValue(), ((AbstractCookingRecipe) recipeholder.value()).experience());
+ AbstractFurnaceBlockEntity.createExperience(worldserver, vec3d, entry.getIntValue(), ((AbstractCookingRecipe) recipeholder.value()).experience(), blockposition, entityplayer, itemstack, amount); // CraftBukkit