Skip to content

Conversation

@MC-Samuel
Copy link
Contributor

Adds in the heart_state tag and mechanism to control a creaking heart's state.
Requested in https://discord.com/channels/315163488085475337/1429656035865530380

// -->
tagProcessor.registerTag(ElementTag.class, "heart_state", (attribute, object) -> {
if (!(object.getBlockState().getBlockData() instanceof CreakingHeart heart)) {
Debug.echoError("The 'LocationTag.heart_state' tag can only be called on a creaking heart block.");
Copy link
Member

Choose a reason for hiding this comment

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

Attribute#echoError

Debug.echoError("The 'LocationTag.heart_state' tag can only be called on a creaking heart block.");
return null;
}
return Utilities.enumlikeToElement(heart.getCreakingHeartState());
Copy link
Member

Choose a reason for hiding this comment

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

Can probably just be new ElementTag(state)? These methods do some extra stuff for legacy/cross-version compatibility, but aren't really needed for normal enum usage.

});

// <--[mechanism]
// @object LocationTag
Copy link
Member

Choose a reason for hiding this comment

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

This seems to be operating on just the BlockData, is there any reason it's on LocationTag and not a MaterialTag property (maybe in MaterialTag.mode)?

@MC-Samuel MC-Samuel marked this pull request as draft October 26, 2025 03:41
@MC-Samuel MC-Samuel marked this pull request as ready for review November 22, 2025 02:03
Comment on lines 86 to 90
else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_21)) {
if (getBlockData() instanceof CreakingHeart creakingHeart) {
return new ElementTag(creakingHeart.getCreakingHeartState());
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I'd follow what we usually do, just put it as an else if on the main if & in-line the version and material checks as there's only one material.

Comment on lines 139 to 145
else if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_21)) {
if (getBlockData() instanceof CreakingHeart creakingHeart) {
if (mechanism.requireEnum(CreakingHeart.State.class)) {
creakingHeart.setCreakingHeartState(value.asEnum(CreakingHeart.State.class));
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Same here

getTripwire().setDisarmed(CoreUtilities.equalsIgnoreCase(mechanism.getValue().asString(), "disarmed"));
}
else if (getBlockData() instanceof Tripwire tripwire) {
tripwire.setDisarmed(CoreUtilities.equalsIgnoreCase(value.toString(), "disarmed"));
Copy link
Member

Choose a reason for hiding this comment

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

You switched these from #asString (generally preferred) to #toString - but in this case it would probably be cleaner to replace this with #asLowerString + just a normal equals?

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.

2 participants