[Bug Report] Error spam when golden spikes hit mobs / No XP dropped
Xalcon opened this issue ยท 2 comments
Describe the bug
When an entity is hit by the golden spikes, the console is spamed with java.lang.NoSuchFieldException: lastHurtByPlayerTime
and the entity does not drop any xp on death.
To Reproduce
Steps to reproduce the behavior:
- Place down Gold Spikes
- Let Entity get hit by Gold Spikes
- See error in console
Expected behavior
No error, xp drop on death
Mod Info (please complete the following information):
- Forge: 40.1.60
- MC Version: 1.18.2
- Mod Version: 2.0.0 (LemonLib 2.1.1)
I had a quick look and your fix didn't work.
You are still using the mojang symbol name lastHurtByPlayerTime
, which is defined in the mojang mappings. Those mappings are only applied in development environments. In production environments (i.e. when launching the game normally), forge uses SRG names since every mod can use their own set of mappings during development. Mods are re-obfuscated during the build process to use SRG names instead, but strings are not touched.
To fix this, you will either need to select the correct name depending on the runtime environment (MOJ for Dev, SRG for Prod) or switch to access transformers.
For my private modpack I've fixed the issue using the latter:
accesstransformer.cfg
:
public net.minecraft.world.entity.LivingEntity f_20889_ # lastHurtByPlayerTime
And then replace the whole try-catch block with
entity.lastHurtByPlayerTime = 100;