|
1 | 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2 | 2 | From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
3 | 3 | Date: Fri, 23 Jun 2023 12:16:28 -0700
|
4 |
| -Subject: [PATCH] Add Sign#getInteractableSideFor |
| 4 | +Subject: [PATCH] More Sign Block API |
5 | 5 |
|
| 6 | +Co-authored-by: SoSeDiK <mrsosedik@gmail.com> |
6 | 7 |
|
7 | 8 | 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
|
8 |
| -index bfe8029852385875af4ebe73c63e688f61042021..a28be7a332659be655f419d969e0c64e659b6c21 100644 |
| 9 | +index bfe8029852385875af4ebe73c63e688f61042021..3070cd2b588f5a69fd8c0d3551e16251680d8c27 100644 |
9 | 10 | --- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
10 | 11 | +++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
11 | 12 | @@ -68,12 +68,17 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C
|
12 | 13 | }
|
13 | 14 |
|
14 | 15 | public boolean isFacingFrontText(net.minecraft.world.entity.player.Player player) {
|
15 |
| -+ // Paper start - Add Sign#getInteractableSideFor |
| 16 | ++ // Paper start - More Sign Block API |
16 | 17 | + return this.isFacingFrontText(player.getX(), player.getZ());
|
17 | 18 | + }
|
18 | 19 | + public boolean isFacingFrontText(double x, double z) {
|
19 |
| -+ // Paper end - Add Sign#getInteractableSideFor |
| 20 | ++ // Paper end - More Sign Block API |
20 | 21 | Block block = this.getBlockState().getBlock();
|
21 | 22 |
|
22 | 23 | if (block instanceof SignBlock blocksign) {
|
23 | 24 | Vec3 vec3d = blocksign.getSignHitboxCenterPosition(this.getBlockState());
|
24 | 25 | - double d0 = player.getX() - ((double) this.getBlockPos().getX() + vec3d.x);
|
25 | 26 | - double d1 = player.getZ() - ((double) this.getBlockPos().getZ() + vec3d.z);
|
26 |
| -+ double d0 = x - ((double) this.getBlockPos().getX() + vec3d.x); // Paper - Add Sign#getInteractableSideFor |
27 |
| -+ double d1 = z - ((double) this.getBlockPos().getZ() + vec3d.z); // Paper - Add Sign#getInteractableSideFor |
| 27 | ++ double d0 = x - ((double) this.getBlockPos().getX() + vec3d.x); // Paper - More Sign Block API |
| 28 | ++ double d1 = z - ((double) this.getBlockPos().getZ() + vec3d.z); // Paper - More Sign Block API |
28 | 29 | float f = blocksign.getYRotationDegrees(this.getBlockState());
|
29 | 30 | float f1 = (float) (Mth.atan2(d1, d0) * 57.2957763671875D) - 90.0F;
|
30 | 31 |
|
31 | 32 | diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
|
32 |
| -index 8303343ecca91076839f4436d6b3a3bf4739c2fd..cefbb015a77b9e3cab56e5ed4fe35fba91641632 100644 |
| 33 | +index 8303343ecca91076839f4436d6b3a3bf4739c2fd..e3c333d26dea9af9dd51e1662f81f1d472ab0233 100644 |
33 | 34 | --- a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
|
34 | 35 | +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
|
35 |
| -@@ -198,6 +198,14 @@ public class CraftSign<T extends SignBlockEntity> extends CraftBlockEntityState< |
| 36 | +@@ -198,6 +198,26 @@ public class CraftSign<T extends SignBlockEntity> extends CraftBlockEntityState< |
36 | 37 | }
|
37 | 38 | // Paper end
|
38 | 39 |
|
39 |
| -+ // Paper start - side facing API |
| 40 | ++ // Paper start - More Sign Block API |
| 41 | ++ @Override |
| 42 | ++ public java.util.UUID getAllowedEditorUniqueId() { |
| 43 | ++ this.ensureNoWorldGeneration(); |
| 44 | ++ return this.getTileEntity().getPlayerWhoMayEdit(); |
| 45 | ++ } |
| 46 | ++ |
| 47 | ++ @Override |
| 48 | ++ public void setAllowedEditorUniqueId(java.util.UUID uuid) { |
| 49 | ++ this.ensureNoWorldGeneration(); |
| 50 | ++ this.getTileEntity().setAllowedPlayerEditor(uuid); |
| 51 | ++ } |
| 52 | ++ |
40 | 53 | + @Override
|
41 | 54 | + public Side getInteractableSideFor(final double x, final double z) {
|
42 | 55 | + this.requirePlaced();
|
43 | 56 | + return this.getSnapshot().isFacingFrontText(x, z) ? Side.FRONT : Side.BACK;
|
44 | 57 | + }
|
45 |
| -+ // Paper end |
| 58 | ++ // Paper end - More Sign Block API |
46 | 59 | +
|
47 | 60 | public static Component[] sanitizeLines(String[] lines) {
|
48 | 61 | Component[] components = new Component[4];
|
|
0 commit comments