Search in sources :

Example 1 with ItemBlueprint

use of com.lowdragmc.multiblocked.api.item.ItemBlueprint in project Multiblocked by Low-Drag-MC.

the class BlueprintRegionRenderer method onRenderWorldLast.

@SubscribeEvent
public static void onRenderWorldLast(RenderWorldLastEvent event) {
    Minecraft mc = Minecraft.getInstance();
    PlayerEntity p = mc.player;
    if (p == null)
        return;
    ItemStack held = p.getItemInHand(Hand.MAIN_HAND);
    if (held.getItem() instanceof ItemBlueprint) {
        BlockPos[] poses = ItemBlueprint.getPos(held);
        if (poses == null)
            return;
        MatrixStack stack = event.getMatrixStack();
        Vector3d pos = mc.gameRenderer.getMainCamera().getPosition();
        stack.pushPose();
        stack.translate(-pos.x, -pos.y, -pos.z);
        RenderSystem.disableDepthTest();
        RenderSystem.disableTexture();
        RenderSystem.enableBlend();
        RenderSystem.disableCull();
        RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder buffer = tessellator.getBuilder();
        buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
        RenderBufferUtils.renderCubeFace(stack, buffer, poses[0].getX(), poses[0].getY(), poses[0].getZ(), poses[1].getX() + 1, poses[1].getY() + 1, poses[1].getZ() + 1, 0.2f, 0.2f, 1f, 0.25f, true);
        tessellator.end();
        buffer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
        RenderSystem.lineWidth(3);
        RenderBufferUtils.renderCubeFrame(stack, buffer, poses[0].getX(), poses[0].getY(), poses[0].getZ(), poses[1].getX() + 1, poses[1].getY() + 1, poses[1].getZ() + 1, 0.0f, 0.0f, 1f, 0.5f);
        tessellator.end();
        RenderSystem.enableCull();
        RenderSystem.disableBlend();
        RenderSystem.enableTexture();
        RenderSystem.enableDepthTest();
        // RenderSystem.color4f(1, 1, 1, 1);
        stack.popPose();
    }
}
Also used : ItemBlueprint(com.lowdragmc.multiblocked.api.item.ItemBlueprint) Tessellator(net.minecraft.client.renderer.Tessellator) Vector3d(net.minecraft.util.math.vector.Vector3d) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) PlayerEntity(net.minecraft.entity.player.PlayerEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

ItemBlueprint (com.lowdragmc.multiblocked.api.item.ItemBlueprint)1 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 Minecraft (net.minecraft.client.Minecraft)1 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)1 Tessellator (net.minecraft.client.renderer.Tessellator)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 ItemStack (net.minecraft.item.ItemStack)1 BlockPos (net.minecraft.util.math.BlockPos)1 Vector3d (net.minecraft.util.math.vector.Vector3d)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1