Is there a way to change the value of the experience that a mob will drop when killed?
I’ve tried this
e.getEntity().offer(Keys.TOTAL_EXPERIENCE, 100);
but the amount of exp i got, for example from a Cow, is the same as usual
Is there a way to change the value of the experience that a mob will drop when killed?
I’ve tried this
e.getEntity().offer(Keys.TOTAL_EXPERIENCE, 100);
but the amount of exp i got, for example from a Cow, is the same as usual
That key is for players, not cows. What you need to do is modify the HarvestEntityEvent
.
Ok, so i’ve done this
@Listener
public void onExperienceDrop(HarvestEntityEvent e) {
System.out.println("EXP DROP");
e.setExperience(0);
}
But it did nothing, the print didn’t get called and also the cow still drops exp
Is it properly registered? If so, sounds like it’s not implemented yet.
Yes, i register it like this in the init
game.getEventManager().registerListeners(this, new EventExperienceDrop());
Use a SpawnEntityEvent event,
Check if it is of instance of XP:
List<Entity> entity = event.getEntities();
if((entity.get(0) instanceof ExperienceOrb)
{
event.setCancelled(true);
}```
That prevents XP from dropping, but it can’t modify the amount.