From 7cfc37b17d6282fe11293cc21492974f190603ee Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sun, 24 Oct 2021 20:29:25 +1100 Subject: [PATCH] Configurable Thunder Chance By: md_5 --- .../server/level/ServerLevel.java.patch | 26 ++++++++++++------- .../java/org/spigotmc/SpigotWorldConfig.java | 6 +++++ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch index edb91975d6..5de8cd8377 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch @@ -79,7 +79,7 @@ + // CraftBukkit start + public final LevelStorageSource.LevelStorageAccess convertable; + public final UUID uuid; -+ + + public LevelChunk getChunkIfLoaded(int x, int z) { + return this.chunkSource.getChunk(x, z, false); + } @@ -112,7 +112,7 @@ + chunkgenerator = new FlatLevelSource(cpf.settings(), worldChunkManager); + } + } - ++ + if (gen != null) { + chunkgenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, chunkgenerator, gen); + } @@ -264,6 +264,15 @@ entityplayer.stopSleepInBed(false, false); }); } +@@ -442,7 +507,7 @@ + ProfilerFiller gameprofilerfiller = Profiler.get(); + + gameprofilerfiller.push("thunder"); +- if (flag && this.isThundering() && this.random.nextInt(100000) == 0) { ++ if (flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && this.random.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot + BlockPos blockposition = this.findLightningTargetAround(this.getBlockRandomPos(j, 0, k, 15)); + + if (this.isRainingAt(blockposition)) { @@ -456,7 +521,7 @@ entityhorseskeleton.setTrap(true); entityhorseskeleton.setAge(0); @@ -455,21 +464,20 @@ - return this.addEntity(entity); + // CraftBukkit start + return this.addFreshEntity(entity, CreatureSpawnEvent.SpawnReason.DEFAULT); - } - -- public boolean addWithUUID(Entity entity) { -- return this.addEntity(entity); ++ } ++ + @Override + public boolean addFreshEntity(Entity entity, CreatureSpawnEvent.SpawnReason reason) { + return this.addEntity(entity, reason); + // CraftBukkit end } -+ public boolean addWithUUID(Entity entity) { + public boolean addWithUUID(Entity entity) { +- return this.addEntity(entity); + // CraftBukkit start + return this.addWithUUID(entity, CreatureSpawnEvent.SpawnReason.DEFAULT); -+ } -+ + } + + public boolean addWithUUID(Entity entity, CreatureSpawnEvent.SpawnReason reason) { + return this.addEntity(entity, reason); + // CraftBukkit end diff --git a/paper-server/src/main/java/org/spigotmc/SpigotWorldConfig.java b/paper-server/src/main/java/org/spigotmc/SpigotWorldConfig.java index 237010b79d..75e4aa5c6c 100644 --- a/paper-server/src/main/java/org/spigotmc/SpigotWorldConfig.java +++ b/paper-server/src/main/java/org/spigotmc/SpigotWorldConfig.java @@ -382,4 +382,10 @@ public class SpigotWorldConfig this.entityMaxTickTime = this.getInt("max-tick-time.entity", 50); this.log("Tile Max Tick Time: " + this.tileMaxTickTime + "ms Entity max Tick Time: " + this.entityMaxTickTime + "ms"); } + + public int thunderChance; + private void thunderChance() + { + this.thunderChance = this.getInt("thunder-chance", 100000); + } }