Skip to content

Multi-Sided Sign Support#2796

Open
MC-Samuel wants to merge 14 commits intoDenizenScript:devfrom
MC-Samuel:sign_back
Open

Multi-Sided Sign Support#2796
MC-Samuel wants to merge 14 commits intoDenizenScript:devfrom
MC-Samuel:sign_back

Conversation

@MC-Samuel
Copy link
Copy Markdown
Contributor

@MC-Samuel MC-Samuel commented Dec 1, 2025

Text on the back of signs was added in MC 1.20. This PR adds in the following:

  • Modernizes ItemTag.sign_contents, it will only look at the sign contents for the front of the sign across versions. A line in the meta references the new property below for information about the back of signs.
  • Adds ItemTag.sign_back_contents for MC 1.20+.
  • Modernizes LocationTag.sign_contents, it will only look at the sign contents for the front of the sign across versions. A line in the meta references the new tag and mechanism below for information about the back of signs.
  • Adds LocationTag.sign_back_contents for MC 1.20+.
  • Adds ability to copy the contents on the back of signs with the copyblock command on MC 1.20+.

else {
for (Component component : sign.lines()) {
output[i++] = PaperModule.stringifyComponent(component);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this probably could be ternary in the for-each statement, since the body is the same

}
CoreUtilities.fixNewLinesToListSeparation(input);
if (input.size() > 4) {
mechanism.echoError("Sign can only hold four lines!");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isnt this missing return statement?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An else for the setting loop below so that the Sign#update still runs, but yeah missing here I think

for (int i = 0; i < 4; i++) {
PaperAPITools.instance.setSignLine(sign, i, "");
}
ListTag list = mechanism.valueAsType(ListTag.class);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this required? sign_contents_back doesnt have it

Comment on lines 116 to 123
public String[] getBackSignLines(Sign sign) {
String[] output = new String[4];
int i = 0;
for (Component component : sign.getSide(Side.BACK).lines()) {
output[i++] = PaperModule.stringifyComponent(component);
}
return output;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that there's two of these, a util method for the List<Component> -> String[] operation would be nice, as both methods are essentially the same

item = _item;
@Override
public ListTag getPropertyValue() {
return new ListTag(Arrays.asList(PaperAPITools.instance.getSignLines((Sign) ((BlockStateMeta) getItemMeta()).getBlockState())), true);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason these methods return a String[]? Seems like it might be cleaner to return a List<String> no?

if (attribute == null) {
return null;
public void setPropertyValue(ListTag value, Mechanism mechanism) {
BlockStateMeta bsm = ((BlockStateMeta) getItemMeta());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use the as(Class) util

}
return null;
bsm.setBlockState(sign);
getItemStack().setItemMeta(bsm);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just setItemMeta

PropertyParser.registerProperty(ItemScript.class, ItemTag.class);
PropertyParser.registerProperty(ItemSignContents.class, ItemTag.class); // Special case handling in ItemComponentsPatch
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_20)) {
PropertyParser.registerProperty(ItemSignContentsBack.class, ItemTag.class);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also has special case handling in ItemComponentsPatch

}
CoreUtilities.fixNewLinesToListSeparation(input);
if (input.size() > 4) {
mechanism.echoError("Sign can only hold four lines!");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An else for the setting loop below so that the Sign#update still runs, but yeah missing here I think

// -->
tagProcessor.registerMechanism("sign_back_glowing", false, ElementTag.class, (object, mechanism, input) -> {
if (!(object.getBlockState() instanceof Sign sign)) {
mechanism.echoError("'sign_back_glowing' mechanism can only be called on Sign blocks.");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifying the mechanism name in the error is kinda redundant, it should show up automatically as part of the context Mechanism#echoError adds

// <LocationTag.sign_glowing>
// -->
tagProcessor.registerMechanism("sign_glowing", false, ElementTag.class, (object, mechanism, input) -> {
if (mechanism.requireBoolean()) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Early return would be nicer than nesting everything here

// <LocationTag.sign_glowing>
// -->
tagProcessor.registerMechanism("sign_glow_color", false, ElementTag.class, (object, mechanism, input) -> {
if (mechanism.requireEnum(DyeColor.class)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, that way you could also have the is it a sign check before the input check

}
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_20)) {
for (String line : ((Sign) sourceState).getSide(Side.BACK).getLines()) {
PaperAPITools.instance.setBackSignLine(((Sign) updateState), n++, line);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this tested? Won't n already be at 4 from the previous loop?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants