From b9a968e5092fcd445667177a0dfbd23c53f3c3bd Mon Sep 17 00:00:00 2001 From: CJDevZ <76665243+CJDevZ@users.noreply.github.com> Date: Sun, 2 Nov 2025 02:27:15 +0100 Subject: [PATCH] Add bitwise operations to the operator argument type - &= - |= - ^= - ~= - <<= - >>= - >>>= --- .../arguments/OperationArgument.java.patch | 29 +++++++++++++++++++ .../commands/ScoreboardCommand.java.patch | 19 ++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 legitslimepaper-server/minecraft-patches/sources/net/minecraft/commands/arguments/OperationArgument.java.patch create mode 100644 legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/commands/ScoreboardCommand.java.patch diff --git a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/commands/arguments/OperationArgument.java.patch b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/commands/arguments/OperationArgument.java.patch new file mode 100644 index 0000000..70b4fe7 --- /dev/null +++ b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/commands/arguments/OperationArgument.java.patch @@ -0,0 +1,29 @@ +--- a/net/minecraft/commands/arguments/OperationArgument.java ++++ b/net/minecraft/commands/arguments/OperationArgument.java +@@ -48,7 +_,9 @@ + + @Override + public CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder) { +- return SharedSuggestionProvider.suggest(new String[]{"=", "+=", "-=", "*=", "/=", "%=", "<", ">", "><"}, builder); ++ return SharedSuggestionProvider.suggest(new String[]{"=", "+=", "-=", "*=", "/=", "%=", "<", ">", "><" ++ , "&=", "|=", "^=", "~=", "<<=", ">>=", ">>>="}, // LegitSlimePaper - Add Bit operations ++ builder); + } + + @Override +@@ -86,6 +_,15 @@ + }; + case "<" -> Math::min; + case ">" -> Math::max; ++ // LegitSlimePaper start - Add Bit operations ++ case "&=" -> (targetScore, sourceScore) -> targetScore & sourceScore; ++ case "|=" -> (targetScore, sourceScore) -> targetScore | sourceScore; ++ case "^=" -> (targetScore, sourceScore) -> targetScore ^ sourceScore; ++ case "~=" -> (targetScore, sourceScore) -> ~sourceScore; ++ case "<<=" -> (targetScore, sourceScore) -> targetScore << sourceScore; ++ case ">>=" -> (targetScore, sourceScore) -> targetScore >> sourceScore; ++ case ">>>=" -> (targetScore, sourceScore) -> targetScore >>> sourceScore; ++ // LegitSlimePaper end - Add Bit operations + default -> throw ERROR_INVALID_OPERATION.create(); + }; + } diff --git a/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/commands/ScoreboardCommand.java.patch b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/commands/ScoreboardCommand.java.patch new file mode 100644 index 0000000..83620f1 --- /dev/null +++ b/legitslimepaper-server/minecraft-patches/sources/net/minecraft/server/commands/ScoreboardCommand.java.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/server/commands/ScoreboardCommand.java ++++ b/net/minecraft/server/commands/ScoreboardCommand.java +@@ -66,6 +_,7 @@ + ); + + public static void register(CommandDispatcher dispatcher, CommandBuildContext context) { ++ OperationArgument operationArgument = OperationArgument.operation(); // LegitSlimePaper - Add Bit operations + dispatcher.register( + Commands.literal("scoreboard") + .requires(Commands.hasPermission(2)) +@@ -365,7 +_,7 @@ + .then( + Commands.argument("targetObjective", ObjectiveArgument.objective()) + .then( +- Commands.argument("operation", OperationArgument.operation()) ++ Commands.argument("operation", operationArgument).suggests(operationArgument::listSuggestions) // LegitSlimePaper - Add Bit operations + .then( + Commands.argument("source", ScoreHolderArgument.scoreHolders()) + .suggests(ScoreHolderArgument.SUGGEST_SCORE_HOLDERS)