some preparation

This commit is contained in:
Boblet 2024-02-13 16:53:25 +01:00
parent daaf50efd4
commit fa06d83b4b
6 changed files with 171 additions and 742 deletions

View File

@ -65,6 +65,7 @@
* Removed some of the lower tier items fomr the red room loot pool, making the average red room better
* Retextured the fallout effect, fallout no longer has large snowflakes and the color now matches the crater better
* High-yield mini nukes no longer create chunk radiation, since they use the MK5 which already has AoE radiation, this prevents dead grass from spawning that makes the crater look uglier
* Balefire spread is now limited to prevent densely vegetated biomes from lagging to hell
## Fixed
* Fixed dupe caused by shift-clicking ashes out of the bricked furnace

View File

@ -25,193 +25,136 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class Balefire extends BlockFire {
private IIcon field_149850_M;
public Balefire()
{
super();
}
private IIcon icon;
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister p_149651_1_) {
field_149850_M = p_149651_1_.registerIcon(this.getTextureName());
}
public Balefire() {
super();
}
@SideOnly(Side.CLIENT)
public IIcon getFireIcon(int p_149840_1_)
{
return field_149850_M;
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int p_149691_1_, int p_149691_2_)
{
return field_149850_M;
}
public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_)
{
if (p_149674_1_.getGameRules().getGameRuleBooleanValue("doFireTick"))
{
boolean flag = p_149674_1_.getBlock(p_149674_2_, p_149674_3_ - 1, p_149674_4_).isFireSource(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_, UP);
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
icon = register.registerIcon(this.getTextureName());
}
if (!this.canPlaceBlockAt(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_))
{
p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_);
}
@SideOnly(Side.CLIENT)
public IIcon getFireIcon(int i) {
return icon;
}
/*if (!flag && p_149674_1_.isRaining() && (p_149674_1_.canLightningStrikeAt(p_149674_2_, p_149674_3_, p_149674_4_) || p_149674_1_.canLightningStrikeAt(p_149674_2_ - 1, p_149674_3_, p_149674_4_) || p_149674_1_.canLightningStrikeAt(p_149674_2_ + 1, p_149674_3_, p_149674_4_) || p_149674_1_.canLightningStrikeAt(p_149674_2_, p_149674_3_, p_149674_4_ - 1) || p_149674_1_.canLightningStrikeAt(p_149674_2_, p_149674_3_, p_149674_4_ + 1)))
{
p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_);
}
else*/
{
int l = 0;
/*int l = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_);
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return icon;
}
if (l < 15)
{
p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, l + p_149674_5_.nextInt(3) / 2, 4);
}*/
public void updateTick(World world, int x, int y, int z, Random rand) {
if(world.getGameRules().getGameRuleBooleanValue("doFireTick")) {
boolean onNetherrack = world.getBlock(x, y - 1, z).isFireSource(world, x, y - 1, z, UP);
p_149674_1_.scheduleBlockUpdate(p_149674_2_, p_149674_3_, p_149674_4_, this, this.tickRate(p_149674_1_) + p_149674_5_.nextInt(10));
if(!this.canPlaceBlockAt(world, x, y, z)) {
world.setBlockToAir(x, y, z);
}
if (!flag && !this.canNeighborBurn(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_))
{
if (!World.doesBlockHaveSolidTopSurface(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_)/* || l > 3*/)
{
p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_);
}
}
/*else if (!flag && !this.canCatchFire(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_, UP) && l == 15 && p_149674_5_.nextInt(4) == 0)
{
//p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_);
}*/
else
{
//boolean flag1 = p_149674_1_.isBlockHighHumidity(p_149674_2_, p_149674_3_, p_149674_4_);
byte b0 = 0;
int meta = world.getBlockMetadata(x, y, z);
/*if (flag1)
{
b0 = -50;
}*/
world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world) + rand.nextInt(10));
this.tryCatchFire(p_149674_1_, p_149674_2_ + 1, p_149674_3_, p_149674_4_, 300 + b0, p_149674_5_, l, WEST );
this.tryCatchFire(p_149674_1_, p_149674_2_ - 1, p_149674_3_, p_149674_4_, 300 + b0, p_149674_5_, l, EAST );
this.tryCatchFire(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_, 250 + b0, p_149674_5_, l, UP );
this.tryCatchFire(p_149674_1_, p_149674_2_, p_149674_3_ + 1, p_149674_4_, 250 + b0, p_149674_5_, l, DOWN );
this.tryCatchFire(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_ - 1, 300 + b0, p_149674_5_, l, SOUTH);
this.tryCatchFire(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_ + 1, 300 + b0, p_149674_5_, l, NORTH);
if(!onNetherrack && !this.canNeighborBurn(world, x, y, z)) {
if(!World.doesBlockHaveSolidTopSurface(world, x, y - 1, z)) {
world.setBlockToAir(x, y, z);
}
} else {
if(meta < 15) {
this.tryCatchFire(world, x + 1, y, z, 500, rand, meta, WEST);
this.tryCatchFire(world, x - 1, y, z, 500, rand, meta, EAST);
this.tryCatchFire(world, x, y - 1, z, 300, rand, meta, UP);
this.tryCatchFire(world, x, y + 1, z, 300, rand, meta, DOWN);
this.tryCatchFire(world, x, y, z - 1, 500, rand, meta, SOUTH);
this.tryCatchFire(world, x, y, z + 1, 500, rand, meta, NORTH);
}
for (int i1 = p_149674_2_ - 1; i1 <= p_149674_2_ + 1; ++i1)
{
for (int j1 = p_149674_4_ - 1; j1 <= p_149674_4_ + 1; ++j1)
{
for (int k1 = p_149674_3_ - 1; k1 <= p_149674_3_ + 4; ++k1)
{
if (i1 != p_149674_2_ || k1 != p_149674_3_ || j1 != p_149674_4_)
{
int l1 = 100;
for(int i1 = x - 1; i1 <= x + 1; ++i1) {
for(int j1 = z - 1; j1 <= z + 1; ++j1) {
for(int k1 = y - 1; k1 <= y + 4; ++k1) {
if(i1 != x || k1 != y || j1 != z) {
int l1 = 100;
if (k1 > p_149674_3_ + 1)
{
l1 += (k1 - (p_149674_3_ + 1)) * 100;
}
if(k1 > y + 1) {
l1 += (k1 - (y + 1)) * 100;
}
int i2 = this.getChanceOfNeighborsEncouragingFire(p_149674_1_, i1, k1, j1);
int i2 = this.getChanceOfNeighborsEncouragingFire(world, i1, k1, j1);
if (i2 > 0)
{
int j2 = (i2 + 40 + p_149674_1_.difficultySetting.getDifficultyId() * 7) / (l + 30);
if(i2 > 0) {
int j2 = (i2 + 40 + world.difficultySetting.getDifficultyId() * 7) / (meta + 30);
/*if (flag1)
{
j2 /= 2;
}*/
if(j2 > 0 && rand.nextInt(l1) <= j2) {
int k2 = meta + rand.nextInt(5) / 4;
if (j2 > 0 && p_149674_5_.nextInt(l1) <= j2)
{
int k2 = l + p_149674_5_.nextInt(5) / 4;
if(k2 > 15) {
k2 = 15;
}
if (k2 > 15)
{
k2 = 15;
}
world.setBlock(i1, k1, j1, this, k2, 3);
}
}
}
}
}
}
}
}
}
p_149674_1_.setBlock(i1, k1, j1, this, k2, 3);
}
}
}
}
}
}
}
}
}
}
private void tryCatchFire(World world, int x, int y, int z, int chance, Random rand, int fireMetadata, ForgeDirection face) {
int flammability = world.getBlock(x, y, z).getFlammability(world, x, y, z, face);
private void tryCatchFire(World p_149841_1_, int p_149841_2_, int p_149841_3_, int p_149841_4_, int p_149841_5_, Random p_149841_6_, int p_149841_7_, ForgeDirection face)
{
int j1 = p_149841_1_.getBlock(p_149841_2_, p_149841_3_, p_149841_4_).getFlammability(p_149841_1_, p_149841_2_, p_149841_3_, p_149841_4_, face);
if(rand.nextInt(chance) < flammability) {
boolean flag = world.getBlock(x, y, z) == Blocks.tnt;
if (p_149841_6_.nextInt(p_149841_5_) < j1)
{
boolean flag = p_149841_1_.getBlock(p_149841_2_, p_149841_3_, p_149841_4_) == Blocks.tnt;
world.setBlock(x, y, z, this, fireMetadata + 1, 3);
p_149841_1_.setBlock(p_149841_2_, p_149841_3_, p_149841_4_, this, 15, 3);
if(flag) {
Blocks.tnt.onBlockDestroyedByPlayer(world, x, y, z, 1);
}
}
}
if (flag)
{
Blocks.tnt.onBlockDestroyedByPlayer(p_149841_1_, p_149841_2_, p_149841_3_, p_149841_4_, 1);
}
}
}
private boolean canNeighborBurn(World world, int x, int y, int z) {
return this.canCatchFire(world, x + 1, y, z, WEST)
|| this.canCatchFire(world, x - 1, y, z, EAST)
|| this.canCatchFire(world, x, y - 1, z, UP)
|| this.canCatchFire(world, x, y + 1, z, DOWN)
|| this.canCatchFire(world, x, y, z - 1, SOUTH)
|| this.canCatchFire(world, x, y, z + 1, NORTH);
}
private boolean canNeighborBurn(World p_149847_1_, int p_149847_2_, int p_149847_3_, int p_149847_4_)
{
return this.canCatchFire(p_149847_1_, p_149847_2_ + 1, p_149847_3_, p_149847_4_, WEST ) ||
this.canCatchFire(p_149847_1_, p_149847_2_ - 1, p_149847_3_, p_149847_4_, EAST ) ||
this.canCatchFire(p_149847_1_, p_149847_2_, p_149847_3_ - 1, p_149847_4_, UP ) ||
this.canCatchFire(p_149847_1_, p_149847_2_, p_149847_3_ + 1, p_149847_4_, DOWN ) ||
this.canCatchFire(p_149847_1_, p_149847_2_, p_149847_3_, p_149847_4_ - 1, SOUTH) ||
this.canCatchFire(p_149847_1_, p_149847_2_, p_149847_3_, p_149847_4_ + 1, NORTH);
}
private int getChanceOfNeighborsEncouragingFire(World world, int x, int y, int z) {
private int getChanceOfNeighborsEncouragingFire(World p_149845_1_, int p_149845_2_, int p_149845_3_, int p_149845_4_)
{
byte b0 = 0;
if(!world.isAirBlock(x, y, z)) {
return 0;
} else {
int spread = 0;
spread = this.getChanceToEncourageFire(world, x + 1, y, z, spread, WEST);
spread = this.getChanceToEncourageFire(world, x - 1, y, z, spread, EAST);
spread = this.getChanceToEncourageFire(world, x, y - 1, z, spread, UP);
spread = this.getChanceToEncourageFire(world, x, y + 1, z, spread, DOWN);
spread = this.getChanceToEncourageFire(world, x, y, z - 1, spread, SOUTH);
spread = this.getChanceToEncourageFire(world, x, y, z + 1, spread, NORTH);
return spread;
}
}
if (!p_149845_1_.isAirBlock(p_149845_2_, p_149845_3_, p_149845_4_))
{
return 0;
}
else
{
int l = b0;
l = this.getChanceToEncourageFire(p_149845_1_, p_149845_2_ + 1, p_149845_3_, p_149845_4_, l, WEST );
l = this.getChanceToEncourageFire(p_149845_1_, p_149845_2_ - 1, p_149845_3_, p_149845_4_, l, EAST );
l = this.getChanceToEncourageFire(p_149845_1_, p_149845_2_, p_149845_3_ - 1, p_149845_4_, l, UP );
l = this.getChanceToEncourageFire(p_149845_1_, p_149845_2_, p_149845_3_ + 1, p_149845_4_, l, DOWN );
l = this.getChanceToEncourageFire(p_149845_1_, p_149845_2_, p_149845_3_, p_149845_4_ - 1, l, SOUTH);
l = this.getChanceToEncourageFire(p_149845_1_, p_149845_2_, p_149845_3_, p_149845_4_ + 1, l, NORTH);
return l;
}
}
public boolean canCatchFire(IBlockAccess world, int x, int y, int z, ForgeDirection face)
{
return world.getBlock(x, y, z).isFlammable(world, x, y, z, face);
}
@Override
public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity p_149670_5_)
{
p_149670_5_.setFire(10);
if(p_149670_5_ instanceof EntityLivingBase)
((EntityLivingBase)p_149670_5_).addPotionEffect(new PotionEffect(HbmPotion.radiation.id, 5 * 20, 9));
}
@Override
public boolean canCatchFire(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
return world.getBlock(x, y, z).isFlammable(world, x, y, z, face);
}
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
entity.setFire(10);
if(entity instanceof EntityLivingBase) ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(HbmPotion.radiation.id, 5 * 20, 9));
}
}

