Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
2.4 KiB
Markdown
Raw Permalink Normal View History

2026-09-09 00:52:19 +02:00
# Saw cutting strength
[Java API index](../API.md)
`ItemSaw.setHarvestLevel(int)` changes an existing FMP saw's cutting strength without reflection. The value is read
by `harvestLevel()`, `getCuttingStrength(ItemStack)` and `getMaxCuttingStrength()`, so recipes and FMP's 3D saw
renderer observe the same updated tier.
IguanaTweaksTConstruct can replace its private-field lookup and write with direct calls:
```java
ItemSaw saw = (ItemSaw) item;
int oldStrength = saw.harvestLevel();
int updatedStrength = HarvestLevelTweaks.getUpdatedHarvestLevel(oldStrength);
saw.setHarvestLevel(updatedStrength);
```
The [compiling example](../../src/test/java/codechicken/microblock/examples/SawStrengthExample.java) contains the
2026-10-15 16:39:36 +02:00
setter call.
2026-09-09 00:52:19 +02:00
2026-09-16 13:56:09 +02:00
Iguana's client proxy also reads the three built-in saws and the renderer mode through `MicroblockProxy$.MODULE$`.
The Java facade exposes the same state directly:
```java
Item stoneSaw = MicroblockProxy.sawStone();
Item ironSaw = MicroblockProxy.sawIron();
Item diamondSaw = MicroblockProxy.sawDiamond();
if (!MicroblockProxy.useSawIcons()) {
// Register the existing 3D saw renderers.
}
```
2026-10-15 16:39:36 +02:00
Keep the companion access only for already released binaries; rebuilt Java consumers should use the static facade.
2026-09-16 13:56:09 +02:00
2026-09-09 00:52:19 +02:00
## State and lifecycle
The setter changes only cutting strength. It does not recalculate the saw's durability or alter existing item-stack
damage. This matches Iguana's current post-construction field mutation. The integer is intentionally unrestricted,
like the constructor and legacy field; the consumer owns its tier mapping.
FMP calculates `MicroMaterialRegistry.getMaxCuttingStrength()` once during ForgeMicroblock post-initialization.
Startup integrations that add or relevel saws must finish first so the cached maximum sees the final tiers. Iguana's
optional ordering should therefore include `before:ForgeMicroblock` while retaining its existing FMP presence gate.
Call the setter on the main initialization thread, before recipes can be used.
The method is specific to `ItemSaw`. Other `Saw` implementations may derive strength from each `ItemStack` and do
not promise mutable global strength.
## Legacy compatibility
The private `harvestLevel: int` field remains in place for existing Iguana releases. It is mutable so the supported
setter and legacy reflection update the same storage. New integrations should use the public getter and setter and
should not catch and ignore API failures.