List of usage examples for net.minecraftforge.event.world NoteBlockEvent.Play getVanillaNoteId
public int getVanillaNoteId()
From source file:vazkii.quark.misc.feature.NoteBlocksMobSounds.java
License:Creative Commons License
@SubscribeEvent public void noteBlockPlayed(NoteBlockEvent.Play event) { BlockPos pos = event.getPos();// w ww. j a va 2 s . c om if (event.getWorld().getBlockState(pos).getBlock() != Blocks.NOTEBLOCK) return; int type = getSkullType(event.getWorld(), pos); if (type != -1 && type != 3) { event.setCanceled(true); SoundEvent sound = null; switch (type) { case 0: sound = SoundEvents.ENTITY_SKELETON_AMBIENT; break; case 1: sound = SoundEvents.ENTITY_WITHER_SKELETON_AMBIENT; break; case 2: sound = SoundEvents.ENTITY_ZOMBIE_AMBIENT; break; case 4: sound = SoundEvents.ENTITY_CREEPER_PRIMED; break; case 5: sound = SoundEvents.ENTITY_ENDERDRAGON_AMBIENT; break; } if (sound != null) { float pitch = (float) Math.pow(2.0, (event.getVanillaNoteId() - 12) / 12.0); event.getWorld().playSound(null, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, sound, SoundCategory.BLOCKS, 1F, pitch); } } }