because as far as I know, only DamageSource.causePlayerDamage will mark the mob for exp drops. The probkem with this method is that it causes the mob to get knocked back, even when I do not call entity.knockBack().
Is there a workaround for this, so I can make the entity drop exp, but not get knocked back?
Ps, target.setLastAttacker does not work.
Rollback Post to RevisionRollBack
Whomsoever takes up this mod shall wield power eternal.
I do if I hit them with a regular attack or a spell that causes knockback, I do not get orbs only if I use a spell that does not cause knockback.
Then just spawn them when using that spell. (Maybe create a SpellNoKnockback superclass that handles this, so you don't have to do it in every single spell.)
Then just spawn them when using that spell. (Maybe create a SpellNoKnockback superclass that handles this, so you don't have to do it in every single spell.)
I would have to store a timestamp for when the player attacked last, then use event listeners to spawn exp if the target has been attacked has been attacked with magic by a player the last 5 sec. How do you suggest storing the data tho? NBT tag?
EDIT: Does anyone know if this can be solved by making a new custom damage type instead?
Custom damage type is a possibility. Make a static DamageSource, just like you would for other items, and apply that damage using your magic spell. To spawn XP orbs, handle the LivingDeathEvent, check if they died to that damage source, and spawn the xp.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
Custom damage type is a possibility. Make a static DamageSource, just like you would for other items, and apply that damage using your magic spell. To spawn XP orbs, handle the LivingDeathEvent, check if they died to that damage source, and spawn the xp.
Very good, and well explained advice! Haven't tried, but 100% sure it will work, thanks!
Hey guys, I am making a mod with spells that deals magic damage, and in order to make the mobs you kill drop exp orbs when they die, I also included
because as far as I know, only DamageSource.causePlayerDamage will mark the mob for exp drops. The probkem with this method is that it causes the mob to get knocked back, even when I do not call entity.knockBack().
Is there a workaround for this, so I can make the entity drop exp, but not get knocked back?
Ps, target.setLastAttacker does not work.
Just spawn the experience orbs yourself
How would I prevent double exp drop?
What do you mean? I thought you don't have any experience orbs dropping atm?
I do if I hit them with a regular attack or a spell that causes knockback, I do not get orbs only if I use a spell that does not cause knockback.
Then just spawn them when using that spell. (Maybe create a SpellNoKnockback superclass that handles this, so you don't have to do it in every single spell.)
I would have to store a timestamp for when the player attacked last, then use event listeners to spawn exp if the target has been attacked has been attacked with magic by a player the last 5 sec. How do you suggest storing the data tho? NBT tag?
EDIT: Does anyone know if this can be solved by making a new custom damage type instead?
Custom damage type is a possibility. Make a static DamageSource, just like you would for other items, and apply that damage using your magic spell. To spawn XP orbs, handle the LivingDeathEvent, check if they died to that damage source, and spawn the xp.
Very good, and well explained advice! Haven't tried, but 100% sure it will work, thanks!
How do I mark a topic as solved?