I'm currently using the following code segment to simulate a player attacking an entity (basically auto attack).
Minecraft mc = Minecraft.getMinecraft();
mc.playerController.attackEntity(mc.player, mob);
where mob is an instance of EntityLiving.
The mod works well when playing locally, but when on servers (especially those with RPG game mode), sometimes the targeted entity won't get hurt when executing the statement.
Does anybody know why it is and how can I modify my code?