From 1f6969e350db69e3e24703a08274d950af90c6a5 Mon Sep 17 00:00:00 2001 From: SoSeDiK Date: Sun, 18 Aug 2024 00:36:27 +0300 Subject: [PATCH] Allow getting/setting the sign's editor uuid (#10637) * Allow getting/setting the sign's editor uuid * rebased --------- Co-authored-by: Jake Potrebic --- ...ideFor.patch => More-Sign-Block-API.patch} | 31 +++++++++++++++++-- ...ideFor.patch => More-Sign-Block-API.patch} | 27 +++++++++++----- 2 files changed, 48 insertions(+), 10 deletions(-) rename patches/api/{Add-Sign-getInteractableSideFor.patch => More-Sign-Block-API.patch} (56%) rename patches/server/{Add-Sign-getInteractableSideFor.patch => More-Sign-Block-API.patch} (76%) diff --git a/patches/api/Add-Sign-getInteractableSideFor.patch b/patches/api/More-Sign-Block-API.patch similarity index 56% rename from patches/api/Add-Sign-getInteractableSideFor.patch rename to patches/api/More-Sign-Block-API.patch index bf9fd5e4db..5f9f0a346e 100644 --- a/patches/api/Add-Sign-getInteractableSideFor.patch +++ b/patches/api/More-Sign-Block-API.patch @@ -1,18 +1,43 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Fri, 23 Jun 2023 12:16:35 -0700 -Subject: [PATCH] Add Sign#getInteractableSideFor +Subject: [PATCH] More Sign Block API +Co-authored-by: SoSeDiK diff --git a/src/main/java/org/bukkit/block/Sign.java b/src/main/java/org/bukkit/block/Sign.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/block/Sign.java +++ b/src/main/java/org/bukkit/block/Sign.java @@ -0,0 +0,0 @@ public interface Sign extends TileState, Colorable { + /** + * Gets the player that is currently allowed to edit this sign.
+ * Edits from other players will be rejected if this value is not null. ++ *

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. ++ *
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. ++ *

Note: 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @return the side the coordinates are facing + */ + @NotNull Side getInteractableSideFor(double x, double z); -+ // Paper end ++ // Paper end - More Sign Block API } diff --git a/patches/server/Add-Sign-getInteractableSideFor.patch b/patches/server/More-Sign-Block-API.patch similarity index 76% rename from patches/server/Add-Sign-getInteractableSideFor.patch rename to patches/server/More-Sign-Block-API.patch index 6491480c48..29a5484edf 100644 --- a/patches/server/Add-Sign-getInteractableSideFor.patch +++ b/patches/server/More-Sign-Block-API.patch @@ -1,8 +1,9 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Fri, 23 Jun 2023 12:16:28 -0700 -Subject: [PATCH] Add Sign#getInteractableSideFor +Subject: [PATCH] More Sign Block API +Co-authored-by: SoSeDiK 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -12,19 +13,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } 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; @@ -36,13 +37,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } // 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];