From 1fe486a5e8241ee8b7f8a46c7dd21d0d6569fbc1 Mon Sep 17 00:00:00 2001
From: gnembon <41132274+gnembon@users.noreply.github.com>
Date: Wed, 11 Oct 2023 18:20:30 +0200
Subject: [PATCH] 23w41a
---
docs/scarpet/api/Auxiliary.md | 8 ++++----
gradle.properties | 2 +-
.../carpet/mixins/Commands_customCommandsMixin.java | 6 ++----
src/main/java/carpet/network/CarpetClient.java | 1 -
.../java/carpet/network/ServerNetworkHandler.java | 4 +---
src/main/java/carpet/script/api/Auxiliary.java | 7 +++----
.../carpet/script/utils/SnoopyCommandSource.java | 12 ++++++------
7 files changed, 17 insertions(+), 23 deletions(-)
diff --git a/docs/scarpet/api/Auxiliary.md b/docs/scarpet/api/Auxiliary.md
index 544ed6c2de..0d264bd8de 100644
--- a/docs/scarpet/api/Auxiliary.md
+++ b/docs/scarpet/api/Auxiliary.md
@@ -407,14 +407,14 @@ read_file('foo', 'shared_text') => ['one', 'two', 'three', '', 'four', '', '
### `run(expr)`
-Runs a vanilla command from the string result of the `expr` and returns a triple of success count,
+Runs a vanilla command from the string result of the `expr` and returns a triple of 0 (unused after success count removal),
intercepted list of output messages, and error message if the command resulted in a failure.
Successful commands return `null` as their error.
-run('fill 1 1 1 10 10 10 air') -> [123, ["Successfully filled 123 blocks"], null] // 123 block were filled, this operation was successful 123 times out of a possible 1000 block volume
-run('give @s stone 4') -> [1, ["Gave 4 [Stone] to gnembon"], null] // this operation was successful once
-run('seed') -> [-170661413, ["Seed: [4031384495743822299]"], null]
+run('fill 1 1 1 10 10 10 air') -> [0, ["Successfully filled 123 blocks"], null]
+run('give @s stone 4') -> [0, ["Gave 4 [Stone] to gnembon"], null]
+run('seed') -> [0, ["Seed: [4031384495743822299]"], null]
run('sed') -> [0, [], "sed<--[HERE]"] // wrong command
diff --git a/gradle.properties b/gradle.properties
index 0beaf261b0..d499899069 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check https://fabricmc.net/develop/
- minecraft_version=23w40a
+ minecraft_version=23w41a
loader_version=0.14.22
jsr305_version=3.0.2
fabric_version=0.89.3+1.20.2
diff --git a/src/main/java/carpet/mixins/Commands_customCommandsMixin.java b/src/main/java/carpet/mixins/Commands_customCommandsMixin.java
index cac7058b6f..88de81457c 100644
--- a/src/main/java/carpet/mixins/Commands_customCommandsMixin.java
+++ b/src/main/java/carpet/mixins/Commands_customCommandsMixin.java
@@ -15,8 +15,6 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-
@Mixin(Commands.class)
public abstract class Commands_customCommandsMixin
@@ -32,14 +30,14 @@ private void onRegister(Commands.CommandSelection commandSelection, CommandBuild
}
@Inject(method = "performCommand", at = @At("HEAD"))
- private void onExecuteBegin(ParseResults parseResults, String string, CallbackInfoReturnable cir)
+ private void onExecuteBegin(ParseResults parseResults, String string, CallbackInfo ci)
{
if (!CarpetSettings.fillUpdates)
CarpetSettings.impendingFillSkipUpdates.set(true);
}
@Inject(method = "performCommand", at = @At("RETURN"))
- private void onExecuteEnd(ParseResults parseResults, String string, CallbackInfoReturnable cir)
+ private void onExecuteEnd(ParseResults parseResults, String string, CallbackInfo ci)
{
CarpetSettings.impendingFillSkipUpdates.set(false);
}
diff --git a/src/main/java/carpet/network/CarpetClient.java b/src/main/java/carpet/network/CarpetClient.java
index 5075adaaea..5be5f45306 100644
--- a/src/main/java/carpet/network/CarpetClient.java
+++ b/src/main/java/carpet/network/CarpetClient.java
@@ -94,7 +94,6 @@ public static void onClientCommand(Tag t)
CarpetSettings.LOG.info("Server Response:");
CompoundTag tag = (CompoundTag) t;
CarpetSettings.LOG.info(" - id: " + tag.getString("id"));
- CarpetSettings.LOG.info(" - code: " + tag.getInt("code"));
if (tag.contains("error"))
{
CarpetSettings.LOG.warn(" - error: " + tag.getString("error"));
diff --git a/src/main/java/carpet/network/ServerNetworkHandler.java b/src/main/java/carpet/network/ServerNetworkHandler.java
index 327fb20c35..6bf8b15319 100644
--- a/src/main/java/carpet/network/ServerNetworkHandler.java
+++ b/src/main/java/carpet/network/ServerNetworkHandler.java
@@ -84,20 +84,18 @@ private static void handleClientCommand(ServerPlayer player, CompoundTag command
String id = commandData.getString("id");
List output = new ArrayList<>();
Component[] error = {null};
- int resultCode = -1;
if (player.getServer() == null)
{
error[0] = Component.literal("No Server");
}
else
{
- resultCode = player.getServer().getCommands().performPrefixedCommand(
+ player.getServer().getCommands().performPrefixedCommand(
new SnoopyCommandSource(player, error, output), command
);
}
CompoundTag result = new CompoundTag();
result.putString("id", id);
- result.putInt("code", resultCode);
if (error[0] != null)
{
result.putString("error", error[0].getContents().toString());
diff --git a/src/main/java/carpet/script/api/Auxiliary.java b/src/main/java/carpet/script/api/Auxiliary.java
index fe2de59978..6fc6a1a42f 100644
--- a/src/main/java/carpet/script/api/Auxiliary.java
+++ b/src/main/java/carpet/script/api/Auxiliary.java
@@ -690,12 +690,11 @@ else if (!interactable && targetBlock == null)
{
Component[] error = {null};
List output = new ArrayList<>();
- Value retval = new NumericValue(s.getServer().getCommands().performPrefixedCommand(
+ s.getServer().getCommands().performPrefixedCommand(
new SnoopyCommandSource(s, error, output),
- lv.get(0).getString())
- );
+ lv.get(0).getString());
return ListValue.of(
- retval,
+ NumericValue.ZERO,
ListValue.wrap(output.stream().map(FormattedTextValue::new)),
FormattedTextValue.of(error[0])
);
diff --git a/src/main/java/carpet/script/utils/SnoopyCommandSource.java b/src/main/java/carpet/script/utils/SnoopyCommandSource.java
index adc181d79a..7e7a89c617 100644
--- a/src/main/java/carpet/script/utils/SnoopyCommandSource.java
+++ b/src/main/java/carpet/script/utils/SnoopyCommandSource.java
@@ -1,7 +1,7 @@
package carpet.script.utils;
import carpet.script.external.Vanilla;
-import com.mojang.brigadier.ResultConsumer;
+import net.minecraft.commands.CommandResultConsumer;
import net.minecraft.commands.CommandSigningContext;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
@@ -33,7 +33,7 @@ public class SnoopyCommandSource extends CommandSourceStack
private final MinecraftServer server;
// skipping silent since snooper is never silent
private final Entity entity;
- private final ResultConsumer resultConsumer;
+ private final CommandResultConsumer resultConsumer;
private final EntityAnchorArgument.Anchor entityAnchor;
private final Vec2 rotation;
// good stuff
@@ -91,7 +91,7 @@ public SnoopyCommandSource(ServerPlayer player, Component[] error, List consumer, EntityAnchorArgument.Anchor entityAnchor, CommandSigningContext context, TaskChainer chainer,
+ private SnoopyCommandSource(CommandSource output, Vec3 pos, Vec2 rot, ServerLevel world, int level, String simpleName, Component name, MinecraftServer server, @Nullable Entity entity, CommandResultConsumer consumer, EntityAnchorArgument.Anchor entityAnchor, CommandSigningContext context, TaskChainer chainer,
Component[] error, List chatOutput
)
{
@@ -134,15 +134,15 @@ public CommandSourceStack withRotation(Vec2 rotation)
}
@Override
- public CommandSourceStack withCallback(ResultConsumer consumer)
+ public CommandSourceStack withCallback(CommandResultConsumer consumer)
{
return new SnoopyCommandSource(output, position, rotation, world, level, simpleName, name, server, entity, consumer, entityAnchor, signingContext, taskChainer, error, chatOutput);
}
@Override
- public CommandSourceStack withCallback(ResultConsumer consumer, BinaryOperator> binaryOperator)
+ public CommandSourceStack withCallback(CommandResultConsumer consumer, BinaryOperator> binaryOperator)
{
- ResultConsumer resultConsumer = binaryOperator.apply(this.resultConsumer, consumer);
+ CommandResultConsumer resultConsumer = binaryOperator.apply(this.resultConsumer, consumer);
return this.withCallback(resultConsumer);
}