GTNewHorizons / GT-New-Horizons-Modpack

New Modpack with Gregtech, Thaumcraft and Witchery
https://www.gtnewhorizons.com/
Other
942 stars 294 forks source link

TConstruct durability overflow #15599

Open TheAimless opened 6 months ago

TheAimless commented 6 months ago

Your GTNH Discord Username

theaimless

Your Pack Version

2.5.0

Your Server

SP

Java Version

Java 17

Type of Server

None

Your Expectation

More material should return 100 durability.

The Reality

Fixing the tool with more material sometimes causes the tool to have lower resulting durability.

Screenshot 2024-02-26 053054 Screenshot 2024-02-26 053111

Your Proposal

Add an overflow check for Tinkers Tools.

Final Checklist

Caedis commented 6 months ago

Can you run /iih or /mt hand and post a screenshot of the tool's NBT data?

Caedis commented 6 months ago

or even better, use /mt hand and click the text to copy it to your clipboard and paste it here

TheAimless commented 6 months ago

Here you go:

.withTag({InfiTool: {RenderExtra: 7, BaseDurability: 621, ExtraAttack: 1, BaseAttack: 2, ToolEXP: 910 as long, HarvestLevel: 0, RenderHead: 7, ModDurability: 0.0 as float, Shoddy: 1.0 as float, RenderHandle: 7, Accessory: 7, MiningSpeed: 456, ExtraBaneOfArthropods: 1, Unbreaking: 0, Damage: 413, HarvestLevel2: 0, BonusDurability: 0, TotalDurability: 621, MiningSpeed2: 456, Head: 7, Attack: 2, Handle: 7, Broken: 0 as byte, Extra: 7, RenderAccessory: 7, ToolLevel: 10, RepairCount: 114, ExtraRedstone: 9211, Modifiers: 5}, display: {Name: "§fNetherrack Lumber Axe"}})
Lyfts commented 6 months ago

I have done some testing and have only been able to reproduce this with Tinkers Gregworks installed. I'm unsure exactly why it happens but it might be ModTGregRepair and ModToolRepair clashing in some way.

Attached is an NEI bookmark containing a lumber axe that with TGregworks installed requires 3 netherrack to fully repair and adding a 4th or 5th netherrack lowers the durability. Without TGregworks installed this requires 6 netherrack to fully repair which could be related to the issue.

bookmarks.zip

leumasme commented 2 days ago

I'm unsure exactly why it happens but it might be ModTGregRepair and ModToolRepair clashing in some way.

I looked into this a bit and agree to this conclusion. (Also: Confirming this is still present in current Nightly 2024-09-05) Both Repair Modification handlers are registered into itemModifiers and processed after each other (ModToolRepair first) This actually leads to tool repairing generally giving more durability than intended - Both Repair Modifier handlers run, calculate the durability to restore, and repair the tool.

In the calculateIfNecessary function, both Repair handlers make sure that no more than half of the repair value of the items would be wasted due to the tool not having that much missing durability. Thus, if the ModToolRepair (which runs first) repairs the tool to near-full durability, the ModTGregRepair will not run, so the tool is only repaired by one of the two handlers which roughly halves the amount that the tool is repaired by.

The correct thing here would probably be to just disable the normal tinkers ModToolRepair. (ModTGregRepair seems to include some explicit support for repairing with GT materials? Not sure why this is required as ModToolRepair seems to be able to repair tools using GT materials fine by using TConstructRegistry.customMaterials) Note that this bugfix would reduce the amount of durability restored by half, making Tinkers tool repairs twice as expensive, which may be a considerable balance change.

Lyfts commented 2 days ago

I'd say that bugfix is worth it despite the balance change, GTNH has been playing easy mode Tinker's for 3+ 8 years now. If need be we can always add an easy mode repair in Tinker' proper.