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

Added property for specially registered tools #2693

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

littlecube8152
Copy link

@littlecube8152 littlecube8152 commented Dec 29, 2024

What

This PR adds another IMaterialProperty called ExtraToolProperty. This new property will

  • Override existing tool properties. For example, boosting the durability flint mining tools is possible now.
  • Add new tool that are not generated. However, the recipe should still be added manually.

Implementation Details

Now ExtraToolProperty and ToolProperty are two different classes inherited from SimpleToolProperty.
ToolProperty keeps all its original functionality, while ExtraToolProperty holds a modification mask for every other tools.
These tool masks are distinguished by the strings defined in ToolClasses.

The get method now takesIGTTool into consideration of overriding the specified properties. Hence, all the tools generated will now adapt the overridden stats.

The soft mallet and plungers are also re-defined using the new method. Now the tool stats are registered in SoftToolAddition and the recipe still registered from ToolRecipeHandler.

Outcome

By introducing this new method, #2692 is fixed since the tools are now correctly generated.
Also, modpacks can now have finer controls over the built-in tools. They are now able to change specific stats of some tools instead of modifying the whole set of tools from a material.

Potential Compatibility Issues

Most modpacks that tweaks the tools by the NBT will likely broken. However, I believe the bug similar #2692 will be fixed.

@littlecube8152 littlecube8152 requested a review from a team as a code owner December 29, 2024 18:55
@littlecube8152 littlecube8152 marked this pull request as draft December 31, 2024 06:29
@littlecube8152 littlecube8152 marked this pull request as ready for review January 1, 2025 10:46
@littlecube8152
Copy link
Author

Crafttweaker and GroovyScript integrations are not implemented yet.
However, I think these code should be reviewed first before we start these.

@littlecube8152 littlecube8152 changed the title Added repairing recipe workaround for specially registered tools Added property for specially registered tools Jan 1, 2025
@ALongStringOfNumbers ALongStringOfNumbers added type: feature New feature or request and removed type: feature New feature or request labels Jan 6, 2025
This fix will eliminate the NullPointerException caused from repairing tools without toolProperty properly set for the material. Therefore, the current soft-mallet/plumber duplications will be fixed since they are separately registered currently.
@littlecube8152 littlecube8152 force-pushed the littlecube-soft-tool-fix branch from 72a5c14 to 2cfcfdb Compare January 6, 2025 12:50
@littlecube8152
Copy link
Author

littlecube8152 commented Jan 6, 2025

The previous one (until 2cfcfdb) is faulty as many properties were not applied properly.
Now it is fixed and the GroovyScript integration is added. The usages are as follows.

OverrideToolProperty Builder

All properties are build through the methods overrideToolBuilder(). It is very similar to toolBuilder(), with the following property:

  • It is a builder of OverrideToolProperty (of course)
  • It has two initialization method: overrideToolBuilder() or overrideToolBuilder(float harvestSpeed, float attackDamage, int durability, int harvestLevel). The first is for only overriding some properties, and the second is for creating new tools (probably for tools without toolStats).
  • Only harvestSpeed, attackDamage, durability, attackSpeed, harvestLevel, enchantment, and durabilityMultiplier can be set in this builder (the missing ones are magnetic, unbreakable, and ignoreCraftingTools).

Overriding Tool Stats on Creation (Adding Material Properties)

Use

overrideToolStats(String toolId, ExtraToolProperty.Builder builder)

toolId is a string indicating the target overridden tool (for example, "pickaxe", "hammer", "knife"), and builder is a builder obtained from previous method.

Overriding Tool Stats on Modification

Use

Material.setOverrideToolStats(String toolId, ExtraToolProperty.Builder builder)

The usage is exactly the same as above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants