protected void playSoundEffect(double x, double y, double z, SoundEvent sound, float volume, float pitch){ if(getWorld().isRemote) return; final double range = 16; List<EntityPlayerMP> players = getWorld().getEntitiesWithinAABB(EntityPlayerMP.class, new AxisAlignedBB( x - range, y - range, z - range, x + range, y + range, z + range)); for(EntityPlayerMP player : players){ player.connection.sendPacket(new SPacketCustomSound(sound.getRegistryName().toString(), SoundCategory.BLOCKS, x, y, z, (float)volume, (float)pitch)); } }
public static void playSoundAtPosition(double x, double y, double z, SoundEvent sound, SoundCategory soundType, float volume, float pitch, World serverWorld){ if(serverWorld.isRemote) return; final double range = 16; List<EntityPlayerMP> players = serverWorld.getEntitiesWithinAABB(EntityPlayerMP.class, new AxisAlignedBB( x - range, y - range, z - range, x + range, y + range, z + range)); for(EntityPlayerMP player : players){ player.connection.sendPacket(new SPacketCustomSound(sound.getRegistryName().toString(), soundType, x, y, z, (float)volume, (float)pitch)); } }
public static void playBigSoundAtPosition(double x, double y, double z, SoundEvent sound, SoundCategory soundType, float volume, float pitch, World serverWorld){ if(serverWorld.isRemote) return; final double range = 50; List<EntityPlayerMP> players = serverWorld.getEntitiesWithinAABB(EntityPlayerMP.class, new AxisAlignedBB( x - range, y - range, z - range, x + range, y + range, z + range)); for(EntityPlayerMP player : players){ player.connection.sendPacket(new SPacketCustomSound(sound.getRegistryName().toString(), soundType, x, y, z, (float)volume, (float)pitch)); } }
protected void playSound(World w, Vec3d position, double range, SoundEvent sound, float volume, float pitch){ if(w.isRemote)return; AxisAlignedBB area = new AxisAlignedBB( position.xCoord - range,position.yCoord - range,position.zCoord - range, position.xCoord + range,position.yCoord + range,position.zCoord + range ); List<EntityPlayerMP> players = w.getEntitiesWithinAABB(EntityPlayerMP.class, area); SPacketCustomSound soundPacket = new SPacketCustomSound(sound.getRegistryName().toString(), SoundCategory.PLAYERS, position.xCoord, position.yCoord, position.zCoord, volume, pitch); for(EntityPlayerMP player : players){ player.connection.sendPacket(soundPacket); } }
protected void playFadedSound(World w, Vec3d position, double range, SoundEvent sound, float volume, float pitch){ if(w.isRemote)return; AxisAlignedBB area = new AxisAlignedBB( position.xCoord - range,position.yCoord - range,position.zCoord - range, position.xCoord + range,position.yCoord + range,position.zCoord + range ); List<EntityPlayerMP> players = w.getEntitiesWithinAABB(EntityPlayerMP.class, area); for(EntityPlayerMP player : players){ float distSqr = (float)player.getPositionVector().squareDistanceTo(position); float localVolume = Math.min(volume,volume/distSqr); SPacketCustomSound soundPacket = new SPacketCustomSound(sound.getRegistryName().toString(), SoundCategory.PLAYERS, position.xCoord, position.yCoord, position.zCoord, localVolume, pitch); player.connection.sendPacket(soundPacket); } }
public void handleCustomSound(SPacketCustomSound packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); this.gameController.getSoundHandler().playSound(new PositionedSoundRecord(new ResourceLocation(packetIn.getSoundName()), packetIn.getCategory(), packetIn.getVolume(), packetIn.getPitch(), false, 0, ISound.AttenuationType.LINEAR, (float)packetIn.getX(), (float)packetIn.getY(), (float)packetIn.getZ())); }
void handleCustomSound(SPacketCustomSound packetIn);