9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/leaf-archived-patches/removed/1.21.4/mcserver/0146-Validate-recipe-display-index-before-retrieving-it.patch
2025-06-29 23:39:55 +08:00

25 lines
1.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Wed, 19 Mar 2025 13:32:39 -0400
Subject: [PATCH] Validate recipe display index before retrieving it
Removed since Paper 1.21.4, fixed on Paper side
diff --git a/net/minecraft/world/item/crafting/RecipeManager.java b/net/minecraft/world/item/crafting/RecipeManager.java
index 4bd1b514f91c0a2c9261b41211a4a341f784a995..5b69c4927174611d62f0f4698215ab97c827c7f5 100644
--- a/net/minecraft/world/item/crafting/RecipeManager.java
+++ b/net/minecraft/world/item/crafting/RecipeManager.java
@@ -206,7 +206,11 @@ public class RecipeManager extends SimplePreparableReloadListener<RecipeMap> imp
@Nullable
public RecipeManager.ServerDisplayInfo getRecipeFromDisplay(RecipeDisplayId display) {
- return this.allDisplays.get(display.index());
+ // Leaf start - Validate recipe display index before retrieving it
+ final int index = display.index();
+
+ return this.allDisplays.size() > index ? this.allDisplays.get(index) : null;
+ // Leaf end - Validate recipe display index before retrieving it
}
public void listDisplaysForRecipe(ResourceKey<Recipe<?>> recipe, Consumer<RecipeDisplayEntry> output) {