From 3a8425d3e9901b3b662141418a07e26c89a65fd3 Mon Sep 17 00:00:00 2001 From: Helvetica Volubi Date: Thu, 24 Apr 2025 21:04:18 +0800 Subject: [PATCH 1/3] bugfix: fix crash when execute setblock with an illegal nbt --- .../0053-SetBlockCommand-crash-fix.patch | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 luminol-server/minecraft-patches/features/0053-SetBlockCommand-crash-fix.patch diff --git a/luminol-server/minecraft-patches/features/0053-SetBlockCommand-crash-fix.patch b/luminol-server/minecraft-patches/features/0053-SetBlockCommand-crash-fix.patch new file mode 100644 index 0000000..6660ba4 --- /dev/null +++ b/luminol-server/minecraft-patches/features/0053-SetBlockCommand-crash-fix.patch @@ -0,0 +1,25 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Helvetica Volubi +Date: Thu, 24 Apr 2025 20:59:52 +0800 +Subject: [PATCH] SetBlockCommand crash fix + + +diff --git a/net/minecraft/server/commands/SetBlockCommand.java b/net/minecraft/server/commands/SetBlockCommand.java +index 05b824409546ba8bacf7efdaeac106af89ff0715..ad7306b42030844d735f42865d7aea3c4d42b01b 100644 +--- a/net/minecraft/server/commands/SetBlockCommand.java ++++ b/net/minecraft/server/commands/SetBlockCommand.java +@@ -119,6 +119,14 @@ public class SetBlockCommand { + // Folia start - region threading + } catch (CommandSyntaxException ex) { + sendMessage(source, ex); ++ // Luminol Start - Server crash fix ++ } catch (IllegalArgumentException iae) { ++ try { ++ throw ERROR_FAILED.create(); ++ } catch (CommandSyntaxException e) { ++ sendMessage(source, e); ++ } ++ // Luminol End - Server crash fix + } + }); + return 1; From 04d414a04b7af3df2b7912c7b42cbbcf84dfbbd8 Mon Sep 17 00:00:00 2001 From: Helvetica Volubi Date: Thu, 24 Apr 2025 23:47:39 +0800 Subject: [PATCH 2/3] feat: origin print complete --- ...d-IllegalArgumentException-crash-fix.patch | 58 +++++++++++++++++++ .../0053-SetBlockCommand-crash-fix.patch | 25 -------- 2 files changed, 58 insertions(+), 25 deletions(-) create mode 100644 luminol-server/minecraft-patches/features/0053-Command-IllegalArgumentException-crash-fix.patch delete mode 100644 luminol-server/minecraft-patches/features/0053-SetBlockCommand-crash-fix.patch diff --git a/luminol-server/minecraft-patches/features/0053-Command-IllegalArgumentException-crash-fix.patch b/luminol-server/minecraft-patches/features/0053-Command-IllegalArgumentException-crash-fix.patch new file mode 100644 index 0000000..87127b5 --- /dev/null +++ b/luminol-server/minecraft-patches/features/0053-Command-IllegalArgumentException-crash-fix.patch @@ -0,0 +1,58 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Helvetica Volubi +Date: Thu, 24 Apr 2025 20:59:52 +0800 +Subject: [PATCH] Command IllegalArgumentException crash fix + + +diff --git a/net/minecraft/server/commands/FillCommand.java b/net/minecraft/server/commands/FillCommand.java +index 89154adfc659afa188cd771e70087e3b1a9c98b9..e622f96e6e116bf491bbea39da099e02ceaee502 100644 +--- a/net/minecraft/server/commands/FillCommand.java ++++ b/net/minecraft/server/commands/FillCommand.java +@@ -210,6 +210,10 @@ public class FillCommand { + // Folia start - region threading + } catch (CommandSyntaxException ex) { + sendMessage(source, ex); ++ // Luminol Start - Server crash fix ++ } catch (IllegalArgumentException ex) { ++ net.minecraft.server.commands.SetBlockCommand.processIAE(source, ex); ++ // Luminol End - Server crash fix + } + }); return 0; // Folia end - region threading + } +diff --git a/net/minecraft/server/commands/SetBlockCommand.java b/net/minecraft/server/commands/SetBlockCommand.java +index 05b824409546ba8bacf7efdaeac106af89ff0715..5c368a70a48260accbbb94a041f4dc9dcf90db4a 100644 +--- a/net/minecraft/server/commands/SetBlockCommand.java ++++ b/net/minecraft/server/commands/SetBlockCommand.java +@@ -86,6 +86,21 @@ public class SetBlockCommand { + } + // Folia end - region threading + ++ // Luminol Start - Server crash fix ++ public static void processIAE(CommandSourceStack src, IllegalArgumentException ex) { ++ Component hoverText = Component.translatable("command.failed") ++ .withStyle(style -> style.withHoverEvent(new net.minecraft.network.chat.HoverEvent(net.minecraft.network.chat.HoverEvent.Action.SHOW_TEXT, Component.literal(ex.getMessage())))); ++ src.sendFailure(hoverText); ++ org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger(); ++ LOGGER.error(ex.getMessage()); ++ StringBuilder stackTrace = new StringBuilder(); ++ for (StackTraceElement element : ex.getStackTrace()) { ++ stackTrace.append(element.toString()).append("\n"); ++ } ++ LOGGER.error(stackTrace.toString()); ++ } ++ // Luminol end - Server crash fix ++ + private static int setBlock( + CommandSourceStack source, BlockPos pos, BlockInput state, SetBlockCommand.Mode mode, @Nullable Predicate predicate + ) throws CommandSyntaxException { +@@ -119,6 +134,10 @@ public class SetBlockCommand { + // Folia start - region threading + } catch (CommandSyntaxException ex) { + sendMessage(source, ex); ++ // Luminol Start - Server crash fix ++ } catch (IllegalArgumentException ex) { ++ processIAE(source, ex); ++ // Luminol End - Server crash fix + } + }); + return 1; diff --git a/luminol-server/minecraft-patches/features/0053-SetBlockCommand-crash-fix.patch b/luminol-server/minecraft-patches/features/0053-SetBlockCommand-crash-fix.patch deleted file mode 100644 index 6660ba4..0000000 --- a/luminol-server/minecraft-patches/features/0053-SetBlockCommand-crash-fix.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Helvetica Volubi -Date: Thu, 24 Apr 2025 20:59:52 +0800 -Subject: [PATCH] SetBlockCommand crash fix - - -diff --git a/net/minecraft/server/commands/SetBlockCommand.java b/net/minecraft/server/commands/SetBlockCommand.java -index 05b824409546ba8bacf7efdaeac106af89ff0715..ad7306b42030844d735f42865d7aea3c4d42b01b 100644 ---- a/net/minecraft/server/commands/SetBlockCommand.java -+++ b/net/minecraft/server/commands/SetBlockCommand.java -@@ -119,6 +119,14 @@ public class SetBlockCommand { - // Folia start - region threading - } catch (CommandSyntaxException ex) { - sendMessage(source, ex); -+ // Luminol Start - Server crash fix -+ } catch (IllegalArgumentException iae) { -+ try { -+ throw ERROR_FAILED.create(); -+ } catch (CommandSyntaxException e) { -+ sendMessage(source, e); -+ } -+ // Luminol End - Server crash fix - } - }); - return 1; From 7e41183c7f554393abf46d694d9376d25d3475d6 Mon Sep 17 00:00:00 2001 From: Helvetica Volubi Date: Tue, 29 Apr 2025 23:49:37 +0800 Subject: [PATCH 3/3] refactor: better log print --- ...ommand-IllegalArgumentException-crash-fix.patch | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/luminol-server/minecraft-patches/features/0053-Command-IllegalArgumentException-crash-fix.patch b/luminol-server/minecraft-patches/features/0053-Command-IllegalArgumentException-crash-fix.patch index 87127b5..426c8b5 100644 --- a/luminol-server/minecraft-patches/features/0053-Command-IllegalArgumentException-crash-fix.patch +++ b/luminol-server/minecraft-patches/features/0053-Command-IllegalArgumentException-crash-fix.patch @@ -20,10 +20,10 @@ index 89154adfc659afa188cd771e70087e3b1a9c98b9..e622f96e6e116bf491bbea39da099e02 }); return 0; // Folia end - region threading } diff --git a/net/minecraft/server/commands/SetBlockCommand.java b/net/minecraft/server/commands/SetBlockCommand.java -index 05b824409546ba8bacf7efdaeac106af89ff0715..5c368a70a48260accbbb94a041f4dc9dcf90db4a 100644 +index 05b824409546ba8bacf7efdaeac106af89ff0715..55911d49c7650b344b46b2cfa9c4ae840ae433c8 100644 --- a/net/minecraft/server/commands/SetBlockCommand.java +++ b/net/minecraft/server/commands/SetBlockCommand.java -@@ -86,6 +86,21 @@ public class SetBlockCommand { +@@ -86,6 +86,15 @@ public class SetBlockCommand { } // Folia end - region threading @@ -32,20 +32,14 @@ index 05b824409546ba8bacf7efdaeac106af89ff0715..5c368a70a48260accbbb94a041f4dc9d + Component hoverText = Component.translatable("command.failed") + .withStyle(style -> style.withHoverEvent(new net.minecraft.network.chat.HoverEvent(net.minecraft.network.chat.HoverEvent.Action.SHOW_TEXT, Component.literal(ex.getMessage())))); + src.sendFailure(hoverText); -+ org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger(); -+ LOGGER.error(ex.getMessage()); -+ StringBuilder stackTrace = new StringBuilder(); -+ for (StackTraceElement element : ex.getStackTrace()) { -+ stackTrace.append(element.toString()).append("\n"); -+ } -+ LOGGER.error(stackTrace.toString()); ++ com.mojang.logging.LogUtils.getLogger().error(ex.getMessage(), ex); + } + // Luminol end - Server crash fix + private static int setBlock( CommandSourceStack source, BlockPos pos, BlockInput state, SetBlockCommand.Mode mode, @Nullable Predicate predicate ) throws CommandSyntaxException { -@@ -119,6 +134,10 @@ public class SetBlockCommand { +@@ -119,6 +128,10 @@ public class SetBlockCommand { // Folia start - region threading } catch (CommandSyntaxException ex) { sendMessage(source, ex);