mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Raytracing CWIS, removed unnecessary out.printlns
This commit is contained in:
parent
d0a9a5cbf9
commit
687bd1a617
@ -144,9 +144,6 @@ public class NukeCustom extends BlockContainer implements IBomb {
|
|||||||
float schrab = f[5];
|
float schrab = f[5];
|
||||||
float euph = f[6];
|
float euph = f[6];
|
||||||
|
|
||||||
System.out.println(tnt);
|
|
||||||
System.out.println(nuke);
|
|
||||||
|
|
||||||
if(euph > 0) {
|
if(euph > 0) {
|
||||||
EntityGrenadeZOMG zomg = new EntityGrenadeZOMG(world);
|
EntityGrenadeZOMG zomg = new EntityGrenadeZOMG(world);
|
||||||
zomg.posX = x + 0.5;
|
zomg.posX = x + 0.5;
|
||||||
|
|||||||
@ -1,11 +1,15 @@
|
|||||||
package com.hbm.blocks.bomb;
|
package com.hbm.blocks.bomb;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.hbm.entity.particle.EntityGasFlameFX;
|
import com.hbm.entity.particle.EntityGasFlameFX;
|
||||||
import com.hbm.entity.projectile.EntityBullet;
|
import com.hbm.entity.projectile.EntityBullet;
|
||||||
|
import com.hbm.lib.ModDamageSource;
|
||||||
import com.hbm.tileentity.bomb.TileEntityTurretCWIS;
|
import com.hbm.tileentity.bomb.TileEntityTurretCWIS;
|
||||||
import com.hbm.tileentity.bomb.TileEntityTurretSpitfire;
|
import com.hbm.tileentity.bomb.TileEntityTurretSpitfire;
|
||||||
|
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.Vec3;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@ -36,7 +40,7 @@ public class TurretCWIS extends TurretBase {
|
|||||||
if(te.spin < 35)
|
if(te.spin < 35)
|
||||||
te.spin += 5;
|
te.spin += 5;
|
||||||
|
|
||||||
if(te.spin > 25) {
|
if(te.spin > 25 && i % 2 == 0) {
|
||||||
Vec3 vector = Vec3.createVectorHelper(
|
Vec3 vector = Vec3.createVectorHelper(
|
||||||
-Math.sin(yaw / 180.0F * (float) Math.PI) * Math.cos(pitch / 180.0F * (float) Math.PI),
|
-Math.sin(yaw / 180.0F * (float) Math.PI) * Math.cos(pitch / 180.0F * (float) Math.PI),
|
||||||
-Math.sin(pitch / 180.0F * (float) Math.PI),
|
-Math.sin(pitch / 180.0F * (float) Math.PI),
|
||||||
@ -45,22 +49,12 @@ public class TurretCWIS extends TurretBase {
|
|||||||
vector.normalize();
|
vector.normalize();
|
||||||
|
|
||||||
if(!world.isRemote) {
|
if(!world.isRemote) {
|
||||||
EntityBullet bullet = new EntityBullet(world);
|
|
||||||
bullet.posX = x + vector.xCoord * 2.5 + 0.5;
|
|
||||||
bullet.posY = y + vector.yCoord * 2.5 + 1.5;
|
|
||||||
bullet.posZ = z + vector.zCoord * 2.5 + 0.5;
|
|
||||||
|
|
||||||
bullet.motionX = vector.xCoord * 3;
|
rayShot(world, vector, x + vector.xCoord * 2.5 + 0.5, y + vector.yCoord * 2.5 + 0.5, z + vector.zCoord * 2.5 + 0.5, 100, 10.0F, 50);
|
||||||
bullet.motionY = vector.yCoord * 3;
|
|
||||||
bullet.motionZ = vector.zCoord * 3;
|
|
||||||
|
|
||||||
bullet.setDamage(65 + rand.nextInt(55));
|
|
||||||
|
|
||||||
world.spawnEntityInWorld(bullet);
|
|
||||||
|
|
||||||
EntityGasFlameFX smoke = new EntityGasFlameFX(world);
|
EntityGasFlameFX smoke = new EntityGasFlameFX(world);
|
||||||
smoke.posX = x + vector.xCoord * 2.5 + 0.5;
|
smoke.posX = x + vector.xCoord * 2.5 + 0.5;
|
||||||
smoke.posY = y + vector.yCoord * 2.5 + 1;
|
smoke.posY = y + vector.yCoord * 2.5 + 1.5;
|
||||||
smoke.posZ = z + vector.zCoord * 2.5 + 0.5;
|
smoke.posZ = z + vector.zCoord * 2.5 + 0.5;
|
||||||
|
|
||||||
smoke.motionX = vector.xCoord * 0.25;
|
smoke.motionX = vector.xCoord * 0.25;
|
||||||
@ -78,6 +72,27 @@ public class TurretCWIS extends TurretBase {
|
|||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void rayShot(World world, Vec3 vec, double posX, double posY, double posZ, int range, float damage, int hitPercent) {
|
||||||
|
List<Entity> entities = world.getLoadedEntityList();
|
||||||
|
|
||||||
|
for(float i = 0; i < range; i += 0.25F) {
|
||||||
|
double pX = posX + vec.xCoord * i;
|
||||||
|
double pY = posY + vec.yCoord * i;
|
||||||
|
double pZ = posZ + vec.zCoord * i;
|
||||||
|
|
||||||
|
for(int j = 0; j < entities.size(); j++) {
|
||||||
|
Entity ent = entities.get(j);
|
||||||
|
if(rand.nextInt(100) < hitPercent) {
|
||||||
|
if(ent.posX + ent.width * 0.75 > pX && ent.posX - ent.width * 0.75 < pX &&
|
||||||
|
ent.posY + ent.height > pY && ent.posY < pY &&
|
||||||
|
ent.posZ + ent.width * 0.75 > pZ && ent.posZ - ent.width * 0.75 < pZ) {
|
||||||
|
ent.attackEntityFrom(ModDamageSource.shrapnel, (damage * 0.25F) + (rand.nextFloat() * damage * 0.75F));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void executeReleaseAction(World world, int i, double yaw, double pitch, int x, int y, int z) { }
|
public void executeReleaseAction(World world, int i, double yaw, double pitch, int x, int y, int z) { }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,7 +35,7 @@ public abstract class EntityMissileBaseAdvanced extends Entity implements IChunk
|
|||||||
double accelXZ;
|
double accelXZ;
|
||||||
boolean isCluster = false;
|
boolean isCluster = false;
|
||||||
private Ticket loaderTicket;
|
private Ticket loaderTicket;
|
||||||
public int health = 10;
|
public int health = 50;
|
||||||
|
|
||||||
public EntityMissileBaseAdvanced(World p_i1582_1_) {
|
public EntityMissileBaseAdvanced(World p_i1582_1_) {
|
||||||
super(p_i1582_1_);
|
super(p_i1582_1_);
|
||||||
|
|||||||
@ -143,7 +143,6 @@ public class ExplosionLarge {
|
|||||||
for(int i = 0; i < debris.size(); i++) {
|
for(int i = 0; i < debris.size(); i++) {
|
||||||
if(debris.get(i) != null) {
|
if(debris.get(i) != null) {
|
||||||
int k = rand.nextInt(debris.get(i).stackSize + 1);
|
int k = rand.nextInt(debris.get(i).stackSize + 1);
|
||||||
System.out.println(k);
|
|
||||||
for(int j = 0; j < k; j++) {
|
for(int j = 0; j < k; j++) {
|
||||||
EntityItem item = new EntityItem(world, x, y, z, new ItemStack(debris.get(i).getItem()));
|
EntityItem item = new EntityItem(world, x, y, z, new ItemStack(debris.get(i).getItem()));
|
||||||
item.motionX = (motionX + rand.nextGaussian() * deviation) * 0.85;
|
item.motionX = (motionX + rand.nextGaussian() * deviation) * 0.85;
|
||||||
|
|||||||
@ -44,8 +44,6 @@ public class WeaponizedCell extends Item {
|
|||||||
|
|
||||||
int randy = (60 * 20) - item.ticksExisted;
|
int randy = (60 * 20) - item.ticksExisted;
|
||||||
|
|
||||||
System.out.println(randy);
|
|
||||||
|
|
||||||
if(randy < 1)
|
if(randy < 1)
|
||||||
randy = 1;
|
randy = 1;
|
||||||
|
|
||||||
@ -63,7 +61,7 @@ public class WeaponizedCell extends Item {
|
|||||||
@Override
|
@Override
|
||||||
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool) {
|
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool) {
|
||||||
|
|
||||||
list.add("A charged energ cell, rigged to explode");
|
list.add("A charged energy cell, rigged to explode");
|
||||||
list.add("when left on the floor for too long.");
|
list.add("when left on the floor for too long.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,9 +61,8 @@ public abstract class TileEntityTurretBase extends TileEntity {
|
|||||||
|
|
||||||
Vec3 turret = Vec3.createVectorHelper(target.posX - (xCoord + 0.5), target.posY + target.getEyeHeight() - (yCoord + 1), target.posZ - (zCoord + 0.5));
|
Vec3 turret = Vec3.createVectorHelper(target.posX - (xCoord + 0.5), target.posY + target.getEyeHeight() - (yCoord + 1), target.posZ - (zCoord + 0.5));
|
||||||
|
|
||||||
if(this instanceof TileEntityTurretCWIS) {
|
if(this instanceof TileEntityTurretCWIS || this instanceof TileEntityTurretSpitfire) {
|
||||||
double[] est = getEstPos(Vec3.createVectorHelper(xCoord + 0.5, yCoord + 1.5, zCoord + 0.5), target);
|
turret = Vec3.createVectorHelper(target.posX - (xCoord + 0.5), target.posY + target.getEyeHeight() - (yCoord + 1.5), target.posZ - (zCoord + 0.5));
|
||||||
turret = Vec3.createVectorHelper(est[0] - (xCoord + 0.5), est[1] - (yCoord + 1.5), est[2] - (zCoord + 0.5));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rotationPitch = -Math.asin(turret.yCoord/turret.lengthVector()) * 180 / Math.PI;
|
rotationPitch = -Math.asin(turret.yCoord/turret.lengthVector()) * 180 / Math.PI;
|
||||||
@ -117,28 +116,7 @@ public abstract class TileEntityTurretBase extends TileEntity {
|
|||||||
if(this instanceof TileEntityTurretTau)
|
if(this instanceof TileEntityTurretTau)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(this instanceof TileEntityTurretCWIS) {
|
return !Library.isObstructed(worldObj, turret.xCoord, turret.yCoord, turret.zCoord, entity.xCoord, entity.yCoord, entity.zCoord);
|
||||||
double[] est = getEstPos(turret, e);
|
|
||||||
return !Library.isObstructed(worldObj, turret.xCoord, turret.yCoord, turret.zCoord, est[0], est[1], est[2]);
|
|
||||||
} else {
|
|
||||||
return !Library.isObstructed(worldObj, turret.xCoord, turret.yCoord, turret.zCoord, entity.xCoord, entity.yCoord, entity.zCoord);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public double[] getEstPos(Vec3 turret, Entity e) {
|
|
||||||
Vec3 dist = Vec3.createVectorHelper(e.posX - turret.xCoord, e.posY - turret.yCoord, e.posZ - turret.zCoord);
|
|
||||||
double travelTime = dist.lengthVector() / 3;
|
|
||||||
double acc = 1;
|
|
||||||
|
|
||||||
if(e instanceof EntityMissileBaseAdvanced) {
|
|
||||||
acc = ((EntityMissileBaseAdvanced)e).velocity;
|
|
||||||
}
|
|
||||||
|
|
||||||
double estX = e.posX + e.motionX * travelTime * acc;
|
|
||||||
double estY = e.posY + e.motionY * travelTime * acc;
|
|
||||||
double estZ = e.posZ + e.motionZ * travelTime * acc;
|
|
||||||
|
|
||||||
return new double[] {estX, estY, estZ};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user