From be86fe55dc5eb1a26dd84a2f3ec031c9eba73868 Mon Sep 17 00:00:00 2001 From: LeonTG Date: Tue, 26 May 2026 21:26:16 +0200 Subject: [PATCH 1/4] Expand Entity Sound API --- .../main/java/org/bukkit/entity/Entity.java | 8 +++++++ .../java/org/bukkit/entity/LivingEntity.java | 23 +++++++++++++++++++ .../craftbukkit/entity/CraftEntity.java | 5 ++++ .../craftbukkit/entity/CraftLivingEntity.java | 16 +++++++++++++ 4 files changed, 52 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/entity/Entity.java b/paper-api/src/main/java/org/bukkit/entity/Entity.java index 2c68aae864a7..6043ef1fc142 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Entity.java +++ b/paper-api/src/main/java/org/bukkit/entity/Entity.java @@ -715,6 +715,14 @@ final class Holder { @NotNull public Sound getSwimHighSpeedSplashSound(); + /** + * Get the {@link org.bukkit.SoundCategory} this entity will use when playing its sounds. + * + * @return the sound category for this entity + */ + @NotNull + org.bukkit.SoundCategory getSoundCategory(); + /** * Returns whether this entity is inside a vehicle. * diff --git a/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java b/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java index 19a48dce7c2f..7fb4cf52d3d8 100644 --- a/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java @@ -1002,6 +1002,15 @@ default boolean addPotionEffect(@NotNull PotionEffect effect) { @Nullable public Sound getHurtSound(); + /** + * Get the {@link Sound} this entity will make when damaged by the given {@link org.bukkit.damage.DamageSource}. + * + * @param damageSource the damage source to get the hurt sound of + * @return the hurt sound, or null if the entity does not make any sound for the given damage source + */ + @Nullable + public Sound getHurtSound(@NotNull org.bukkit.damage.DamageSource damageSource); + /** * Get the {@link Sound} this entity will make on death. * @@ -1061,6 +1070,20 @@ default boolean addPotionEffect(@NotNull PotionEffect effect) { @NotNull public Sound getEatingSound(@NotNull ItemStack itemStack); + /** + * Get the sound volume at which this entity plays its sounds with + * + * @return the sound volume of this entity + */ + public float getSoundVolume(); + + /** + * Get the sound pitch at which this entity plays its sounds with + * + * @return the sound pitch of this entity + */ + public float getVoicePitch(); + /** * Returns true if this entity can breathe underwater and will not take * suffocation damage when its air supply reaches zero. diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 2f40476da09c..cfcbd34a14aa 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -613,6 +613,11 @@ public Sound getSwimHighSpeedSplashSound() { return CraftSound.minecraftToBukkit(this.getHandle().getSwimHighSpeedSplashSound()); } + @Override + public org.bukkit.SoundCategory getSoundCategory() { + return org.bukkit.SoundCategory.valueOf(this.getHandle().getSoundSource().name()); + } + @Override public void setMetadata(String metadataKey, MetadataValue newMetadataValue) { this.server.getEntityMetadata().setMetadata(this, metadataKey, newMetadataValue); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index aefc65543fc1..88a0c059f67a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -879,6 +879,12 @@ public Sound getHurtSound() { return (sound != null) ? CraftSound.minecraftToBukkit(sound) : null; } + @Override + public Sound getHurtSound(org.bukkit.damage.DamageSource damageSource) { + SoundEvent sound = this.getHandle().getHurtSound(((CraftDamageSource) damageSource).getHandle()); + return (sound != null) ? CraftSound.minecraftToBukkit(sound) : null; + } + @Override public Sound getDeathSound() { SoundEvent sound = this.getHandle().getDeathSound(); @@ -905,6 +911,16 @@ public Sound getDrinkingSound(ItemStack itemStack) { return this.getEatingSound(itemStack); } + @Override + public float getSoundVolume() { + return this.getHandle().getSoundVolume(); + } + + @Override + public float getVoicePitch() { + return this.getHandle().getVoicePitch(); + } + @Override public Sound getEatingSound(ItemStack itemStack) { Preconditions.checkArgument(itemStack != null, "itemStack must not be null"); From 687a185ff004bf8135ca3c401374bdc84ada29de Mon Sep 17 00:00:00 2001 From: LeonTG Date: Tue, 26 May 2026 22:04:13 +0200 Subject: [PATCH 2/4] Fixes to imports, as requested --- paper-api/src/main/java/org/bukkit/entity/Entity.java | 5 +++-- paper-api/src/main/java/org/bukkit/entity/LivingEntity.java | 5 +++-- .../main/java/org/bukkit/craftbukkit/entity/CraftEntity.java | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/entity/Entity.java b/paper-api/src/main/java/org/bukkit/entity/Entity.java index 6043ef1fc142..5804c4b9573e 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Entity.java +++ b/paper-api/src/main/java/org/bukkit/entity/Entity.java @@ -13,6 +13,7 @@ import org.bukkit.Nameable; import org.bukkit.Server; import org.bukkit.Sound; +import org.bukkit.SoundCategory; import org.bukkit.World; import org.bukkit.block.BlockFace; import org.bukkit.block.PistonMoveReaction; @@ -716,12 +717,12 @@ final class Holder { public Sound getSwimHighSpeedSplashSound(); /** - * Get the {@link org.bukkit.SoundCategory} this entity will use when playing its sounds. + * Get the {@link SoundCategory} this entity will use when playing its sounds. * * @return the sound category for this entity */ @NotNull - org.bukkit.SoundCategory getSoundCategory(); + SoundCategory getSoundCategory(); /** * Returns whether this entity is inside a vehicle. diff --git a/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java b/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java index 7fb4cf52d3d8..2968f1c50ed5 100644 --- a/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java @@ -16,6 +16,7 @@ import org.bukkit.World; import org.bukkit.attribute.Attributable; import org.bukkit.block.Block; +import org.bukkit.damage.DamageSource; import org.bukkit.entity.memory.MemoryKey; import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; @@ -1003,13 +1004,13 @@ default boolean addPotionEffect(@NotNull PotionEffect effect) { public Sound getHurtSound(); /** - * Get the {@link Sound} this entity will make when damaged by the given {@link org.bukkit.damage.DamageSource}. + * Get the {@link Sound} this entity will make when damaged by the given {@link DamageSource}. * * @param damageSource the damage source to get the hurt sound of * @return the hurt sound, or null if the entity does not make any sound for the given damage source */ @Nullable - public Sound getHurtSound(@NotNull org.bukkit.damage.DamageSource damageSource); + public Sound getHurtSound(@NotNull DamageSource damageSource); /** * Get the {@link Sound} this entity will make on death. diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index cfcbd34a14aa..fab37a0b07f9 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -44,6 +44,7 @@ import org.bukkit.Location; import org.bukkit.Server; import org.bukkit.Sound; +import org.bukkit.SoundCategory; import org.bukkit.World; import org.bukkit.block.BlockFace; import org.bukkit.block.PistonMoveReaction; @@ -614,8 +615,8 @@ public Sound getSwimHighSpeedSplashSound() { } @Override - public org.bukkit.SoundCategory getSoundCategory() { - return org.bukkit.SoundCategory.valueOf(this.getHandle().getSoundSource().name()); + public SoundCategory getSoundCategory() { + return SoundCategory.valueOf(this.getHandle().getSoundSource().name()); } @Override From b4dad140a514a0889683d581f50e27f8fd2ca672 Mon Sep 17 00:00:00 2001 From: LeonTG Date: Tue, 26 May 2026 22:05:06 +0200 Subject: [PATCH 3/4] Also add the requested Preconditions --- .../java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 88a0c059f67a..3da59cf586ad 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -881,6 +881,8 @@ public Sound getHurtSound() { @Override public Sound getHurtSound(org.bukkit.damage.DamageSource damageSource) { + Preconditions.checkArgument(damageSource != null, "damageSource cannot be null"); + SoundEvent sound = this.getHandle().getHurtSound(((CraftDamageSource) damageSource).getHandle()); return (sound != null) ? CraftSound.minecraftToBukkit(sound) : null; } From 65ea9979cc97a0e210f691a92f66d3c456904331 Mon Sep 17 00:00:00 2001 From: LeonTG Date: Fri, 12 Jun 2026 18:23:31 +0200 Subject: [PATCH 4/4] Done @Lulu13022002 --- paper-api/src/main/java/org/bukkit/entity/LivingEntity.java | 2 +- .../java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java b/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java index 2968f1c50ed5..71806cb1e6f6 100644 --- a/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java @@ -1083,7 +1083,7 @@ default boolean addPotionEffect(@NotNull PotionEffect effect) { * * @return the sound pitch of this entity */ - public float getVoicePitch(); + public float getSoundPitch(); /** * Returns true if this entity can breathe underwater and will not take diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 3da59cf586ad..9a9edd4daddd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -919,7 +919,7 @@ public float getSoundVolume() { } @Override - public float getVoicePitch() { + public float getSoundPitch() { return this.getHandle().getVoicePitch(); }