Feat: Add 'with' methods to CommandSourceStack (#11868)

This commit is contained in:
Strokkur24
2025-01-11 22:29:16 +01:00
committed by GitHub
parent c94922514a
commit c2f24e1567
4 changed files with 67 additions and 6 deletions

View File

@@ -10,10 +10,10 @@ when if this was fixed on the client, that wouldn't be needed.
Mojira Issue: https://bugs.mojang.com/browse/MC-235045
diff --git a/net/minecraft/commands/CommandSourceStack.java b/net/minecraft/commands/CommandSourceStack.java
index 704a63890a06d793f8ac3452838917e7c7335232..75262c8c9eaecb4a88a94f4076d67119c67a97da 100644
index cf923441da598637be74a5ffa4b4f948e01ff532..cbf32be9235921ebcaca88225120c2ca70a72771 100644
--- a/net/minecraft/commands/CommandSourceStack.java
+++ b/net/minecraft/commands/CommandSourceStack.java
@@ -652,4 +652,20 @@ public class CommandSourceStack implements ExecutionCommandSource<CommandSourceS
@@ -676,4 +676,20 @@ public class CommandSourceStack implements ExecutionCommandSource<CommandSourceS
return this.source.getBukkitSender(this);
}
// CraftBukkit end

View File

@@ -18,6 +18,37 @@
public CommandSourceStack(
CommandSource source,
@@ -187,6 +_,30 @@
this.chatMessageChainer
);
}
+
+ // Paper start - Expose 'with' functions from the CommandSourceStack
+ @Override
+ public CommandSourceStack withLocation(org.bukkit.Location location) {
+ return this.getLocation().equals(location)
+ ? this
+ : new CommandSourceStack(
+ this.source,
+ new Vec3(location.x(), location.y(), location.z()),
+ new Vec2(location.getPitch(), location.getYaw()),
+ ((org.bukkit.craftbukkit.CraftWorld) location.getWorld()).getHandle(),
+ this.permissionLevel,
+ this.textName,
+ this.displayName,
+ this.server,
+ this.entity,
+ this.silent,
+ this.resultCallback,
+ this.anchor,
+ this.signingContext,
+ this.chatMessageChainer
+ );
+ }
+ // Paper end - Expose 'with' functions from the CommandSourceStack
public CommandSourceStack withRotation(Vec2 rotation) {
return this.rotation.equals(rotation)
@@ -391,9 +_,44 @@
@Override