Package net.minecraft.util

Examples of net.minecraft.util.Vec3


            this.shootingItem = ((EntityPlayer) shootingEntity).getCurrentEquippedItem();
            if (this.shootingItem != null) {
                this.damage = ModuleManager.computeModularProperty(shootingItem, BladeLauncherModule.BLADE_DAMAGE);
            }
        }
        Vec3 direction = shootingEntity.getLookVec().normalize();
        double speed = 1.0;
        double scale = 1;
        this.motionX = direction.xCoord * speed;
        this.motionY = direction.yCoord * speed;
        this.motionZ = direction.zCoord * speed;
 
View Full Code Here


    static final double root2 = Math.sqrt(2);

    public static MovingObjectPosition raytraceEntities(World world, EntityPlayer player, boolean collisionFlag, double reachDistance) {

        MovingObjectPosition pickedEntity = null;
        Vec3 playerPosition = Vec3.createVectorHelper(player.posX, player.posY + player.getEyeHeight(), player.posZ);
        Vec3 playerLook = player.getLookVec();

        Vec3 playerViewOffset = Vec3.createVectorHelper(playerPosition.xCoord + playerLook.xCoord * reachDistance, playerPosition.yCoord
                + playerLook.yCoord * reachDistance, playerPosition.zCoord + playerLook.zCoord * reachDistance);

        double playerBorder = 1.1 * reachDistance;
        AxisAlignedBB boxToScan = player.boundingBox.expand(playerBorder, playerBorder, playerBorder);
        // AxisAlignedBB boxToScan =
View Full Code Here

        }
        return pickedEntity;
    }

    public static MovingObjectPosition raytraceBlocks(World world, EntityPlayer player, boolean collisionFlag, double reachDistance) {
        Vec3 playerPosition = Vec3.createVectorHelper(player.posX, player.posY + player.getEyeHeight(), player.posZ);
        Vec3 playerLook = player.getLookVec();

        Vec3 playerViewOffset = Vec3.createVectorHelper(playerPosition.xCoord + playerLook.xCoord * reachDistance, playerPosition.yCoord
                + playerLook.yCoord * reachDistance, playerPosition.zCoord + playerLook.zCoord * reachDistance);
        return world.rayTraceBlocks(playerPosition, playerViewOffset);
    }
