Skip to content

Commit

Permalink
Register new tag & mechanism presented as location.waxed (#2527)
Browse files Browse the repository at this point in the history
* add tag & mechanism for `location.waxed`

* describe more `ElementTag` return

* hop into 1.20 version checker

* change the description on tag `locationtag.waxed`

* mechanism require boolean
  • Loading branch information
pobab committed Sep 10, 2023
1 parent 5e07800 commit 5b964d2
Showing 1 changed file with 37 additions and 0 deletions.
Expand Up @@ -4350,6 +4350,43 @@ else if (material.hasModernData() && material.getModernData() instanceof org.buk
brushableBlock.setItem(item.getItemStack());
brushableBlock.update();
});

// <--[tag]
// @attribute <LocationTag.waxed>
// @returns ElementTag(Boolean)
// @mechanism LocationTag.waxed
// @group world
// @description
// If the location is a sign block, returns whether it is waxed (locked to prevent players editing the text).
// -->
tagProcessor.registerTag(ElementTag.class, "waxed", (attribute, object) -> {
if (!(object.getBlockStateForTag(attribute) instanceof Sign sign)) {
attribute.echoError("Location is not a valid Sign block.");
return null;
}
return new ElementTag(sign.isWaxed());
});

// <--[mechanism]
// @object LocationTag
// @name waxed
// @input ElementTag(Boolean)
// @description
// Sets whether the sign at the location is waxed (locked to prevent players editing the text).
// @tags
// <LocationTag.waxed>
// -->
tagProcessor.registerMechanism("waxed", false, ElementTag.class, (object, mechanism, value) -> {
if (!mechanism.requireBoolean()) {
return;
}
if (!(object.getBlockState() instanceof Sign sign)) {
mechanism.echoError("'waxed' mechanism can only be called on Sign blocks.");
return;
}
sign.setWaxed(value.asBoolean());
sign.update();
});
}

// <--[mechanism]
Expand Down

0 comments on commit 5b964d2

Please sign in to comment.