Mobs fix crash and not drop XP when dying by fire from sunlight #3398

Merged
ancientmarinerdev merged 3 commits from mob_death_xp_drop into master 2023-02-08 20:44:15 +01:00

Hopefully fixes crashes for #3403

  • Taken from the issue:

Crash 1 - The only way I can see it going wrong with the parameter is if the yaw or the pos is invalid. I have exited from the method if it cannot get any of these.

Crash 2 is that self.acc is wrong. I don't know how it got in that state, but I've added a check to see it's valid before it sets velocity.

Fixes #3179 for sunlight burning

  • The issue was that there was no death cause received by the code that identified the mob dead.

  • This was the catch all at the end of env_damage. After finding this was the check that succeeded, I commented it out and burning mobs would not die.

As a result:

  • I added a death check at the end of fire death so this will catch it and pass in the correct death cause, rather than waiting for it to run through the whole mob step to be caught.

  • I moved env_damage to the top with all the damage dealing mob code. If a mob dies in method, we have to know before deciding to move on with any other processing and ideally exit out of the mob_step

  • I added in the death cause unknown so we know what is causing a death and where it is being triggered.

Testing

/time 20000

wait for zombies

/time 9000

watch them die, and verify they don't drop xp orbs

Hopefully fixes crashes for #3403 * Taken from the issue: > Crash 1 - The only way I can see it going wrong with the parameter is if the yaw or the pos is invalid. I have exited from the method if it cannot get any of these. > > Crash 2 is that self.acc is wrong. I don't know how it got in that state, but I've added a check to see it's valid before it sets velocity. Fixes #3179 for sunlight burning * The issue was that there was no death cause received by the code that identified the mob dead. * This was the catch all at the end of env_damage. After finding this was the check that succeeded, I commented it out and burning mobs would not die. As a result: * I added a death check at the end of fire death so this will catch it and pass in the correct death cause, rather than waiting for it to run through the whole mob step to be caught. * I moved env_damage to the top with all the damage dealing mob code. If a mob dies in method, we have to know before deciding to move on with any other processing and ideally exit out of the mob_step * I added in the death cause unknown so we know what is causing a death and where it is being triggered. ### Testing /time 20000 wait for zombies /time 9000 watch them die, and verify they don't drop xp orbs
Contributor

From the wiki:

Experience orbs drop only if a mob dies less than three seconds after being attacked (melee, bow, snowballs, eggs, and potions causing instant damage) by a player or by a player's pet wolf, though not by a player-activated dispenser.

So whatever the cause of death, other than dispensed stuff, I think we should only check if a player or tamed wolf damaged the mobs less than three seconds before dying.

Can mobs get timers when damaged by players or tamed wolves? If so, if the timer is >0 on death, drop XP orbs.

From [the wiki](https://minecraft.fandom.com/wiki/Drops#Experience_orbs): > Experience orbs drop only if a mob dies less than three seconds after being attacked (melee, bow, snowballs, eggs, and potions causing instant damage) by a player or by a player's pet wolf, though not by a player-activated dispenser. So whatever the cause of death, other than dispensed stuff, I think we should only check if a player or tamed wolf damaged the mobs less than three seconds before dying. Can mobs get timers when damaged by players or tamed wolves? If so, if the timer is >0 on death, drop XP orbs.
Member

Can mobs get timers when damaged by players or tamed wolves? If so, if the timer is >0 on death, drop XP orbs.

This sounds reasonable. Though probably time consuming to implement.

> Can mobs get timers when damaged by players or tamed wolves? If so, if the timer is >0 on death, drop XP orbs. This sounds reasonable. Though probably time consuming to implement.
ancientmarinerdev changed title from WIP: Mobs should not drop XP when dying by fire from sunlight to WIP: Mobs fix crash and not drop XP when dying by fire from sunlight 2023-02-06 05:47:28 +01:00
Member

There's an easier way. When a player damages the mob, store the os.time. When the mob dies, compare os.time to the stored time to see if it's within the allotted timeframe, and act accordingly.

There's an easier way. When a player damages the mob, store the os.time. When the mob dies, compare os.time to the stored time to see if it's within the allotted timeframe, and act accordingly.
ancientmarinerdev changed title from WIP: Mobs fix crash and not drop XP when dying by fire from sunlight to Mobs fix crash and not drop XP when dying by fire from sunlight 2023-02-07 01:35:20 +01:00
Author
Owner

I have added crash fixes to this and it is ready for review. As it is a crash, I will likely move it in sooner, but any feedback I can happily implement after the event if anyone catches anything as I do plan to work further on this code later.

I have added crash fixes to this and it is ready for review. As it is a crash, I will likely move it in sooner, but any feedback I can happily implement after the event if anyone catches anything as I do plan to work further on this code later.
ancientmarinerdev force-pushed mob_death_xp_drop from 0261529264 to b834e790a7 2023-02-08 20:34:15 +01:00 Compare
ancientmarinerdev merged commit 30bb1ab075 into master 2023-02-08 20:44:15 +01:00
ancientmarinerdev deleted branch mob_death_xp_drop 2023-02-08 20:44:37 +01:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: VoxeLibre/VoxeLibre#3398
No description provided.