Hello Im trying to get this function. Especially the offhand.hitentity to work. Everytime I face a mob the item swings but doesn't hurt the mob and if I face away from the mob the game crashes.
@SubscribeEvent
public static void dualweild(MouseEvent event)
{
EntityLivingBase target = (EntityLivingBase) Minecraft.getMinecraft().pointedEntity;
EntityPlayer player = Minecraft.getMinecraft().player;
ItemStack mainhand = player.getHeldItemMainhand();
ItemStack offhand = player.getHeldItemOffhand();
//right mouse button is 1
if (event.getButton() == 1)
{
if (offhand.getItem() instanceof ItemKnife)
{
offhand.hitEntity(target, player);
offhand.damageItem(1, player);
player.swingArm(EnumHand.OFF_HAND);
}
else
{
return;
}
}
}