Search in sources :

Example 16 with VoxelShape

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();
        }
    }
}
Also used : BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe) ModuleCategory(org.bleachhack.module.ModuleCategory) EventClientMove(org.bleachhack.event.events.EventClientMove) Box(net.minecraft.util.math.Box) EventWorldRender(org.bleachhack.event.events.EventWorldRender) BlockPos(net.minecraft.util.math.BlockPos) Renderer(org.bleachhack.util.render.Renderer) VoxelShape(net.minecraft.util.shape.VoxelShape) Mode(net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket.Mode) Module(org.bleachhack.module.Module) QuadColor(org.bleachhack.util.render.color.QuadColor) LadderBlock(net.minecraft.block.LadderBlock) Stream(java.util.stream.Stream) Vec3d(net.minecraft.util.math.Vec3d) SettingColor(org.bleachhack.setting.module.SettingColor) SettingToggle(org.bleachhack.setting.module.SettingToggle) Comparator(java.util.Comparator) ClientCommandC2SPacket(net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket) EventTick(org.bleachhack.event.events.EventTick) VoxelShape(net.minecraft.util.shape.VoxelShape) ClientCommandC2SPacket(net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket) LadderBlock(net.minecraft.block.LadderBlock) Box(net.minecraft.util.math.Box) BlockPos(net.minecraft.util.math.BlockPos) Vec3d(net.minecraft.util.math.Vec3d) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 17 with VoxelShape

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;
}
Also used : VoxelShape(net.minecraft.util.shape.VoxelShape) BlockState(net.minecraft.block.BlockState) LilyPadBlock(net.minecraft.block.LilyPadBlock)

Example 18 with VoxelShape

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);
        }
    }
}
Also used : VoxelShape(net.minecraft.util.shape.VoxelShape) PacketMine(meteordevelopment.meteorclient.systems.modules.player.PacketMine) Box(net.minecraft.util.math.Box) BlockPos(net.minecraft.util.math.BlockPos)

Example 19 with VoxelShape

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;
}
Also used : BlockState(net.minecraft.block.BlockState) VoxelShape(net.minecraft.util.shape.VoxelShape)

Example 20 with VoxelShape

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();
}
Also used : VoxelShape(net.minecraft.util.shape.VoxelShape) Box(net.minecraft.util.math.Box) EventHandler(meteordevelopment.orbit.EventHandler)

Aggregations

VoxelShape (net.minecraft.util.shape.VoxelShape)62 BlockState (net.minecraft.block.BlockState)22 BlockPos (net.minecraft.util.math.BlockPos)22 Box (net.minecraft.util.math.Box)14 Vec3d (net.minecraft.util.math.Vec3d)10 Direction (net.minecraft.util.math.Direction)7 DoomFireEntity (mod.azure.doom.entity.projectiles.entity.DoomFireEntity)6 Inject (org.spongepowered.asm.mixin.injection.Inject)5 ArrayList (java.util.ArrayList)4 ChunkAwareBlockCollisionSweeper (me.jellysquid.mods.lithium.common.entity.movement.ChunkAwareBlockCollisionSweeper)4 Entity (net.minecraft.entity.Entity)4 EventHandler (mathax.client.eventbus.EventHandler)3 EventHandler (meteordevelopment.orbit.EventHandler)3 Block (net.minecraft.block.Block)3 EvokerFangsEntity (net.minecraft.entity.mob.EvokerFangsEntity)3 BleachSubscribe (org.bleachhack.eventbus.BleachSubscribe)3 Redirect (org.spongepowered.asm.mixin.injection.Redirect)3 IMatrix4f (dev.hypnotic.utils.mixin.IMatrix4f)2 Color (java.awt.Color)2 Iterator (java.util.Iterator)2