aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/level/BaseCommandBlock.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/BaseCommandBlock.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/level/BaseCommandBlock.java.patch151
1 files changed, 151 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/BaseCommandBlock.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/BaseCommandBlock.java.patch
new file mode 100644
index 0000000000..8cdd6c747e
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/level/BaseCommandBlock.java.patch
@@ -0,0 +1,151 @@
+--- a/net/minecraft/world/level/BaseCommandBlock.java
++++ b/net/minecraft/world/level/BaseCommandBlock.java
+@@ -19,6 +19,7 @@
+ import net.minecraft.world.phys.Vec3;
+
+ public abstract class BaseCommandBlock implements CommandSource {
++
+ private static final SimpleDateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm:ss");
+ private static final Component DEFAULT_NAME = Component.literal("@");
+ private long lastExecution = -1L;
+@@ -28,8 +29,16 @@
+ @Nullable
+ private Component lastOutput;
+ private String command = "";
+- private Component name = DEFAULT_NAME;
++ private Component name;
++ // CraftBukkit start
++ @Override
++ public abstract org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper);
++ // CraftBukkit end
+
++ public BaseCommandBlock() {
++ this.name = BaseCommandBlock.DEFAULT_NAME;
++ }
++
+ public int getSuccessCount() {
+ return this.successCount;
+ }
+@@ -73,8 +82,8 @@
+ if (nbt.contains("LastOutput", 8) && this.trackOutput) {
+ try {
+ this.lastOutput = Component.Serializer.fromJson(nbt.getString("LastOutput"));
+- } catch (Throwable var3) {
+- this.lastOutput = Component.literal(var3.getMessage());
++ } catch (Throwable throwable) {
++ this.lastOutput = Component.literal(throwable.getMessage());
+ }
+ } else {
+ this.lastOutput = null;
+@@ -89,6 +98,7 @@
+ } else {
+ this.lastExecution = -1L;
+ }
++
+ }
+
+ public void setCommand(String command) {
+@@ -101,40 +111,48 @@
+ }
+
+ public boolean performCommand(Level level) {
+- if (level.isClientSide || level.getGameTime() == this.lastExecution) {
+- return false;
+- } else if ("Searge".equalsIgnoreCase(this.command)) {
+- this.lastOutput = Component.literal("#itzlipofutzli");
+- this.successCount = 1;
+- return true;
+- } else {
+- this.successCount = 0;
+- MinecraftServer server = this.getLevel().getServer();
+- if (server.isCommandBlockEnabled() && !StringUtil.isNullOrEmpty(this.command)) {
+- try {
+- this.lastOutput = null;
+- CommandSourceStack commandSourceStack = this.createCommandSourceStack().withCallback((flag, i) -> {
+- if (flag) {
+- this.successCount++;
+- }
+- });
+- server.getCommands().performPrefixedCommand(commandSourceStack, this.command);
+- } catch (Throwable var6) {
+- CrashReport crashReport = CrashReport.forThrowable(var6, "Executing command block");
+- CrashReportCategory crashReportCategory = crashReport.addCategory("Command to be executed");
+- crashReportCategory.setDetail("Command", this::getCommand);
+- crashReportCategory.setDetail("Name", () -> this.getName().getString());
+- throw new ReportedException(crashReport);
++ if (!level.isClientSide && level.getGameTime() != this.lastExecution) {
++ if ("Searge".equalsIgnoreCase(this.command)) {
++ this.lastOutput = Component.literal("#itzlipofutzli");
++ this.successCount = 1;
++ return true;
++ } else {
++ this.successCount = 0;
++ MinecraftServer minecraftserver = this.getLevel().getServer();
++
++ if (minecraftserver.isCommandBlockEnabled() && !StringUtil.isNullOrEmpty(this.command)) {
++ try {
++ this.lastOutput = null;
++ CommandSourceStack commandlistenerwrapper = this.createCommandSourceStack().withCallback((flag, i) -> {
++ if (flag) {
++ ++this.successCount;
++ }
++
++ });
++
++ minecraftserver.getCommands().dispatchServerCommand(commandlistenerwrapper, this.command); // CraftBukkit
++ } catch (Throwable throwable) {
++ CrashReport crashreport = CrashReport.forThrowable(throwable, "Executing command block");
++ CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Command to be executed");
++
++ crashreportsystemdetails.setDetail("Command", this::getCommand);
++ crashreportsystemdetails.setDetail("Name", () -> {
++ return this.getName().getString();
++ });
++ throw new ReportedException(crashreport);
++ }
+ }
+- }
+
+- if (this.updateLastExecution) {
+- this.lastExecution = level.getGameTime();
+- } else {
+- this.lastExecution = -1L;
+- }
++ if (this.updateLastExecution) {
++ this.lastExecution = level.getGameTime();
++ } else {
++ this.lastExecution = -1L;
++ }
+
+- return true;
++ return true;
++ }
++ } else {
++ return false;
+ }
+ }
+
+@@ -146,16 +164,21 @@
+ if (name != null) {
+ this.name = name;
+ } else {
+- this.name = DEFAULT_NAME;
++ this.name = BaseCommandBlock.DEFAULT_NAME;
+ }
++
+ }
+
+ @Override
+ public void sendSystemMessage(Component component) {
+ if (this.trackOutput) {
+- this.lastOutput = Component.literal("[" + TIME_FORMAT.format(new Date()) + "] ").append(component);
++ SimpleDateFormat simpledateformat = BaseCommandBlock.TIME_FORMAT;
++ Date date = new Date();
++
++ this.lastOutput = Component.literal("[" + simpledateformat.format(date) + "] ").append(component);
+ this.onUpdated();
+ }
++
+ }
+
+ public abstract ServerLevel getLevel();