From d41367ee6d7e7102537c3ff88ca540f0e32841cb Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sun, 11 Sep 2022 22:24:15 +1000 Subject: [PATCH] #1100: Add methods to get sounds from entities By: Parker Hawke --- .../net/minecraft/world/entity/Entity.patch | 89 ++++++++++++------- .../world/entity/EntityInsentient.patch | 45 ++++++---- .../minecraft/world/entity/EntityLiving.patch | 80 +++++++++++------ .../craftbukkit/entity/CraftEntity.java | 18 ++++ .../craftbukkit/entity/CraftLivingEntity.java | 42 +++++++++ .../bukkit/craftbukkit/entity/CraftMob.java | 10 ++- .../craftbukkit/entity/CraftRaider.java | 7 ++ 7 files changed, 215 insertions(+), 76 deletions(-) diff --git a/paper-server/nms-patches/net/minecraft/world/entity/Entity.patch b/paper-server/nms-patches/net/minecraft/world/entity/Entity.patch index c81e4b3189..9cd95dadae 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/Entity.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/Entity.patch @@ -253,7 +253,28 @@ if (this.onGround) { block.stepOn(this.level, blockposition, iblockdata, this); } -@@ -1290,6 +1466,7 @@ +@@ -938,6 +1114,20 @@ + return SoundEffects.GENERIC_SPLASH; + } + ++ // CraftBukkit start - Add delegate methods ++ public SoundEffect getSwimSound0() { ++ return getSwimSound(); ++ } ++ ++ public SoundEffect getSwimSplashSound0() { ++ return getSwimSplashSound(); ++ } ++ ++ public SoundEffect getSwimHighSpeedSplashSound0() { ++ return getSwimHighSpeedSplashSound(); ++ } ++ // CraftBukkit end ++ + protected void checkInsideBlocks() { + AxisAlignedBB axisalignedbb = this.getBoundingBox(); + BlockPosition blockposition = new BlockPosition(axisalignedbb.minX + 0.001D, axisalignedbb.minY + 0.001D, axisalignedbb.minZ + 0.001D); +@@ -1290,6 +1480,7 @@ this.yo = d1; this.zo = d4; this.setPos(d3, d1, d4); @@ -261,7 +282,7 @@ } public void moveTo(Vec3D vec3d) { -@@ -1480,6 +1657,12 @@ +@@ -1480,6 +1671,12 @@ return false; } @@ -274,7 +295,7 @@ public void awardKillScore(Entity entity, int i, DamageSource damagesource) { if (entity instanceof EntityPlayer) { CriterionTriggers.ENTITY_KILLED_PLAYER.trigger((EntityPlayer) entity, this, damagesource); -@@ -1513,7 +1696,7 @@ +@@ -1513,7 +1710,7 @@ } else { String s = this.getEncodeId(); @@ -283,7 +304,7 @@ return false; } else { nbttagcompound.putString("id", s); -@@ -1538,6 +1721,18 @@ +@@ -1538,6 +1735,18 @@ Vec3D vec3d = this.getDeltaMovement(); nbttagcompound.put("Motion", this.newDoubleList(vec3d.x, vec3d.y, vec3d.z)); @@ -302,7 +323,7 @@ nbttagcompound.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot())); nbttagcompound.putFloat("FallDistance", this.fallDistance); nbttagcompound.putShort("Fire", (short) this.remainingFireTicks); -@@ -1546,6 +1741,22 @@ +@@ -1546,6 +1755,22 @@ nbttagcompound.putBoolean("Invulnerable", this.invulnerable); nbttagcompound.putInt("PortalCooldown", this.portalCooldown); nbttagcompound.putUUID("UUID", this.getUUID()); @@ -325,7 +346,7 @@ IChatBaseComponent ichatbasecomponent = this.getCustomName(); if (ichatbasecomponent != null) { -@@ -1613,6 +1824,11 @@ +@@ -1613,6 +1838,11 @@ } } @@ -337,7 +358,7 @@ return nbttagcompound; } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); -@@ -1696,6 +1912,44 @@ +@@ -1696,6 +1926,44 @@ } else { throw new IllegalStateException("Entity has invalid position"); } @@ -382,7 +403,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT"); CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded"); -@@ -1771,9 +2025,22 @@ +@@ -1771,9 +2039,22 @@ } else if (this.level.isClientSide) { return null; } else { @@ -405,7 +426,7 @@ this.level.addFreshEntity(entityitem); return entityitem; } -@@ -1867,7 +2134,7 @@ +@@ -1867,7 +2148,7 @@ this.setPose(EntityPose.STANDING); this.vehicle = entity; @@ -414,7 +435,7 @@ entity.getIndirectPassengersStream().filter((entity2) -> { return entity2 instanceof EntityPlayer; }).forEach((entity2) -> { -@@ -1898,7 +2165,7 @@ +@@ -1898,7 +2179,7 @@ Entity entity = this.vehicle; this.vehicle = null; @@ -423,7 +444,7 @@ } } -@@ -1907,10 +2174,31 @@ +@@ -1907,10 +2188,31 @@ this.removeVehicle(); } @@ -456,7 +477,7 @@ if (this.passengers.isEmpty()) { this.passengers = ImmutableList.of(entity); } else { -@@ -1926,12 +2214,32 @@ +@@ -1926,12 +2228,32 @@ } } @@ -490,7 +511,7 @@ if (this.passengers.size() == 1 && this.passengers.get(0) == entity) { this.passengers = ImmutableList.of(); } else { -@@ -1942,6 +2250,7 @@ +@@ -1942,6 +2264,7 @@ entity.boardingCooldown = 60; } @@ -498,7 +519,7 @@ } protected boolean canAddPassenger(Entity entity) { -@@ -2004,14 +2313,20 @@ +@@ -2004,14 +2327,20 @@ if (this.isInsidePortal) { MinecraftServer minecraftserver = worldserver.getServer(); @@ -522,7 +543,7 @@ this.level.getProfiler().pop(); } -@@ -2129,6 +2444,13 @@ +@@ -2129,6 +2458,13 @@ } public void setSwimming(boolean flag) { @@ -536,7 +557,7 @@ this.setSharedFlag(4, flag); } -@@ -2174,8 +2496,12 @@ +@@ -2174,8 +2510,12 @@ return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false; } @@ -550,7 +571,7 @@ } public boolean getSharedFlag(int i) { -@@ -2194,7 +2520,7 @@ +@@ -2194,7 +2534,7 @@ } public int getMaxAirSupply() { @@ -559,7 +580,7 @@ } public int getAirSupply() { -@@ -2202,7 +2528,18 @@ +@@ -2202,7 +2542,18 @@ } public void setAirSupply(int i) { @@ -579,7 +600,7 @@ } public int getTicksFrozen() { -@@ -2229,11 +2566,41 @@ +@@ -2229,11 +2580,41 @@ public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) { this.setRemainingFireTicks(this.remainingFireTicks + 1); @@ -598,8 +619,9 @@ + this.setSecondsOnFire(entityCombustEvent.getDuration(), false); + } + // CraftBukkit end -+ } -+ + } + +- this.hurt(DamageSource.LIGHTNING_BOLT, 5.0F); + // CraftBukkit start + if (thisBukkitEntity instanceof Hanging) { + HangingBreakByEntityEvent hangingEvent = new HangingBreakByEntityEvent((Hanging) thisBukkitEntity, stormBukkitEntity); @@ -608,9 +630,8 @@ + if (hangingEvent.isCancelled()) { + return; + } - } - -- this.hurt(DamageSource.LIGHTNING_BOLT, 5.0F); ++ } ++ + if (this.fireImmune()) { + return; + } @@ -623,7 +644,7 @@ } public void onAboveBubbleCol(boolean flag) { -@@ -2391,15 +2758,38 @@ +@@ -2391,15 +2772,38 @@ @Nullable public Entity changeDimension(WorldServer worldserver) { @@ -664,7 +685,7 @@ this.level.getProfiler().popPush("reloading"); Entity entity = this.getType().create(worldserver); -@@ -2408,9 +2798,17 @@ +@@ -2408,9 +2812,17 @@ entity.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot()); entity.setDeltaMovement(shapedetectorshape.speed); worldserver.addDuringTeleport(entity); @@ -672,19 +693,19 @@ - WorldServer.makeObsidianPlatform(worldserver); + if (worldserver.getTypeKey() == WorldDimension.END) { // CraftBukkit + WorldServer.makeObsidianPlatform(worldserver, this); // CraftBukkit -+ } + } + // CraftBukkit start - Forward the CraftEntity to the new entity + this.getBukkitEntity().setHandle(entity); + entity.bukkitEntity = this.getBukkitEntity(); + + if (this instanceof EntityInsentient) { + ((EntityInsentient) this).dropLeash(true, false); // Unleash to prevent duping of leads. - } ++ } + // CraftBukkit end } this.removeAfterChangingDimensions(); -@@ -2431,20 +2829,34 @@ +@@ -2431,20 +2843,34 @@ @Nullable protected ShapeDetectorShape findDimensionEntryPoint(WorldServer worldserver) { @@ -724,7 +745,7 @@ IBlockData iblockdata = this.level.getBlockState(this.portalEntrancePos); EnumDirection.EnumAxis enumdirection_enumaxis; Vec3D vec3d; -@@ -2461,8 +2873,8 @@ +@@ -2461,8 +2887,8 @@ vec3d = new Vec3D(0.5D, 0.0D, 0.0D); } @@ -735,7 +756,7 @@ } } else { BlockPosition blockposition1; -@@ -2472,8 +2884,14 @@ +@@ -2472,8 +2898,14 @@ } else { blockposition1 = worldserver.getHeightmapPos(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSharedSpawnPos()); } @@ -751,7 +772,7 @@ } } -@@ -2481,8 +2899,23 @@ +@@ -2481,8 +2913,23 @@ return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose())); } @@ -777,7 +798,7 @@ } public boolean canChangeDimensions() { -@@ -2691,7 +3124,26 @@ +@@ -2691,7 +3138,26 @@ } public final void setBoundingBox(AxisAlignedBB axisalignedbb) { @@ -805,7 +826,7 @@ } protected float getEyeHeight(EntityPose entitypose, EntitySize entitysize) { -@@ -2979,6 +3431,11 @@ +@@ -2979,6 +3445,11 @@ vec3d = vec3d.add(vec3d1); ++k1; } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/EntityInsentient.patch b/paper-server/nms-patches/net/minecraft/world/entity/EntityInsentient.patch index 630a518cb9..127361db1b 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityInsentient.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityInsentient.patch @@ -81,7 +81,20 @@ } @Override -@@ -453,16 +505,26 @@ +@@ -364,6 +416,12 @@ + return null; + } + ++ // CraftBukkit start - Add delegate method ++ public SoundEffect getAmbientSound0() { ++ return getAmbientSound(); ++ } ++ // CraftBukkit end ++ + @Override + public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { + super.addAdditionalSaveData(nbttagcompound); +@@ -453,16 +511,26 @@ nbttagcompound.putBoolean("NoAI", this.isNoAi()); } @@ -110,7 +123,7 @@ NBTTagList nbttaglist; int i; -@@ -509,6 +571,11 @@ +@@ -509,6 +577,11 @@ } this.setNoAi(nbttagcompound.getBoolean("NoAI")); @@ -122,7 +135,7 @@ } @Override -@@ -577,7 +644,7 @@ +@@ -577,7 +650,7 @@ protected void pickUpItem(EntityItem entityitem) { ItemStack itemstack = entityitem.getItem(); @@ -131,7 +144,7 @@ this.onItemPickup(entityitem); this.take(entityitem, itemstack.getCount()); entityitem.discard(); -@@ -586,15 +653,29 @@ +@@ -586,15 +659,29 @@ } public boolean equipItemIfPossible(ItemStack itemstack) { @@ -162,7 +175,7 @@ } this.setItemSlotAndDropWhenKilled(enumitemslot, itemstack); -@@ -732,6 +813,7 @@ +@@ -732,6 +819,7 @@ @Override protected final void serverAiStep() { ++this.noActionTime; @@ -170,7 +183,7 @@ this.level.getProfiler().push("sensing"); this.sensing.tick(); this.level.getProfiler().pop(); -@@ -1125,6 +1207,12 @@ +@@ -1125,6 +1213,12 @@ if (!this.isAlive()) { return EnumInteractionResult.PASS; } else if (this.getLeashHolder() == entityhuman) { @@ -183,7 +196,7 @@ this.dropLeash(true, !entityhuman.getAbilities().instabuild); return EnumInteractionResult.sidedSuccess(this.level.isClientSide); } else { -@@ -1148,6 +1236,12 @@ +@@ -1148,6 +1242,12 @@ ItemStack itemstack = entityhuman.getItemInHand(enumhand); if (itemstack.is(Items.LEAD) && this.canBeLeashed(entityhuman)) { @@ -196,7 +209,7 @@ this.setLeashedTo(entityhuman, true); itemstack.shrink(1); return EnumInteractionResult.sidedSuccess(this.level.isClientSide); -@@ -1163,7 +1257,7 @@ +@@ -1163,7 +1263,7 @@ if (itemstack.getItem() instanceof ItemMonsterEgg) { if (this.level instanceof WorldServer) { ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem(); @@ -205,7 +218,7 @@ optional.ifPresent((entityinsentient) -> { this.onOffspringSpawnedFromEgg(entityhuman, entityinsentient); -@@ -1213,12 +1307,19 @@ +@@ -1213,12 +1313,19 @@ return this.restrictRadius != -1.0F; } @@ -226,7 +239,7 @@ t0.copyPosition(this); t0.setBaby(this.isBaby()); -@@ -1250,7 +1351,12 @@ +@@ -1250,7 +1357,12 @@ } } @@ -240,7 +253,7 @@ if (this.isPassenger()) { Entity entity = this.getVehicle(); -@@ -1270,6 +1376,7 @@ +@@ -1270,6 +1382,7 @@ if (this.leashHolder != null) { if (!this.isAlive() || !this.leashHolder.isAlive()) { @@ -248,7 +261,7 @@ this.dropLeash(true, true); } -@@ -1281,7 +1388,9 @@ +@@ -1281,7 +1394,9 @@ this.leashHolder = null; this.leashInfoTag = null; if (!this.level.isClientSide && flag1) { @@ -258,7 +271,7 @@ } if (!this.level.isClientSide && flag && this.level instanceof WorldServer) { -@@ -1331,6 +1440,7 @@ +@@ -1331,6 +1446,7 @@ boolean flag1 = super.startRiding(entity, flag); if (flag1 && this.isLeashed()) { @@ -266,7 +279,7 @@ this.dropLeash(true, true); } -@@ -1355,7 +1465,9 @@ +@@ -1355,7 +1471,9 @@ } if (this.tickCount > 100) { @@ -276,7 +289,7 @@ this.leashInfoTag = null; } } -@@ -1432,7 +1544,14 @@ +@@ -1432,7 +1550,14 @@ int i = EnchantmentManager.getFireAspect(this); if (i > 0) { @@ -292,7 +305,7 @@ } boolean flag = entity.hurt(DamageSource.mobAttack(this), f); -@@ -1500,9 +1619,10 @@ +@@ -1500,9 +1625,10 @@ @Override protected void removeAfterChangingDimensions() { super.removeAfterChangingDimensions(); diff --git a/paper-server/nms-patches/net/minecraft/world/entity/EntityLiving.patch b/paper-server/nms-patches/net/minecraft/world/entity/EntityLiving.patch index d7c72bc467..a20a6f687c 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/EntityLiving.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/EntityLiving.patch @@ -556,7 +556,36 @@ } -@@ -1559,9 +1825,14 @@ +@@ -1504,6 +1770,28 @@ + return itemstack.getEatingSound(); + } + ++ // CraftBukkit start - Add delegate methods ++ public SoundEffect getHurtSound0(DamageSource damagesource) { ++ return getHurtSound(damagesource); ++ } ++ ++ public SoundEffect getDeathSound0() { ++ return getDeathSound(); ++ } ++ ++ public SoundEffect getFallDamageSound0(int fallHeight) { ++ return getFallDamageSound(fallHeight); ++ } ++ ++ public SoundEffect getDrinkingSound0(ItemStack itemstack) { ++ return getDrinkingSound(itemstack); ++ } ++ ++ public SoundEffect getEatingSound0(ItemStack itemstack) { ++ return getEatingSound(itemstack); ++ } ++ // CraftBukkit end ++ + @Override + public void setOnGround(boolean flag) { + super.setOnGround(flag); +@@ -1559,9 +1847,14 @@ int i = this.calculateFallDamage(f, f1); if (i > 0) { @@ -572,7 +601,7 @@ return true; } else { return flag; -@@ -1610,7 +1881,7 @@ +@@ -1610,7 +1903,7 @@ protected float getDamageAfterArmorAbsorb(DamageSource damagesource, float f) { if (!damagesource.isBypassArmor()) { @@ -581,7 +610,7 @@ f = CombatMath.getDamageAfterAbsorb(f, (float) this.getArmorValue(), (float) this.getAttributeValue(GenericAttributes.ARMOR_TOUGHNESS)); } -@@ -1623,7 +1894,8 @@ +@@ -1623,7 +1916,8 @@ } else { int i; @@ -591,7 +620,7 @@ i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; int j = 25 - i; float f1 = f * (float) j; -@@ -1656,29 +1928,172 @@ +@@ -1656,29 +1950,172 @@ } } @@ -694,10 +723,7 @@ + if (damagesource.isDamageHelmet() && !this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) { + this.hurtHelmet(damagesource, f); + } - -- f = Math.max(f - this.getAbsorptionAmount(), 0.0F); -- this.setAbsorptionAmount(this.getAbsorptionAmount() - (f1 - f)); -- float f2 = f1 - f; ++ + // Apply damage to armor + if (!damagesource.isBypassArmor()) { + float armorDamage = (float) (event.getDamage() + event.getDamage(DamageModifier.BLOCKING) + event.getDamage(DamageModifier.HARD_HAT)); @@ -714,7 +740,10 @@ + this.blockUsingShield((EntityLiving) entity); + } + } -+ + +- f = Math.max(f - this.getAbsorptionAmount(), 0.0F); +- this.setAbsorptionAmount(this.getAbsorptionAmount() - (f1 - f)); +- float f2 = f1 - f; + absorptionModifier = (float) -event.getDamage(DamageModifier.ABSORPTION); + this.setAbsorptionAmount(Math.max(this.getAbsorptionAmount() - absorptionModifier, 0.0F)); + float f2 = absorptionModifier; @@ -774,27 +803,28 @@ } public CombatTracker getCombatTracker() { -@@ -1699,8 +2114,18 @@ +@@ -1699,9 +2136,19 @@ } public final void setArrowCount(int i) { - this.entityData.set(EntityLiving.DATA_ARROW_COUNT_ID, i); + // CraftBukkit start + setArrowCount(i, false); -+ } -+ + } + + public final void setArrowCount(int i, boolean flag) { + ArrowBodyCountChangeEvent event = CraftEventFactory.callArrowBodyCountChangeEvent(this, getArrowCount(), i, flag); + if (event.isCancelled()) { + return; + } + this.entityData.set(EntityLiving.DATA_ARROW_COUNT_ID, event.getNewAmount()); - } ++ } + // CraftBukkit end - ++ public final int getStingerCount() { return (Integer) this.entityData.get(EntityLiving.DATA_STINGER_COUNT_ID); -@@ -1996,6 +2421,12 @@ + } +@@ -1996,6 +2443,12 @@ public abstract ItemStack getItemBySlot(EnumItemSlot enumitemslot); @@ -807,7 +837,7 @@ @Override public abstract void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack); -@@ -2239,6 +2670,7 @@ +@@ -2239,6 +2692,7 @@ } if (this.onGround && !this.level.isClientSide) { @@ -815,7 +845,7 @@ this.setSharedFlag(7, false); } } else { -@@ -2772,6 +3204,7 @@ +@@ -2772,6 +3226,7 @@ } if (!this.level.isClientSide) { @@ -823,7 +853,7 @@ this.setSharedFlag(7, flag); } -@@ -2931,14 +3364,21 @@ +@@ -2931,14 +3386,21 @@ @Override public boolean isPickable() { @@ -847,7 +877,7 @@ @Override public float getYHeadRot() { return this.yHeadRot; -@@ -3133,7 +3573,25 @@ +@@ -3133,7 +3595,25 @@ } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { this.triggerItemUseEffects(this.useItem, 16); @@ -874,7 +904,7 @@ if (itemstack != this.useItem) { this.setItemInHand(enumhand, itemstack); -@@ -3211,6 +3669,12 @@ +@@ -3211,6 +3691,12 @@ } public boolean randomTeleport(double d0, double d1, double d2, boolean flag) { @@ -887,7 +917,7 @@ double d3 = this.getX(); double d4 = this.getY(); double d5 = this.getZ(); -@@ -3235,16 +3699,41 @@ +@@ -3235,16 +3721,41 @@ } if (flag2) { @@ -932,7 +962,7 @@ } else { if (flag) { world.broadcastEntityEvent(this, (byte) 46); -@@ -3254,7 +3743,7 @@ +@@ -3254,7 +3765,7 @@ ((EntityCreature) this).getNavigation().stop(); } @@ -941,7 +971,7 @@ } } -@@ -3337,7 +3826,7 @@ +@@ -3337,7 +3848,7 @@ } public void stopSleeping() { @@ -950,7 +980,7 @@ World world = this.level; java.util.Objects.requireNonNull(this.level); -@@ -3369,7 +3858,7 @@ +@@ -3369,7 +3880,7 @@ @Nullable public EnumDirection getBedOrientation() { @@ -959,7 +989,7 @@ return blockposition != null ? BlockBed.getBedOrientation(this.level, blockposition) : null; } -@@ -3417,7 +3906,7 @@ +@@ -3417,7 +3928,7 @@ Pair pair = (Pair) iterator.next(); if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) { 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 4606c8d439..6d51dd2da6 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 @@ -15,6 +15,7 @@ import net.minecraft.network.chat.IChatBaseComponent; import net.minecraft.server.level.EntityPlayer; import net.minecraft.server.level.PlayerChunkMap; import net.minecraft.server.level.WorldServer; +import net.minecraft.sounds.SoundEffect; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityAreaEffectCloud; @@ -162,10 +163,12 @@ import net.minecraft.world.phys.AxisAlignedBB; import org.bukkit.EntityEffect; import org.bukkit.Location; import org.bukkit.Server; +import org.bukkit.Sound; import org.bukkit.World; import org.bukkit.block.BlockFace; import org.bukkit.block.PistonMoveReaction; import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftSound; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer; @@ -757,6 +760,21 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { } } + @Override + public Sound getSwimSound() { + return CraftSound.getBukkit(getHandle().getSwimSound0()); + } + + @Override + public Sound getSwimSplashSound() { + return CraftSound.getBukkit(getHandle().getSwimSplashSound0()); + } + + @Override + public Sound getSwimHighSpeedSplashSound() { + return CraftSound.getBukkit(getHandle().getSwimHighSpeedSplashSound0()); + } + public void setHandle(final Entity entity) { this.entity = entity; } 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 1f9fc1586d..e372264f5a 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 @@ -8,6 +8,7 @@ import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.UUID; +import net.minecraft.sounds.SoundEffect; import net.minecraft.world.EnumHand; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.effect.MobEffect; @@ -43,10 +44,12 @@ import org.apache.commons.lang.Validate; import org.bukkit.FluidCollisionMode; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.attribute.Attribute; import org.bukkit.attribute.AttributeInstance; import org.bukkit.block.Block; import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftSound; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.entity.memory.CraftMemoryKey; import org.bukkit.craftbukkit.entity.memory.CraftMemoryMapper; @@ -697,6 +700,45 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { getHandle().getBrain().setMemory(CraftMemoryKey.fromMemoryKey(memoryKey), CraftMemoryMapper.toNms(t)); } + @Override + public Sound getHurtSound() { + SoundEffect sound = getHandle().getHurtSound0(DamageSource.GENERIC); + return (sound != null) ? CraftSound.getBukkit(sound) : null; + } + + @Override + public Sound getDeathSound() { + SoundEffect sound = getHandle().getDeathSound0(); + return (sound != null) ? CraftSound.getBukkit(sound) : null; + } + + @Override + public Sound getFallDamageSound(int fallHeight) { + return CraftSound.getBukkit(getHandle().getFallDamageSound0(fallHeight)); + } + + @Override + public Sound getFallDamageSoundSmall() { + return CraftSound.getBukkit(getHandle().getFallSounds().small()); + } + + @Override + public Sound getFallDamageSoundBig() { + return CraftSound.getBukkit(getHandle().getFallSounds().big()); + } + + @Override + public Sound getDrinkingSound(ItemStack itemStack) { + Preconditions.checkArgument(itemStack != null, "itemStack must not be null"); + return CraftSound.getBukkit(getHandle().getDrinkingSound0(CraftItemStack.asNMSCopy(itemStack))); + } + + @Override + public Sound getEatingSound(ItemStack itemStack) { + Preconditions.checkArgument(itemStack != null, "itemStack must not be null"); + return CraftSound.getBukkit(getHandle().getEatingSound0(CraftItemStack.asNMSCopy(itemStack))); + } + @Override public boolean canBreatheUnderwater() { return getHandle().canBreatheUnderwater(); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java index 44123bf9e4..10eccc5fd5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java @@ -1,11 +1,13 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; -import net.minecraft.resources.MinecraftKey; +import net.minecraft.sounds.SoundEffect; import net.minecraft.world.entity.EntityInsentient; import org.bukkit.Bukkit; import org.bukkit.NamespacedKey; +import org.bukkit.Sound; import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftSound; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Mob; @@ -45,6 +47,12 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { return getHandle().aware; } + @Override + public Sound getAmbientSound() { + SoundEffect sound = getHandle().getAmbientSound0(); + return (sound != null) ? CraftSound.getBukkit(sound) : null; + } + @Override public EntityInsentient getHandle() { return (EntityInsentient) entity; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java index 8132e8c396..9dadccadee 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java @@ -3,8 +3,10 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; import net.minecraft.core.BlockPosition; import net.minecraft.world.entity.raid.EntityRaider; +import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftSound; import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.entity.Raider; @@ -59,4 +61,9 @@ public abstract class CraftRaider extends CraftMonster implements Raider { public void setCanJoinRaid(boolean join) { getHandle().setCanJoinRaid(join); } + + @Override + public Sound getCelebrationSound() { + return CraftSound.getBukkit(getHandle().getCelebrateSound()); + } }