From fdfc7a40a4630bf15d1151082442cdea3aec12cd Mon Sep 17 00:00:00 2001 From: MartinTheDragon Date: Fri, 11 Mar 2022 17:17:16 +0100 Subject: [PATCH] Delay fallout chunks and adjust ore chances --- src/main/java/com/hbm/config/BombConfig.java | 5 +- .../hbm/entity/effect/EntityFalloutRain.java | 47 +++++++++++-------- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/hbm/config/BombConfig.java b/src/main/java/com/hbm/config/BombConfig.java index 68443e8e9..8e325df4f 100644 --- a/src/main/java/com/hbm/config/BombConfig.java +++ b/src/main/java/com/hbm/config/BombConfig.java @@ -23,7 +23,7 @@ public class BombConfig { public static int mk4 = 1024; public static int blastSpeed = 1024; public static int falloutRange = 100; - public static int fSpeed = 256; + public static int fDelay = 4; public static int limitExplosionLifespan = 0; public static void loadFromConfig(Configuration config) { @@ -88,5 +88,8 @@ public class BombConfig { Property falloutRangeProp = config.get(CATEGORY_NUKE, "6.03_falloutRange", 100); falloutRangeProp.comment = "Radius of fallout area (base radius * value in percent)"; falloutRange = falloutRangeProp.getInt(); + Property falloutDelayProp = config.get(CATEGORY_NUKE, "6.04_falloutDelay", 4); + falloutDelayProp.comment = "How many ticks to wait for the next fallout chunk computation"; + fDelay = falloutDelayProp.getInt(); } } diff --git a/src/main/java/com/hbm/entity/effect/EntityFalloutRain.java b/src/main/java/com/hbm/entity/effect/EntityFalloutRain.java index a9a012c4a..67963d3ef 100644 --- a/src/main/java/com/hbm/entity/effect/EntityFalloutRain.java +++ b/src/main/java/com/hbm/entity/effect/EntityFalloutRain.java @@ -1,6 +1,7 @@ package com.hbm.entity.effect; import com.hbm.blocks.ModBlocks; +import com.hbm.config.BombConfig; import com.hbm.config.RadiationConfig; import com.hbm.config.VersatileConfig; import com.hbm.saveddata.AuxSavedData; @@ -32,6 +33,8 @@ public class EntityFalloutRain extends Entity { this.isImmuneToFire = true; } + private int tickDelay = BombConfig.fDelay; + @Override public void onUpdate() { if(!worldObj.isRemote) { @@ -40,23 +43,28 @@ public class EntityFalloutRain extends Entity { firstTick = false; } - if (!chunksToProcess.isEmpty()) { - long chunkPos = chunksToProcess.remove(chunksToProcess.size() - 1); // Just so it doesn't shift the whole list every time - int chunkPosX = (int) (chunkPos & Integer.MAX_VALUE); - int chunkPosZ = (int) (chunkPos >> 32 & Integer.MAX_VALUE); - for (int x = chunkPosX << 4; x <= (chunkPosX << 4) + 16; x++) for (int z = chunkPosZ << 4; z <= (chunkPosZ << 4) + 16; z++) - stomp(x, z, Math.hypot(x - posX, z - posZ) * 100 / getScale()); - } else if (!outerChunksToProcess.isEmpty()) { - long chunkPos = outerChunksToProcess.remove(outerChunksToProcess.size() - 1); - int chunkPosX = (int) (chunkPos & Integer.MAX_VALUE); - int chunkPosZ = (int) (chunkPos >> 32 & Integer.MAX_VALUE); - for (int x = chunkPosX << 4; x <= (chunkPosX << 4) + 16; x++) for (int z = chunkPosZ << 4; z <= (chunkPosZ << 4) + 16; z++) { - double distance = Math.hypot(x - posX, z - posZ); - if (distance <= getScale()) stomp(x, z, distance * 100 / getScale()); - } - } else setDead(); + if (tickDelay == 0) { + tickDelay = BombConfig.fDelay; + if (!chunksToProcess.isEmpty()) { + long chunkPos = chunksToProcess.remove(chunksToProcess.size() - 1); // Just so it doesn't shift the whole list every time + int chunkPosX = (int) (chunkPos & Integer.MAX_VALUE); + int chunkPosZ = (int) (chunkPos >> 32 & Integer.MAX_VALUE); + for (int x = chunkPosX << 4; x <= (chunkPosX << 4) + 16; x++) for (int z = chunkPosZ << 4; z <= (chunkPosZ << 4) + 16; z++) + stomp(x, z, Math.hypot(x - posX, z - posZ) * 100 / getScale()); + } else if (!outerChunksToProcess.isEmpty()) { + long chunkPos = outerChunksToProcess.remove(outerChunksToProcess.size() - 1); + int chunkPosX = (int) (chunkPos & Integer.MAX_VALUE); + int chunkPosZ = (int) (chunkPos >> 32 & Integer.MAX_VALUE); + for (int x = chunkPosX << 4; x <= (chunkPosX << 4) + 16; x++) for (int z = chunkPosZ << 4; z <= (chunkPosZ << 4) + 16; z++) { + double distance = Math.hypot(x - posX, z - posZ); + if (distance <= getScale()) stomp(x, z, distance * 100 / getScale()); + } + } else setDead(); + } - if(this.isDead) { + tickDelay--; + + if(this.isDead) { if(RadiationConfig.rain > 0 && getScale() > 150) { worldObj.getWorldInfo().setRaining(true); worldObj.getWorldInfo().setThundering(true); @@ -97,6 +105,7 @@ public class EntityFalloutRain extends Entity { Collections.reverse(outerChunksToProcess); } + // TODO cache chunks? private void stomp(int x, int z, double dist) { int depth = 0; @@ -154,7 +163,7 @@ public class EntityFalloutRain extends Entity { return; } else if(b == Blocks.sand) { - if(rand.nextInt(60) == 0) + if(rand.nextInt(20) == 0) worldObj.setBlock(x, y, z, meta == 0 ? ModBlocks.waste_trinitite : ModBlocks.waste_trinitite_red); return; } @@ -171,9 +180,9 @@ public class EntityFalloutRain extends Entity { else if (b == Blocks.coal_ore) { int ra = rand.nextInt(150); - if (ra < 7) { + if (ra < 20) { worldObj.setBlock(x, y, z, Blocks.diamond_ore); - } else if (ra < 10) { + } else if (ra < 30) { worldObj.setBlock(x, y, z, Blocks.emerald_ore); } return;