3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 04:20:04 +01:00

Allow getting/setting the sign's editor uuid (#10637)

* Allow getting/setting the sign's editor uuid

* rebased

---------

Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Dieser Commit ist enthalten in:
SoSeDiK 2024-08-18 00:36:27 +03:00 committet von GitHub
Ursprung 44017487a8
Commit 64c9ee6584
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194
2 geänderte Dateien mit 53 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -1,18 +1,43 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Fri, 23 Jun 2023 12:16:35 -0700
Subject: [PATCH] Add Sign#getInteractableSideFor
Subject: [PATCH] More Sign Block API
Co-authored-by: SoSeDiK <mrsosedik@gmail.com>
diff --git a/src/main/java/org/bukkit/block/Sign.java b/src/main/java/org/bukkit/block/Sign.java
index 1fdb1144949adc3a2b5cbc3aca94d2f8e0c6d9ee..7983ccb54f5f358dea1ffb530b9cc5bd716fb9b1 100644
index 1fdb1144949adc3a2b5cbc3aca94d2f8e0c6d9ee..340e3adcc57227f2e570826681ea81b9159805de 100644
--- a/src/main/java/org/bukkit/block/Sign.java
+++ b/src/main/java/org/bukkit/block/Sign.java
@@ -187,4 +187,34 @@ public interface Sign extends TileState, Colorable {
@@ -182,9 +182,58 @@ public interface Sign extends TileState, Colorable {
/**
* Gets the player that is currently allowed to edit this sign. <br>
* Edits from other players will be rejected if this value is not null.
+ * <br><br>You should prefer {@link #getAllowedEditorUniqueId()} if you don't
+ * need the player instance as this method will fetch the player from UUID.
*
* @return the player allowed to edit this sign, or null
*/
@Nullable
public Player getAllowedEditor();
+ // Paper start - get side for player
+ // Paper start - More Sign Block API
+ /**
+ * Gets the allowed editor's UUID.
+ * <br>Edits from other players will be rejected if this value is not null.
+ *
+ * @return the allowed editor's UUID, or null
+ */
+ @Nullable java.util.UUID getAllowedEditorUniqueId();
+
+ /**
+ * Sets the allowed editor's UUID.
+ * <br><br><b>Note:</b> the server sets the UUID back to null if the player can't
+ * interact with the sign (is either offline or outside the allowed interaction range).
+ *
+ * @param uuid the allowed editor's UUID
+ */
+ void setAllowedEditorUniqueId(@Nullable java.util.UUID uuid);
+
+ /**
+ * Compute the side facing the specified entity.
+ *
@ -41,5 +66,5 @@ index 1fdb1144949adc3a2b5cbc3aca94d2f8e0c6d9ee..7983ccb54f5f358dea1ffb530b9cc5bd
+ * @return the side the coordinates are facing
+ */
+ @NotNull Side getInteractableSideFor(double x, double z);
+ // Paper end
+ // Paper end - More Sign Block API
}

Datei anzeigen

@ -1,48 +1,61 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Fri, 23 Jun 2023 12:16:28 -0700
Subject: [PATCH] Add Sign#getInteractableSideFor
Subject: [PATCH] More Sign Block API
Co-authored-by: SoSeDiK <mrsosedik@gmail.com>
diff --git a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
index bfe8029852385875af4ebe73c63e688f61042021..a28be7a332659be655f419d969e0c64e659b6c21 100644
index bfe8029852385875af4ebe73c63e688f61042021..3070cd2b588f5a69fd8c0d3551e16251680d8c27 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
@@ -68,12 +68,17 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C
}
public boolean isFacingFrontText(net.minecraft.world.entity.player.Player player) {
+ // Paper start - Add Sign#getInteractableSideFor
+ // Paper start - More Sign Block API
+ return this.isFacingFrontText(player.getX(), player.getZ());
+ }
+ public boolean isFacingFrontText(double x, double z) {
+ // Paper end - Add Sign#getInteractableSideFor
+ // Paper end - More Sign Block API
Block block = this.getBlockState().getBlock();
if (block instanceof SignBlock blocksign) {
Vec3 vec3d = blocksign.getSignHitboxCenterPosition(this.getBlockState());
- double d0 = player.getX() - ((double) this.getBlockPos().getX() + vec3d.x);
- double d1 = player.getZ() - ((double) this.getBlockPos().getZ() + vec3d.z);
+ double d0 = x - ((double) this.getBlockPos().getX() + vec3d.x); // Paper - Add Sign#getInteractableSideFor
+ double d1 = z - ((double) this.getBlockPos().getZ() + vec3d.z); // Paper - Add Sign#getInteractableSideFor
+ double d0 = x - ((double) this.getBlockPos().getX() + vec3d.x); // Paper - More Sign Block API
+ double d1 = z - ((double) this.getBlockPos().getZ() + vec3d.z); // Paper - More Sign Block API
float f = blocksign.getYRotationDegrees(this.getBlockState());
float f1 = (float) (Mth.atan2(d1, d0) * 57.2957763671875D) - 90.0F;
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
index 8303343ecca91076839f4436d6b3a3bf4739c2fd..cefbb015a77b9e3cab56e5ed4fe35fba91641632 100644
index 8303343ecca91076839f4436d6b3a3bf4739c2fd..e3c333d26dea9af9dd51e1662f81f1d472ab0233 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
@@ -198,6 +198,14 @@ public class CraftSign<T extends SignBlockEntity> extends CraftBlockEntityState<
@@ -198,6 +198,26 @@ public class CraftSign<T extends SignBlockEntity> extends CraftBlockEntityState<
}
// Paper end
+ // Paper start - side facing API
+ // Paper start - More Sign Block API
+ @Override
+ public java.util.UUID getAllowedEditorUniqueId() {
+ this.ensureNoWorldGeneration();
+ return this.getTileEntity().getPlayerWhoMayEdit();
+ }
+
+ @Override
+ public void setAllowedEditorUniqueId(java.util.UUID uuid) {
+ this.ensureNoWorldGeneration();
+ this.getTileEntity().setAllowedPlayerEditor(uuid);
+ }
+
+ @Override
+ public Side getInteractableSideFor(final double x, final double z) {
+ this.requirePlaced();
+ return this.getSnapshot().isFacingFrontText(x, z) ? Side.FRONT : Side.BACK;
+ }
+ // Paper end
+ // Paper end - More Sign Block API
+
public static Component[] sanitizeLines(String[] lines) {
Component[] components = new Component[4];