View File

@ -3,8 +3,7 @@ package com.hbm.explosion;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
public class ExplosionNukeAdvanced
{
public class ExplosionNukeAdvanced {
public int posX;
public int posY;
public int posZ;
@ -20,7 +19,7 @@ public class ExplosionNukeAdvanced
private int element;
public float explosionCoefficient = 1.0F;
public int type = 0;
public void saveToNbt(NBTTagCompound nbt, String name) {
nbt.setInteger(name + "posX", posX);
nbt.setInteger(name + "posY", posY);
@ -37,7 +36,7 @@ public class ExplosionNukeAdvanced
nbt.setFloat(name + "explosionCoefficient", explosionCoefficient);
nbt.setInteger(name + "type", type);
}
public void readFromNbt(NBTTagCompound nbt, String name) {
posX = nbt.getInteger(name + "posX");
posY = nbt.getInteger(name + "posY");
@ -54,92 +53,64 @@ public class ExplosionNukeAdvanced
explosionCoefficient = nbt.getFloat(name + "explosionCoefficient");
type = nbt.getInteger(name + "type");
}
public ExplosionNukeAdvanced(int x, int y, int z, World world, int rad, float coefficient, int typ)
{
public ExplosionNukeAdvanced(int x, int y, int z, World world, int rad, float coefficient, int typ) {
this.posX = x;
this.posY = y;
this.posZ = z;
this.worldObj = world;
this.radius = rad;
this.radius2 = this.radius * this.radius;
this.explosionCoefficient = Math.min(Math.max((rad + coefficient * (y - 60))/(coefficient*rad), 1/coefficient),1.0f); //scale the coefficient depending on detonation height
this.explosionCoefficient = Math.min(Math.max((rad + coefficient * (y - 60)) / (coefficient * rad), 1 / coefficient), 1.0f);
this.type = typ;
this.nlimit = this.radius2 * 4; //How many total columns should be broken (radius ^ 2 is one quadrant, there are 4 quadrants)
this.nlimit = this.radius2 * 4;
}
public boolean update()
{
switch(this.type)
{
case 0:
breakColumn(this.lastposX, this.lastposZ); break;
case 1:
vapor(this.lastposX, this.lastposZ); break;
case 2:
waste(this.lastposX, this.lastposZ); break;
public boolean update() {
switch(this.type) {
case 0: breakColumn(this.lastposX, this.lastposZ); break;
case 1: vapor(this.lastposX, this.lastposZ); break;
case 2: waste(this.lastposX, this.lastposZ); break;
}
this.shell = (int) Math.floor((Math.sqrt(n) + 1) / 2); //crazy stuff I can't explain
this.shell = (int) Math.floor((Math.sqrt(n) + 1) / 2);
int shell2 = this.shell * 2;
this.leg = (int) Math.floor((this.n - (shell2 - 1) * (shell2 - 1)) / shell2);
this.element = (this.n - (shell2 - 1) * (shell2 - 1)) - shell2 * this.leg - this.shell + 1;
this.lastposX = this.leg == 0 ? this.shell : this.leg == 1 ? -this.element : this.leg == 2 ? -this.shell : this.element;
this.lastposZ = this.leg == 0 ? this.element : this.leg == 1 ? this.shell : this.leg == 2 ? -this.element : -this.shell;
this.n++;
return this.n > this.nlimit; //return whether we are done or not
return this.n > this.nlimit;
}
private void breakColumn(int x, int z)
{
int dist = this.radius2 - (x * x + z * z); //we have two sides of the triangle (hypotenuse is radius, one leg is (x*x+z*z)) this calculates the third one
if (dist > 0) //check if any blocks have to be broken here
{
dist = (int) Math.sqrt(dist); //calculate sphere height at this (x,z) coordinate
for (int y = dist; y > -dist * this.explosionCoefficient; y--) //go from top to bottom to favor light updates
{
if(y<8){//only spare blocks that are mostly below epicenter
y-= ExplosionNukeGeneric.destruction(this.worldObj, this.posX + x, this.posY + y, this.posZ + z);//spare blocks below
}else{//don't spare blocks above epicenter
private void breakColumn(int x, int z) {
int dist = this.radius2 - (x * x + z * z);
if(dist > 0) {
dist = (int) Math.sqrt(dist);
for(int y = dist; y > -dist * this.explosionCoefficient; y--) {
if(y < 8) {
y -= ExplosionNukeGeneric.destruction(this.worldObj, this.posX + x, this.posY + y, this.posZ + z);
} else {
ExplosionNukeGeneric.destruction(this.worldObj, this.posX + x, this.posY + y, this.posZ + z);
}
}
}
}
private void vapor(int x, int z)
{
private void vapor(int x, int z) {
int dist = this.radius2 - (x * x + z * z);
if (dist > 0)
{
if(dist > 0) {
dist = (int) Math.sqrt(dist);
//int dist0 = (int)Math.sqrt(this.radius2*0.15f - (x * x + z * z));
for (int y = dist; y > -dist * this.explosionCoefficient; y--)
{
y-=ExplosionNukeGeneric.vaporDest(this.worldObj, this.posX + x, this.posY + y, this.posZ + z);
/*
if(dist0>0){//skip blocks already in the destruction zone: we will
if(y>=dist0 || y<=-dist0*this.explosionCoefficient){
y-=ExplosionNukeGeneric.vaporDest(this.worldObj, this.posX + x, this.posY + y, this.posZ + z);
}
}else{
y-=ExplosionNukeGeneric.vaporDest(this.worldObj, this.posX + x, this.posY + y, this.posZ + z);
}*/
for(int y = dist; y > -dist * this.explosionCoefficient; y--) {
y -= ExplosionNukeGeneric.vaporDest(this.worldObj, this.posX + x, this.posY + y, this.posZ + z);
}
}
}
private void waste(int x, int z)
{
private void waste(int x, int z) {
int dist = this.radius2 - (x * x + z * z);
if (dist > 0)
{
if(dist > 0) {
dist = (int) Math.sqrt(dist);
for (int y = dist; y > -dist * this.explosionCoefficient; y--)
{
for(int y = dist; y > -dist * this.explosionCoefficient; y--) {
if(radius >= 95)
ExplosionNukeGeneric.wasteDest(this.worldObj, this.posX + x, this.posY + y, this.posZ + z);
else

View File

@ -1,519 +0,0 @@
package com.hbm.explosion;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.init.Blocks;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class ExplosionNukeRay {
List<FloatTriplet> affectedBlocks = new ArrayList<>();
int posX;
int posY;
int posZ;
World world;
int strength;
int length;
int processed;
int gspNumMax;
int gspNum;
double gspX;
double gspY;
public boolean isAusf3Complete = false;
/*[[unused]]
int count;
int speed;
int startY;
int startCir;
Random rand = new Random();
private double overrideRange = 0;
*/
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.length = length;
//Ausf3, must be double
//Mk 4.5, must be int32
// Total number of points
this.gspNumMax = (int)(2.5 * Math.PI * Math.pow(this.strength,2));
this.gspNum = 1;
// The beginning of the generalized spiral points
this.gspX = Math.PI;
this.gspY = 0.0;
/*[[unused]]
// this.startY = strength;
this.startY = 0;
this.startCir = 0;
this.count = count;
this.speed = speed;
//starts at around 80, becomes 8 at length 500
this.overrideRange = Math.max((Math.log(length) * 4 - 2.5D) * 10, 0);
*/
}
// Raise one generalized spiral points
private void generateGspUp(){
if (this.gspNum < this.gspNumMax) {
int k = this.gspNum + 1;
double hk = -1.0 + 2.0 * (k - 1.0) / (this.gspNumMax - 1.0);
this.gspX = Math.acos(hk);
double prev_lon = this.gspY;
double lon = prev_lon + 3.6 / Math.sqrt(this.gspNumMax) / Math.sqrt(1.0 - hk * hk);
this.gspY = lon % (Math.PI * 2);
} else {
this.gspX = 0.0;
this.gspY = 0.0;
}
this.gspNum++;
}
// Get Cartesian coordinates for spherical coordinates
private Vec3 getSpherical2cartesian(){
double dx = Math.sin(this.gspX) * Math.cos(this.gspY);
double dz = Math.sin(this.gspX) * Math.sin(this.gspY);
double dy = Math.cos(this.gspX);
return Vec3.createVectorHelper(dx, dy, dz);
}
//currently used by mk4
public void collectTipMk4_5(int count) {
int amountProcessed = 0;
while (this.gspNumMax >= this.gspNum){
// Get Cartesian coordinates for spherical coordinates
Vec3 vec = this.getSpherical2cartesian();
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));
double fac = 100 - ((double) i) / ((double) length) * 100;
fac *= 0.07D;
if(!world.getBlock((int)x0, (int)y0, (int)z0).getMaterial().isLiquid())
res -= Math.pow(world.getBlock((int)x0, (int)y0, (int)z0).getExplosionResistance(null), 7.5D - fac);
else
res -= Math.pow(Blocks.air.getExplosionResistance(null), 7.5D - fac);
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(lastPos);
}
break;
}
}
// Raise one generalized spiral points
this.generateGspUp();
amountProcessed++;
if(amountProcessed >= count) {
return;
}
}
isAusf3Complete = true;
}
public void processTip(int count) {
int processedBlocks = 0;
int braker = 0;
for(int l = 0; l < Integer.MAX_VALUE; l++) {
if(processedBlocks >= count)
return;
if(braker >= count * 50)
return;
if(l > affectedBlocks.size() - 1)
break;
if(affectedBlocks.isEmpty())
return;
int in = affectedBlocks.size() - 1;
float x = affectedBlocks.get(in).xCoord;
float y = affectedBlocks.get(in).yCoord;
float z = affectedBlocks.get(in).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.isAirBlock(x0, y0, z0)) {
world.setBlock(x0, y0, z0, Blocks.air);
processedBlocks++;
}
braker++;
}
affectedBlocks.remove(in);
}
processed += count;
}
/*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));
}
}
}
}*/
/*
@Untested //override range
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);
//Blast resistance calculations are still done to preserve the general shape,
//but if the blast were to be stopped within this range we go through with it anyway.
//There is currently no blast resistance limit on this, could change in the future.
boolean inOverrideRange = this.overrideRange >= length;
if((res > 0 || inOverrideRange) && world.getBlock((int)x0, (int)y0, (int)z0) != Blocks.air) {
lastPos = new FloatTriplet(x0, y0, z0);
}
// Only stop if we are either out of range or if the remaining strength is 0 while being outside the override range
if((res <= 0 && !inOverrideRange) || 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 collectTipExperimental(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));
double fac = 100 - ((double) i) / ((double) length) * 100;
fac *= 0.07D;
if(!world.getBlock((int)x0, (int)y0, (int)z0).getMaterial().isLiquid())
res -= Math.pow(world.getBlock((int)x0, (int)y0, (int)z0).getExplosionResistance(null), 7.5D - fac);
else
res -= Math.pow(Blocks.air.getExplosionResistance(null), 7.5D - fac);
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 collectTipAusf3(int count) {
int amountProcessed = 0;
//Axial
//StartY starts at this.length
for(double y = startY; y >= -strength; y -= (0.35D + ( Math.pow((strength - Math.abs(y)) / strength, 1.5D) * 0.3D))) {
double sectionRad = Math.sqrt(Math.pow(strength, 2) - Math.pow(y, 2));
double circumference = (1.5 * Math.PI * sectionRad + rand.nextDouble()) * (sectionRad / strength + 0.1D);
//circumference = Math.ceil(circumference);
//Radial
//StartCir starts at circumference
for(int r = startCir; r < circumference; r ++) {
Vec3 vec = Vec3.createVectorHelper(sectionRad, y, 0);
vec = vec.normalize();
if(y > 0)
vec.rotateAroundZ((float) (y / sectionRad) * 0.15F);
if(y < 0)
vec.rotateAroundZ((float) (y / sectionRad) * -0.15F);
vec.rotateAroundY((float) (360 / circumference * r));
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));
double fac = 100 - ((double) i) / ((double) length) * 100;
fac *= 0.07D;
if(!world.getBlock((int)x0, (int)y0, (int)z0).getMaterial().isLiquid())
res -= Math.pow(world.getBlock((int)x0, (int)y0, (int)z0).getExplosionResistance(null), 7.5D - fac);
else
res -= Math.pow(Blocks.air.getExplosionResistance(null), 7.5D - fac);
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;
}
}
amountProcessed++;
if(amountProcessed >= count) {
startY = y + 1;
startCir = startCir + 1;
return;
}
}
}
isAusf3Complete = true;
}*/
//Dysfunctional, punches hole into ground
/*public void collectTipAusf3(int count) {
int amountProcessed = 0;
//Axial
//StartY starts at this.length
for(int y = startY; y >= -length; y--) {
double circumference = 2 * Math.PI * Math.sqrt(Math.pow(y, 2) + Math.pow(length, 2));
circumference = Math.ceil(circumference);
//Radial
//StartCir starts at circumference
for(int r = startCir; r < circumference; r ++) {
Vec3 vec = Vec3.createVectorHelper(1, y, 0);
vec.normalize();
vec.rotateAroundY((float) (360 / circumference * r));
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));
double fac = 100 - ((double) i) / ((double) length) * 100;
fac *= 0.07D;
if(!world.getBlock((int)x0, (int)y0, (int)z0).getMaterial().isLiquid())
res -= Math.pow(world.getBlock((int)x0, (int)y0, (int)z0).getExplosionResistance(null), 7.5D - fac);
else
res -= Math.pow(Blocks.air.getExplosionResistance(null), 7.5D - fac);
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;
}
}
amountProcessed++;
if(amountProcessed >= count) {
startY = y + 1;
startCir = startCir + 1;
return;
}
}
}
isAusf3Complete = true;
}*/
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;
}
}
}

View File

@ -0,0 +1,23 @@
package com.hbm.explosion;
import com.hbm.blocks.ModBlocks;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class ExplosionNukeRayBalefire extends ExplosionNukeRayBatched {
public ExplosionNukeRayBalefire(World world, int x, int y, int z, int strength, int speed, int length) {
super(world, x, y, z, strength, speed, length);
}
protected void handleTip(int x, int y, int z) {
if(world.rand.nextInt(5) == 0 && world.getBlock(x, y - 1, z).isSideSolid(world, x, y - 1, z, ForgeDirection.UP)) {
world.setBlock(x, y, z, ModBlocks.balefire, 0, 3);
} else {
world.setBlock(x, y, z, Blocks.air, 0, 3);
}
}
}

View File

@ -234,12 +234,22 @@ public class ExplosionNukeRayBatched {
}
}
for(BlockPos pos : toRem) world.setBlock(pos.getX(), pos.getY(), pos.getZ(), Blocks.air, 0, toRemTips.contains(pos) ? 3 : 2);
for(BlockPos pos : toRem) {
if(toRemTips.contains(pos)) {
this.handleTip(pos.getX(), pos.getY(), pos.getZ());
} else {
world.setBlock(pos.getX(), pos.getY(), pos.getZ(), Blocks.air, 0, 2);
}
}
perChunk.remove(coord);
orderedChunks.remove(0);
}
protected void handleTip(int x, int y, int z) {
world.setBlock(x, y, z, Blocks.air, 0, 3);
}
public class FloatTriplet {
public float xCoord;
public float yCoord;