use of chronosacaria.mcdw.api.interfaces.IOffhandAttack in project MCDungeonsWeapons by chronosacaria.
the class CombatEventHandler method checkForOffHandAttack.
public static void checkForOffHandAttack() {
MinecraftClient mc = MinecraftClient.getInstance();
PlayerEntity player = mc.player;
HitResult hitResult = mc.crosshairTarget;
if (MinecraftClient.getInstance().world != null && MinecraftClient.getInstance().currentScreen == null && !MinecraftClient.getInstance().isPaused() && player != null && !player.isBlocking()) {
ItemStack offhand = player.getOffHandStack();
if (offhand.getItem() instanceof IOffhandAttack) {
if (hitResult instanceof EntityHitResult) {
if (mc.crosshairTarget != null && mc.interactionManager != null) {
mc.interactionManager.attackEntity(player, ((EntityHitResult) mc.crosshairTarget).getEntity());
}
}
}
}
}
Aggregations