use of net.minecraft.util.shape.VoxelShape in project BleachHack by BleachDrinker420.
the class AutoParkour method onTick.
@BleachSubscribe
public void onTick(EventTick event) {
if (smartPos != null) {
if (mc.player.getY() - 0.5 < smartPos.getY() && mc.player.getVelocity().y < 0) {
smartPos = null;
}
}
if (!mc.player.isSneaking() && mc.player.isOnGround()) {
smartPos = null;
Box box = mc.player.getBoundingBox().offset(0, -0.51, 0);
Stream<VoxelShape> blockCollisions = mc.world.getBlockCollisions(mc.player, box);
if (blockCollisions.findAny().isEmpty()) {
if (getSetting(0).asToggle().getState() && !mc.player.isSprinting()) {
mc.player.setSprinting(true);
mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, Mode.START_SPRINTING));
}
if (getSetting(1).asToggle().getState()) {
Vec3d lookVec = mc.player.getPos().add(new Vec3d(0, 0, 3.5).rotateY(-(float) Math.toRadians(mc.player.getYaw())));
BlockPos nearestPos = BlockPos.streamOutwards(mc.player.getBlockPos().down(), 4, 1, 4).map(BlockPos::toImmutable).filter(pos -> (mc.world.isTopSolid(pos, mc.player) && mc.world.getBlockCollisions(mc.player, new Box(pos.up(), pos.add(1, 3, 1))).findAny().isEmpty()) || mc.world.getBlockState(pos).getBlock() instanceof LadderBlock || mc.world.getBlockState(pos.up()).getBlock() instanceof LadderBlock).filter(pos -> mc.player.getPos().distanceTo(Vec3d.of(pos).add(0.5, 1, 0.5)) >= 1).filter(pos -> mc.player.getPos().distanceTo(Vec3d.of(pos).add(0.5, 1, 0.5)) <= 4.5).sorted(Comparator.comparing(pos -> pos.getSquaredDistance(lookVec, false))).findFirst().orElse(null);
if (nearestPos != null) {
smartPos = nearestPos;
}
}
mc.player.jump();
}
}
}
use of net.minecraft.util.shape.VoxelShape in project wildmod by Osmiooo.
the class ChestBoatEntity method method_7548.
public float method_7548() {
Box box = this.getBoundingBox();
Box box2 = new Box(box.minX, box.minY - 0.001D, box.minZ, box.maxX, box.minY, box.maxZ);
int i = MathHelper.floor(box2.minX) - 1;
int j = MathHelper.ceil(box2.maxX) + 1;
int k = MathHelper.floor(box2.minY) - 1;
int l = MathHelper.ceil(box2.maxY) + 1;
int m = MathHelper.floor(box2.minZ) - 1;
int n = MathHelper.ceil(box2.maxZ) + 1;
VoxelShape voxelShape = VoxelShapes.cuboid(box2);
float f = 0.0F;
int o = 0;
BlockPos.Mutable mutable = new BlockPos.Mutable();
for (int p = i; p < j; ++p) {
for (int q = m; q < n; ++q) {
int r = (p != i && p != j - 1 ? 0 : 1) + (q != m && q != n - 1 ? 0 : 1);
if (r != 2) {
for (int s = k; s < l; ++s) {
if (r <= 0 || s != k && s != l - 1) {
mutable.set(p, s, q);
BlockState blockState = this.world.getBlockState(mutable);
if (!(blockState.getBlock() instanceof LilyPadBlock) && VoxelShapes.matchesAnywhere(blockState.getCollisionShape(this.world, mutable).offset((double) p, (double) s, (double) q), voxelShape, BooleanBiFunction.AND)) {
f += blockState.getBlock().getSlipperiness();
++o;
}
}
}
}
}
}
return f / (float) o;
}
use of net.minecraft.util.shape.VoxelShape in project meteor-client by MeteorDevelopment.
the class BreakIndicators method renderPacket.
private void renderPacket(Render3DEvent event, List<PacketMine.MyBlock> blocks) {
for (PacketMine.MyBlock block : blocks) {
if (block.mining && block.progress != Double.POSITIVE_INFINITY) {
VoxelShape shape = block.blockState.getOutlineShape(mc.world, block.blockPos);
if (shape.isEmpty())
return;
Box orig = shape.getBoundingBox();
Box box = orig;
double progressNormalised = block.progress > 1 ? 1 : block.progress;
double shrinkFactor = 1d - progressNormalised;
BlockPos pos = block.blockPos;
renderBlock(event, box, orig, pos, shrinkFactor, progressNormalised);
}
}
}
use of net.minecraft.util.shape.VoxelShape in project meteor-client by MeteorDevelopment.
the class SBlock method isNeighbour.
private boolean isNeighbour(Direction dir) {
blockPos.set(x + dir.getOffsetX(), y + dir.getOffsetY(), z + dir.getOffsetZ());
BlockState neighbourState = mc.world.getBlockState(blockPos);
if (neighbourState.getBlock() != state.getBlock())
return false;
VoxelShape cube = VoxelShapes.fullCube();
VoxelShape shape = state.getOutlineShape(mc.world, blockPos);
VoxelShape neighbourShape = neighbourState.getOutlineShape(mc.world, blockPos);
if (shape.isEmpty())
shape = cube;
if (neighbourShape.isEmpty())
neighbourShape = cube;
switch(dir) {
case SOUTH:
if (shape.getMax(Direction.Axis.Z) == 1 && neighbourShape.getMin(Direction.Axis.Z) == 0)
return true;
break;
case NORTH:
if (shape.getMin(Direction.Axis.Z) == 0 && neighbourShape.getMax(Direction.Axis.Z) == 1)
return true;
break;
case EAST:
if (shape.getMax(Direction.Axis.X) == 1 && neighbourShape.getMin(Direction.Axis.X) == 0)
return true;
break;
case WEST:
if (shape.getMin(Direction.Axis.X) == 0 && neighbourShape.getMax(Direction.Axis.X) == 1)
return true;
break;
case UP:
if (shape.getMax(Direction.Axis.Y) == 1 && neighbourShape.getMin(Direction.Axis.Y) == 0)
return true;
break;
case DOWN:
if (shape.getMin(Direction.Axis.Y) == 0 && neighbourShape.getMax(Direction.Axis.Y) == 1)
return true;
break;
}
return false;
}
use of net.minecraft.util.shape.VoxelShape in project meteor-client by MeteorDevelopment.
the class Parkour method onTick.
@EventHandler
private void onTick(TickEvent.Post event) {
if (!mc.player.isOnGround() || mc.options.jumpKey.isPressed())
return;
if (mc.player.isSneaking() || mc.options.sneakKey.isPressed())
return;
Box box = mc.player.getBoundingBox();
Box adjustedBox = box.offset(0, -0.5, 0).expand(-0.001, 0, -0.001);
Stream<VoxelShape> blockCollisions = Streams.stream(mc.world.getBlockCollisions(mc.player, adjustedBox));
if (blockCollisions.findAny().isPresent())
return;
mc.player.jump();
}
Aggregations