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>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/EnderEyeItem.java
|
||||
+++ b/net/minecraft/world/item/EnderEyeItem.java
|
||||
@@ -62,7 +62,25 @@
|
||||
@@ -62,7 +62,27 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,13 @@
|
||||
+ // 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) {
|
||||
+ final net.minecraft.server.level.ServerLevel serverLevel = (net.minecraft.server.level.ServerLevel) world; // Paper - respect global sound events gamerule - ensured by isClientSide check above
|
||||
+ for (ServerPlayer player : serverLevel.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 = serverLevel.getGlobalSoundRangeSquared(config -> config.endPortalSoundRadius); // Paper - respect global sound events gamerule
|
||||
+ if (!serverLevel.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;
|
||||
@@ -27,7 +29,7 @@
|
||||
}
|
||||
|
||||
return InteractionResult.SUCCESS;
|
||||
@@ -99,7 +117,11 @@
|
||||
@@ -99,7 +119,11 @@
|
||||
entityendersignal.setItem(itemstack);
|
||||
entityendersignal.signalTo(blockposition);
|
||||
world.gameEvent((Holder) GameEvent.PROJECTILE_SHOOT, entityendersignal.position(), GameEvent.Context.of((Entity) user));
|
||||
|
||||
Reference in New Issue
Block a user