Search in sources :

Example 1 with RaycastContext

use of net.minecraft.world.RaycastContext in project meteor-rejects by AntiCope.

the class Confuse method onTick.

@EventHandler
private void onTick(TickEvent.Pre event) {
    // Delay
    delayWaited++;
    if (delayWaited < delay.get())
        return;
    delayWaited = 0;
    // Targetting
    target = TargetUtils.getPlayerTarget(range.get(), priority.get());
    if (target == null)
        return;
    Vec3d entityPos = target.getPos();
    Vec3d playerPos = mc.player.getPos();
    Random r = new Random();
    BlockHitResult hit;
    int halfRange = range.get() / 2;
    switch(mode.get()) {
        case RandomTP:
            double x = r.nextDouble() * range.get() - halfRange;
            double y = 0;
            double z = r.nextDouble() * range.get() - halfRange;
            Vec3d addend = new Vec3d(x, y, z);
            Vec3d goal = entityPos.add(addend);
            if (mc.world.getBlockState(new BlockPos(goal.x, goal.y, goal.z)).getBlock() != Blocks.AIR) {
                goal = new Vec3d(x, playerPos.y, z);
            }
            if (mc.world.getBlockState(new BlockPos(goal.x, goal.y, goal.z)).getBlock() == Blocks.AIR) {
                hit = mc.world.raycast(new RaycastContext(mc.player.getPos(), goal, RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.ANY, mc.player));
                if (!moveThroughBlocks.get() && hit.isInsideBlock()) {
                    delayWaited = (int) (delay.get() - 1);
                    break;
                }
                mc.player.updatePosition(goal.x, goal.y, goal.z);
            } else {
                delayWaited = (int) (delay.get() - 1);
            }
            break;
        case Switch:
            Vec3d diff = entityPos.subtract(playerPos);
            Vec3d diff1 = new Vec3d(Utils.clamp(diff.x, -halfRange, halfRange), Utils.clamp(diff.y, -halfRange, halfRange), Utils.clamp(diff.z, -halfRange, halfRange));
            Vec3d goal2 = entityPos.add(diff1);
            hit = mc.world.raycast(new RaycastContext(mc.player.getPos(), goal2, RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.ANY, mc.player));
            if (!moveThroughBlocks.get() && hit.isInsideBlock()) {
                delayWaited = (int) (delay.get() - 1);
                break;
            }
            mc.player.updatePosition(goal2.x, goal2.y, goal2.z);
            break;
        case Circle:
            delay.set(0);
            circleProgress += circleSpeed.get();
            if (circleProgress > 360)
                circleProgress -= 360;
            double rad = Math.toRadians(circleProgress);
            double sin = Math.sin(rad) * 3;
            double cos = Math.cos(rad) * 3;
            Vec3d current = new Vec3d(entityPos.x + sin, playerPos.y, entityPos.z + cos);
            hit = mc.world.raycast(new RaycastContext(mc.player.getPos(), current, RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.ANY, mc.player));
            if (!moveThroughBlocks.get() && hit.isInsideBlock())
                break;
            mc.player.updatePosition(current.x, current.y, current.z);
            break;
    }
}
Also used : Random(java.util.Random) RaycastContext(net.minecraft.world.RaycastContext) BlockPos(net.minecraft.util.math.BlockPos) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Vec3d(net.minecraft.util.math.Vec3d) EventHandler(meteordevelopment.orbit.EventHandler)

Example 2 with RaycastContext

use of net.minecraft.world.RaycastContext in project FallingAttackFabric by hamusuke0323.

the class FallingAttackShockWave method getEntitiesStruckByShockWave.

public List<LivingEntity> getEntitiesStruckByShockWave() {
    return this.world.getEntitiesByClass(LivingEntity.class, this.box, livingEntity -> {
        double d = distanceTo2D(livingEntity.getPos(), this.pos);
        boolean flag = !this.exceptEntities.contains(livingEntity) && !livingEntity.isSpectator() && livingEntity != this.owner && d >= this.secondary.getRadius() && this.primary.getRadius() >= d;
        for (int i = 0; i < 2 && flag; i++) {
            Vec3d vec3d = new Vec3d(livingEntity.getX(), livingEntity.getBodyY(0.5D * (double) i), livingEntity.getZ());
            HitResult hitResult = this.world.raycast(new RaycastContext(this.pos, vec3d, RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.NONE, this.owner));
            if (hitResult.getType() == HitResult.Type.MISS) {
                return true;
            }
        }
        return false;
    });
}
Also used : HitResult(net.minecraft.util.hit.HitResult) RaycastContext(net.minecraft.world.RaycastContext) Vec3d(net.minecraft.util.math.Vec3d)

Example 3 with RaycastContext

use of net.minecraft.world.RaycastContext in project BleachHack by BleachDrinker420.

the class WorldUtils method getLegitLookPos.

