Search in sources :

Example 1 with BlockBreakingInfo

use of net.minecraft.client.render.BlockBreakingInfo in project Client by MatHax.

the class BreakIndicators method renderNormal.

private void renderNormal(Render3DEvent event) {
    Map<Integer, BlockBreakingInfo> blocks = ((WorldRendererAccessor) mc.worldRenderer).getBlockBreakingInfos();
    float ownBreakingStage = ((ClientPlayerInteractionManagerAccessor) mc.interactionManager).getBreakingProgress();
    BlockPos ownBreakingPos = ((ClientPlayerInteractionManagerAccessor) mc.interactionManager).getCurrentBreakingBlockPos();
    if (ownBreakingPos != null && mc.interactionManager.isBreakingBlock()) {
        BlockState state = mc.world.getBlockState(ownBreakingPos);
        VoxelShape shape = state.getOutlineShape(mc.world, ownBreakingPos);
        if (shape.isEmpty() || shape == null)
            return;
        Box orig = shape.getBoundingBox();
        Box box = orig;
        double shrinkFactor = 1d - ownBreakingStage;
        double progress = 1d - shrinkFactor;
        renderBlock(event, box, orig, ownBreakingPos, shrinkFactor, progress);
    }
    blocks.values().forEach(info -> {
        BlockPos pos = info.getPos();
        int stage = info.getStage();
        if (pos.equals(ownBreakingPos))
            return;
        BlockState state = mc.world.getBlockState(pos);
        VoxelShape shape = state.getOutlineShape(mc.world, pos);
        if (shape.isEmpty())
            return;
        Box orig = shape.getBoundingBox();
        Box box = orig;
        double shrinkFactor = (9 - (stage + 1)) / 9d;
        double progress = 1d - shrinkFactor;
        renderBlock(event, box, orig, pos, shrinkFactor, progress);
    });
}
Also used : WorldRendererAccessor(mathax.client.mixin.WorldRendererAccessor) ClientPlayerInteractionManagerAccessor(mathax.client.mixin.ClientPlayerInteractionManagerAccessor) BlockState(net.minecraft.block.BlockState) VoxelShape(net.minecraft.util.shape.VoxelShape) BlockBreakingInfo(net.minecraft.client.render.BlockBreakingInfo) BlockPos(net.minecraft.util.math.BlockPos) Box(net.minecraft.util.math.Box)

Example 2 with BlockBreakingInfo

use of net.minecraft.client.render.BlockBreakingInfo in project meteor-client by MeteorDevelopment.

the class BreakIndicators method renderNormal.

private void renderNormal(Render3DEvent event) {
    Map<Integer, BlockBreakingInfo> blocks = ((WorldRendererAccessor) mc.worldRenderer).getBlockBreakingInfos();
    float ownBreakingStage = ((ClientPlayerInteractionManagerAccessor) mc.interactionManager).getBreakingProgress();
    BlockPos ownBreakingPos = ((ClientPlayerInteractionManagerAccessor) mc.interactionManager).getCurrentBreakingBlockPos();
    if (ownBreakingPos != null && mc.interactionManager.isBreakingBlock()) {
        BlockState state = mc.world.getBlockState(ownBreakingPos);
        VoxelShape shape = state.getOutlineShape(mc.world, ownBreakingPos);
        if (shape.isEmpty() || shape == null)
            return;
        Box orig = shape.getBoundingBox();
        Box box = orig;
        double shrinkFactor = 1d - ownBreakingStage;
        double progress = 1d - shrinkFactor;
        renderBlock(event, box, orig, ownBreakingPos, shrinkFactor, progress);
    }
    blocks.values().forEach(info -> {
        BlockPos pos = info.getPos();
        int stage = info.getStage();
        if (pos.equals(ownBreakingPos))
            return;
        BlockState state = mc.world.getBlockState(pos);
        VoxelShape shape = state.getOutlineShape(mc.world, pos);
        if (shape.isEmpty())
            return;
        Box orig = shape.getBoundingBox();
        Box box = orig;
        double shrinkFactor = (9 - (stage + 1)) / 9d;
        double progress = 1d - shrinkFactor;
        renderBlock(event, box, orig, pos, shrinkFactor, progress);
    });
}
Also used : WorldRendererAccessor(meteordevelopment.meteorclient.mixin.WorldRendererAccessor) ClientPlayerInteractionManagerAccessor(meteordevelopment.meteorclient.mixin.ClientPlayerInteractionManagerAccessor) BlockState(net.minecraft.block.BlockState) VoxelShape(net.minecraft.util.shape.VoxelShape) BlockBreakingInfo(net.minecraft.client.render.BlockBreakingInfo) BlockPos(net.minecraft.util.math.BlockPos) Box(net.minecraft.util.math.Box)

Aggregations

BlockState (net.minecraft.block.BlockState)2 BlockBreakingInfo (net.minecraft.client.render.BlockBreakingInfo)2 BlockPos (net.minecraft.util.math.BlockPos)2 Box (net.minecraft.util.math.Box)2 VoxelShape (net.minecraft.util.shape.VoxelShape)2 ClientPlayerInteractionManagerAccessor (mathax.client.mixin.ClientPlayerInteractionManagerAccessor)1 WorldRendererAccessor (mathax.client.mixin.WorldRendererAccessor)1 ClientPlayerInteractionManagerAccessor (meteordevelopment.meteorclient.mixin.ClientPlayerInteractionManagerAccessor)1 WorldRendererAccessor (meteordevelopment.meteorclient.mixin.WorldRendererAccessor)1