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);
}
}
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();
}
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));
}
}
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());
}
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());
}
}
}
Aggregations