geforkt von Mirrors/Paper
31699ae9a8
* Updated Upstream (Bukkit/CraftBukkit) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: a6a9d2a4 Remove some old ApiStatus.Experimental annotations be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration 08f86d1c PR-971: Add Player methods for client-side potion effects 2e3024a9 PR-963: Add API for in-world structures a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality 1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent CraftBukkit Changes: 38fd4bd50 Fix accidentally renamed internal damage method 80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage 7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects 4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration 22a541a29 Improve support for per-world game rules cb7dccce2 PR-1348: Add Player methods for client-side potion effects b8d6109f0 PR-1335: Add API for in-world structures 4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity e74107678 Fix Crafter maximum stack size 0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality 4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason 20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette 3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook 333701839 SPIGOT-7572: Bee nests generated without bees f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
102 Zeilen
8.9 KiB
Diff
102 Zeilen
8.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
Date: Tue, 31 May 2016 22:53:50 -0400
|
|
Subject: [PATCH] Fix global sound handling
|
|
|
|
* Only send global sounds to same world if limiting radius
|
|
* respect global sound events gamerule
|
|
|
|
Co-authored-by: Evan McCarthy <evanmccarthy@outlook.com>
|
|
Co-authored-by: lexikiq <noellekiq@gmail.com>
|
|
Co-authored-by: Aikar <aikar@aikar.co>
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
index ddab865f4237b91020f3c5f9726d93f8dbf0eda6..5f0885c13116ad070dc076cca5a527b2a616c541 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1318,7 +1318,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
|
|
@Override
|
|
public void levelEvent(@Nullable Player player, int eventId, BlockPos pos, int data) {
|
|
- this.server.getPlayerList().broadcast(player, (double) pos.getX(), (double) pos.getY(), (double) pos.getZ(), 64.0D, this.dimension(), new ClientboundLevelEventPacket(eventId, pos, data, false));
|
|
+ this.server.getPlayerList().broadcast(player, (double) pos.getX(), (double) pos.getY(), (double) pos.getZ(), 64.0D, this.dimension(), new ClientboundLevelEventPacket(eventId, pos, data, false)); // Paper - diff on change (the 64.0 distance is used as defaults for sound ranges in spigot config for ender dragon, end portal and wither)
|
|
}
|
|
|
|
public int getLogicalHeight() {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
|
index aea9366215973555de88e67310b7fbe033f45cd5..2471800014d1661c2f422e5a24f0f3b00fa838f2 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
|
@@ -680,11 +680,12 @@ public class EnderDragon extends Mob implements Enemy {
|
|
// CraftBukkit start - Use relative location for far away sounds
|
|
// this.level().globalLevelEvent(1028, this.blockPosition(), 0);
|
|
int viewDistance = ((ServerLevel) this.level()).getCraftServer().getViewDistance() * 16;
|
|
- for (net.minecraft.server.level.ServerPlayer player : this.level().getServer().getPlayerList().players) {
|
|
+ for (net.minecraft.server.level.ServerPlayer player : this.level().getPlayersForGlobalSoundGamerule()) { // Paper - respect global sound events gamerule
|
|
double deltaX = this.getX() - player.getX();
|
|
double deltaZ = this.getZ() - player.getZ();
|
|
double distanceSquared = deltaX * deltaX + deltaZ * deltaZ;
|
|
- if ( this.level().spigotConfig.dragonDeathSoundRadius > 0 && distanceSquared > this.level().spigotConfig.dragonDeathSoundRadius * this.level().spigotConfig.dragonDeathSoundRadius ) continue; // Spigot
|
|
+ final double soundRadiusSquared = this.level().getGlobalSoundRangeSquared(config -> config.dragonDeathSoundRadius); // Paper - respect global sound events gamerule
|
|
+ if ( !this.level().getGameRules().getBoolean(GameRules.RULE_GLOBAL_SOUND_EVENTS) && distanceSquared > soundRadiusSquared ) continue; // Spigot // Paper - respect global sound events gamerule
|
|
if (distanceSquared > viewDistance * viewDistance) {
|
|
double deltaLength = Math.sqrt(distanceSquared);
|
|
double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance;
|
|
diff --git a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
|
index 8d3f3987f2a6816752bdb2e477338d6dbdd6b7b7..14b09adeb9222600c24f3fb846ea8aee467952e6 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
|
@@ -271,11 +271,12 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob
|
|
// CraftBukkit start - Use relative location for far away sounds
|
|
// this.level().globalLevelEvent(1023, new BlockPosition(this), 0);
|
|
int viewDistance = ((ServerLevel) this.level()).getCraftServer().getViewDistance() * 16;
|
|
- for (ServerPlayer player : (List<ServerPlayer>) MinecraftServer.getServer().getPlayerList().players) {
|
|
+ for (ServerPlayer player : this.level().getPlayersForGlobalSoundGamerule()) { // Paper - respect global sound events gamerule
|
|
double deltaX = this.getX() - player.getX();
|
|
double deltaZ = this.getZ() - player.getZ();
|
|
double distanceSquared = deltaX * deltaX + deltaZ * deltaZ;
|
|
- if ( this.level().spigotConfig.witherSpawnSoundRadius > 0 && distanceSquared > this.level().spigotConfig.witherSpawnSoundRadius * this.level().spigotConfig.witherSpawnSoundRadius ) continue; // Spigot
|
|
+ final double soundRadiusSquared = this.level().getGlobalSoundRangeSquared(config -> config.witherSpawnSoundRadius); // Paper - respect global sound events gamerule
|
|
+ if ( !this.level().getGameRules().getBoolean(GameRules.RULE_GLOBAL_SOUND_EVENTS) && distanceSquared > soundRadiusSquared ) continue; // Spigot // Paper - respect global sound events gamerule
|
|
if (distanceSquared > viewDistance * viewDistance) {
|
|
double deltaLength = Math.sqrt(distanceSquared);
|
|
double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance;
|
|
diff --git a/src/main/java/net/minecraft/world/item/EnderEyeItem.java b/src/main/java/net/minecraft/world/item/EnderEyeItem.java
|
|
index 5bc68514a1e8a212e2681f06b918548c0ec565b6..1977e702f6af39ebf100c1f2f2edc2d1c4d003b0 100644
|
|
--- a/src/main/java/net/minecraft/world/item/EnderEyeItem.java
|
|
+++ b/src/main/java/net/minecraft/world/item/EnderEyeItem.java
|
|
@@ -64,11 +64,12 @@ public class EnderEyeItem extends Item {
|
|
// world.b(1038, blockposition1.c(1, 0, 1), 0);
|
|
int viewDistance = world.getCraftServer().getViewDistance() * 16;
|
|
BlockPos soundPos = blockposition1.offset(1, 0, 1);
|
|
- for (ServerPlayer player : world.getServer().getPlayerList().players) {
|
|
+ for (ServerPlayer player : world.getPlayersForGlobalSoundGamerule()) { // Paper - respect global sound events gamerule
|
|
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
|
|
+ final double soundRadiusSquared = world.getGlobalSoundRangeSquared(config -> config.endPortalSoundRadius); // Paper - respect global sound events gamerule
|
|
+ if (!world.getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_GLOBAL_SOUND_EVENTS) && distanceSquared > soundRadiusSquared) continue; // Spigot // Paper - respect global sound events gamerule
|
|
if (distanceSquared > viewDistance * viewDistance) {
|
|
double deltaLength = Math.sqrt(distanceSquared);
|
|
double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance;
|
|
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
|
index f11e00b3a7164e8af6e33a9a09328539df5405fc..610ce2574a61fcee00f5224b554b285079a75698 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
@@ -1268,4 +1268,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
|
|
|
private ExplosionInteraction() {}
|
|
}
|
|
+ // Paper start - respect global sound events gamerule
|
|
+ public List<net.minecraft.server.level.ServerPlayer> getPlayersForGlobalSoundGamerule() {
|
|
+ return this.getGameRules().getBoolean(GameRules.RULE_GLOBAL_SOUND_EVENTS) ? ((ServerLevel) this).getServer().getPlayerList().players : ((ServerLevel) this).players();
|
|
+ }
|
|
+
|
|
+ public double getGlobalSoundRangeSquared(java.util.function.Function<org.spigotmc.SpigotWorldConfig, Integer> rangeFunction) {
|
|
+ final double range = rangeFunction.apply(this.spigotConfig);
|
|
+ return range <= 0 ? 64.0 * 64.0 : range * range; // 64 is taken from default in ServerLevel#levelEvent
|
|
+ }
|
|
+ // Paper end - respect global sound events gamerule
|
|
}
|