So I am trying to make essentially a necromancer sorta thing and I can't seem to get the LivingChangeTargetEvent to work, I don't know much about events so I'm not sure if I am doing something wrong with the BusSubscriber or something? With this code and other various debug codes it never did or changed anything.
@Mod.EventBusSubscriber(modid = RSGArmoury.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE)
public class RSGEvents {
@SubscribeEvent
public void undeadArmyIgnore(LivingChangeTargetEvent event) {
if (event.getEntity() instanceof Player player) {
event.setNewTarget(null);
}
}
using this debug does nothing.
@SubscribeEvent
public void undeadArmyIgnore(LivingChangeTargetEvent event) {
event.getNewTarget().sendSystemMessage(Component.literal("New Target Debug"));
event.getOriginalTarget().sendSystemMessage(Component.literal("Original Target Debug"));
event.getEntity().sendSystemMessage(Component.literal("Entity Debug"));
if (event.getNewTarget() instanceof Player player) {
event.setNewTarget(null);
}
}