mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
More Sign Block API
Co-authored-by: SoSeDiK <mrsosedik@gmail.com>
This commit is contained in:
parent
bfd4276e56
commit
5b97ae9832
2 changed files with 44 additions and 11 deletions
|
@ -27,16 +27,29 @@
|
|||
|
||||
public class SignBlockEntity extends BlockEntity {
|
||||
|
||||
@@ -61,7 +67,7 @@
|
||||
@@ -61,13 +67,18 @@
|
||||
return new SignText();
|
||||
}
|
||||
|
||||
- public boolean isFacingFrontText(Player player) {
|
||||
+ public boolean isFacingFrontText(net.minecraft.world.entity.player.Player player) {
|
||||
+ // Paper start - More Sign Block API
|
||||
+ return this.isFacingFrontText(player.getX(), player.getZ());
|
||||
+ }
|
||||
+ public boolean isFacingFrontText(double x, double z) {
|
||||
+ // Paper end - More Sign Block API
|
||||
Block block = this.getBlockState().getBlock();
|
||||
|
||||
if (block instanceof SignBlock blocksign) {
|
||||
@@ -101,7 +107,7 @@
|
||||
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 - 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;
|
||||
|
||||
@@ -101,7 +112,7 @@
|
||||
protected void saveAdditional(CompoundTag nbt, HolderLookup.Provider registries) {
|
||||
super.saveAdditional(nbt, registries);
|
||||
DynamicOps<Tag> dynamicops = registries.createSerializationContext(NbtOps.INSTANCE);
|
||||
|
@ -45,7 +58,7 @@
|
|||
Logger logger = SignBlockEntity.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -121,7 +127,7 @@
|
||||
@@ -121,7 +132,7 @@
|
||||
protected void loadAdditional(CompoundTag nbt, HolderLookup.Provider registries) {
|
||||
super.loadAdditional(nbt, registries);
|
||||
DynamicOps<Tag> dynamicops = registries.createSerializationContext(NbtOps.INSTANCE);
|
||||
|
@ -54,7 +67,7 @@
|
|||
Logger logger;
|
||||
|
||||
if (nbt.contains("front_text")) {
|
||||
@@ -161,7 +167,7 @@
|
||||
@@ -161,7 +172,7 @@
|
||||
|
||||
if (world instanceof ServerLevel worldserver) {
|
||||
try {
|
||||
|
@ -63,7 +76,7 @@
|
|||
} catch (CommandSyntaxException commandsyntaxexception) {
|
||||
;
|
||||
}
|
||||
@@ -170,15 +176,17 @@
|
||||
@@ -170,15 +181,17 @@
|
||||
return text;
|
||||
}
|
||||
|
||||
|
@ -83,7 +96,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -188,19 +196,43 @@
|
||||
@@ -188,19 +201,43 @@
|
||||
return this.setText((SignText) textChanger.apply(signtext), front);
|
||||
}
|
||||
|
||||
|
@ -135,7 +148,7 @@
|
|||
}
|
||||
|
||||
public boolean setText(SignText text, boolean front) {
|
||||
@@ -227,11 +259,11 @@
|
||||
@@ -227,11 +264,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,7 +162,7 @@
|
|||
boolean flag1 = false;
|
||||
Component[] aichatbasecomponent = this.getText(front).getMessages(player.isTextFilteringEnabled());
|
||||
int i = aichatbasecomponent.length;
|
||||
@@ -242,7 +274,17 @@
|
||||
@@ -242,7 +279,17 @@
|
||||
ClickEvent chatclickable = chatmodifier.getClickEvent();
|
||||
|
||||
if (chatclickable != null && chatclickable.getAction() == ClickEvent.Action.RUN_COMMAND) {
|
||||
|
@ -168,7 +181,7 @@
|
|||
flag1 = true;
|
||||
}
|
||||
}
|
||||
@@ -250,11 +292,55 @@
|
||||
@@ -250,11 +297,55 @@
|
||||
return flag1;
|
||||
}
|
||||
|
||||
|
@ -226,7 +239,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -273,12 +359,17 @@
|
||||
@@ -273,12 +364,17 @@
|
||||
|
||||
@Nullable
|
||||
public UUID getPlayerWhoMayEdit() {
|
||||
|
@ -245,7 +258,7 @@
|
|||
}
|
||||
|
||||
public boolean isWaxed() {
|
||||
@@ -296,7 +387,7 @@
|
||||
@@ -296,7 +392,7 @@
|
||||
}
|
||||
|
||||
public boolean playerIsTooFarAwayToEdit(UUID uuid) {
|
||||
|
|
|
@ -198,6 +198,26 @@ public class CraftSign<T extends SignBlockEntity> extends CraftBlockEntityState<
|
|||
}
|
||||
// Paper end
|
||||
|
||||
// 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 - More Sign Block API
|
||||
|
||||
public static Component[] sanitizeLines(String[] lines) {
|
||||
Component[] components = new Component[4];
|
||||
|
||||
|
|
Loading…
Reference in a new issue