Delay fallout chunks and adjust ore chances

This commit is contained in:
MartinTheDragon 2022-03-11 17:17:16 +01:00
parent 4cf9d64d8e
commit fdfc7a40a4
No known key found for this signature in database
GPG Key ID: F03B4EA7AB5A6C23
2 changed files with 32 additions and 20 deletions

View File

@ -23,7 +23,7 @@ public class BombConfig {
public static int mk4 = 1024; public static int mk4 = 1024;
public static int blastSpeed = 1024; public static int blastSpeed = 1024;
public static int falloutRange = 100; public static int falloutRange = 100;
public static int fSpeed = 256; public static int fDelay = 4;
public static int limitExplosionLifespan = 0; public static int limitExplosionLifespan = 0;
public static void loadFromConfig(Configuration config) { public static void loadFromConfig(Configuration config) {
@ -88,5 +88,8 @@ public class BombConfig {
Property falloutRangeProp = config.get(CATEGORY_NUKE, "6.03_falloutRange", 100); Property falloutRangeProp = config.get(CATEGORY_NUKE, "6.03_falloutRange", 100);
falloutRangeProp.comment = "Radius of fallout area (base radius * value in percent)"; falloutRangeProp.comment = "Radius of fallout area (base radius * value in percent)";
falloutRange = falloutRangeProp.getInt(); 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();
} }
} }

View File

@ -1,6 +1,7 @@
package com.hbm.entity.effect; package com.hbm.entity.effect;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.config.BombConfig;
import com.hbm.config.RadiationConfig; import com.hbm.config.RadiationConfig;
import com.hbm.config.VersatileConfig; import com.hbm.config.VersatileConfig;
import com.hbm.saveddata.AuxSavedData; import com.hbm.saveddata.AuxSavedData;
@ -32,6 +33,8 @@ public class EntityFalloutRain extends Entity {
this.isImmuneToFire = true; this.isImmuneToFire = true;
} }
private int tickDelay = BombConfig.fDelay;
@Override @Override
public void onUpdate() { public void onUpdate() {
if(!worldObj.isRemote) { if(!worldObj.isRemote) {
@ -40,23 +43,28 @@ public class EntityFalloutRain extends Entity {
firstTick = false; firstTick = false;
} }
if (!chunksToProcess.isEmpty()) { if (tickDelay == 0) {
long chunkPos = chunksToProcess.remove(chunksToProcess.size() - 1); // Just so it doesn't shift the whole list every time tickDelay = BombConfig.fDelay;
int chunkPosX = (int) (chunkPos & Integer.MAX_VALUE); if (!chunksToProcess.isEmpty()) {
int chunkPosZ = (int) (chunkPos >> 32 & Integer.MAX_VALUE); long chunkPos = chunksToProcess.remove(chunksToProcess.size() - 1); // Just so it doesn't shift the whole list every time
for (int x = chunkPosX << 4; x <= (chunkPosX << 4) + 16; x++) for (int z = chunkPosZ << 4; z <= (chunkPosZ << 4) + 16; z++) int chunkPosX = (int) (chunkPos & Integer.MAX_VALUE);
stomp(x, z, Math.hypot(x - posX, z - posZ) * 100 / getScale()); int chunkPosZ = (int) (chunkPos >> 32 & Integer.MAX_VALUE);
} else if (!outerChunksToProcess.isEmpty()) { for (int x = chunkPosX << 4; x <= (chunkPosX << 4) + 16; x++) for (int z = chunkPosZ << 4; z <= (chunkPosZ << 4) + 16; z++)
long chunkPos = outerChunksToProcess.remove(outerChunksToProcess.size() - 1); stomp(x, z, Math.hypot(x - posX, z - posZ) * 100 / getScale());
int chunkPosX = (int) (chunkPos & Integer.MAX_VALUE); } else if (!outerChunksToProcess.isEmpty()) {
int chunkPosZ = (int) (chunkPos >> 32 & Integer.MAX_VALUE); long chunkPos = outerChunksToProcess.remove(outerChunksToProcess.size() - 1);
for (int x = chunkPosX << 4; x <= (chunkPosX << 4) + 16; x++) for (int z = chunkPosZ << 4; z <= (chunkPosZ << 4) + 16; z++) { int chunkPosX = (int) (chunkPos & Integer.MAX_VALUE);
double distance = Math.hypot(x - posX, z - posZ); int chunkPosZ = (int) (chunkPos >> 32 & Integer.MAX_VALUE);
if (distance <= getScale()) stomp(x, z, distance * 100 / getScale()); 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);
} else setDead(); if (distance <= getScale()) stomp(x, z, distance * 100 / getScale());
}
} else setDead();
}
if(this.isDead) { tickDelay--;
if(this.isDead) {
if(RadiationConfig.rain > 0 && getScale() > 150) { if(RadiationConfig.rain > 0 && getScale() > 150) {
worldObj.getWorldInfo().setRaining(true); worldObj.getWorldInfo().setRaining(true);
worldObj.getWorldInfo().setThundering(true); worldObj.getWorldInfo().setThundering(true);
@ -97,6 +105,7 @@ public class EntityFalloutRain extends Entity {
Collections.reverse(outerChunksToProcess); Collections.reverse(outerChunksToProcess);
} }
// TODO cache chunks?
private void stomp(int x, int z, double dist) { private void stomp(int x, int z, double dist) {
int depth = 0; int depth = 0;
@ -154,7 +163,7 @@ public class EntityFalloutRain extends Entity {
return; return;
} else if(b == Blocks.sand) { } 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); worldObj.setBlock(x, y, z, meta == 0 ? ModBlocks.waste_trinitite : ModBlocks.waste_trinitite_red);
return; return;
} }
@ -171,9 +180,9 @@ public class EntityFalloutRain extends Entity {
else if (b == Blocks.coal_ore) { else if (b == Blocks.coal_ore) {
int ra = rand.nextInt(150); int ra = rand.nextInt(150);
if (ra < 7) { if (ra < 20) {
worldObj.setBlock(x, y, z, Blocks.diamond_ore); worldObj.setBlock(x, y, z, Blocks.diamond_ore);
} else if (ra < 10) { } else if (ra < 30) {
worldObj.setBlock(x, y, z, Blocks.emerald_ore); worldObj.setBlock(x, y, z, Blocks.emerald_ore);
} }
return; return;