Search in sources :

Example 1 with EntityFireball

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);
}
Also used : EntityLiving(net.minecraft.entity.EntityLiving) EntityFireball(net.minecraft.entity.projectile.EntityFireball)

Example 2 with EntityFireball

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;
    }
}
Also used : Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) PacketSpawnParticle(pneumaticCraft.common.network.PacketSpawnParticle) TargetPoint(cpw.mods.fml.common.network.NetworkRegistry.TargetPoint) TargetPoint(cpw.mods.fml.common.network.NetworkRegistry.TargetPoint) PacketPlaySound(pneumaticCraft.common.network.PacketPlaySound) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) EntityItem(net.minecraft.entity.item.EntityItem) PacketSetEntityMotion(pneumaticCraft.common.network.PacketSetEntityMotion) EntityFireball(net.minecraft.entity.projectile.EntityFireball)

Aggregations

EntityFireball (net.minecraft.entity.projectile.EntityFireball)2 TargetPoint (cpw.mods.fml.common.network.NetworkRegistry.TargetPoint)1 Entity (net.minecraft.entity.Entity)1 EntityLiving (net.minecraft.entity.EntityLiving)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityItem (net.minecraft.entity.item.EntityItem)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 TileEntity (net.minecraft.tileentity.TileEntity)1 PacketPlaySound (pneumaticCraft.common.network.PacketPlaySound)1 PacketSetEntityMotion (pneumaticCraft.common.network.PacketSetEntityMotion)1 PacketSpawnParticle (pneumaticCraft.common.network.PacketSpawnParticle)1