Woot

Woot

24M Downloads

Ender Shard counting Ender Dragon Kill too many times.

MidoriKami opened this issue ยท 9 comments

commented

When fighting the Vanilla Ender Dragon, if you are fighting the dragon with a bow, you can keep shooting the dragon after it 'dies' and get credit for 1 kill each time you hit the 'dead' dragon.

commented

Minecraft Forge v1.12.2-14.23.3.2678-universal

I am using the modpack "All the Mods 3" Version 5.9.5 with the following changes to the versions:
environmentaltech-1.12.2-2.0.10a
valkyrielib-1.12.2-2.0.10b
dismantler-0.1.2

I could perform more analysis or debugging from my end if you are having any trouble reproducing.
Personally, as a cheaty way to get the dragon shard easier I think this is a neat 'feature', but is definitely unintended.

mods.txt

commented

Looks like I can replicate this.
I basically added some debug to my onLivingDeath event handler, which is called by Forge when an entity dies. I end up with 3 events for the same dragon.

I'm just trying to work out why I get three when I would expect only one.
Could well be that I misunderstand this event, or this event is slightly different for the Dragon.
I'll have to dig a bit further as to why.

[12:08:43] [Server thread/INFO]: Woot: onLivingDeathEvent: net.minecraft.util.EntityDamageSourceIndirect@190944a1/EntityDragon['Ender Dragon'/517644, l='Mob Test', x=37.97, y=61.38, z=8.05] [12:08:44] [Server thread/INFO]: Woot: onLivingDeathEvent: net.minecraft.util.EntityDamageSourceIndirect@195ccb53/EntityDragon['Ender Dragon'/517644, l='Mob Test', x=36.79, y=60.73, z=8.36] [12:08:45] [Server thread/INFO]: Woot: onLivingDeathEvent: net.minecraft.util.EntityDamageSourceIndirect@56b91956/EntityDragon['Ender Dragon'/517644, l='Mob Test', x=29.59, y=59.77, z=7.38]

commented

This looks like it could be fun one as I hook directly into the Forge event.
Can you let me know which version of Forge you are using and a mod list if possible.

It is always possible that I'm not handing the event correctly, so I'll need to do some investigation.

commented

I am wondering if a status effect of some kind (like poison, if you can poison the dragon) could cause it to trigger more death notifications.

commented

After looking at the code and from some comments from a reply on the Forge forums.
There seems to be some code that ticks the Dragon health back up by 1 point between the point you kill it and when it stops moving. Some there is scope for you getting more than one onLivingDeathEvent on the Dragon specifically - or anything derived from the Dragon class.
(I could of course being falling into confirmation bias, since I've found something that looks like it explains it).

I'm not sure about how to fix it.
I'll look at trying to filter out the duplicates when I receive them, the only risk of course being that I might end up filtering out legitimate kills.
There is a Entity.getUniqueID/getCachedUniqueIdString that I could cache and compare. Then I could drop any events for a mob I had already processed.

commented

Caching the last few event origin entities seems to work.
I now only process the first onLivingDeathEvent rather than all of them, so this is looking promising.

[10:20:10] [Server thread/INFO]: Woot: onLivingDeathEvent: [10:20:10] [Server thread/INFO]: Woot: onLivingDeathEvent: processing [10:20:11] [Server thread/INFO]: Woot: onLivingDeathEvent: [10:20:11] [Server thread/INFO]: Woot: onLivingDeathEvent: drop due to duplicate [10:20:12] [Server thread/INFO]: Woot: onLivingDeathEvent: [10:20:12] [Server thread/INFO]: Woot: onLivingDeathEvent: drop due to duplicate [10:20:12] [Server thread/INFO]: Woot: onLivingDeathEvent: [10:20:12] [Server thread/INFO]: Woot: onLivingDeathEvent: drop due to duplicate

commented

(Forewarning, Not a minecraft mod developer)
Clever solution, is this fix applied only to the EnderDragon? or to your eventListener?

Is there a chance that an improperly coded mod to not generate unique UUID's for each entity or is that handled in the forge/vanilla codebase?

commented

It is applied to my event listener code, so it will handle all mobs.
I've set the cache to be 10 slots, so that should be enough to catch the event being generated by the mob, while still allowing other death events from other mobs in between. Not infallible, but it should remove the issue in the majority of cases.

The unigue UUID is a method from the vanilla codebase's Entity class.

commented