Conversation
…nism. Added back-of-sign support to CopyBlock command
| else { | ||
| for (Component component : sign.lines()) { | ||
| output[i++] = PaperModule.stringifyComponent(component); | ||
| } |
There was a problem hiding this comment.
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!"); |
There was a problem hiding this comment.
isnt this missing return statement?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
is this required? sign_contents_back doesnt have it
| 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; | ||
| } |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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()); |
| } | ||
| return null; | ||
| bsm.setBlockState(sign); | ||
| getItemStack().setItemMeta(bsm); |
| 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); |
There was a problem hiding this comment.
This also has special case handling in ItemComponentsPatch
| } | ||
| CoreUtilities.fixNewLinesToListSeparation(input); | ||
| if (input.size() > 4) { | ||
| mechanism.echoError("Sign can only hold four lines!"); |
There was a problem hiding this comment.
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."); |
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Was this tested? Won't n already be at 4 from the previous loop?
Text on the back of signs was added in MC 1.20. This PR adds in the following:
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.ItemTag.sign_back_contentsfor MC 1.20+.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.LocationTag.sign_back_contentsfor MC 1.20+.copyblockcommand on MC 1.20+.