Skip to content

Commit a41043f

Browse files
authored
Add back command source for command blocks with output disabled and fix bukkit->minecraft not respecting output disabled for minecart command blocks (#13271)
1 parent 893ea74 commit a41043f

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed

paper-server/patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@
2525
}
2626
} catch (Throwable var8) {
2727
CrashReport crashReport = CrashReport.forThrowable(var8, "Executing command block");
28+
@@ -133,9 +_,8 @@
29+
}
30+
}
31+
32+
- @Nullable
33+
- private BaseCommandBlock.CloseableCommandBlockSource createSource() {
34+
- return this.trackOutput ? new BaseCommandBlock.CloseableCommandBlockSource() : null;
35+
+ public BaseCommandBlock.CloseableCommandBlockSource createSource() { // Paper - public, remove nullable
36+
+ return new BaseCommandBlock.CloseableCommandBlockSource(this.trackOutput); // Paper - add back source when output disabled
37+
}
38+
39+
public Component getName() {
2840
@@ -168,7 +_,7 @@
2941
}
3042

@@ -34,7 +46,7 @@
3446
return InteractionResult.PASS;
3547
} else {
3648
if (player.level().isClientSide()) {
37-
@@ -185,7 +_,7 @@
49+
@@ -185,10 +_,21 @@
3850

3951
public abstract boolean isValid();
4052

@@ -43,10 +55,35 @@
4355
private static final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ofPattern("HH:mm:ss", Locale.ROOT);
4456
private boolean closed;
4557

46-
@@ -207,6 +_,7 @@
58+
+ // Paper start - add back source when output disabled
59+
+ private final boolean trackOutput;
60+
+ public CloseableCommandBlockSource(final boolean trackOutput) {
61+
+ this.trackOutput = trackOutput;
62+
+ }
63+
+ @io.papermc.paper.annotation.DoNotUse @Deprecated
64+
+ public CloseableCommandBlockSource() {
65+
+ this(true);
66+
+ }
67+
+ // Paper end - add back source when output disabled
68+
+
69+
@Override
70+
public boolean acceptsSuccess() {
71+
return !this.closed && BaseCommandBlock.this.getLevel().getGameRules().getBoolean(GameRules.RULE_SENDCOMMANDFEEDBACK);
72+
@@ -196,7 +_,7 @@
73+
74+
@Override
75+
public boolean acceptsFailure() {
76+
- return !this.closed;
77+
+ return this.trackOutput && !this.closed; // Paper - add back source when output disabled
78+
}
79+
80+
@Override
81+
@@ -206,7 +_,8 @@
82+
4783
@Override
4884
public void sendSystemMessage(Component message) {
49-
if (!this.closed) {
85+
- if (!this.closed) {
86+
+ if (this.trackOutput && !this.closed) { // Paper - add back source when output disabled
5087
+ org.spigotmc.AsyncCatcher.catchOp("sendSystemMessage to a command block"); // Paper - Don't broadcast messages to command blocks
5188
BaseCommandBlock.this.lastOutput = Component.literal("[" + TIME_FORMAT.format(ZonedDateTime.now()) + "] ").append(message);
5289
BaseCommandBlock.this.onUpdated();

paper-server/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static CommandSourceStack getListener(CommandSender sender) {
7575
if (sender instanceof CraftEntity entity) {
7676
if (sender instanceof CommandMinecart) {
7777
return ((CraftMinecartCommand) sender).getHandle().getCommandBlock().createCommandSourceStack(
78-
((CraftMinecartCommand) sender).getHandle().getCommandBlock().new CloseableCommandBlockSource()
78+
((CraftMinecartCommand) sender).getHandle().getCommandBlock().createSource()
7979
);
8080
}
8181

0 commit comments

Comments
 (0)