Paper/patches/server/0648-More-CommandBlock-API.patch
Nassim Jahnke e035fd7034
Updated Upstream (Bukkit/CraftBukkit/Spigot)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
cc9aa21a SPIGOT-6399, SPIGOT-7344: Clarify collidable behavior for player entities
f23325b6 Add API for per-world simulation distances
26e1774e Add API for per-world view distances
0b541e60 Add PlayerLoginEvent#getRealAddress
5f027d2d PR-949: Add Vector#fromJOML() overloads for read-only vector types

CraftBukkit Changes:
bcf56171a PR-1321: Clean up some stuff which got missed during previous PRs
7f833a2d1 SPIGOT-7462: Players no longer drop XP after dying near a Sculk Catalyst
752aac669 Implement APIs for per world view and simulation distances
57d7ef433 Preserve empty enchantment tags for glow effect
465ec3fb4 Remove connected check on setScoreboard
f90ce621e Use one PermissibleBase for all command blocks
5876cca44 SPIGOT-7550: Fix creation of Arrow instances
f03fc3aa3 SPIGOT-7549: ServerTickManager#setTickRate incorrect Precondition
9d7f49b01 SPIGOT-7548: Fix wrong spawn location for experience orb and dropped item

Spigot Changes:
ed9ba9a4 Drop no longer required patch ignoring -o option
86b5dd6a SPIGOT-7546: Fix hardcoded check for outdated client message
aa7cde7a Remove obsolete APIs for per world view and simulation distances
6dff577e Remove obsolete patch preserving empty `ench` tags
a3bf95b8 Remove obsolete PlayerLoginEvent#getRealAddress
1b02f5d6 Remove obsolete connected check on setScoreboard patch
acf717eb Remove obsolete command block PermissibleBase patch
053fa2a9 Remove redundant patch dealing with null tile entities
2023-12-26 00:18:13 +01:00

101 lines
4.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Thu, 23 Sep 2021 10:40:09 -0700
Subject: [PATCH] More CommandBlock API
diff --git a/src/main/java/io/papermc/paper/commands/PaperCommandBlockHolder.java b/src/main/java/io/papermc/paper/commands/PaperCommandBlockHolder.java
new file mode 100644
index 0000000000000000000000000000000000000000..0b42306f17bf8850a13a51067c2d19e7583187e5
--- /dev/null
+++ b/src/main/java/io/papermc/paper/commands/PaperCommandBlockHolder.java
@@ -0,0 +1,33 @@
+package io.papermc.paper.commands;
+
+import io.papermc.paper.adventure.PaperAdventure;
+import io.papermc.paper.command.CommandBlockHolder;
+import net.kyori.adventure.text.Component;
+import net.minecraft.world.level.BaseCommandBlock;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public interface PaperCommandBlockHolder extends CommandBlockHolder {
+
+ BaseCommandBlock getCommandBlockHandle();
+
+ @Override
+ default @NotNull Component lastOutput() {
+ return PaperAdventure.asAdventure(getCommandBlockHandle().getLastOutput());
+ }
+
+ @Override
+ default void lastOutput(@Nullable Component lastOutput) {
+ getCommandBlockHandle().setLastOutput(PaperAdventure.asVanilla(lastOutput));
+ }
+
+ @Override
+ default int getSuccessCount() {
+ return getCommandBlockHandle().getSuccessCount();
+ }
+
+ @Override
+ default void setSuccessCount(int successCount) {
+ getCommandBlockHandle().setSuccessCount(successCount);
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java
index 7f5d930b6bfaf9a0042f9be4be68f2cc111b304e..63f6b97d82c8b98eb1379b5c30f6c75eb22f7c23 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java
@@ -5,7 +5,7 @@ import org.bukkit.World;
import org.bukkit.block.CommandBlock;
import org.bukkit.craftbukkit.util.CraftChatMessage;
-public class CraftCommandBlock extends CraftBlockEntityState<CommandBlockEntity> implements CommandBlock {
+public class CraftCommandBlock extends CraftBlockEntityState<CommandBlockEntity> implements CommandBlock, io.papermc.paper.commands.PaperCommandBlockHolder {
public CraftCommandBlock(World world, CommandBlockEntity tileEntity) {
super(world, tileEntity);
@@ -50,5 +50,10 @@ public class CraftCommandBlock extends CraftBlockEntityState<CommandBlockEntity>
public void name(net.kyori.adventure.text.Component name) {
getSnapshot().getCommandBlock().setName(name == null ? net.minecraft.network.chat.Component.literal("@") : io.papermc.paper.adventure.PaperAdventure.asVanilla(name));
}
+
+ @Override
+ public net.minecraft.world.level.BaseCommandBlock getCommandBlockHandle() {
+ return getSnapshot().getCommandBlock();
+ }
// Paper end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java
index 92e21126a9347f1ee2279ab09bb6abf2344ad2e2..0ee159d488b15e571f9b19ec852fe279755696fa 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java
@@ -13,7 +13,7 @@ import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.Plugin;
-public class CraftMinecartCommand extends CraftMinecart implements CommandMinecart {
+public class CraftMinecartCommand extends CraftMinecart implements CommandMinecart, io.papermc.paper.commands.PaperCommandBlockHolder {
private final PermissibleBase perm = new PermissibleBase(this);
public CraftMinecartCommand(CraftServer server, MinecartCommandBlock entity) {
@@ -64,6 +64,17 @@ public class CraftMinecartCommand extends CraftMinecart implements CommandMineca
public net.kyori.adventure.text.@org.jetbrains.annotations.NotNull Component name() {
return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.getHandle().getCommandBlock().getName());
}
+
+ @Override
+ public net.minecraft.world.level.BaseCommandBlock getCommandBlockHandle() {
+ return getHandle().getCommandBlock();
+ }
+
+ @Override
+ public void lastOutput(net.kyori.adventure.text.Component lastOutput) {
+ io.papermc.paper.commands.PaperCommandBlockHolder.super.lastOutput(lastOutput);
+ getCommandBlockHandle().onUpdated();
+ }
// Paper end
@Override