Search in sources :

Example 1 with ItemBlueprint

use of com.cleanroommc.multiblocked.api.item.ItemBlueprint in project Multiblocked by CleanroomMC.

the class BlueprintRegionRenderer method render.

public static void render(RenderWorldLastEvent event) {
    EntityPlayerSP p = Minecraft.getMinecraft().player;
    ItemStack held = p.getHeldItemMainhand();
    if (held.getItem() instanceof ItemBlueprint) {
        BlockPos[] poses = ItemBlueprint.getPos(held);
        if (poses == null)
            return;
        double doubleX = p.lastTickPosX + (p.posX - p.lastTickPosX) * event.getPartialTicks();
        double doubleY = p.lastTickPosY + (p.posY - p.lastTickPosY) * event.getPartialTicks();
        double doubleZ = p.lastTickPosZ + (p.posZ - p.lastTickPosZ) * event.getPartialTicks();
        GlStateManager.pushMatrix();
        GlStateManager.translate(-doubleX, -doubleY, -doubleZ);
        GlStateManager.disableDepth();
        GlStateManager.disableTexture2D();
        GlStateManager.enableBlend();
        GlStateManager.disableCull();
        GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder buffer = tessellator.getBuffer();
        buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
        RenderBufferUtils.renderCubeFace(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.draw();
        buffer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
        GlStateManager.glLineWidth(3);
        RenderBufferUtils.renderCubeFrame(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.draw();
        GlStateManager.enableCull();
        GlStateManager.disableBlend();
        GlStateManager.enableTexture2D();
        GlStateManager.enableDepth();
        GlStateManager.color(1, 1, 1);
        GlStateManager.popMatrix();
    }
}
Also used : ItemBlueprint(com.cleanroommc.multiblocked.api.item.ItemBlueprint) Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) BlockPos(net.minecraft.util.math.BlockPos) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemBlueprint (com.cleanroommc.multiblocked.api.item.ItemBlueprint)1 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)1 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)1 Tessellator (net.minecraft.client.renderer.Tessellator)1 ItemStack (net.minecraft.item.ItemStack)1 BlockPos (net.minecraft.util.math.BlockPos)1