Hello, im kind of a newbie on creating mods, and i been trying to make simples mods so far, Right now, i'm creating a mod which detect an specific type of mob and kill it if reach a certain number, by far the mod is detecting the mob and counting them but at the time it reach the limit number, it don't do anything. The Game don't tweak, don't crash, just i't don't run the method i call, which is kill().
public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand pUsedHand) {
final var TotalCows = pLevel.getNearbyEntities(Cow.class, TargetingConditions.forNonCombat(), pPlayer, pPlayer.getBoundingBox().inflate(5));
if(pLevel.isClientSide){
if(pPlayer.getItemInHand(InteractionHand.MAIN_HAND).getItem() == this.asItem()){
if(!TotalCows.isEmpty()){
if(TotalCows.get(0).isAlive()){
TotalCows.get(0).kill();
}
}else{
pPlayer.sendSystemMessage(Component.literal("No hay vacas"));
}
}
}
The sendSystemMessage is get triggered, and when i change the method .kill() by any other like send a message it got called, can i get some tips, and a clue of what i'm missing