use of net.minecraft.entity.projectile.EntityFireball in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class RotationMatrices method applyTransform.
public static final void applyTransform(double[] wholeTransform, double[] rotationTransform, Entity ent) {
Vector entityPos = new Vector(ent.posX, ent.posY, ent.posZ);
Vector entityLook = new Vector(ent.getLook(1.0F));
Vector entityMotion = new Vector(ent.motionX, ent.motionY, ent.motionZ);
if (ent instanceof EntityFireball) {
EntityFireball ball = (EntityFireball) ent;
entityMotion.X = ball.accelerationX;
entityMotion.Y = ball.accelerationY;
entityMotion.Z = ball.accelerationZ;
}
applyTransform(wholeTransform, entityPos);
doRotationOnly(rotationTransform, entityLook);
doRotationOnly(rotationTransform, entityMotion);
entityLook.normalize();
// This is correct
ent.rotationPitch = (float) MathHelper.wrapDegrees(BigBastardMath.getPitchFromVec3d(entityLook));
ent.prevRotationPitch = ent.rotationPitch;
ent.rotationYaw = (float) MathHelper.wrapDegrees(BigBastardMath.getYawFromVec3d(entityLook, ent.rotationPitch));
ent.prevRotationYaw = ent.rotationYaw;
if (ent instanceof EntityLiving) {
EntityLiving living = (EntityLiving) ent;
living.rotationYawHead = ent.rotationYaw;
living.prevRotationYawHead = ent.rotationYaw;
}
if (ent instanceof EntityFireball) {
EntityFireball ball = (EntityFireball) ent;
ball.accelerationX = entityMotion.X;
ball.accelerationY = entityMotion.Y;
ball.accelerationZ = entityMotion.Z;
}
ent.motionX = entityMotion.X;
ent.motionY = entityMotion.Y;
ent.motionZ = entityMotion.Z;
ent.setPosition(entityPos.X, entityPos.Y, entityPos.Z);
}
use of net.minecraft.entity.projectile.EntityFireball in project PneumaticCraft by MineMaarten.
the class TileEntityAirCannon method fire.
private synchronized boolean fire() {
Entity itemShot = getCloseEntityIfUpgraded();
if (getPressure(ForgeDirection.UNKNOWN) >= PneumaticValues.MIN_PRESSURE_AIR_CANNON && (itemShot != null || inventory[0] != null)) {
double[] velocity = getVelocityVector(heightAngle, rotationAngle, getForce());
addAir((int) (-500 * getForce()), ForgeDirection.UNKNOWN);
boolean shootingInventory = false;
if (itemShot == null) {
shootingInventory = true;
itemShot = getPayloadEntity();
if (itemShot instanceof EntityItem) {
inventory[0] = null;
if (getUpgrades(ItemMachineUpgrade.UPGRADE_BLOCK_TRACKER) > 0) {
trackedItems.add((EntityItem) itemShot);
}
} else {
inventory[0].stackSize--;
if (inventory[0].stackSize <= 0)
inventory[0] = null;
}
} else if (itemShot instanceof EntityPlayer) {
EntityPlayerMP entityplayermp = (EntityPlayerMP) itemShot;
if (entityplayermp.playerNetServerHandler.func_147362_b().isChannelOpen()) {
entityplayermp.setPositionAndUpdate(xCoord + 0.5D, yCoord + 1.8D, zCoord + 0.5D);
}
}
if (itemShot.isRiding()) {
itemShot.mountEntity((Entity) null);
}
itemShot.setPosition(xCoord + 0.5D, yCoord + 1.8D, zCoord + 0.5D);
NetworkHandler.sendToAllAround(new PacketSetEntityMotion(itemShot, velocity[0], velocity[1], velocity[2]), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 64));
if (itemShot instanceof EntityFireball) {
velocity[0] *= 0.05D;
velocity[1] *= 0.05D;
velocity[2] *= 0.05D;
}
itemShot.motionX = velocity[0];
itemShot.motionY = velocity[1];
itemShot.motionZ = velocity[2];
itemShot.onGround = false;
itemShot.isCollided = false;
itemShot.isCollidedHorizontally = false;
itemShot.isCollidedVertically = false;
if (itemShot instanceof EntityLivingBase)
((EntityLivingBase) itemShot).setJumping(true);
if (shootingInventory && !worldObj.isRemote)
worldObj.spawnEntityInWorld(itemShot);
for (int i = 0; i < 10; i++) {
double velX = velocity[0] * 0.4D + (rand.nextGaussian() - 0.5D) * 0.05D;
double velY = velocity[1] * 0.4D + (rand.nextGaussian() - 0.5D) * 0.05D;
double velZ = velocity[2] * 0.4D + (rand.nextGaussian() - 0.5D) * 0.05D;
NetworkHandler.sendToAllAround(new PacketSpawnParticle("largesmoke", xCoord + 0.5D, yCoord + 0.7D, zCoord + 0.5D, velX, velY, velZ), worldObj);
}
NetworkHandler.sendToAllAround(new PacketPlaySound(Sounds.CANNON_SOUND, xCoord, yCoord, zCoord, 1.0F, rand.nextFloat() / 4F + 0.75F, true), worldObj);
return true;
} else {
return false;
}
}
Aggregations