Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
1e38743b1d
Also fixes build as a result of an upstream force push --- work/Bukkit Submodule work/Bukkit 217dc08d..d13fdf8c: > SPIGOT-4637: Add source block to BlockPhysicsEvent. --- work/CraftBukkit Submodule work/CraftBukkit acbba8ba..cb98c6ea: > Fix line endings in CraftDefaultPermissions > SPIGOT-4637: Add source block to BlockPhysicsEvent. --- work/Spigot Submodule work/Spigot 75ee78a0c...4165cd8f4 (commits not present) > (Manually Added) - Appears to be a result of an upstream force push > (Manually Added) - Changed: SPIGOT-4636: Add creative mode NBT permissions
87 Zeilen
4.8 KiB
Diff
87 Zeilen
4.8 KiB
Diff
From c2829c83506f017fd6cd1f60c3a8c8a5b010f2e7 Mon Sep 17 00:00:00 2001
|
|
From: Trigary <trigary0@gmail.com>
|
|
Date: Fri, 14 Sep 2018 17:42:08 +0200
|
|
Subject: [PATCH] Limit lightning strike effect distance
|
|
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
index e04204055..30985cdfc 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
@@ -237,6 +237,28 @@ public class PaperWorldConfig {
|
|
skeleHorseSpawnChance = 0.01D; // Vanilla value
|
|
}
|
|
}
|
|
+
|
|
+ public double sqrMaxThunderDistance;
|
|
+ public double sqrMaxLightningImpactSoundDistance;
|
|
+ public double maxLightningFlashDistance;
|
|
+ private void lightningStrikeDistanceLimit() {
|
|
+ sqrMaxThunderDistance = getInt("lightning-strike-distance-limit.sound", -1);
|
|
+ if (sqrMaxThunderDistance > 0) {
|
|
+ sqrMaxThunderDistance *= sqrMaxThunderDistance;
|
|
+ }
|
|
+
|
|
+ sqrMaxLightningImpactSoundDistance = getInt("lightning-strike-distance-limit.impact-sound", -1);
|
|
+ if (sqrMaxLightningImpactSoundDistance < 0) {
|
|
+ sqrMaxLightningImpactSoundDistance = 32 * 32; //Vanilla value
|
|
+ } else {
|
|
+ sqrMaxLightningImpactSoundDistance *= sqrMaxLightningImpactSoundDistance;
|
|
+ }
|
|
+
|
|
+ maxLightningFlashDistance = getInt("lightning-strike-distance-limit.flash", -1);
|
|
+ if (maxLightningFlashDistance < 0) {
|
|
+ maxLightningFlashDistance = 512; // Vanilla value
|
|
+ }
|
|
+ }
|
|
|
|
public boolean firePhysicsEventForRedstone = false;
|
|
private void firePhysicsEventForRedstone() {
|
|
diff --git a/src/main/java/net/minecraft/server/EntityLightning.java b/src/main/java/net/minecraft/server/EntityLightning.java
|
|
index 7781babf5..50f620009 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityLightning.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityLightning.java
|
|
@@ -60,6 +60,17 @@ public class EntityLightning extends EntityWeather {
|
|
double deltaX = this.locX - player.locX;
|
|
double deltaZ = this.locZ - player.locZ;
|
|
double distanceSquared = deltaX * deltaX + deltaZ * deltaZ;
|
|
+ // Paper start - Limit lightning strike effect distance
|
|
+ if (distanceSquared <= this.world.paperConfig.sqrMaxLightningImpactSoundDistance) {
|
|
+ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.ENTITY_LIGHTNING_BOLT_IMPACT,
|
|
+ SoundCategory.WEATHER, this.locX, this.locY, this.locZ, 2.0f, 0.5F + this.random.nextFloat() * 0.2F));
|
|
+ }
|
|
+
|
|
+ if (world.paperConfig.sqrMaxThunderDistance != -1 && distanceSquared >= world.paperConfig.sqrMaxThunderDistance) {
|
|
+ continue;
|
|
+ }
|
|
+
|
|
+ // Paper end
|
|
if (distanceSquared > viewDistance * viewDistance) {
|
|
double deltaLength = Math.sqrt(distanceSquared);
|
|
double relativeX = player.locX + (deltaX / deltaLength) * viewDistance;
|
|
@@ -70,7 +81,7 @@ public class EntityLightning extends EntityWeather {
|
|
}
|
|
}
|
|
// CraftBukkit end
|
|
- this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_LIGHTNING_BOLT_IMPACT, SoundCategory.WEATHER, 2.0F, 0.5F + this.random.nextFloat() * 0.2F);
|
|
+ //this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_LIGHTNING_BOLT_IMPACT, SoundCategory.WEATHER, 2.0f, 0.5F + this.random.nextFloat() * 0.2F); // Paper - Limit lightning strike effect distance (the packet is now sent from inside the loop)
|
|
}
|
|
|
|
--this.lifeTicks;
|
|
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
|
index 19ce77c4a..8e23d060d 100644
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
|
@@ -1065,7 +1065,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
|
}
|
|
// CraftBukkit end
|
|
if (super.strikeLightning(entity)) {
|
|
- this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entity.locX, entity.locY, entity.locZ, 512.0D, this, new PacketPlayOutSpawnEntityWeather(entity)); // CraftBukkit - Use dimension, // Paper - use world instead of dimension
|
|
+ this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entity.locX, entity.locY, entity.locZ, this.paperConfig.maxLightningFlashDistance, this, new PacketPlayOutSpawnEntityWeather(entity)); // CraftBukkit - Use dimension, // Paper - use world instead of dimension, limit lightning strike effect distance
|
|
return true;
|
|
} else {
|
|
return false;
|
|
--
|
|
2.20.1
|
|
|