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;
}
}
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;
});
}
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;
}
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;
}
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;
}
Aggregations