#1134: Add custom sound parameter option for playSound with entity as source
This commit is contained in:
parent
ab8ace6857
commit
b1059a82ea
@ -1571,6 +1571,11 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
playSound(entity, sound, org.bukkit.SoundCategory.MASTER, volume, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(Entity entity, String 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;
|
||||
@ -1582,6 +1587,17 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(Entity entity, String 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(Holder.direct(SoundEffect.createVariableRangeEvent(new MinecraftKey(sound))), net.minecraft.sounds.SoundCategory.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, getHandle().getRandom().nextLong());
|
||||
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) {
|
||||
|
@ -532,6 +532,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
playSound(entity, sound, org.bukkit.SoundCategory.MASTER, volume, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(org.bukkit.entity.Entity entity, String 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;
|
||||
@ -540,6 +545,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
getHandle().connection.send(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(org.bukkit.entity.Entity entity, String 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(Holder.direct(SoundEffect.createVariableRangeEvent(new MinecraftKey(sound))), net.minecraft.sounds.SoundCategory.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, getHandle().getRandom().nextLong());
|
||||
getHandle().connection.send(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopSound(Sound sound) {
|
||||
stopSound(sound, null);
|
||||
|
Loading…
x
Reference in New Issue
Block a user