Skip to content

Conversation

@MC-Samuel
Copy link
Contributor

Adds in a tag and mechanism to return and change the slots of a crafter block that are disabled.

Requested in https://discord.com/channels/315163488085475337/1417201910489939988

Open to naming suggestions, this was kind of the cleanest thing I could think of since there's already an EntityTag.disabled_slots

}
for (String slot : input) {
ElementTag element = new ElementTag(slot);
if (element.isInt() && element.asInt() > 0 && element.asInt() <= 9) {
Copy link
Contributor

Choose a reason for hiding this comment

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

i would probably put asInt() part into its own variable since its doing the same operation 3 times

// @mechanism LocationTag.crafter_disabled_slots
// @group world
// @description
// Returns the disabled slots of a crafter block from left to right, top to bottom.
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if the order of the list is something we should be guaranteeing here? Realistically any usage should depend on what the actual slots are, not where they are in the list.

// Returns the disabled slots of a crafter block from left to right, top to bottom.
// -->
tagProcessor.registerTag(ListTag.class, "crafter_disabled_slots", (attribute, object) -> {
if (!(object.getBlockState() instanceof Crafter crafter)) {
Copy link
Member

Choose a reason for hiding this comment

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

#getBlockStateForTag

// -->
tagProcessor.registerTag(ListTag.class, "crafter_disabled_slots", (attribute, object) -> {
if (!(object.getBlockState() instanceof Crafter crafter)) {
Debug.echoError("The 'LocationTag.crafter_disabled_slots' tag can only be called on a crafter 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

Comment on lines 4562 to 4564
else {
mechanism.echoError("'" + slot + "' is not a valid slot for the 'crafter_disabled_slots' mechanism.");
}
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 early return this while you're at it

continue;
}
}
mechanism.echoError("'" + slot + "' is not a valid slot for the 'crafter_disabled_slots' mechanism.");
Copy link
Member

Choose a reason for hiding this comment

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

This being here is a slightly confusing flow imo, as you have to look at the nested continue above and all - I'd just go with early returning on the int check &/ range check above.

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