use of net.minecraft.network.play.server.SPlaySoundEffectPacket in project Magma-1.16.x by magmafoundation.
the class CraftPlayer method playNote.
@Override
public void playNote(Location loc, byte instrument, byte note) {
if (getHandle().connection == null)
return;
String instrumentName = null;
switch(instrument) {
case 0:
instrumentName = "harp";
break;
case 1:
instrumentName = "basedrum";
break;
case 2:
instrumentName = "snare";
break;
case 3:
instrumentName = "hat";
break;
case 4:
instrumentName = "bass";
break;
case 5:
instrumentName = "flute";
break;
case 6:
instrumentName = "bell";
break;
case 7:
instrumentName = "guitar";
break;
case 8:
instrumentName = "chime";
break;
case 9:
instrumentName = "xylophone";
break;
}
float f = (float) Math.pow(2.0D, (note - 12.0D) / 12.0D);
getHandle().connection.send(new SPlaySoundEffectPacket(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.util.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f));
}
use of net.minecraft.network.play.server.SPlaySoundEffectPacket in project LoliServer by Loli-Server.
the class CraftPlayer method playSound.
@Override
public void playSound(Location loc, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) {
if (loc == null || sound == null || category == null || getHandle().connection == null)
return;
SPlaySoundEffectPacket packet = new SPlaySoundEffectPacket(CraftSound.getSoundEffect(sound), net.minecraft.util.SoundCategory.valueOf(category.name()), loc.getX(), loc.getY(), loc.getZ(), volume, pitch);
getHandle().connection.send(packet);
}
use of net.minecraft.network.play.server.SPlaySoundEffectPacket in project LoliServer by Loli-Server.
the class CraftPlayer method playNote.
@Override
public void playNote(Location loc, byte instrument, byte note) {
if (getHandle().connection == null)
return;
String instrumentName = null;
switch(instrument) {
case 0:
instrumentName = "harp";
break;
case 1:
instrumentName = "basedrum";
break;
case 2:
instrumentName = "snare";
break;
case 3:
instrumentName = "hat";
break;
case 4:
instrumentName = "bass";
break;
case 5:
instrumentName = "flute";
break;
case 6:
instrumentName = "bell";
break;
case 7:
instrumentName = "guitar";
break;
case 8:
instrumentName = "chime";
break;
case 9:
instrumentName = "xylophone";
break;
}
float f = (float) Math.pow(2.0D, (note - 12.0D) / 12.0D);
getHandle().connection.send(new SPlaySoundEffectPacket(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.util.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f));
}
use of net.minecraft.network.play.server.SPlaySoundEffectPacket in project Create_Aeronautics by Eriksonnaren.
the class ServerWorldEventMixin method playSound.
/**
* @author RyanHCode
*/
@Overwrite(remap = false)
public void playSound(@Nullable PlayerEntity pPlayer, double pX, double pY, double pZ, SoundEvent pSound, SoundCategory pCategory, float pVolume, float pPitch) {
if (((Object) this) instanceof ServerWorld && ((ServerWorld) (Object) this).dimension() == AirshipDimensionManager.WORLD_ID) {
// get position of entity
Vector3d pos = new Vector3d(pX, pY, pZ);
BlockPos bPos = new BlockPos(pos);
// get airship plot id
int id = AirshipManager.getIdFromPlotPos(bPos);
BlockPos plotPos = AirshipManager.getPlotPosFromId(id);
// get airship
AirshipContraptionEntity airship = AirshipManager.INSTANCE.AllAirships.get(id);
if (airship != null) {
Vector3d position = new Vector3d(bPos.getX(), bPos.getY(), bPos.getZ());
position = position.subtract(plotPos.getX(), plotPos.getY(), plotPos.getZ());
position = airship.toGlobalVector(position, 1.0f);
airship.level.playSound(pPlayer, position.x, position.y, position.z, pSound, pCategory, pVolume, pPitch);
return;
}
}
net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(pPlayer, pSound, pCategory, pVolume, pPitch);
if (event.isCanceled() || event.getSound() == null)
return;
pSound = event.getSound();
pCategory = event.getCategory();
pVolume = event.getVolume();
server.getPlayerList().broadcast(pPlayer, pX, pY, pZ, pVolume > 1.0F ? (double) (16.0F * pVolume) : 16.0D, ((ServerWorld) (Object) this).dimension(), new SPlaySoundEffectPacket(pSound, pCategory, pX, pY, pZ, pVolume, pPitch));
}
use of net.minecraft.network.play.server.SPlaySoundEffectPacket in project Magma-1.16.x by magmafoundation.
the class CraftPlayer method playSound.
@Override
public void playSound(Location loc, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) {
if (loc == null || sound == null || category == null || getHandle().connection == null)
return;
SPlaySoundEffectPacket packet = new SPlaySoundEffectPacket(CraftSound.getSoundEffect(sound), net.minecraft.util.SoundCategory.valueOf(category.name()), loc.getX(), loc.getY(), loc.getZ(), volume, pitch);
getHandle().connection.send(packet);
}
Aggregations