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..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; @@ -715,6 +716,14 @@ final class Holder { @NotNull public Sound getSwimHighSpeedSplashSound(); + /** + * Get the {@link SoundCategory} this entity will use when playing its sounds. + * + * @return the sound category for this entity + */ + @NotNull + 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..71806cb1e6f6 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; @@ -1002,6 +1003,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 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 DamageSource damageSource); + /** * Get the {@link Sound} this entity will make on death. * @@ -1061,6 +1071,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 getSoundPitch(); + /** * 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..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; @@ -613,6 +614,11 @@ public Sound getSwimHighSpeedSplashSound() { return CraftSound.minecraftToBukkit(this.getHandle().getSwimHighSpeedSplashSound()); } + @Override + public SoundCategory getSoundCategory() { + return 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..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 @@ -879,6 +879,14 @@ public Sound getHurtSound() { return (sound != null) ? CraftSound.minecraftToBukkit(sound) : null; } + @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; + } + @Override public Sound getDeathSound() { SoundEvent sound = this.getHandle().getDeathSound(); @@ -905,6 +913,16 @@ public Sound getDrinkingSound(ItemStack itemStack) { return this.getEatingSound(itemStack); } + @Override + public float getSoundVolume() { + return this.getHandle().getSoundVolume(); + } + + @Override + public float getSoundPitch() { + return this.getHandle().getVoicePitch(); + } + @Override public Sound getEatingSound(ItemStack itemStack) { Preconditions.checkArgument(itemStack != null, "itemStack must not be null");