Search in sources :

Example 21 with VoxelShape

use of net.minecraft.util.shape.VoxelShape in project Hypnotic-Client by Hypnotic-Development.

the class RenderUtils method drawOutlineBox.

public static void drawOutlineBox(MatrixStack matrixStack, Box bb, Color color, boolean draw) {
    Color color1 = color;
    Matrix4f matrix4f = matrixStack.peek().getPositionMatrix();
    BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
    if (draw)
        bufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINES, /*LINES*/
        VertexFormats.POSITION_COLOR);
    VoxelShape shape = VoxelShapes.cuboid(bb);
    shape.forEachEdge((x1, y1, z1, x2, y2, z2) -> {
        bufferBuilder.vertex(matrix4f, (float) x1, (float) y1, (float) z1).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
        bufferBuilder.vertex(matrix4f, (float) x2, (float) y2, (float) z2).color(color1.getRed(), color1.getGreen(), color1.getBlue(), color1.getAlpha()).next();
    });
    if (draw) {
        bufferBuilder.end();
        BufferRenderer.draw(bufferBuilder);
    }
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) IMatrix4f(dev.hypnotic.utils.mixin.IMatrix4f) VoxelShape(net.minecraft.util.shape.VoxelShape) Color(java.awt.Color) BufferBuilder(net.minecraft.client.render.BufferBuilder)

Example 22 with VoxelShape

use of net.minecraft.util.shape.VoxelShape in project Hypnotic-Client by Hypnotic-Development.

the class BlockMixin method pushEntitiesUpBeforeBlockChange.

@Inject(method = "pushEntitiesUpBeforeBlockChange", at = @At("HEAD"), cancellable = true)
private static void pushEntitiesUpBeforeBlockChange(BlockState from, BlockState to, World world, BlockPos pos, CallbackInfoReturnable<BlockState> cir) {
    VoxelShape voxelShape = VoxelShapes.combine(from.getCollisionShape(world, pos), to.getCollisionShape(world, pos), BooleanBiFunction.ONLY_SECOND).offset((double) pos.getX(), (double) pos.getY(), (double) pos.getZ());
    EventCollide.Block event = new EventCollide.Block(voxelShape.getBoundingBox(), pos);
    event.call();
    if (event.isCancelled())
        cir.cancel();
}
Also used : EventCollide(dev.hypnotic.event.events.EventCollide) VoxelShape(net.minecraft.util.shape.VoxelShape) Block(net.minecraft.block.Block) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 23 with VoxelShape

use of net.minecraft.util.shape.VoxelShape in project Biome-Makeover by Lemonszz.

the class AdjudicatorFangGoal method conjureFangs.

private void conjureFangs(double x, double z, double maxY, double y, float yaw, int warmup) {
    BlockPos blockPos = new BlockPos(x, y, z);
    boolean bl = false;
    double d = 0.0D;
    do {
        BlockPos blockPos2 = blockPos.down();
        BlockState blockState = adjudicator.world.getBlockState(blockPos2);
        if (blockState.isSideSolidFullSquare(adjudicator.world, blockPos2, Direction.UP)) {
            if (!adjudicator.world.isAir(blockPos)) {
                BlockState blockState2 = adjudicator.world.getBlockState(blockPos);
                VoxelShape voxelShape = blockState2.getCollisionShape(adjudicator.world, blockPos);
                if (!voxelShape.isEmpty()) {
                    d = voxelShape.getMax(Direction.Axis.Y);
                }
            }
            bl = true;
            break;
        }
        blockPos = blockPos.down();
    } while (blockPos.getY() >= MathHelper.floor(maxY) - 1);
    if (bl) {
        adjudicator.world.spawnEntity(new EvokerFangsEntity(adjudicator.world, x, (double) blockPos.getY() + d, z, yaw, warmup, adjudicator));
    }
}
Also used : BlockState(net.minecraft.block.BlockState) VoxelShape(net.minecraft.util.shape.VoxelShape) BlockPos(net.minecraft.util.math.BlockPos) EvokerFangsEntity(net.minecraft.entity.mob.EvokerFangsEntity)

Example 24 with VoxelShape

use of net.minecraft.util.shape.VoxelShape in project JexClient by DustinRepo.

the class MixinPowderSnowBlock method getCollisionShape.

@Inject(method = "getCollisionShape", at = @At("HEAD"), cancellable = true)
public void getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> ci) {
    EntityShapeContext entityShapeContext;
    Entity entity;
    VoxelShape shape = null;
    if (context instanceof EntityShapeContext && (entity = (entityShapeContext = (EntityShapeContext) context).getEntity()) != null) {
        if (entity.fallDistance > 2.5f) {
            shape = FALLING_SHAPE;
        }
        boolean bl = entity instanceof FallingBlockEntity;
        if (bl || PowderSnowBlock.canWalkOnPowderSnow(entity) && context.isAbove(VoxelShapes.fullCube(), pos, false) && !context.isDescending()) {
            shape = super.getCollisionShape(state, world, pos, context);
        }
    }
    EventBlockCollisionShape eventBlockCollisionShape = new EventBlockCollisionShape(pos, state.getBlock(), shape).run();
    if (eventBlockCollisionShape.isCancelled())
        ci.setReturnValue(eventBlockCollisionShape.getVoxelShape());
}
Also used : FallingBlockEntity(net.minecraft.entity.FallingBlockEntity) Entity(net.minecraft.entity.Entity) FallingBlockEntity(net.minecraft.entity.FallingBlockEntity) VoxelShape(net.minecraft.util.shape.VoxelShape) EventBlockCollisionShape(me.dustin.jex.event.world.EventBlockCollisionShape) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 25 with VoxelShape

use of net.minecraft.util.shape.VoxelShape in project Client by MatHax.

the class ClickTP method onTick.

@EventHandler
private void onTick(TickEvent.Post event) {
    if (mc.player.isUsingItem())
        return;
    if (mc.options.useKey.isPressed()) {
        HitResult hitResult = mc.player.raycast(maxDistance.get(), 1f / 20f, false);
        if (hitResult.getType() == HitResult.Type.ENTITY && mc.player.interact(((EntityHitResult) hitResult).getEntity(), Hand.MAIN_HAND) != ActionResult.PASS)
            return;
        if (hitResult.getType() == HitResult.Type.BLOCK) {
            BlockPos pos = ((BlockHitResult) hitResult).getBlockPos();
            Direction side = ((BlockHitResult) hitResult).getSide();
            if (mc.world.getBlockState(pos).onUse(mc.world, mc.player, Hand.MAIN_HAND, (BlockHitResult) hitResult) != ActionResult.PASS)
                return;
            BlockState state = mc.world.getBlockState(pos);
            VoxelShape shape = state.getCollisionShape(mc.world, pos);
            if (shape.isEmpty())
                shape = state.getOutlineShape(mc.world, pos);
            double height = shape.isEmpty() ? 1 : shape.getMax(Direction.Axis.Y);
            mc.player.setPosition(pos.getX() + 0.5 + side.getOffsetX(), pos.getY() + height, pos.getZ() + 0.5 + side.getOffsetZ());
        }
    }
}
Also used : BlockHitResult(net.minecraft.util.hit.BlockHitResult) HitResult(net.minecraft.util.hit.HitResult) EntityHitResult(net.minecraft.util.hit.EntityHitResult) BlockState(net.minecraft.block.BlockState) VoxelShape(net.minecraft.util.shape.VoxelShape) BlockPos(net.minecraft.util.math.BlockPos) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Direction(net.minecraft.util.math.Direction) EventHandler(mathax.client.eventbus.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