Example usage for net.minecraftforge.event.entity.player PlayerInteractEvent.LeftClickEmpty getHand

List of usage examples for net.minecraftforge.event.entity.player PlayerInteractEvent.LeftClickEmpty getHand

Introduction

In this page you can find the example usage for net.minecraftforge.event.entity.player PlayerInteractEvent.LeftClickEmpty getHand.

Prototype

@Nonnull
public Hand getHand() 

Source Link

Usage

From source file:org.blockartistry.DynSurround.client.handlers.PlayerActionHandler.java

License:MIT License

@SubscribeEvent
public void onItemSwing(@Nonnull final PlayerInteractEvent.LeftClickEmpty event) {
    if (event.getEntityPlayer() == null || event.getEntityPlayer().world == null)
        return;/*  ww  w.j a  va  2s  .c om*/

    if (event.getEntityPlayer().world.isRemote && EnvironState.isPlayer(event.getEntityPlayer())) {
        final ItemStack currentItem = event.getEntityPlayer().getHeldItem(event.getHand());
        final SoundEffect soundEffect = this.itemRegistry.getSwingSound(currentItem);
        if (soundEffect != null) {
            final BasicSound<?> sound = soundEffect.createSound(EnvironState.getPlayer());
            sound.setRoutable(DSurround.isInstalledOnServer());
            SoundEffectHandler.INSTANCE.playSound(sound);
        }
    }
}