mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 15:30:19 +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>
This commit is contained in:
parent
0f622bb732
commit
1f6969e350
2 changed files with 48 additions and 10 deletions
|
@ -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 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. <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 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ * @return the side the coordinates are facing
|
||||
+ */
|
||||
+ @NotNull Side getInteractableSideFor(double x, double z);
|
||||
+ // Paper end
|
||||
+ // Paper end - More Sign Block API
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
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 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];
|
Loading…
Reference in a new issue