Skip to content
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

Fix GT tools not working for some mod actions #1706

Closed
wants to merge 1 commit into from

Conversation

serenibyss
Copy link
Collaborator

What:
This PR fixes GT tools not working in some cases for other mods. For example as detailed in #1704, trees from the Dynamic Trees mod cannot be chopped with a GT Axe or Saw.

How solved:
I overrode getToolClasses in ToolMetaItem, and specified tool classes in each tool type as applicable.

Outcome:
Closes #1704

Additional info:
As we are now marking "extra" tools as their proper classes, it is possible that additional compatibility with other mods will achieved. Particularly our Wrench and Crowbar.

Comment on lines +24 to +26
private static final Set<String> HAMMER_TOOL_CLASSES = new HashSet<String>() {{
add("hammer"); add("pickaxe");
}};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably better to use ImmutableSet.of("hammer", "pickaxe") or similar here. If the Set itself is mutable then a caller could modify it, and the double-brace approach will also create an anonymous inner class which is probably not desirable.

Copy link
Member

Choose a reason for hiding this comment

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

I also think these should be immutable from our side to keep them safe. Regarding double braces they have to be addressed too.

Comment on lines +28 to +30
private static final Set<String> HAMMER_TOOL_CLASSES = new HashSet<String>() {{
add("pickaxe"); add("hammer");
}};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same thing as other comment, perhaps also should be called JACKHAMMER_[...] rather than HAMMER_[...]

Copy link
Contributor

Choose a reason for hiding this comment

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

It uses "hammer" in canMineBlock, so it should be consistent:

return (tool != null && (tool.equals("hammer") || tool.equals("pickaxe"))) ||

Copy link
Contributor

Choose a reason for hiding this comment

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

All these if statements could be changed to something like:

return HAMMER_TOOL_CLASSES.contains(tool) ||

It will be slightly less efficient, but easier to maintain in future.
i.e. you won't have subtle bugs introduced by inconsistencies between getToolClasses() and canMineBlock()

Copy link
Collaborator

Choose a reason for hiding this comment

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

It uses "hammer" in canMineBlock, so it should be consistent:

I clearly meant the name of the constant, not the value of the strings in the Set.

All these if statements could be changed to something like:

Not sure what this has to do with this block of code; perhaps create a separate "conversation" linked to the code you're talking about so we have the appropriate context.

@Exaxxion
Copy link
Collaborator

Exaxxion commented Aug 8, 2021

Besides the review comments and some more cases of the same issues, the code looks fine.

@serenibyss serenibyss closed this Jun 7, 2022
@serenibyss serenibyss deleted the fixdynamictrees branch June 7, 2022 02:02
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.

[BUG] Cannot chop down trees with GTCE axes
4 participants