mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Explosion MK4 finished, tsar retexture
This commit is contained in:
parent
37e5eecef7
commit
28164d5292
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 418 KiB After Width: | Height: | Size: 17 KiB |
@ -2,6 +2,7 @@ package com.hbm.blocks.test;
|
|||||||
|
|
||||||
import com.hbm.entity.logic.EntityNukeExplosionMK4;
|
import com.hbm.entity.logic.EntityNukeExplosionMK4;
|
||||||
import com.hbm.lib.RefStrings;
|
import com.hbm.lib.RefStrings;
|
||||||
|
import com.hbm.main.MainRegistry;
|
||||||
import com.hbm.tileentity.bomb.TileEntityTestBombAdvanced;
|
import com.hbm.tileentity.bomb.TileEntityTestBombAdvanced;
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
@ -133,11 +134,6 @@ public class TestBombAdvanced extends BlockContainer {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
world.setBlock(x, y, z, Blocks.air);
|
world.setBlock(x, y, z, Blocks.air);
|
||||||
EntityNukeExplosionMK4 mk4 = new EntityNukeExplosionMK4(world);
|
world.spawnEntityInWorld(EntityNukeExplosionMK4.statFac(world, MainRegistry.x * 20, x, y, z));
|
||||||
mk4.strength = 40;
|
|
||||||
mk4.count = 100000;
|
|
||||||
mk4.speed = 50;
|
|
||||||
mk4.setPosition(x + 0.5, y + 0.5, z + 0.5);
|
|
||||||
world.spawnEntityInWorld(mk4);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.hbm.entity.grenade;
|
|||||||
|
|
||||||
import com.hbm.entity.logic.EntityNukeExplosionAdvanced;
|
import com.hbm.entity.logic.EntityNukeExplosionAdvanced;
|
||||||
import com.hbm.entity.logic.EntityNukeExplosionMK3;
|
import com.hbm.entity.logic.EntityNukeExplosionMK3;
|
||||||
|
import com.hbm.entity.logic.EntityNukeExplosionMK4;
|
||||||
import com.hbm.explosion.ExplosionParticle;
|
import com.hbm.explosion.ExplosionParticle;
|
||||||
import com.hbm.explosion.ExplosionParticleB;
|
import com.hbm.explosion.ExplosionParticleB;
|
||||||
import com.hbm.main.MainRegistry;
|
import com.hbm.main.MainRegistry;
|
||||||
@ -29,15 +30,15 @@ public class EntityGrenadeNuclear extends EntityGrenadeBase
|
|||||||
if (!this.worldObj.isRemote)
|
if (!this.worldObj.isRemote)
|
||||||
{
|
{
|
||||||
this.setDead();
|
this.setDead();
|
||||||
EntityNukeExplosionMK3 entity0 = new EntityNukeExplosionMK3(this.worldObj);
|
/*EntityNukeExplosionMK3 entity0 = new EntityNukeExplosionMK3(this.worldObj);
|
||||||
entity0.posX = this.posX;
|
entity0.posX = this.posX;
|
||||||
entity0.posY = this.posY;
|
entity0.posY = this.posY;
|
||||||
entity0.posZ = this.posZ;
|
entity0.posZ = this.posZ;
|
||||||
entity0.destructionRange = MainRegistry.nukaRadius;
|
entity0.destructionRange = MainRegistry.nukaRadius;
|
||||||
entity0.speed = 25;
|
entity0.speed = 25;
|
||||||
entity0.coefficient = 10.0F;
|
entity0.coefficient = 10.0F;*/
|
||||||
|
|
||||||
this.worldObj.spawnEntityInWorld(entity0);
|
this.worldObj.spawnEntityInWorld(EntityNukeExplosionMK4.statFac(worldObj, MainRegistry.nukaRadius * 2, posX, posY, posZ));
|
||||||
if(rand.nextInt(100) == 0)
|
if(rand.nextInt(100) == 0)
|
||||||
{
|
{
|
||||||
ExplosionParticleB.spawnMush(this.worldObj, (int)this.posX, (int)this.posY - 2, (int)this.posZ);
|
ExplosionParticleB.spawnMush(this.worldObj, (int)this.posX, (int)this.posY - 2, (int)this.posZ);
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
package com.hbm.entity.logic;
|
package com.hbm.entity.logic;
|
||||||
|
|
||||||
import com.hbm.explosion.ExplosionLarge;
|
import com.hbm.explosion.ExplosionLarge;
|
||||||
|
import com.hbm.explosion.ExplosionNukeRay;
|
||||||
|
import com.hbm.main.MainRegistry;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
@ -9,31 +11,47 @@ import net.minecraft.world.World;
|
|||||||
public class EntityNukeExplosionMK4 extends Entity {
|
public class EntityNukeExplosionMK4 extends Entity {
|
||||||
|
|
||||||
//Strength of the blast
|
//Strength of the blast
|
||||||
public long strength;
|
public int strength;
|
||||||
//How many rays should be created
|
//How many rays should be created
|
||||||
public long count;
|
public int count;
|
||||||
//How many rays are calculated per tick
|
//How many rays are calculated per tick
|
||||||
public int speed;
|
public int speed;
|
||||||
//How many rays have already been processed
|
public int length;
|
||||||
public long done;
|
|
||||||
|
ExplosionNukeRay explosion;
|
||||||
|
|
||||||
public EntityNukeExplosionMK4(World p_i1582_1_) {
|
public EntityNukeExplosionMK4(World p_i1582_1_) {
|
||||||
super(p_i1582_1_);
|
super(p_i1582_1_);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityNukeExplosionMK4(World world, long strength, long count, int speed) {
|
public EntityNukeExplosionMK4(World world, int strength, int count, int speed, int length) {
|
||||||
super(world);
|
super(world);
|
||||||
this.strength = strength;
|
this.strength = strength;
|
||||||
this.count = count;
|
this.count = count;
|
||||||
this.speed = speed;
|
this.speed = speed;
|
||||||
|
this.length = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate() {
|
public void onUpdate() {
|
||||||
ExplosionLarge.destructionRay(worldObj, posX, posY, posZ, speed, strength);
|
|
||||||
done += speed;
|
if(strength == 0) {
|
||||||
if(done >= count)
|
|
||||||
this.setDead();
|
this.setDead();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(explosion == null)
|
||||||
|
explosion = new ExplosionNukeRay(worldObj, (int)this.posX, (int)this.posY, (int)this.posZ, this.strength, this.count, this.speed, this.length);
|
||||||
|
|
||||||
|
if(explosion.getStoredSize() < count / length) {
|
||||||
|
//if(!worldObj.isRemote)
|
||||||
|
explosion.collectTip(speed);
|
||||||
|
} else if(explosion.getProgress() < count) {
|
||||||
|
//if(!worldObj.isRemote)
|
||||||
|
explosion.processTip(speed / length);
|
||||||
|
} else {
|
||||||
|
this.setDead();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -50,5 +68,15 @@ public class EntityNukeExplosionMK4 extends Entity {
|
|||||||
protected void writeEntityToNBT(NBTTagCompound p_70014_1_) {
|
protected void writeEntityToNBT(NBTTagCompound p_70014_1_) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static EntityNukeExplosionMK4 statFac(World world, int r, double x, double y, double z) {
|
||||||
|
EntityNukeExplosionMK4 mk4 = new EntityNukeExplosionMK4(world);
|
||||||
|
mk4.strength = r;
|
||||||
|
mk4.count = (int)(4 * Math.PI * Math.pow(mk4.strength, 2) * 25);
|
||||||
|
mk4.speed = (mk4.count / 500);
|
||||||
|
mk4.setPosition(x, y, z);
|
||||||
|
mk4.length = mk4.strength / 2;
|
||||||
|
return mk4;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,45 +20,6 @@ public class ExplosionLarge {
|
|||||||
|
|
||||||
static Random rand = new Random();
|
static Random rand = new Random();
|
||||||
|
|
||||||
public static void destructionRay(World world, double posX, double posY, double posZ, int count, long strength) {
|
|
||||||
|
|
||||||
for(int k = 0; k < count; k++) {
|
|
||||||
double phi = rand.nextDouble() * (Math.PI * 2);
|
|
||||||
double costheta = rand.nextDouble() * 2 - 1;
|
|
||||||
double theta = Math.acos(costheta);
|
|
||||||
double x = Math.sin( theta) * Math.cos( phi );
|
|
||||||
double y = Math.sin( theta) * Math.sin( phi );
|
|
||||||
double z = Math.cos( theta );
|
|
||||||
|
|
||||||
Vec3 vec = Vec3.createVectorHelper(x, y, z);
|
|
||||||
int length = (int)Math.ceil(strength);
|
|
||||||
|
|
||||||
float res = strength;
|
|
||||||
|
|
||||||
for(int i = 0; i < length; i ++) {
|
|
||||||
|
|
||||||
int x0 = (int)(posX + (vec.xCoord * i));
|
|
||||||
int y0 = (int)(posY + (vec.yCoord * i));
|
|
||||||
int z0 = (int)(posZ + (vec.zCoord * i));
|
|
||||||
|
|
||||||
if(!world.isRemote) {
|
|
||||||
|
|
||||||
if(world.getBlock(x0, y0, z0).getMaterial().isLiquid()) {
|
|
||||||
world.setBlock(x0, y0, z0, Blocks.air);
|
|
||||||
}
|
|
||||||
|
|
||||||
res -= Math.pow(world.getBlock(x0, y0, z0).getExplosionResistance(null), 2);
|
|
||||||
|
|
||||||
if(res > 0 && world.getBlock(x0, y0, z0) != Blocks.air) {
|
|
||||||
|
|
||||||
|
|
||||||
world.setBlock(x0, y0, z0, Blocks.air);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void spawnParticles(World world, double x, double y, double z, int count) {
|
public static void spawnParticles(World world, double x, double y, double z, int count) {
|
||||||
|
|
||||||
for(int i = 0; i < count; i++) {
|
for(int i = 0; i < count; i++) {
|
||||||
|
|||||||
193
com/hbm/explosion/ExplosionNukeRay.java
Normal file
193
com/hbm/explosion/ExplosionNukeRay.java
Normal file
@ -0,0 +1,193 @@
|
|||||||
|
package com.hbm.explosion;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import com.hbm.main.MainRegistry;
|
||||||
|
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
|
import net.minecraft.world.ChunkPosition;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class ExplosionNukeRay {
|
||||||
|
|
||||||
|
List<FloatTriplet> affectedBlocks = new ArrayList();
|
||||||
|
int posX;
|
||||||
|
int posY;
|
||||||
|
int posZ;
|
||||||
|
Random rand = new Random();
|
||||||
|
World world;
|
||||||
|
int strength;
|
||||||
|
int count;
|
||||||
|
int speed;
|
||||||
|
int processed;
|
||||||
|
int length;
|
||||||
|
|
||||||
|
public ExplosionNukeRay(World world, int x, int y, int z, int strength, int count, int speed, int length) {
|
||||||
|
this.world = world;
|
||||||
|
this.posX = x;
|
||||||
|
this.posY = y;
|
||||||
|
this.posZ = z;
|
||||||
|
this.strength = strength;
|
||||||
|
this.count = count;
|
||||||
|
this.speed = speed;
|
||||||
|
this.length = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public void processBunch(int count) {
|
||||||
|
for(int l = processed; l < processed + count; l++) {
|
||||||
|
|
||||||
|
if(l > affectedBlocks.size() - 1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
int x = affectedBlocks.get(l).chunkPosX;
|
||||||
|
int y = affectedBlocks.get(l).chunkPosY;
|
||||||
|
int z = affectedBlocks.get(l).chunkPosZ;
|
||||||
|
|
||||||
|
if(world.getBlock(x, y, z) != Blocks.air)
|
||||||
|
{
|
||||||
|
world.setBlock(x, y, z, Blocks.air);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
processed += count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void collectBunch(int count) {
|
||||||
|
|
||||||
|
for(int k = 0; k < count; k++) {
|
||||||
|
double phi = rand.nextDouble() * (Math.PI * 2);
|
||||||
|
double costheta = rand.nextDouble() * 2 - 1;
|
||||||
|
double theta = Math.acos(costheta);
|
||||||
|
double x = Math.sin( theta) * Math.cos( phi );
|
||||||
|
double y = Math.sin( theta) * Math.sin( phi );
|
||||||
|
double z = Math.cos( theta );
|
||||||
|
|
||||||
|
Vec3 vec = Vec3.createVectorHelper(x, y, z);
|
||||||
|
int length = (int)Math.ceil(strength);
|
||||||
|
|
||||||
|
float res = strength;
|
||||||
|
|
||||||
|
for(int i = 0; i < length; i ++) {
|
||||||
|
|
||||||
|
if(i > this.length)
|
||||||
|
break;
|
||||||
|
|
||||||
|
int x0 = (int)(posX + (vec.xCoord * i));
|
||||||
|
int y0 = (int)(posY + (vec.yCoord * i));
|
||||||
|
int z0 = (int)(posZ + (vec.zCoord * i));
|
||||||
|
if(!world.getBlock(x0, y0, z0).getMaterial().isLiquid())
|
||||||
|
res -= Math.pow(world.getBlock(x0, y0, z0).getExplosionResistance(null), 1.25);
|
||||||
|
else
|
||||||
|
res -= Math.pow(Blocks.air.getExplosionResistance(null), 1.25);
|
||||||
|
|
||||||
|
if(res > 0 && world.getBlock(x0, y0, z0) != Blocks.air) {
|
||||||
|
if(affectedBlocks.size() < Integer.MAX_VALUE - 100)
|
||||||
|
affectedBlocks.add(new ChunkPosition(x0, y0, z0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public void processTip(int count) {
|
||||||
|
for(int l = processed; l < processed + count; l++) {
|
||||||
|
|
||||||
|
if(l > affectedBlocks.size() - 1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
float x = affectedBlocks.get(l).xCoord;
|
||||||
|
float y = affectedBlocks.get(l).yCoord;
|
||||||
|
float z = affectedBlocks.get(l).zCoord;
|
||||||
|
|
||||||
|
world.setBlock((int)x, (int)y, (int)z, Blocks.air);
|
||||||
|
|
||||||
|
Vec3 vec = Vec3.createVectorHelper(x - this.posX, y - this.posY, z - this.posZ);
|
||||||
|
double pX = vec.xCoord / vec.lengthVector();
|
||||||
|
double pY = vec.yCoord / vec.lengthVector();
|
||||||
|
double pZ = vec.zCoord / vec.lengthVector();
|
||||||
|
|
||||||
|
for(int i = 0; i < vec.lengthVector(); i ++) {
|
||||||
|
int x0 = (int)(posX + pX * i);
|
||||||
|
int y0 = (int)(posY + pY * i);
|
||||||
|
int z0 = (int)(posZ + pZ * i);
|
||||||
|
|
||||||
|
if(world.getBlock(x0, y0, z0) != Blocks.air)
|
||||||
|
world.setBlock(x0, y0, z0, Blocks.air);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
processed += count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void collectTip(int count) {
|
||||||
|
|
||||||
|
for(int k = 0; k < count; k++) {
|
||||||
|
double phi = rand.nextDouble() * (Math.PI * 2);
|
||||||
|
double costheta = rand.nextDouble() * 2 - 1;
|
||||||
|
double theta = Math.acos(costheta);
|
||||||
|
double x = Math.sin(theta) * Math.cos(phi);
|
||||||
|
double y = Math.sin(theta) * Math.sin(phi);
|
||||||
|
double z = Math.cos(theta);
|
||||||
|
|
||||||
|
Vec3 vec = Vec3.createVectorHelper(x, y, z);
|
||||||
|
int length = (int)Math.ceil(strength);
|
||||||
|
|
||||||
|
float res = strength;
|
||||||
|
|
||||||
|
FloatTriplet lastPos = null;
|
||||||
|
|
||||||
|
for(int i = 0; i < length; i ++) {
|
||||||
|
|
||||||
|
if(i > this.length)
|
||||||
|
break;
|
||||||
|
|
||||||
|
float x0 = (float) (posX + (vec.xCoord * i));
|
||||||
|
float y0 = (float) (posY + (vec.yCoord * i));
|
||||||
|
float z0 = (float) (posZ + (vec.zCoord * i));
|
||||||
|
|
||||||
|
if(!world.getBlock((int)x0, (int)y0, (int)z0).getMaterial().isLiquid())
|
||||||
|
res -= Math.pow(world.getBlock((int)x0, (int)y0, (int)z0).getExplosionResistance(null), 1.25);
|
||||||
|
else
|
||||||
|
res -= Math.pow(Blocks.air.getExplosionResistance(null), 1.25);
|
||||||
|
|
||||||
|
if(res > 0 && world.getBlock((int)x0, (int)y0, (int)z0) != Blocks.air) {
|
||||||
|
lastPos = new FloatTriplet(x0, y0, z0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(res <= 0 || i + 1 >= this.length) {
|
||||||
|
if(affectedBlocks.size() < Integer.MAX_VALUE - 100 && lastPos != null)
|
||||||
|
affectedBlocks.add(new FloatTriplet(lastPos.xCoord, lastPos.yCoord, lastPos.zCoord));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteStorage() {
|
||||||
|
this.affectedBlocks.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStoredSize() {
|
||||||
|
return this.affectedBlocks.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getProgress() {
|
||||||
|
return this.processed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FloatTriplet {
|
||||||
|
public float xCoord;
|
||||||
|
public float yCoord;
|
||||||
|
public float zCoord;
|
||||||
|
|
||||||
|
public FloatTriplet(float x, float y, float z) {
|
||||||
|
xCoord = x;
|
||||||
|
yCoord = y;
|
||||||
|
zCoord = z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user