From 1131b22447d5df20056b366a469715fd5b4804e3 Mon Sep 17 00:00:00 2001 From: Quantum Date: Mon, 15 Nov 2021 01:05:09 -0500 Subject: [PATCH] "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 --- .../entities/EntityThermonuclearBlast.java | 78 ++++++++++++------- 1 file changed, 48 insertions(+), 30 deletions(-) diff --git a/src/main/java/trinity/entities/EntityThermonuclearBlast.java b/src/main/java/trinity/entities/EntityThermonuclearBlast.java index 3c9a503..9ba0aa1 100644 --- a/src/main/java/trinity/entities/EntityThermonuclearBlast.java +++ b/src/main/java/trinity/entities/EntityThermonuclearBlast.java @@ -2,9 +2,9 @@ package trinity.entities; import java.util.List; -//import icbm.classic.api.ExplosiveRefs; -//import icbm.classic.content.blast.BlastEMP; -//import icbm.classic.content.blast.threaded.BlastNuclear; +import icbm.classic.api.refs.ICBMExplosives; +import icbm.classic.content.blast.BlastEMP; +// import icbm.classic.content.blast.threaded.BlastNuclear; import nc.init.NCBlocks; import nc.worldgen.biome.NCBiomes; import net.minecraft.block.Block; @@ -65,6 +65,7 @@ public class EntityThermonuclearBlast extends Entity { public int age = 0; public int destructionRange = 0; + public int falloutIntensity = 0; //public ExplosionBalefire exp; public int speed = 1; public boolean did = false; @@ -73,6 +74,7 @@ public class EntityThermonuclearBlast extends Entity { protected void readEntityFromNBT(NBTTagCompound nbt) { age = nbt.getInteger("age"); destructionRange = nbt.getInteger("destructionRange"); + falloutIntensity = nbt.getInteger("falloutIntensity"); speed = nbt.getInteger("speed"); did = nbt.getBoolean("did"); @@ -88,6 +90,7 @@ public class EntityThermonuclearBlast extends Entity { protected void writeEntityToNBT(NBTTagCompound nbt) { nbt.setInteger("age", age); nbt.setInteger("destructionRange", destructionRange); + nbt.setInteger("falloutIntensity", falloutIntensity); nbt.setInteger("speed", speed); nbt.setBoolean("did", did); @@ -108,29 +111,53 @@ public class EntityThermonuclearBlast extends Entity { { //if(GeneralConfig.enableExtendedLogging && !world.isRemote) // 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; } speed += 1; //increase speed to keep up with expansion - - boolean flag = false; - + + boolean shouldDie = false; + for(int i = 0; i < this.speed; i++) { - flag = exp.update(); - - if(flag) { + shouldDie = exp.update(); + + if(shouldDie) { this.setDead(); } } 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); - - 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); ExplosionNukeGeneric.dealDamage(this.world, (int)this.posX, (int)this.posY, (int)this.posZ, this.destructionRange * 2); @@ -338,33 +365,24 @@ public class EntityThermonuclearBlast extends Entity { } */ public void setIntensity(int i) { - - this.dataManager.set(INTENSITY, Integer.valueOf(i)); + this.falloutIntensity = i; } public int getIntensity() { - int intensity = this.dataManager.get(INTENSITY); - + int intensity = this.falloutIntensity; + return intensity == 0 ? 1 : intensity; } - - public void setScale(int 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 void setScale(int i) { + this.destructionRange = i; } public int getScale() { - int scale = this.dataManager.get(SCALE); - + int scale = this.destructionRange; + return scale == 0 ? 1 : scale; } }