public static Vec3d getLegitLookPos(Box box, Direction dir, boolean raycast, int res, double extrude) {
    Vec3d eyePos = mc.player.getEyePos();
    Vec3d blockPos = new Vec3d(box.minX, box.minY, box.minZ).add((dir == Direction.WEST ? -extrude : dir.getOffsetX() * box.getXLength() + extrude), (dir == Direction.DOWN ? -extrude : dir.getOffsetY() * box.getYLength() + extrude), (dir == Direction.NORTH ? -extrude : dir.getOffsetZ() * box.getZLength() + extrude));
    for (double i = 0; i <= 1; i += 1d / (double) res) {
        for (double j = 0; j <= 1; j += 1d / (double) res) {
            Vec3d lookPos = blockPos.add((dir.getAxis() == Axis.X ? 0 : i * box.getXLength()), (dir.getAxis() == Axis.Y ? 0 : dir.getAxis() == Axis.Z ? j * box.getYLength() : i * box.getYLength()), (dir.getAxis() == Axis.Z ? 0 : j * box.getZLength()));
            if (eyePos.distanceTo(lookPos) > 4.55)
                continue;
            if (raycast) {
                if (mc.world.raycast(new RaycastContext(eyePos, lookPos, RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.NONE, mc.player)).getType() == HitResult.Type.MISS) {
                    return lookPos;
                }
            } else {
                return lookPos;
            }
        }
    }
    return null;
}
Also used : RaycastContext(net.minecraft.world.RaycastContext) Vec3d(net.minecraft.util.math.Vec3d)

Example 4 with RaycastContext

use of net.minecraft.world.RaycastContext in project orion by AntiCope.

the class AutoCityPlus method getDirection.

private Direction getDirection(BlockPos pos) {
    // stolen from supakeks ez
    Vec3d eyesPos = new Vec3d(mc.player.getX(), mc.player.getY() + mc.player.getEyeHeight(mc.player.getPose()), mc.player.getZ());
    for (Direction direction : Direction.values()) {
        RaycastContext raycastContext = new RaycastContext(eyesPos, new Vec3d(pos.getX() + 0.5 + direction.getVector().getX() * 0.5, pos.getY() + 0.5 + direction.getVector().getY() * 0.5, pos.getZ() + 0.5 + direction.getVector().getZ() * 0.5), RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.NONE, mc.player);
        BlockHitResult result = mc.world.raycast(raycastContext);
        if (result != null && result.getType() == HitResult.Type.BLOCK && result.getBlockPos().equals(pos)) {
            return direction;
        }
    }
    if ((double) pos.getY() > eyesPos.y) {
        // The player can never see the top of a block if they are under it
        return Direction.DOWN;
    }
    return Direction.UP;
}
Also used : RaycastContext(net.minecraft.world.RaycastContext) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Direction(net.minecraft.util.math.Direction) Vec3d(net.minecraft.util.math.Vec3d)

Example 5 with RaycastContext

use of net.minecraft.world.RaycastContext in project Client by MatHax.

the class Notebot method rayTraceCheck.

// Stolen from crystal aura :)
private Direction rayTraceCheck(BlockPos pos) {
    Vec3d eyesPos = new Vec3d(mc.player.getX(), mc.player.getY() + mc.player.getEyeHeight(mc.player.getPose()), mc.player.getZ());
    for (Direction direction : Direction.values()) {
        RaycastContext raycastContext = new RaycastContext(eyesPos, new Vec3d(pos.getX() + 0.5 + direction.getVector().getX() * 0.5, pos.getY() + 0.5 + direction.getVector().getY() * 0.5, pos.getZ() + 0.5 + direction.getVector().getZ() * 0.5), RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.NONE, mc.player);
        BlockHitResult result = mc.world.raycast(raycastContext);
        if (result != null && result.getType() == HitResult.Type.BLOCK && result.getBlockPos().equals(pos))
            return direction;
    }
    if (pos.getY() > eyesPos.y)
        return Direction.DOWN;
    return Direction.UP;
}
Also used : RaycastContext(net.minecraft.world.RaycastContext) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Direction(net.minecraft.util.math.Direction) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

RaycastContext (net.minecraft.world.RaycastContext)16 BlockHitResult (net.minecraft.util.hit.BlockHitResult)12 Vec3d (net.minecraft.util.math.Vec3d)11 HitResult (net.minecraft.util.hit.HitResult)4 BlockPos (net.minecraft.util.math.BlockPos)4 PlayerEntity (net.minecraft.entity.player.PlayerEntity)3 List (java.util.List)2 IVec3d (meteordevelopment.meteorclient.mixininterface.IVec3d)2 EventHandler (meteordevelopment.orbit.EventHandler)2 BlockEntity (net.minecraft.block.entity.BlockEntity)2 Entity (net.minecraft.entity.Entity)2 CompoundTag (net.minecraft.nbt.CompoundTag)2 Hand (net.minecraft.util.Hand)2 Box (net.minecraft.util.math.Box)2 Direction (net.minecraft.util.math.Direction)2 BaritoneAPI (baritone.api.BaritoneAPI)1 FloatingBlock (com.aether.blocks.FloatingBlock)1 AetherNonLivingEntity (com.aether.entities.AetherNonLivingEntity)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1