"Fixed" Thermonuclear explosions

Looks like the devs were in the middle of rewriting this class

Thermonukes would cause a crash because setScale tries to set a
dataManager thing that was never registered

Once that bug was fixed the crash stopped happening but the explosion
didnt do much so I readded a lot of commented out code

Works for now, will have to see what the devs were planning to do with
this so I can impliment it right or just steal what they did
This commit is contained in:
Thomas Muller 2021-11-15 01:05:09 -05:00
parent 43915e43f0
commit 1131b22447
Signed by: thomas
GPG key ID: AF006EB730564952

View file

@ -2,8 +2,8 @@ package trinity.entities;
import java.util.List; import java.util.List;
//import icbm.classic.api.ExplosiveRefs; import icbm.classic.api.refs.ICBMExplosives;
//import icbm.classic.content.blast.BlastEMP; import icbm.classic.content.blast.BlastEMP;
// import icbm.classic.content.blast.threaded.BlastNuclear; // import icbm.classic.content.blast.threaded.BlastNuclear;
import nc.init.NCBlocks; import nc.init.NCBlocks;
import nc.worldgen.biome.NCBiomes; import nc.worldgen.biome.NCBiomes;
@ -65,6 +65,7 @@ public class EntityThermonuclearBlast extends Entity {
public int age = 0; public int age = 0;
public int destructionRange = 0; public int destructionRange = 0;
public int falloutIntensity = 0;
//public ExplosionBalefire exp; //public ExplosionBalefire exp;
public int speed = 1; public int speed = 1;
public boolean did = false; public boolean did = false;
@ -73,6 +74,7 @@ public class EntityThermonuclearBlast extends Entity {
protected void readEntityFromNBT(NBTTagCompound nbt) { protected void readEntityFromNBT(NBTTagCompound nbt) {
age = nbt.getInteger("age"); age = nbt.getInteger("age");
destructionRange = nbt.getInteger("destructionRange"); destructionRange = nbt.getInteger("destructionRange");
falloutIntensity = nbt.getInteger("falloutIntensity");
speed = nbt.getInteger("speed"); speed = nbt.getInteger("speed");
did = nbt.getBoolean("did"); did = nbt.getBoolean("did");
@ -88,6 +90,7 @@ public class EntityThermonuclearBlast extends Entity {
protected void writeEntityToNBT(NBTTagCompound nbt) { protected void writeEntityToNBT(NBTTagCompound nbt) {
nbt.setInteger("age", age); nbt.setInteger("age", age);
nbt.setInteger("destructionRange", destructionRange); nbt.setInteger("destructionRange", destructionRange);
nbt.setInteger("falloutIntensity", falloutIntensity);
nbt.setInteger("speed", speed); nbt.setInteger("speed", speed);
nbt.setBoolean("did", did); nbt.setBoolean("did", did);
@ -109,20 +112,44 @@ public class EntityThermonuclearBlast extends Entity {
//if(GeneralConfig.enableExtendedLogging && !world.isRemote) //if(GeneralConfig.enableExtendedLogging && !world.isRemote)
// MainRegistry.logger.log(Level.INFO, "[NUKE] Initialized BF explosion at " + posX + " / " + posY + " / " + posZ + " with strength " + destructionRange + "!"); // MainRegistry.logger.log(Level.INFO, "[NUKE] Initialized BF explosion at " + posX + " / " + posY + " / " + posZ + " with strength " + destructionRange + "!");
exp = new ExplosionThermonuclear((int)this.posX, (int)this.posY, (int)this.posZ, this.world, this.destructionRange); exp = new ExplosionThermonuclear((int)this.posX, (int)this.posY, (int)this.posZ, this.world, getScale());
EntityFalloutRain fallout = new EntityFalloutRain(this.world);
fallout.posX = this.posX;
fallout.posY = this.posY;
fallout.posZ = this.posZ;
fallout.setScale((int)(this.getScale() * TrinityConfig.fallout_multiplier));
fallout.setThermonuclear(true);
fallout.setIntensity(this.getIntensity());
this.world.spawnEntity(fallout);
EntityShockwave shock = new EntityShockwave(this.world);
shock.posX = this.posX;
shock.posY = this.posY;
shock.posZ = this.posZ;
shock.setScale(this.getScale() * 2);
this.world.spawnEntity(shock);
if(Trinity.ICBMLoaded)
{
new BlastEMP().setBlastWorld(this.world).setBlastSource(this).setBlastPosition(this.posX, this.posY, this.posZ)
.setBlastSize(getScale()*2)
.setExplosiveData(ICBMExplosives.EMP)
.buildBlast().runBlast();
}
this.did = true; this.did = true;
} }
speed += 1; //increase speed to keep up with expansion speed += 1; //increase speed to keep up with expansion
boolean flag = false; boolean shouldDie = false;
for(int i = 0; i < this.speed; i++) for(int i = 0; i < this.speed; i++)
{ {
flag = exp.update(); shouldDie = exp.update();
if(flag) { if(shouldDie) {
this.setDead(); this.setDead();
} }
} }
@ -130,7 +157,7 @@ public class EntityThermonuclearBlast extends Entity {
if(rand.nextInt(5) == 0) if(rand.nextInt(5) == 0)
this.world.playSound(null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.AMBIENT, 10000.0F, 0.8F + this.rand.nextFloat() * 0.2F); this.world.playSound(null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.AMBIENT, 10000.0F, 0.8F + this.rand.nextFloat() * 0.2F);
if(!flag) if(!shouldDie)
{ {
this.world.playSound(null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_LIGHTNING_THUNDER, SoundCategory.AMBIENT, 10000.0F, 0.8F + this.rand.nextFloat() * 0.2F); this.world.playSound(null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_LIGHTNING_THUNDER, SoundCategory.AMBIENT, 10000.0F, 0.8F + this.rand.nextFloat() * 0.2F);
ExplosionNukeGeneric.dealDamage(this.world, (int)this.posX, (int)this.posY, (int)this.posZ, this.destructionRange * 2); ExplosionNukeGeneric.dealDamage(this.world, (int)this.posX, (int)this.posY, (int)this.posZ, this.destructionRange * 2);
@ -338,32 +365,23 @@ public class EntityThermonuclearBlast extends Entity {
} }
*/ */
public void setIntensity(int i) { public void setIntensity(int i) {
this.falloutIntensity = i;
this.dataManager.set(INTENSITY, Integer.valueOf(i));
} }
public int getIntensity() { public int getIntensity() {
int intensity = this.dataManager.get(INTENSITY); int intensity = this.falloutIntensity;
return intensity == 0 ? 1 : intensity; return intensity == 0 ? 1 : intensity;
} }
public void setScale(int i) { public void setScale(int i) {
this.destructionRange = i;
this.dataManager.set(SCALE, Integer.valueOf(i));
/*if(Trinity.ICBMLoaded)
{
new BlastEMP().setBlastWorld(this.world).setBlastSource(this).setBlastPosition(this.posX, this.posY, this.posZ)
.setBlastSize(i*2)
.setExplosiveData(ExplosiveRefs.EMP)
.buildBlast().runBlast();
}*/
} }
public int getScale() { public int getScale() {
int scale = this.dataManager.get(SCALE); int scale = this.destructionRange;
return scale == 0 ? 1 : scale; return scale == 0 ? 1 : scale;
} }