Search in sources :

Example 1 with ItemBlockSelectorFloating

use of ivorius.reccomplex.item.ItemBlockSelectorFloating in project RecurrentComplex by Ivorforce.

the class SelectionRenderer method renderSelection.

public static void renderSelection(EntityLivingBase entity, int ticks, float partialTicks) {
    Minecraft mc = Minecraft.getMinecraft();
    BlockPos selPoint1 = null;
    BlockPos selPoint2 = null;
    SelectionOwner owner = SelectionOwner.getOwner(entity, null);
    if (owner != null) {
        selPoint1 = owner.getSelectedPoint1();
        selPoint2 = owner.getSelectedPoint2();
    }
    GL11.glLineWidth(3.0f);
    if (selPoint1 != null) {
        GlStateManager.color(0.6f, 0.8f, 0.95f);
        AreaRenderer.renderAreaLined(new BlockArea(selPoint1, selPoint1), 0.03f);
    }
    if (selPoint2 != null) {
        GlStateManager.color(0.2f, 0.45f, 0.65f);
        AreaRenderer.renderAreaLined(new BlockArea(selPoint2, selPoint2), 0.04f);
    }
    for (EnumHand enumHand : EnumHand.values()) {
        ItemStack heldItem = entity.getHeldItem(enumHand);
        if (heldItem != null && heldItem.getItem() instanceof ItemBlockSelectorFloating) {
            float selectionRange = ((ItemBlockSelectorFloating) heldItem.getItem()).getSelectionRange(heldItem);
            BlockPos hoverPoint = ItemBlockSelectorFloating.getHoveredBlock(entity, selectionRange);
            GlStateManager.color(0.6f, 0.6f, 1.0f);
            AreaRenderer.renderAreaLined(new BlockArea(hoverPoint, hoverPoint), 0.05f);
        }
    }
    if (selPoint1 != null && selPoint2 != null) {
        BlockArea selArea = new BlockArea(selPoint1, selPoint2);
        GlStateManager.color(0.4f, 0.65f, 0.8f);
        AreaRenderer.renderAreaLined(selArea, 0.02f);
        GlStateManager.enableBlend();
        OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
        GlStateManager.alphaFunc(GL11.GL_GREATER, 0.0001f);
        ResourceLocation curTex = TEXTURE[MathHelper.floor((ticks + partialTicks) * 0.75f) % TEXTURE.length];
        mc.renderEngine.bindTexture(curTex);
        GlStateManager.color(0.2f, 0.5f, 0.6f, 0.5f);
        AreaRenderer.renderArea(selArea, false, true, 0.01f);
        GlStateManager.color(0.4f, 0.65f, 0.8f, 0.75f);
        AreaRenderer.renderArea(selArea, false, false, 0.01f);
        GlStateManager.alphaFunc(GL11.GL_GREATER, 0.002f);
        GlStateManager.disableBlend();
    }
}
Also used : BlockArea(ivorius.ivtoolkit.blocks.BlockArea) SelectionOwner(ivorius.reccomplex.capability.SelectionOwner) ItemBlockSelectorFloating(ivorius.reccomplex.item.ItemBlockSelectorFloating) EnumHand(net.minecraft.util.EnumHand) ResourceLocation(net.minecraft.util.ResourceLocation) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft)

Aggregations

BlockArea (ivorius.ivtoolkit.blocks.BlockArea)1 SelectionOwner (ivorius.reccomplex.capability.SelectionOwner)1 ItemBlockSelectorFloating (ivorius.reccomplex.item.ItemBlockSelectorFloating)1 Minecraft (net.minecraft.client.Minecraft)1 ItemStack (net.minecraft.item.ItemStack)1 EnumHand (net.minecraft.util.EnumHand)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 BlockPos (net.minecraft.util.math.BlockPos)1