Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // prevent moused over blocks being outlined in the usual way (ie. by raytracing from player to block)
- @SubscribeEvent
- public static void onHighlightBlockEvent(DrawSelectionEvent.HighlightBlock evt) {
- if (MC.level != null) {
- drawSelectionBox(evt.getMatrix());
- evt.setCanceled(true);
- }
- }
- static BlockPos testBlockPos = new BlockPos(346,64,-273);
- public static void drawSelectionBox(PoseStack matrix)
- {
- Entity camEntity = MC.getCameraEntity();
- BlockPos blockpos = testBlockPos;
- BlockState blockstate = MC.level.getBlockState(blockpos);
- double d0 = camEntity.getX();
- double d1 = camEntity.getY() + camEntity.getEyeHeight();
- double d2 = camEntity.getZ();
- if (!blockstate.isAir()) {
- VertexConsumer vertexConsumer = MC.renderBuffers().bufferSource().getBuffer(RenderType.lines());
- final double xIn = (double) blockpos.getX() - d0;
- final double yIn = (double) blockpos.getY() - d1;
- final double zIn = (double) blockpos.getZ() - d2;
- VoxelShape shapeIn = blockstate.getShape(MC.level, blockpos); // need to put back in ISelectionThingo?
- Matrix4f matrix4f = matrix.last().pose();
- shapeIn.forAllEdges((x0, y0, z0, x1, y1, z1) ->
- {
- vertexConsumer.vertex(matrix4f, (float) (x0 + xIn), (float) (y0 + yIn), (float) (z0 + zIn)).color(1.0f,1.0f,1.0f,1.0f).endVertex();
- vertexConsumer.vertex(matrix4f, (float) (x1 + xIn), (float) (y1 + yIn), (float) (z1 + zIn)).color(1.0f,1.0f,1.0f,1.0f).endVertex();
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement