OneLemonyBoi / MiniUtilities

https://www.curseforge.com/minecraft/mc-mods/miniutilities
MIT License
12 stars 17 forks source link

[Bug Report] Error spam when golden spikes hit mobs / No XP dropped #136

Closed Xalcon closed 2 years ago

Xalcon commented 2 years ago

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:

  1. Place down Gold Spikes
  2. Let Entity get hit by Gold Spikes
  3. See error in console

Expected behavior No error, xp drop on death

Mod Info (please complete the following information):

OneLemonyBoi commented 2 years ago

fixed in dev

Xalcon commented 2 years ago

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;