View Full Code Here

        if (pickedBlock == null) {
            return pickedEntity;
        } else if (pickedEntity == null) {
            return pickedBlock;
        } else {
            Vec3 playerPosition = Vec3.createVectorHelper(player.posX, player.posY + player.getEyeHeight(), player.posZ);
            double dBlock = pickedBlock.hitVec.distanceTo(playerPosition);
            double dEntity = pickedEntity.hitVec.distanceTo(playerPosition);
            if (dEntity < dBlock) {
                return pickedEntity;
            } else {
View Full Code Here

        float strafekey = movementInput.strafeKey;
        boolean downkey = movementInput.downKey;
        boolean sneakkey = movementInput.sneakKey;
        double thrustUsed = 0;
        if (flightControl) {
            Vec3 desiredDirection = player.getLookVec().normalize();
            double strafeX = desiredDirection.zCoord;
            double strafeZ = -desiredDirection.xCoord;
            double scaleStrafe = (strafeX * strafeX + strafeZ * strafeZ);
            double flightVerticality = 0;
            ItemStack helm = player.getCurrentArmor(3);
            if (helm != null && helm.getItem() instanceof IModularItem) {
                flightVerticality = ModuleManager.computeModularProperty(helm, FlightControlModule.FLIGHT_VERTICALITY);
            }
            desiredDirection.xCoord = desiredDirection.xCoord * Math.signum(forwardkey) + strafeX * Math.signum(strafekey);
            desiredDirection.yCoord = flightVerticality * desiredDirection.yCoord * Math.signum(forwardkey) + (jumpkey ? 1 : 0) - (downkey ? 1 : 0);
            desiredDirection.zCoord = desiredDirection.zCoord * Math.signum(forwardkey) + strafeZ * Math.signum(strafekey);

            desiredDirection = desiredDirection.normalize();
            // Gave up on this... I suck at math apparently
            // double ux = player.motionX / thrust;
            // double uy = player.motionY / thrust;
            // double uz = player.motionZ / thrust;
            // double vx = desiredDirection.xCoord;
            // double vy = desiredDirection.yCoord;
            // double vz = desiredDirection.zCoord;
            // double b = (2 * ux * vx + 2 * uy * vy + 2 * uz * vz);
            // double c = (ux * ux + uy * uy + uz * uz - 1);
            //
            // double actualThrust = (-b + Math.sqrt(b * b - 4 * c))
            // / (2);
            //
            // player.motionX = desiredDirection.xCoord *
            // actualThrust;
            // player.motionY = desiredDirection.yCoord *
            // actualThrust;
            // player.motionZ = desiredDirection.zCoord *
            // actualThrust;

            // Brakes
            if (player.motionY < 0 && desiredDirection.yCoord >= 0) {
                if (-player.motionY > thrust) {
                    player.motionY += thrust;
                    thrustUsed += thrust;
                    thrust = 0;
                } else {
                    thrust -= player.motionY;
                    thrustUsed += player.motionY;
                    player.motionY = 0;
                }
            }
            if (player.motionY < -1) {
                thrust += 1 + player.motionY;
                thrustUsed -= 1 + player.motionY;
                player.motionY = -1;
            }
            if (Math.abs(player.motionX) > 0 && desiredDirection.lengthVector() == 0) {
                if (Math.abs(player.motionX) > thrust) {
                    player.motionX -= Math.signum(player.motionX) * thrust;
                    thrustUsed += thrust;
                    thrust = 0;
                } else {
                    thrust -= Math.abs(player.motionX);
                    thrustUsed += Math.abs(player.motionX);
                    player.motionX = 0;
                }
            }
            if (Math.abs(player.motionZ) > 0 && desiredDirection.lengthVector() == 0) {
                if (Math.abs(player.motionZ) > thrust) {
                    player.motionZ -= Math.signum(player.motionZ) * thrust;
                    thrustUsed += thrust;
                    thrust = 0;
                } else {
                    thrustUsed += Math.abs(player.motionZ);
                    thrust -= Math.abs(player.motionZ);
                    player.motionZ = 0;
                }
            }

            // Thrusting, finally :V
            double vx = thrust * desiredDirection.xCoord;
            double vy = thrust * desiredDirection.yCoord;
            double vz = thrust * desiredDirection.zCoord;
            player.motionX += vx;
            player.motionY += vy;
            player.motionZ += vz;
            thrustUsed += thrust;

        } else {
            Vec3 playerHorzFacing = player.getLookVec();
            playerHorzFacing.yCoord = 0;
            playerHorzFacing.normalize();
            if (forwardkey == 0) {
                player.motionY += thrust;
            } else {
                player.motionY += thrust / root2;
                player.motionX += playerHorzFacing.xCoord * thrust / root2 * Math.signum(forwardkey);
 
View Full Code Here

    public String getDescription() {
        return "An assembly which accelerates a projectile to supersonic speeds using magnetic force. Heavy recoil.";
    }

    public void drawParticleStreamTo(EntityPlayer source, World world, double x, double y, double z) {
        Vec3 direction = source.getLookVec().normalize();
        double scale = 1.0;
        double xoffset = 1.3f;
        double yoffset = -.2;
        double zoffset = 0.3f;
        Vec3 horzdir = direction.normalize();
        horzdir.yCoord = 0;
        horzdir = horzdir.normalize();
        double cx = source.posX + direction.xCoord * xoffset - direction.yCoord * horzdir.xCoord * yoffset - horzdir.zCoord * zoffset;
        double cy = source.posY + source.getEyeHeight() + direction.yCoord * xoffset + (1 - Math.abs(direction.yCoord)) * yoffset;
        double cz = source.posZ + direction.zCoord * xoffset - direction.yCoord * horzdir.zCoord * yoffset + horzdir.xCoord * zoffset;
        double dx = x - cx;
        double dy = y - cy;
View Full Code Here

            MovingObjectPosition hitMOP = MusePlayerUtils.doCustomRayTrace(player.worldObj, player, true, range);
            world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / ((float) Math.random() * 0.4F + 0.8F));

            double damage = ModuleManager.computeModularProperty(itemStack, IMPULSE) / 100.0;
            double knockback = damage / 20.0;
            Vec3 lookVec = player.getLookVec();
            if (hitMOP != null) {
                switch (hitMOP.typeOfHit) {
                    case ENTITY:
                        drawParticleStreamTo(player, world, hitMOP.hitVec.xCoord, hitMOP.hitVec.yCoord, hitMOP.hitVec.zCoord);
                        DamageSource damageSource = DamageSource.causePlayerDamage(player);
View Full Code Here

            map.put(side, value);
    }

    private Map<ForgeDirection, Vec3> calculateHitPoints(Vec3 near, Vec3 far)
    {
        Vec3 diff = far.subtract(near);

        Map<ForgeDirection, Vec3> result = Maps.newEnumMap(ForgeDirection.class);
        addPoint(result, ForgeDirection.WEST, calculateXPoint(near, diff, negX));
        addPoint(result, ForgeDirection.EAST, calculateXPoint(near, diff, posX));
View Full Code Here

    }

    public Map<ForgeDirection, Vec3> calculateMouseHits()
    {
        OpenGLLib.updateMatrices();
        Vec3 near = getMouseVector(0);
        Vec3 far = getMouseVector(1);

        return calculateHitPoints(near, far);
    }
View Full Code Here

    }

    public HitCoord getNearestHit()
    {
        OpenGLLib.updateMatrices();
        Vec3 near = getMouseVector(0);
        Vec3 far = getMouseVector(1);

        Map<ForgeDirection, Vec3> hits = calculateHitPoints(near, far);

        if (hits.isEmpty())
            return null;
View Full Code Here

TOP

Related Classes of net.minecraft.util.Vec3

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.