GregTechCEu / GregTech

GregTech CE 1.12 fork continuing progression and development
GNU Lesser General Public License v3.0
239 stars 179 forks source link

Tools lose their oredicts after deal a damage #1452

Closed Exzept1on closed 1 year ago

Exzept1on commented 1 year ago

GregTech CEu Version

2.5.0

Modpack Used

TFG:NH R4.1.12

Addons Installed

GM v1.1.6

Environment

Singleplayer

New Worlds

Yes

Cross-Mod Interaction

Unsure

Expected Behavior

Tool must not lose oredict

Actual Behavior

Lose their oredicts

Steps to Reproduce

1) Take any tool, for example knife 2) Do something.. 3) If you have spent durability, then the oredicts are also gone, congratulations.

Additional Information

https://user-images.githubusercontent.com/52341158/214824525-8e0e6b49-81ba-4430-98be-a02c4725ff3b.mp4

Xikaro commented 1 year ago

error persisted gregtech-1.12.2-2.5.2-beta image image

msgerbs commented 1 year ago

I'm also seeing this on 2.5.2-beta.

TechLord22 commented 1 year ago

On the current master branch, with commit hash 96e838b, I am unable to reproduce this. Can you provide further reproduction steps?

Exzept1on commented 1 year ago

they lose the oredict that Crafttweaker or Groovyscript(not tested) assigns to them

before using the tool: image

after using(where knife oredict) image

Steps:

  1. Assign any oredict to GT tool
  2. Try to use tool in world
  3. And now, where added oredict :trollface:
IntegerLimit commented 1 year ago

Can confirm on 2.5.2 beta. Testing with current master now.

msgerbs commented 1 year ago

Personally, I am playing on TFGNH-Extended 4.2.2 if that helps. https://github.com/TerraFirmaGreg-New-Horizons/TFG-NewHorizons-1.12.2/releases/tag/R4.2.2

TechLord22 commented 1 year ago

After further investigation we found the reason why, and it is something you can fix within your scripts.

Currently adding a GT tool to an oredict with CT, like this, will have the problem:

<ore:mySword>.add(<gregtech:sword>)

The root cause of this is a bug in the Forge OreDictionary, which uses the item's damage/durability to retrieve the ore dictionaries it possesses. It in reality should be using the item's metadata. In order to work around this bug, we create a special case where a tool is using the wildcard metadata upon oredict registration, so it behaves correctly.

In order to utilize our workaround, you will need to adjust your scripts to look like the following:

<ore:mySword>.add(<gregtech:sword:*>)
// or
<ore:mySword>.add(<gregtech:sword:32767>)

Both methods are equivalent. * or 32767 is the item meta wildcard value, which is intended for use when you want to accept any meta value for your itemstack.

If you add GT tools to ore dictionaries with the meta wildcard value, you should no longer experience this bug.

Exzept1on commented 1 year ago

Nice, it's really works, thank you!