diff --git a/com/hbm/blocks/test/TestEventTester.java b/com/hbm/blocks/test/TestEventTester.java index c1593d0a7..3a9016ec0 100644 --- a/com/hbm/blocks/test/TestEventTester.java +++ b/com/hbm/blocks/test/TestEventTester.java @@ -12,6 +12,8 @@ import com.hbm.entity.effect.EntityBlackHole; import com.hbm.entity.effect.EntityCloudFleija; import com.hbm.entity.effect.EntityCloudFleijaRainbow; import com.hbm.entity.projectile.EntityMeteor; +import com.hbm.explosion.ExplosionNukeRay; +import com.hbm.explosion.ExplosionNukeRay.FloatTriplet; import com.hbm.main.MainRegistry; import com.hbm.main.ModEventHandler; import com.hbm.potion.PotionEffectTaint; @@ -24,6 +26,7 @@ import net.minecraft.block.material.Material; import net.minecraft.enchantment.EnchantmentProtection; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import net.minecraft.tileentity.TileEntity; @@ -240,7 +243,7 @@ public class TestEventTester extends Block { - if(!worldObj.isRemote) { + /*if(!worldObj.isRemote) { SatelliteSavedData data = (SatelliteSavedData)worldObj.perWorldStorage.loadData(SatelliteSavedData.class, "satellites"); if(data == null) { worldObj.perWorldStorage.setData("satellites", new SatelliteSavedData(worldObj)); @@ -251,7 +254,10 @@ public class TestEventTester extends Block { par5EntityPlayer.addChatComponentMessage(new ChatComponentText(sat.satelliteID + ": " + sat.satelliteType.name())); } data.markDirty(); - } + }*/ + + if(!worldObj.isRemote) + buildEvent(worldObj, par2, par3, par4, 30); return true; } @@ -272,6 +278,33 @@ public class TestEventTester extends Block { return true; }*/ + + public void buildEvent(World world, int x, int y, int z, int r) { + + Random rand = new Random(); + + for(double h = r; h >= -r; h -= (0.2D + ((r - Math.abs(h)) / r * 0.6D))) { + + double sectionRad = Math.sqrt(Math.pow(r, 2) - Math.pow(h, 2)); + double circumference = 4 * Math.PI * sectionRad + rand.nextGaussian() * 0.5 + 0.25D; + + System.out.println(h + " " + circumference); + + for(int c = 0; c < circumference; c++) { + + Vec3 vec = Vec3.createVectorHelper(sectionRad, h, 0); + vec = vec.normalize(); + //vec.rotateAroundZ((float) (h / sectionRad) * -2); + vec.rotateAroundY((float) (360 / circumference * c)); + + int dX = (int) Math.round(vec.xCoord * r + x); + int dY = (int) Math.round(vec.yCoord * r + y); + int dZ = (int) Math.round(vec.zCoord * r + z); + + world.setBlock(dX, dY, dZ, Blocks.gold_block); + } + } + } public void killEvent(World world, int x, int y, int z) { diff --git a/com/hbm/creativetabs/MachineTab.java b/com/hbm/creativetabs/MachineTab.java index 8ebd2b906..5805affb1 100644 --- a/com/hbm/creativetabs/MachineTab.java +++ b/com/hbm/creativetabs/MachineTab.java @@ -11,7 +11,6 @@ public class MachineTab extends CreativeTabs { public MachineTab(int p_i1853_1_, String p_i1853_2_) { super(p_i1853_1_, p_i1853_2_); - setBackgroundImageName("item_search.png"); } @Override diff --git a/com/hbm/creativetabs/TemplateTab.java b/com/hbm/creativetabs/TemplateTab.java index 388c92b19..d5609a3ea 100644 --- a/com/hbm/creativetabs/TemplateTab.java +++ b/com/hbm/creativetabs/TemplateTab.java @@ -11,6 +11,7 @@ public class TemplateTab extends CreativeTabs { public TemplateTab(int p_i1853_1_, String p_i1853_2_) { super(p_i1853_1_, p_i1853_2_); + setBackgroundImageName("item_search.png"); } @Override diff --git a/com/hbm/entity/logic/EntityNukeExplosionMK4.java b/com/hbm/entity/logic/EntityNukeExplosionMK4.java index f82ea3d54..9bc3cb8a9 100644 --- a/com/hbm/entity/logic/EntityNukeExplosionMK4.java +++ b/com/hbm/entity/logic/EntityNukeExplosionMK4.java @@ -7,6 +7,7 @@ import com.hbm.explosion.ExplosionNukeRay; import com.hbm.main.MainRegistry; import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; @@ -46,15 +47,23 @@ public class EntityNukeExplosionMK4 extends Entity { ExplosionNukeGeneric.dealDamage(this.worldObj, (int)this.posX, (int)this.posY, (int)this.posZ, this.length * 2); - if(explosion == null) + 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(!worldObj.isRemote) + for(int x = (int) (posX - 1); x <= (int) (posX + 1); x++) + for(int y = (int) (posY - 1); y <= (int) (posY + 1); y++) + for(int z = (int) (posZ - 1); z <= (int) (posZ + 1); z++) + worldObj.setBlock(x, y, z, Blocks.air); + } - if(explosion.getStoredSize() < count / length) { + //if(explosion.getStoredSize() < count / length) { + if(!explosion.isAusf3Complete) { //if(!worldObj.isRemote) //MainRegistry.logger.info(explosion.getStoredSize() + " / " + count / length); //explosion.collectTip(speed * 10); - explosion.collectTipExperimental(speed * 10); - } else if(explosion.getProgress() < (count / length) * 0.99) { + explosion.collectTipAusf3(speed * 10); + } else if(explosion.getStoredSize() > 0) { //if(!worldObj.isRemote) //MainRegistry.logger.info(explosion.getProgress() + " / " + count / length); explosion.processTip(speed); diff --git a/com/hbm/explosion/ExplosionNukeRay.java b/com/hbm/explosion/ExplosionNukeRay.java index 638e2c384..684a36391 100644 --- a/com/hbm/explosion/ExplosionNukeRay.java +++ b/com/hbm/explosion/ExplosionNukeRay.java @@ -25,6 +25,9 @@ public class ExplosionNukeRay { int speed; int processed; int length; + double startY; + int startCir; + public boolean isAusf3Complete = false; public ExplosionNukeRay(World world, int x, int y, int z, int strength, int count, int speed, int length) { this.world = world; @@ -35,6 +38,8 @@ public class ExplosionNukeRay { this.count = count; this.speed = speed; this.length = length; + this.startY = strength; + this.startCir = 0; } /*public void processBunch(int count) { @@ -93,14 +98,17 @@ public class ExplosionNukeRay { }*/ public void processTip(int count) { - for(int l = processed; l < processed + count; l++) { + for(int l = 0; l < 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; + if(affectedBlocks.isEmpty()) + return; + + float x = affectedBlocks.get(0).xCoord; + float y = affectedBlocks.get(0).yCoord; + float z = affectedBlocks.get(0).zCoord; world.setBlock((int)x, (int)y, (int)z, Blocks.air); @@ -117,6 +125,8 @@ public class ExplosionNukeRay { //if(world.getBlock(x0, y0, z0) != Blocks.air) world.setBlock(x0, y0, z0, Blocks.air); } + + affectedBlocks.remove(0); } processed += count; @@ -213,6 +223,147 @@ public class ExplosionNukeRay { } } + 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(); }