-
-
Notifications
You must be signed in to change notification settings - Fork 113
Tag and mechanism to disable crafter slots #2781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
| } | ||
| for (String slot : input) { | ||
| ElementTag element = new ElementTag(slot); | ||
| if (element.isInt() && element.asInt() > 0 && element.asInt() <= 9) { |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Attribute#echoError
| else { | ||
| mechanism.echoError("'" + slot + "' is not a valid slot for the 'crafter_disabled_slots' mechanism."); | ||
| } |
There was a problem hiding this comment.
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."); |
There was a problem hiding this comment.
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.
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