I'm making an Item that when used, it'll make all mobs stop chasing the player that used it. I tried user.endCombat();
, but that didn't work.
Here is some of my code:
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
if(!user.getItemCooldownManager().isCoolingDown(this)) {
// insert code here where mobs chasing player forget about the player/stop chasing the player.
user.getItemCooldownManager().set(this, 3 * 20);
}
return super.use(world, user, hand);
}
So, how do I make the player stop getting chased by mobs (like zombies) when the player uses the item (right-clicks)?