Search in sources :

Example 1 with ClientPlayerInteractionManagerAccessor

use of mathax.client.mixin.ClientPlayerInteractionManagerAccessor 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)

Aggregations

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