Raytracing CWIS, removed unnecessary out.printlns

This commit is contained in:
HbmMods 2018-02-12 17:05:54 +01:00
parent d0a9a5cbf9
commit 687bd1a617
6 changed files with 33 additions and 46 deletions

View File

@ -143,9 +143,6 @@ public class NukeCustom extends BlockContainer implements IBomb {
float dirty = f[4];
float schrab = f[5];
float euph = f[6];
System.out.println(tnt);
System.out.println(nuke);
if(euph > 0) {
EntityGrenadeZOMG zomg = new EntityGrenadeZOMG(world);

View File

@ -1,11 +1,15 @@
package com.hbm.blocks.bomb;
import java.util.List;
import com.hbm.entity.particle.EntityGasFlameFX;
import com.hbm.entity.projectile.EntityBullet;
import com.hbm.lib.ModDamageSource;
import com.hbm.tileentity.bomb.TileEntityTurretCWIS;
import com.hbm.tileentity.bomb.TileEntityTurretSpitfire;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
@ -36,7 +40,7 @@ public class TurretCWIS extends TurretBase {
if(te.spin < 35)
te.spin += 5;
if(te.spin > 25) {
if(te.spin > 25 && i % 2 == 0) {
Vec3 vector = Vec3.createVectorHelper(
-Math.sin(yaw / 180.0F * (float) Math.PI) * Math.cos(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();
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;
bullet.motionY = vector.yCoord * 3;
bullet.motionZ = vector.zCoord * 3;
bullet.setDamage(65 + rand.nextInt(55));
world.spawnEntityInWorld(bullet);
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);
EntityGasFlameFX smoke = new EntityGasFlameFX(world);
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.motionX = vector.xCoord * 0.25;
@ -77,6 +71,27 @@ public class TurretCWIS extends TurretBase {
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
public void executeReleaseAction(World world, int i, double yaw, double pitch, int x, int y, int z) { }

View File

@ -35,7 +35,7 @@ public abstract class EntityMissileBaseAdvanced extends Entity implements IChunk
double accelXZ;
boolean isCluster = false;
private Ticket loaderTicket;
public int health = 10;
public int health = 50;
public EntityMissileBaseAdvanced(World p_i1582_1_) {
super(p_i1582_1_);

View File

@ -143,7 +143,6 @@ public class ExplosionLarge {
for(int i = 0; i < debris.size(); i++) {
if(debris.get(i) != null) {
int k = rand.nextInt(debris.get(i).stackSize + 1);
System.out.println(k);
for(int j = 0; j < k; j++) {
EntityItem item = new EntityItem(world, x, y, z, new ItemStack(debris.get(i).getItem()));
item.motionX = (motionX + rand.nextGaussian() * deviation) * 0.85;

View File

@ -44,8 +44,6 @@ public class WeaponizedCell extends Item {
int randy = (60 * 20) - item.ticksExisted;
System.out.println(randy);
if(randy < 1)
randy = 1;
@ -63,7 +61,7 @@ public class WeaponizedCell extends Item {
@Override
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.");
}
}

View File

@ -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));
if(this instanceof TileEntityTurretCWIS) {
double[] est = getEstPos(Vec3.createVectorHelper(xCoord + 0.5, yCoord + 1.5, zCoord + 0.5), target);
turret = Vec3.createVectorHelper(est[0] - (xCoord + 0.5), est[1] - (yCoord + 1.5), est[2] - (zCoord + 0.5));
if(this instanceof TileEntityTurretCWIS || this instanceof TileEntityTurretSpitfire) {
turret = Vec3.createVectorHelper(target.posX - (xCoord + 0.5), target.posY + target.getEyeHeight() - (yCoord + 1.5), target.posZ - (zCoord + 0.5));
}
rotationPitch = -Math.asin(turret.yCoord/turret.lengthVector()) * 180 / Math.PI;
@ -117,28 +116,7 @@ public abstract class TileEntityTurretBase extends TileEntity {
if(this instanceof TileEntityTurretTau)
return true;
if(this instanceof TileEntityTurretCWIS) {
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};
return !Library.isObstructed(worldObj, turret.xCoord, turret.yCoord, turret.zCoord, entity.xCoord, entity.yCoord, entity.zCoord);
}
@Override