2023-09-24 20:47:17 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Video <videogamesm12@gmail.com>
|
|
|
|
Date: Sun, 13 Mar 2022 18:42:07 -0600
|
|
|
|
Subject: [PATCH] Fixes Knowledge Books causing log spam when invalid data is
|
|
|
|
provided
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java b/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java
|
2024-04-16 05:12:25 +00:00
|
|
|
index 5ebc309aed545a4c22970e617519fe916a29fa3c..14a35465e41c9ecb51bea5b084e2637ebd21d295 100644
|
2023-09-24 20:47:17 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java
|
|
|
|
@@ -40,9 +40,9 @@ public class KnowledgeBookItem extends Item {
|
|
|
|
|
2024-04-16 05:12:25 +00:00
|
|
|
for (int i = 0; i < listTag.size(); i++) {
|
2023-09-24 20:47:17 +00:00
|
|
|
String string = listTag.getString(i);
|
|
|
|
- Optional<RecipeHolder<?>> optional = recipeManager.byKey(new ResourceLocation(string));
|
|
|
|
+ Optional<RecipeHolder<?>> optional = recipeManager.byKey(ResourceLocation.tryParse(string)); // Scissors - Validate resource locations
|
|
|
|
if (!optional.isPresent()) {
|
2024-04-16 05:12:25 +00:00
|
|
|
- LOGGER.error("Invalid recipe: {}", string);
|
2023-09-24 20:47:17 +00:00
|
|
|
+ // Scissors - Don't log errors caused by invalid recipes being provided
|
|
|
|
return InteractionResultHolder.fail(itemStack);
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -55,7 +55,7 @@ public class KnowledgeBookItem extends Item {
|
|
|
|
|
|
|
|
return InteractionResultHolder.sidedSuccess(itemStack, world.isClientSide());
|
|
|
|
} else {
|
2024-04-16 05:12:25 +00:00
|
|
|
- LOGGER.error("Tag not valid: {}", compoundTag);
|
2023-09-24 20:47:17 +00:00
|
|
|
+ // Scissors - Don't throw errors into the logs if an NBT compound isn't present or is missing the Recipes tag.
|
|
|
|
return InteractionResultHolder.fail(itemStack);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java
|
2023-12-10 23:16:21 +00:00
|
|
|
index e904bf8b6a7d18a0e846c3b59e2d7f3d6e530e39..65b076b376bf6ab363a3eb62dfa2c96c45624957 100644
|
2023-09-24 20:47:17 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java
|
|
|
|
@@ -41,7 +41,11 @@ public class CraftMetaKnowledgeBook extends CraftMetaItem implements KnowledgeBo
|
|
|
|
for (int i = 0; i < pages.size(); i++) {
|
|
|
|
String recipe = pages.getString(i);
|
|
|
|
|
|
|
|
- this.addRecipe(CraftNamespacedKey.fromString(recipe));
|
|
|
|
+ // Scissors start - Don't add recipes with invalid namespaces
|
|
|
|
+ try {
|
|
|
|
+ this.addRecipe(CraftNamespacedKey.fromString(recipe));
|
|
|
|
+ } catch (Exception ignored) {}
|
|
|
|
+ // Scissors end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|