mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 17:57:34 +01:00
parent
602f8cb433
commit
9b581cce11
@ -24,12 +24,14 @@ import java.util.stream.Collectors;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutCustomSoundEffect;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutEntitySound;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutUpdateTime;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutWorldEvent;
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
import net.minecraft.server.level.ChunkMapDistance;
|
||||
import net.minecraft.server.level.EntityPlayer;
|
||||
import net.minecraft.server.level.PlayerChunk;
|
||||
import net.minecraft.server.level.PlayerChunkMap;
|
||||
import net.minecraft.server.level.Ticket;
|
||||
import net.minecraft.server.level.TicketType;
|
||||
import net.minecraft.server.level.WorldServer;
|
||||
@ -1514,6 +1516,22 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
world.getServer().getPlayerList().broadcast(null, x, y, z, volume > 1.0F ? 16.0F * volume : 16.0D, this.world.dimension(), packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(Entity entity, Sound sound, float volume, float pitch) {
|
||||
playSound(entity, sound, org.bukkit.SoundCategory.MASTER, volume, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(Entity entity, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) {
|
||||
if (!(entity instanceof CraftEntity craftEntity) || entity.getWorld() != this || sound == null || category == null) return;
|
||||
|
||||
PacketPlayOutEntitySound packet = new PacketPlayOutEntitySound(CraftSound.getSoundEffect(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), craftEntity.getHandle(), volume, pitch);
|
||||
PlayerChunkMap.EntityTracker entityTracker = getHandle().getChunkSource().chunkMap.entityMap.get(entity.getEntityId());
|
||||
if (entityTracker != null) {
|
||||
entityTracker.broadcastAndSend(packet);
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<String, GameRules.GameRuleKey<?>> gamerules;
|
||||
public static synchronized Map<String, GameRules.GameRuleKey<?>> getGameRulesNMS() {
|
||||
if (gamerules != null) {
|
||||
|
@ -44,6 +44,7 @@ import net.minecraft.network.protocol.game.PacketPlayOutChat;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutCustomPayload;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutCustomSoundEffect;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutEntitySound;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutExperience;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutGameStateChange;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutMap;
|
||||
@ -501,6 +502,19 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
getHandle().connection.send(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(org.bukkit.entity.Entity entity, Sound sound, float volume, float pitch) {
|
||||
playSound(entity, sound, org.bukkit.SoundCategory.MASTER, volume, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(org.bukkit.entity.Entity entity, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) {
|
||||
if (!(entity instanceof CraftEntity craftEntity) || sound == null || category == null || getHandle().connection == null) return;
|
||||
|
||||
PacketPlayOutEntitySound packet = new PacketPlayOutEntitySound(CraftSound.getSoundEffect(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), craftEntity.getHandle(), volume, pitch);
|
||||
getHandle().connection.send(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopSound(Sound sound) {
|
||||
stopSound(sound, null);
|
||||
|
Loading…
Reference in New Issue
Block a user