mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-03 23:07:40 +01:00
Configurable dragon death and wither spawn sounds
By: drXor <mcyoungsota@gmail.com>
This commit is contained in:
parent
59b0d3d6b2
commit
1cb6ba6942
@ -91,7 +91,7 @@
|
|||||||
|
|
||||||
for (int k1 = i; k1 <= l; ++k1) {
|
for (int k1 = i; k1 <= l; ++k1) {
|
||||||
for (int l1 = j; l1 <= i1; ++l1) {
|
for (int l1 = j; l1 <= i1; ++l1) {
|
||||||
@@ -467,14 +494,61 @@
|
@@ -467,7 +494,11 @@
|
||||||
|
|
||||||
if (!iblockdata.isAir() && !iblockdata.is(BlockTags.DRAGON_TRANSPARENT)) {
|
if (!iblockdata.isAir() && !iblockdata.is(BlockTags.DRAGON_TRANSPARENT)) {
|
||||||
if (world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !iblockdata.is(BlockTags.DRAGON_IMMUNE)) {
|
if (world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !iblockdata.is(BlockTags.DRAGON_IMMUNE)) {
|
||||||
@ -104,11 +104,10 @@
|
|||||||
} else {
|
} else {
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
}
|
@@ -476,6 +507,49 @@
|
||||||
+ }
|
}
|
||||||
+ }
|
}
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ // CraftBukkit start - Set off an EntityExplodeEvent for the dragon exploding all these blocks
|
+ // CraftBukkit start - Set off an EntityExplodeEvent for the dragon exploding all these blocks
|
||||||
+ // SPIGOT-4882: don't fire event if nothing hit
|
+ // SPIGOT-4882: don't fire event if nothing hit
|
||||||
+ if (!flag1) {
|
+ if (!flag1) {
|
||||||
@ -130,7 +129,7 @@
|
|||||||
+ org.bukkit.Material blockId = block.getType();
|
+ org.bukkit.Material blockId = block.getType();
|
||||||
+ if (blockId.isAir()) {
|
+ if (blockId.isAir()) {
|
||||||
+ continue;
|
+ continue;
|
||||||
}
|
+ }
|
||||||
+
|
+
|
||||||
+ CraftBlock craftBlock = ((CraftBlock) block);
|
+ CraftBlock craftBlock = ((CraftBlock) block);
|
||||||
+ BlockPos blockposition = craftBlock.getPosition();
|
+ BlockPos blockposition = craftBlock.getPosition();
|
||||||
@ -148,13 +147,14 @@
|
|||||||
+ nmsBlock.wasExploded((ServerLevel) this.level(), blockposition, this.explosionSource);
|
+ nmsBlock.wasExploded((ServerLevel) this.level(), blockposition, this.explosionSource);
|
||||||
+
|
+
|
||||||
+ this.level().removeBlock(blockposition, false);
|
+ this.level().removeBlock(blockposition, false);
|
||||||
}
|
+ }
|
||||||
}
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
+
|
||||||
if (flag1) {
|
if (flag1) {
|
||||||
BlockPos blockposition1 = new BlockPos(i + this.random.nextInt(l - i + 1), j + this.random.nextInt(i1 - j + 1), k + this.random.nextInt(j1 - k + 1));
|
BlockPos blockposition1 = new BlockPos(i + this.random.nextInt(l - i + 1), j + this.random.nextInt(i1 - j + 1), k + this.random.nextInt(j1 - k + 1));
|
||||||
@@ -531,14 +605,29 @@
|
|
||||||
|
@@ -531,7 +605,7 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void kill(ServerLevel world) {
|
public void kill(ServerLevel world) {
|
||||||
@ -163,13 +163,12 @@
|
|||||||
this.gameEvent(GameEvent.ENTITY_DIE);
|
this.gameEvent(GameEvent.ENTITY_DIE);
|
||||||
if (this.dragonFight != null) {
|
if (this.dragonFight != null) {
|
||||||
this.dragonFight.updateDragon(this);
|
this.dragonFight.updateDragon(this);
|
||||||
this.dragonFight.setDragonKilled(this);
|
@@ -540,7 +614,22 @@
|
||||||
+ }
|
|
||||||
+
|
}
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ // CraftBukkit start - SPIGOT-2420: Special case, the ender dragon drops 12000 xp for the first kill and 500 xp for every other kill and this over time.
|
+ // CraftBukkit start - SPIGOT-2420: Special case, the ender dragon drops 12000 xp for the first kill and 500 xp for every other kill and this over time.
|
||||||
+ @Override
|
@Override
|
||||||
+ public int getExpReward(ServerLevel worldserver, Entity entity) {
|
+ public int getExpReward(ServerLevel worldserver, Entity entity) {
|
||||||
+ // CraftBukkit - Moved from #tickDeath method
|
+ // CraftBukkit - Moved from #tickDeath method
|
||||||
+ boolean flag = worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT);
|
+ boolean flag = worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT);
|
||||||
@ -177,15 +176,17 @@
|
|||||||
+
|
+
|
||||||
+ if (this.dragonFight != null && !this.dragonFight.hasPreviouslyKilledDragon()) {
|
+ if (this.dragonFight != null && !this.dragonFight.hasPreviouslyKilledDragon()) {
|
||||||
+ short0 = 12000;
|
+ short0 = 12000;
|
||||||
}
|
+ }
|
||||||
|
+
|
||||||
+ return flag ? short0 : 0;
|
+ return flag ? short0 : 0;
|
||||||
}
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
+
|
||||||
@Override
|
+ @Override
|
||||||
protected void tickDeath() {
|
protected void tickDeath() {
|
||||||
@@ -555,16 +644,21 @@
|
if (this.dragonFight != null) {
|
||||||
|
this.dragonFight.updateDragon(this);
|
||||||
|
@@ -555,21 +644,43 @@
|
||||||
this.level().addParticle(ParticleTypes.EXPLOSION_EMITTER, this.getX() + (double) f, this.getY() + 2.0D + (double) f1, this.getZ() + (double) f2, 0.0D, 0.0D, 0.0D);
|
this.level().addParticle(ParticleTypes.EXPLOSION_EMITTER, this.getX() + (double) f, this.getY() + 2.0D + (double) f1, this.getZ() + (double) f2, 0.0D, 0.0D, 0.0D);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +209,30 @@
|
|||||||
ExperienceOrb.award(worldserver, this.position(), Mth.floor((float) short0 * 0.08F));
|
ExperienceOrb.award(worldserver, this.position(), Mth.floor((float) short0 * 0.08F));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -592,7 +686,7 @@
|
if (this.dragonDeathTime == 1 && !this.isSilent()) {
|
||||||
|
- worldserver.globalLevelEvent(1028, this.blockPosition(), 0);
|
||||||
|
+ // CraftBukkit start - Use relative location for far away sounds
|
||||||
|
+ // worldserver.globalLevelEvent(1028, this.blockPosition(), 0);
|
||||||
|
+ int viewDistance = worldserver.getCraftServer().getViewDistance() * 16;
|
||||||
|
+ for (net.minecraft.server.level.ServerPlayer player : worldserver.getServer().getPlayerList().players) {
|
||||||
|
+ double deltaX = this.getX() - player.getX();
|
||||||
|
+ double deltaZ = this.getZ() - player.getZ();
|
||||||
|
+ double distanceSquared = deltaX * deltaX + deltaZ * deltaZ;
|
||||||
|
+ if ( worldserver.spigotConfig.dragonDeathSoundRadius > 0 && distanceSquared > worldserver.spigotConfig.dragonDeathSoundRadius * worldserver.spigotConfig.dragonDeathSoundRadius ) continue; // Spigot
|
||||||
|
+ if (distanceSquared > viewDistance * viewDistance) {
|
||||||
|
+ double deltaLength = Math.sqrt(distanceSquared);
|
||||||
|
+ double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance;
|
||||||
|
+ double relativeZ = player.getZ() + (deltaZ / deltaLength) * viewDistance;
|
||||||
|
+ player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(1028, new BlockPos((int) relativeX, (int) this.getY(), (int) relativeZ), 0, true));
|
||||||
|
+ } else {
|
||||||
|
+ player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(1028, new BlockPos((int) this.getX(), (int) this.getY(), (int) this.getZ()), 0, true));
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // CraftBukkit end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -592,7 +703,7 @@
|
||||||
if (world1 instanceof ServerLevel) {
|
if (world1 instanceof ServerLevel) {
|
||||||
ServerLevel worldserver1 = (ServerLevel) world1;
|
ServerLevel worldserver1 = (ServerLevel) world1;
|
||||||
|
|
||||||
@ -217,7 +241,7 @@
|
|||||||
ExperienceOrb.award(worldserver1, this.position(), Mth.floor((float) short0 * 0.2F));
|
ExperienceOrb.award(worldserver1, this.position(), Mth.floor((float) short0 * 0.2F));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -600,7 +694,7 @@
|
@@ -600,7 +711,7 @@
|
||||||
this.dragonFight.setDragonKilled(this);
|
this.dragonFight.setDragonKilled(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +250,7 @@
|
|||||||
this.gameEvent(GameEvent.ENTITY_DIE);
|
this.gameEvent(GameEvent.ENTITY_DIE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -814,6 +908,7 @@
|
@@ -814,6 +925,7 @@
|
||||||
super.addAdditionalSaveData(nbt);
|
super.addAdditionalSaveData(nbt);
|
||||||
nbt.putInt("DragonPhase", this.phaseManager.getCurrentPhase().getPhase().getId());
|
nbt.putInt("DragonPhase", this.phaseManager.getCurrentPhase().getPhase().getId());
|
||||||
nbt.putInt("DragonDeathTime", this.dragonDeathTime);
|
nbt.putInt("DragonDeathTime", this.dragonDeathTime);
|
||||||
@ -234,7 +258,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -827,6 +922,11 @@
|
@@ -827,6 +939,11 @@
|
||||||
this.dragonDeathTime = nbt.getInt("DragonDeathTime");
|
this.dragonDeathTime = nbt.getInt("DragonDeathTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
public class WitherBoss extends Monster implements RangedAttackMob {
|
public class WitherBoss extends Monster implements RangedAttackMob {
|
||||||
|
|
||||||
@@ -252,15 +261,40 @@
|
@@ -252,15 +261,41 @@
|
||||||
i = this.getInvulnerableTicks() - 1;
|
i = this.getInvulnerableTicks() - 1;
|
||||||
this.bossEvent.setProgress(1.0F - (float) i / 220.0F);
|
this.bossEvent.setProgress(1.0F - (float) i / 220.0F);
|
||||||
if (i <= 0) {
|
if (i <= 0) {
|
||||||
@ -62,6 +62,7 @@
|
|||||||
+ double deltaX = this.getX() - player.getX();
|
+ double deltaX = this.getX() - player.getX();
|
||||||
+ double deltaZ = this.getZ() - player.getZ();
|
+ double deltaZ = this.getZ() - player.getZ();
|
||||||
+ double distanceSquared = deltaX * deltaX + deltaZ * deltaZ;
|
+ double distanceSquared = deltaX * deltaX + deltaZ * deltaZ;
|
||||||
|
+ if ( world.spigotConfig.witherSpawnSoundRadius > 0 && distanceSquared > world.spigotConfig.witherSpawnSoundRadius * world.spigotConfig.witherSpawnSoundRadius ) continue; // Spigot
|
||||||
+ if (distanceSquared > viewDistance * viewDistance) {
|
+ if (distanceSquared > viewDistance * viewDistance) {
|
||||||
+ double deltaLength = Math.sqrt(distanceSquared);
|
+ double deltaLength = Math.sqrt(distanceSquared);
|
||||||
+ double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance;
|
+ double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance;
|
||||||
@ -82,7 +83,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -305,6 +339,7 @@
|
@@ -305,6 +340,7 @@
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
LivingEntity entityliving1 = (LivingEntity) list.get(this.random.nextInt(list.size()));
|
LivingEntity entityliving1 = (LivingEntity) list.get(this.random.nextInt(list.size()));
|
||||||
|
|
||||||
@ -90,7 +91,7 @@
|
|||||||
this.setAlternativeTarget(i, entityliving1.getId());
|
this.setAlternativeTarget(i, entityliving1.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -331,6 +366,11 @@
|
@@ -331,6 +367,11 @@
|
||||||
BlockState iblockdata = world.getBlockState(blockposition);
|
BlockState iblockdata = world.getBlockState(blockposition);
|
||||||
|
|
||||||
if (WitherBoss.canDestroy(iblockdata)) {
|
if (WitherBoss.canDestroy(iblockdata)) {
|
||||||
@ -102,7 +103,7 @@
|
|||||||
flag = world.destroyBlock(blockposition, true, this) || flag;
|
flag = world.destroyBlock(blockposition, true, this) || flag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -342,7 +382,7 @@
|
@@ -342,7 +383,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.tickCount % 20 == 0) {
|
if (this.tickCount % 20 == 0) {
|
||||||
@ -111,7 +112,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.bossEvent.setProgress(this.getHealth() / this.getMaxHealth());
|
this.bossEvent.setProgress(this.getHealth() / this.getMaxHealth());
|
||||||
@@ -499,7 +539,7 @@
|
@@ -499,7 +540,7 @@
|
||||||
@Override
|
@Override
|
||||||
public void checkDespawn() {
|
public void checkDespawn() {
|
||||||
if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.shouldDespawnInPeaceful()) {
|
if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.shouldDespawnInPeaceful()) {
|
||||||
|
@ -1,6 +1,33 @@
|
|||||||
--- a/net/minecraft/world/item/EnderEyeItem.java
|
--- a/net/minecraft/world/item/EnderEyeItem.java
|
||||||
+++ b/net/minecraft/world/item/EnderEyeItem.java
|
+++ b/net/minecraft/world/item/EnderEyeItem.java
|
||||||
@@ -99,7 +99,11 @@
|
@@ -62,7 +62,25 @@
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- world.globalLevelEvent(1038, blockposition1.offset(1, 0, 1), 0);
|
||||||
|
+ // CraftBukkit start - Use relative location for far away sounds
|
||||||
|
+ // world.globalLevelEvent(1038, blockposition1.offset(1, 0, 1), 0);
|
||||||
|
+ int viewDistance = world.getCraftServer().getViewDistance() * 16;
|
||||||
|
+ BlockPos soundPos = blockposition1.offset(1, 0, 1);
|
||||||
|
+ for (ServerPlayer player : world.getServer().getPlayerList().players) {
|
||||||
|
+ double deltaX = soundPos.getX() - player.getX();
|
||||||
|
+ double deltaZ = soundPos.getZ() - player.getZ();
|
||||||
|
+ double distanceSquared = deltaX * deltaX + deltaZ * deltaZ;
|
||||||
|
+ if (world.spigotConfig.endPortalSoundRadius > 0 && distanceSquared > world.spigotConfig.endPortalSoundRadius * world.spigotConfig.endPortalSoundRadius) continue; // Spigot
|
||||||
|
+ if (distanceSquared > viewDistance * viewDistance) {
|
||||||
|
+ double deltaLength = Math.sqrt(distanceSquared);
|
||||||
|
+ double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance;
|
||||||
|
+ double relativeZ = player.getZ() + (deltaZ / deltaLength) * viewDistance;
|
||||||
|
+ player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(1038, new BlockPos((int) relativeX, (int) soundPos.getY(), (int) relativeZ), 0, true));
|
||||||
|
+ } else {
|
||||||
|
+ player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(1038, soundPos, 0, true));
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // CraftBukkit end
|
||||||
|
}
|
||||||
|
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
@@ -99,7 +117,11 @@
|
||||||
entityendersignal.setItem(itemstack);
|
entityendersignal.setItem(itemstack);
|
||||||
entityendersignal.signalTo(blockposition);
|
entityendersignal.signalTo(blockposition);
|
||||||
world.gameEvent((Holder) GameEvent.PROJECTILE_SHOOT, entityendersignal.position(), GameEvent.Context.of((Entity) user));
|
world.gameEvent((Holder) GameEvent.PROJECTILE_SHOOT, entityendersignal.position(), GameEvent.Context.of((Entity) user));
|
||||||
|
@ -276,4 +276,22 @@ public class SpigotWorldConfig
|
|||||||
this.enableZombiePigmenPortalSpawns = this.getBoolean( "enable-zombie-pigmen-portal-spawns", true );
|
this.enableZombiePigmenPortalSpawns = this.getBoolean( "enable-zombie-pigmen-portal-spawns", true );
|
||||||
this.log( "Allow Zombie Pigmen to spawn from portal blocks: " + this.enableZombiePigmenPortalSpawns );
|
this.log( "Allow Zombie Pigmen to spawn from portal blocks: " + this.enableZombiePigmenPortalSpawns );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int dragonDeathSoundRadius;
|
||||||
|
private void keepDragonDeathPerWorld()
|
||||||
|
{
|
||||||
|
this.dragonDeathSoundRadius = this.getInt( "dragon-death-sound-radius", 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public int witherSpawnSoundRadius;
|
||||||
|
private void witherSpawnSoundRadius()
|
||||||
|
{
|
||||||
|
this.witherSpawnSoundRadius = this.getInt( "wither-spawn-sound-radius", 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public int endPortalSoundRadius;
|
||||||
|
private void endPortalSoundRadius()
|
||||||
|
{
|
||||||
|
this.endPortalSoundRadius = this.getInt( "end-portal-sound-radius", 0 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user