Java Code Examples for net.minecraft.client.renderer.GlStateManager#resetColor()

The following examples show how to use net.minecraft.client.renderer.GlStateManager#resetColor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Tower.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Tower visuals
 *
 * @param event
 */
@EventTarget
public void onRender2D(final Render2DEvent event) {
    if(counterDisplayValue.get()) {
        GlStateManager.pushMatrix();

        final BlockOverlay blockOverlay = (BlockOverlay) LiquidBounce.moduleManager.getModule(BlockOverlay.class);
        if (blockOverlay.getState() && blockOverlay.getInfoValue().get() && blockOverlay.getCurrentBlock() != null)
            GlStateManager.translate(0, 15F, 0);

        final String info = "Blocks: §7" + getBlocksAmount();
        final ScaledResolution scaledResolution = new ScaledResolution(mc);

        RenderUtils.drawBorderedRect((scaledResolution.getScaledWidth() / 2) - 2,
                (scaledResolution.getScaledHeight() / 2) + 5,
                (scaledResolution.getScaledWidth() / 2) + Fonts.font40.getStringWidth(info) + 2,
                (scaledResolution.getScaledHeight() / 2) + 16, 3, Color.BLACK.getRGB(), Color.BLACK.getRGB());
        GlStateManager.resetColor();
        Fonts.font40.drawString(info, scaledResolution.getScaledWidth() / 2,
                scaledResolution.getScaledHeight() / 2 + 7, Color.WHITE.getRGB());

        GlStateManager.popMatrix();
    }
}
 
Example 2
Source File: VboRenderListSchematic.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void renderChunkLayer(BlockRenderLayer layer)
{
    if (this.initialized)
    {
        for (RenderChunk renderChunk : this.renderChunks)
        {
            this.renderBlocks(renderChunk.getVertexBufferByLayer(layer.ordinal()), renderChunk);
        }

        OpenGlHelper.glBindBuffer(OpenGlHelper.GL_ARRAY_BUFFER, 0);
        GlStateManager.resetColor();

        this.renderChunks.clear();
    }
}
 
Example 3
Source File: NullStyle.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void drawPanel(int mouseX, int mouseY, Panel panel) {
    RenderUtils.drawRect((float) panel.getX() - 3, (float) panel.getY(), (float) panel.getX() + panel.getWidth() + 3, (float) panel.getY() + 19, ClickGUI.generateColor().getRGB());
    if(panel.getFade() > 0)
        RenderUtils.drawBorderedRect((float) panel.getX(), (float) panel.getY() + 19, (float) panel.getX() + panel.getWidth(), panel.getY() + 19 + panel.getFade(), 1, Integer.MIN_VALUE, Integer.MIN_VALUE);
    GlStateManager.resetColor();
    float textWidth = Fonts.font35.getStringWidth("§f" + StringUtils.stripControlCodes(panel.getName()));
    Fonts.font35.drawString("§f" + panel.getName(), (int) (panel.getX() - (textWidth - 100.0F) / 2F), panel.getY() + 7, Integer.MAX_VALUE);
}
 
Example 4
Source File: ElementRenderer.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
@InvokeEvent
public void onRenderTick(RenderHUDEvent event) {
    if (!minecraft.inGameHasFocus || minecraft.gameSettings.showDebugInfo) return;
    renderElements();
    GlStateManager.resetColor();

}
 
Example 5
Source File: RenderUtils.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
public static void drawAxisAlignedBB(final AxisAlignedBB axisAlignedBB, final Color color) {
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);
    glLineWidth(2F);
    glDisable(GL_TEXTURE_2D);
    glDisable(GL_DEPTH_TEST);
    glDepthMask(false);
    glColor(color);
    drawFilledBox(axisAlignedBB);
    GlStateManager.resetColor();
    glEnable(GL_TEXTURE_2D);
    glEnable(GL_DEPTH_TEST);
    glDepthMask(true);
    glDisable(GL_BLEND);
}
 
Example 6
Source File: LiquidBounceStyle.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void drawDescription(int mouseX, int mouseY, String text) {
    int textWidth = Fonts.font35.getStringWidth(text);

    RenderUtils.drawBorderedRect(mouseX + 9, mouseY, mouseX + textWidth + 14, mouseY + Fonts.font35.FONT_HEIGHT + 3, 1, new Color(255, 255, 255, 90).getRGB(), Integer.MIN_VALUE);
    GlStateManager.resetColor();
    Fonts.font35.drawString(text, mouseX + 12, mouseY + (Fonts.font35.FONT_HEIGHT) / 2, Integer.MAX_VALUE);
}
 
Example 7
Source File: SlowlyStyle.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void drawDescription(int mouseX, int mouseY, String text) {
    int textWidth = Fonts.font35.getStringWidth(text);

    RenderUtils.drawBorderedRect(mouseX + 9, mouseY, mouseX + textWidth + 14, mouseY + Fonts.font35.FONT_HEIGHT + 3, 3F, new Color(42, 57, 79).getRGB(), new Color(42, 57, 79).getRGB());
    GlStateManager.resetColor();
    Fonts.font35.drawString(text, mouseX + 12, mouseY + (Fonts.font35.FONT_HEIGHT / 2), Color.WHITE.getRGB());
}
 
Example 8
Source File: SlowlyStyle.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void drawButtonElement(int mouseX, int mouseY, ButtonElement buttonElement) {
    Gui.drawRect(buttonElement.getX() - 1, buttonElement.getY() - 1, buttonElement.getX() + buttonElement.getWidth() + 1, buttonElement.getY() + buttonElement.getHeight() + 1, hoverColor(buttonElement.getColor() != Integer.MAX_VALUE ? new Color(7, 152, 252) : new Color(54, 71, 96), buttonElement.hoverTime).getRGB());

    GlStateManager.resetColor();

    Fonts.font35.drawString(buttonElement.getDisplayName(), buttonElement.getX() + 5, buttonElement.getY() + 5, Color.WHITE.getRGB());
}
 
Example 9
Source File: ValkyriumEnginePartTileEntityRenderer.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Override
public void render(TileEntityValkyriumEnginePart tileentity, double x, double y, double z,
    float partialTick,
    int destroyStage, float alpha) {

    this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    GlStateManager.pushMatrix();
    GlStateManager.disableLighting();

    GlStateManager.translate(x, y, z);
    GlStateManager.disableAlpha();
    GlStateManager.disableBlend();

    int brightness = tileentity.getWorld().getCombinedLight(tileentity.getPos(), 0);

    GlStateManager.pushMatrix();
    if (!tileentity.isPartOfAssembledMultiblock()) {
        IBlockState state = Blocks.IRON_BLOCK.getDefaultState();
        Tessellator tessellator = Tessellator.getInstance();
        FastBlockModelRenderer
            .renderBlockModel(tessellator, tileentity.getWorld(), state, brightness);
    } else if (tileentity.isMaster()) {
        // Im not sure why this has to be done, something is wrong with my rotation
        // intuition.
        float tileYaw =
            -tileentity.getMultiBlockSchematic().getMultiblockRotation().getYaw() + 180;

        GlStateManager.translate(.5, 0, .5);
        GlStateManager.scale(3, 3, 3);
        GlStateManager.rotate(tileYaw, 0, 1, 0);
        GlStateManager.translate(-.5, 0, -.5);

        double keyframe = tileentity.getCurrentKeyframe(partialTick);

        GibsAnimationRegistry.getAnimation("valkyrium_engine")
            .renderAnimation(keyframe, brightness);
    }

    GlStateManager.popMatrix();
    GlStateManager.popMatrix();
    GlStateManager.enableLighting();
    GlStateManager.resetColor();
}
 
Example 10
Source File: MixinGuiNewChat.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
@Inject(method = "drawChat", at = @At("HEAD"), cancellable = true)
private void drawChat(int p_drawChat_1_, final CallbackInfo callbackInfo) {
    final HUD hud = (HUD) LiquidBounce.moduleManager.getModule(HUD.class);

    if(hud.getState() && hud.fontChatValue.get()) {
        callbackInfo.cancel();
        if(this.mc.gameSettings.chatVisibility != EntityPlayer.EnumChatVisibility.HIDDEN) {
            int lvt_2_1_ = this.getLineCount();
            boolean lvt_3_1_ = false;
            int lvt_4_1_ = 0;
            int lvt_5_1_ = this.drawnChatLines.size();
            float lvt_6_1_ = this.mc.gameSettings.chatOpacity * 0.9F + 0.1F;
            if(lvt_5_1_ > 0) {
                if(this.getChatOpen()) {
                    lvt_3_1_ = true;
                }

                float lvt_7_1_ = this.getChatScale();
                int lvt_8_1_ = MathHelper.ceiling_float_int((float) this.getChatWidth() / lvt_7_1_);
                GlStateManager.pushMatrix();
                GlStateManager.translate(2.0F, 20.0F, 0.0F);
                GlStateManager.scale(lvt_7_1_, lvt_7_1_, 1.0F);

                int lvt_9_1_;
                int lvt_11_1_;
                int lvt_14_1_;
                for(lvt_9_1_ = 0; lvt_9_1_ + this.scrollPos < this.drawnChatLines.size() && lvt_9_1_ < lvt_2_1_; ++lvt_9_1_) {
                    ChatLine lvt_10_1_ = (ChatLine) this.drawnChatLines.get(lvt_9_1_ + this.scrollPos);
                    if(lvt_10_1_ != null) {
                        lvt_11_1_ = p_drawChat_1_ - lvt_10_1_.getUpdatedCounter();
                        if(lvt_11_1_ < 200 || lvt_3_1_) {
                            double lvt_12_1_ = (double) lvt_11_1_ / 200.0D;
                            lvt_12_1_ = 1.0D - lvt_12_1_;
                            lvt_12_1_ *= 10.0D;
                            lvt_12_1_ = MathHelper.clamp_double(lvt_12_1_, 0.0D, 1.0D);
                            lvt_12_1_ *= lvt_12_1_;
                            lvt_14_1_ = (int) (255.0D * lvt_12_1_);
                            if(lvt_3_1_) {
                                lvt_14_1_ = 255;
                            }

                            lvt_14_1_ = (int) ((float) lvt_14_1_ * lvt_6_1_);
                            ++lvt_4_1_;
                            if(lvt_14_1_ > 3) {
                                int lvt_15_1_ = 0;
                                int lvt_16_1_ = -lvt_9_1_ * 9;
                                Gui.drawRect(lvt_15_1_, lvt_16_1_ - 9, lvt_15_1_ + lvt_8_1_ + 4, lvt_16_1_, lvt_14_1_ / 2 << 24);
                                String lvt_17_1_ = lvt_10_1_.getChatComponent().getFormattedText();
                                Fonts.font40.drawStringWithShadow(lvt_17_1_, (float) lvt_15_1_ + 2, (float) (lvt_16_1_ - 8), 16777215 + (lvt_14_1_ << 24));
                                GL11.glColor4f(1, 1, 1, 1);
                                GlStateManager.resetColor();
                            }
                        }
                    }
                }

                if(lvt_3_1_) {
                    lvt_9_1_ = Fonts.font40.FONT_HEIGHT;
                    GlStateManager.translate(-3.0F, 0.0F, 0.0F);
                    int lvt_10_2_ = lvt_5_1_ * lvt_9_1_ + lvt_5_1_;
                    lvt_11_1_ = lvt_4_1_ * lvt_9_1_ + lvt_4_1_;
                    int lvt_12_2_ = this.scrollPos * lvt_11_1_ / lvt_5_1_;
                    int lvt_13_1_ = lvt_11_1_ * lvt_11_1_ / lvt_10_2_;
                    if(lvt_10_2_ != lvt_11_1_) {
                        lvt_14_1_ = lvt_12_2_ > 0 ? 170 : 96;
                        int lvt_15_2_ = this.isScrolled ? 13382451 : 3355562;
                        Gui.drawRect(0, -lvt_12_2_, 2, -lvt_12_2_ - lvt_13_1_, lvt_15_2_ + (lvt_14_1_ << 24));
                        Gui.drawRect(2, -lvt_12_2_, 1, -lvt_12_2_ - lvt_13_1_, 13421772 + (lvt_14_1_ << 24));
                    }
                }

                GlStateManager.popMatrix();
            }
        }
    }
}
 
Example 11
Source File: RenderGlobalSchematic.java    From litematica with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void renderBlockLayer(BlockRenderLayer layer)
{
    this.mc.entityRenderer.enableLightmap();

    if (OpenGlHelper.useVbo())
    {
        GlStateManager.glEnableClientState(GL11.GL_VERTEX_ARRAY);
        OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
        GlStateManager.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
        OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapTexUnit);
        GlStateManager.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
        OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
        GlStateManager.glEnableClientState(GL11.GL_COLOR_ARRAY);
    }

    this.renderContainer.renderChunkLayer(layer);

    if (OpenGlHelper.useVbo())
    {
        for (VertexFormatElement vertexformatelement : DefaultVertexFormats.BLOCK.getElements())
        {
            VertexFormatElement.EnumUsage vertexformatelement$enumusage = vertexformatelement.getUsage();
            int index = vertexformatelement.getIndex();

            switch (vertexformatelement$enumusage)
            {
                case POSITION:
                    GlStateManager.glDisableClientState(GL11.GL_VERTEX_ARRAY);
                    break;
                case UV:
                    OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit + index);
                    GlStateManager.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
                    OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
                    break;
                case COLOR:
                    GlStateManager.glDisableClientState(GL11.GL_COLOR_ARRAY);
                    GlStateManager.resetColor();
                default:
            }
        }
    }

    this.mc.entityRenderer.disableLightmap();
}
 
Example 12
Source File: NullStyle.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void drawButtonElement(int mouseX, int mouseY, ButtonElement buttonElement) {
    GlStateManager.resetColor();
    Fonts.font35.drawString(buttonElement.getDisplayName(), (int) (buttonElement.getX() - (Fonts.font35.getStringWidth(buttonElement.getDisplayName()) - 100.0f) / 2.0f), buttonElement.getY() + 6, buttonElement.getColor());
}
 
Example 13
Source File: LiquidBounceStyle.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void drawButtonElement(int mouseX, int mouseY, ButtonElement buttonElement) {
    GlStateManager.resetColor();
    Fonts.font35.drawString(buttonElement.getDisplayName(), (int) (buttonElement.getX() - (Fonts.font35.getStringWidth(buttonElement.getDisplayName()) - 100.0f) / 2.0f), buttonElement.getY() + 6, buttonElement.getColor());
}
 
Example 14
Source File: MixinRenderPlayer.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Inject(method = "doRender", at = @At("HEAD"), cancellable = true)
private void doRender(AbstractClientPlayer entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) {
    GlStateManager.resetColor();

    hyperiumRenderPlayer.doRender(entity, x, y, z, partialTicks, renderManager);
}
 
Example 15
Source File: RenderUtils.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
public static void drawBlockBox(final BlockPos blockPos, final Color color, final boolean outline) {
    final RenderManager renderManager = mc.getRenderManager();
    final Timer timer = mc.timer;

    final double x = blockPos.getX() - renderManager.renderPosX;
    final double y = blockPos.getY() - renderManager.renderPosY;
    final double z = blockPos.getZ() - renderManager.renderPosZ;

    AxisAlignedBB axisAlignedBB = new AxisAlignedBB(x, y, z, x + 1.0, y + 1.0, z + 1.0);
    final Block block = BlockUtils.getBlock(blockPos);

    if (block != null) {
        final EntityPlayer player = mc.thePlayer;

        final double posX = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) timer.renderPartialTicks;
        final double posY = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) timer.renderPartialTicks;
        final double posZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) timer.renderPartialTicks;
        axisAlignedBB = block.getSelectedBoundingBox(mc.theWorld, blockPos)
                .expand(0.0020000000949949026D, 0.0020000000949949026D, 0.0020000000949949026D)
                .offset(-posX, -posY, -posZ);
    }

    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    enableGlCap(GL_BLEND);
    disableGlCap(GL_TEXTURE_2D, GL_DEPTH_TEST);
    glDepthMask(false);

    glColor(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha() != 255 ? color.getAlpha() : outline ? 26 : 35);
    drawFilledBox(axisAlignedBB);

    if (outline) {
        glLineWidth(1F);
        enableGlCap(GL_LINE_SMOOTH);
        glColor(color);

        drawSelectionBoundingBox(axisAlignedBB);
    }

    GlStateManager.resetColor();
    glDepthMask(true);
    resetCaps();
}
 
Example 16
Source File: CustomCrosshair.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void drawCrosshair() {
    int screenWidth = ResolutionUtil.current().getScaledWidth() / 2;
    int screenHeight = ResolutionUtil.current().getScaledHeight() / 2;
    if (!enabled && !mc.gameSettings.hideGUI) {
        if (mc.gameSettings.showDebugInfo) {
            drawDebugAxisCrosshair(screenWidth, screenHeight);
        }
    }
    if (enabled && (mc.gameSettings.thirdPersonView <= 0 || visibleThirdPerson) && (!mc.gameSettings.hideGUI || visibleHiddenGui) && (
        !mc.thePlayer
            .isSpectator() || visibleSpectator)) {
        if (!visibleDefault) {
            return;
        }
        if (mc.gameSettings.hideGUI) {
            GlStateManager.clear(GL11.GL_ACCUM);
            GlStateManager.matrixMode(GL11.GL_PROJECTION);
            GlStateManager.loadIdentity();
            GlStateManager.ortho(0.0, ResolutionUtil.current().getScaledWidth_double(),
                ResolutionUtil.current().getScaledHeight_double(), 0.0, 1000.0, 3000.0);
            GlStateManager.matrixMode(GL11.GL_MODELVIEW);
            GlStateManager.loadIdentity();
            GlStateManager.translate(0.0f, 0.0f, -2000.0f);
        }
        ++rainbowColourTick;
        Color renderColour = colour;
        int renderGap = gap;
        if (rainbowCrosshair) {
            int red = (int) (
                Math.sin(rainbowSpeed / 100000.0f * rainbowColourTick + 0.0f) * 127.0
                    + 128.0);
            int green = (int) (
                Math.sin(rainbowSpeed / 100000.0f * rainbowColourTick + 2.0f) * 127.0
                    + 128.0);
            int blue = (int) (
                Math.sin(rainbowSpeed / 100000.0f * rainbowColourTick + 4.0f) * 127.0
                    + 128.0);
            renderColour = new Color(red, green, blue, 255);
        }

        if (!mc.thePlayer.isSpectator() && dynamicBow
            && mc.thePlayer.getHeldItem() != null) {
            ItemStack item = mc.thePlayer.getHeldItem();
            int useCount = mc.thePlayer.getItemInUseCount();
            if (dynamicBow
                && mc.thePlayer.getHeldItem().getItem() == Items.bow) {
                float bowExtension =
                    (item.getItem().getMaxItemUseDuration(item) - useCount) / 20.0f;
                if (useCount == 0 || bowExtension > 1.0f) {
                    bowExtension = 1.0f;
                }
                renderGap =
                    gap + (int) ((1.0f - bowExtension) * (gap + 5) * 2.0f);
            }
        }

        if (!mc.gameSettings.showDebugInfo || visibleDebug) {
            switch (crosshairType) {
                case CIRCLE:
                    drawCircleCrosshair(screenWidth, screenHeight, renderGap,
                        renderColour);
                    break;
                case SQUARE:
                    drawSquareCrosshair(screenWidth, screenHeight, renderGap,
                        renderColour);
                    break;
                case ARROW:
                    drawArrowCrosshair(screenWidth, screenHeight, renderGap, renderColour);
                    break;
                case X:
                    drawXCrosshair(screenWidth, screenHeight, renderGap, renderColour);
                    break;
                default:
                    drawCrossCrosshair(screenWidth, screenHeight, renderGap, renderColour);
                    break;
            }

            if (dot) {
                CustomCrosshairGraphics
                    .drawFilledRectangle(screenWidth, screenHeight, screenWidth + 1,
                        screenHeight + 1, colourDot);
            }
        } else {
            drawDebugAxisCrosshair(screenWidth, screenHeight);
        }
    }
    GlStateManager.resetColor();
}
 
Example 17
Source File: Teleport.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
@EventTarget
public void onRender3D(final Render3DEvent event) {
    if(modeValue.get().equals("AAC3.5.0"))
        return;

    final Vec3 lookVec = new Vec3(mc.thePlayer.getLookVec().xCoord * 300, mc.thePlayer.getLookVec().yCoord * 300, mc.thePlayer.getLookVec().zCoord * 300);
    final Vec3 posVec = new Vec3(mc.thePlayer.posX, mc.thePlayer.posY + 1.62, mc.thePlayer.posZ);

    objectPosition = mc.thePlayer.worldObj.rayTraceBlocks(posVec, posVec.add(lookVec), false, ignoreNoCollision.get(), false);

    if (objectPosition == null || objectPosition.getBlockPos() == null)
        return;

    final BlockPos belowBlockPos = new BlockPos(objectPosition.getBlockPos().getX(), objectPosition.getBlockPos().getY() - 1, objectPosition.getBlockPos().getZ());
    
    fixedY = BlockUtils.getBlock(objectPosition.getBlockPos()) instanceof BlockFence ? (mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, mc.thePlayer.getEntityBoundingBox().offset(objectPosition.getBlockPos().getX() + 0.5D - mc.thePlayer.posX, objectPosition.getBlockPos().getY() + 1.5D - mc.thePlayer.posY, objectPosition.getBlockPos().getZ() + 0.5D - mc.thePlayer.posZ)).isEmpty() ? 0.5D : 0D) : BlockUtils.getBlock(belowBlockPos) instanceof BlockFence ? (!mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, mc.thePlayer.getEntityBoundingBox().offset(objectPosition.getBlockPos().getX() + 0.5D - mc.thePlayer.posX, objectPosition.getBlockPos().getY() + 0.5D - mc.thePlayer.posY, objectPosition.getBlockPos().getZ() + 0.5D - mc.thePlayer.posZ)).isEmpty() || BlockUtils.getBlock(objectPosition.getBlockPos()).getCollisionBoundingBox(mc.theWorld, objectPosition.getBlockPos(), BlockUtils.getBlock(objectPosition.getBlockPos()).getDefaultState()) == null ? 0D : 0.5D - BlockUtils.getBlock(objectPosition.getBlockPos()).getBlockBoundsMaxY()) : BlockUtils.getBlock(objectPosition.getBlockPos()) instanceof BlockSnow ? BlockUtils.getBlock(objectPosition.getBlockPos()).getBlockBoundsMaxY() - 0.125D : 0D;
    
    final int x = objectPosition.getBlockPos().getX();
    final double y = (BlockUtils.getBlock(objectPosition.getBlockPos()).getCollisionBoundingBox(mc.theWorld, objectPosition.getBlockPos(), BlockUtils.getBlock(objectPosition.getBlockPos()).getDefaultState()) == null ? objectPosition.getBlockPos().getY() + BlockUtils.getBlock(objectPosition.getBlockPos()).getBlockBoundsMaxY() : BlockUtils.getBlock(objectPosition.getBlockPos()).getCollisionBoundingBox(mc.theWorld, objectPosition.getBlockPos(), BlockUtils.getBlock(objectPosition.getBlockPos()).getDefaultState()).maxY) - 1D + fixedY;
    final int z = objectPosition.getBlockPos().getZ();

    if(!(BlockUtils.getBlock(objectPosition.getBlockPos()) instanceof BlockAir)) {
        final RenderManager renderManager = mc.getRenderManager();

        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glEnable(GL_BLEND);
        glLineWidth(2F);
        glDisable(GL_TEXTURE_2D);
        glDisable(GL_DEPTH_TEST);
        glDepthMask(false);
        RenderUtils.glColor(modeValue.get().equalsIgnoreCase("minesucht") && mc.thePlayer.getPosition().getY() != y + 1 ? new Color(255, 0, 0, 90) : !mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, mc.thePlayer.getEntityBoundingBox().offset(x + 0.5D - mc.thePlayer.posX, y + 1D - mc.thePlayer.posY, z + 0.5D - mc.thePlayer.posZ)).isEmpty() ? new Color(255, 0, 0, 90) : new Color(0, 255, 0, 90));
        RenderUtils.drawFilledBox(new AxisAlignedBB(x - renderManager.renderPosX, (y + 1) - renderManager.renderPosY, z - renderManager.renderPosZ, x - renderManager.renderPosX + 1.0D, y + 1.2D - renderManager.renderPosY, z - renderManager.renderPosZ + 1.0D));
        glEnable(GL_TEXTURE_2D);
        glEnable(GL_DEPTH_TEST);
        glDepthMask(true);
        glDisable(GL_BLEND);

        RenderUtils.renderNameTag(Math.round(mc.thePlayer.getDistance(x + 0.5D, y + 1D, z + 0.5D)) + "m", x + 0.5, y + 1.7, z + 0.5);
        GlStateManager.resetColor();
    }
}
 
Example 18
Source File: MixinTileEntityRendererDispatcher.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Inject(method = "render(Lnet/minecraft/tileentity/TileEntity;FI)V",
    at = @At("HEAD"),
    cancellable = true)
private void preRender(TileEntity tileentityIn, float partialTicks, int destroyStage,
    CallbackInfo callbackInfo) {
    if (!hasChanged) {
        BlockPos pos = tileentityIn.getPos();
        Optional<PhysicsObject> physicsObject = ValkyrienUtils
            .getPhysicsObject(tileentityIn.getWorld(), tileentityIn.getPos());

        if (physicsObject.isPresent()) {
            try {
                GlStateManager.resetColor();

                if (drawingBatch) {
                    this.drawBatch(MinecraftForgeClient.getRenderPass());
                    this.preDrawBatch();
                }

                physicsObject.get()
                    .getShipRenderer()
                    .applyRenderTransform(partialTicks);

                double playerX = TileEntityRendererDispatcher.staticPlayerX;
                double playerY = TileEntityRendererDispatcher.staticPlayerY;
                double playerZ = TileEntityRendererDispatcher.staticPlayerZ;

                TileEntityRendererDispatcher.staticPlayerX = physicsObject.get()
                    .getShipRenderer().offsetPos.getX();
                TileEntityRendererDispatcher.staticPlayerY = physicsObject.get()
                    .getShipRenderer().offsetPos.getY();
                TileEntityRendererDispatcher.staticPlayerZ = physicsObject.get()
                    .getShipRenderer().offsetPos.getZ();

                hasChanged = true;
                if (drawingBatch) {
                    this.render(tileentityIn, partialTicks, destroyStage);
                    this.drawBatch(MinecraftForgeClient.getRenderPass());
                    this.preDrawBatch();
                } else {
                    this.render(tileentityIn, partialTicks, destroyStage);
                }
                hasChanged = false;
                TileEntityRendererDispatcher.staticPlayerX = playerX;
                TileEntityRendererDispatcher.staticPlayerY = playerY;
                TileEntityRendererDispatcher.staticPlayerZ = playerZ;

                physicsObject.get()
                    .getShipRenderer()
                    .inverseTransform(partialTicks);
            } catch (Exception e) {
                e.printStackTrace();
            }
            callbackInfo.cancel();
        }
    }
}
 
Example 19
Source File: MixinGuiButtonExt.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
   if (visible) {
      final FontRenderer fontRenderer =
         mc.getLanguageManager().isCurrentLocaleUnicode() ? mc.fontRendererObj : Fonts.font35;
      hovered = (mouseX >= this.xPosition && mouseY >= this.yPosition &&
                 mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height);

      final int delta = RenderUtils.deltaTime;

      if (enabled && hovered) {
         cut += 0.05F * delta;

         if (cut >= 4) cut = 4;

         alpha += 0.3F * delta;

         if (alpha >= 210) alpha = 210;
      } else {
         cut -= 0.05F * delta;

         if (cut <= 0) cut = 0;

         alpha -= 0.3F * delta;

         if (alpha <= 120) alpha = 120;
      }

      Gui.drawRect(this.xPosition + (int) this.cut, this.yPosition,
                   this.xPosition + this.width - (int) this.cut, this.yPosition + this.height,
                   this.enabled ? new Color(0F, 0F, 0F, this.alpha / 255F).getRGB() :
                   new Color(0.5F, 0.5F, 0.5F, 0.5F).getRGB());

      mc.getTextureManager().bindTexture(buttonTextures);
      mouseDragged(mc, mouseX, mouseY);

      fontRenderer.drawStringWithShadow(displayString,
                                        (float) ((this.xPosition + this.width / 2) -
                                                 fontRenderer.getStringWidth(displayString) / 2),
                                        this.yPosition + (this.height - 5) / 2F, 14737632);
      GlStateManager.resetColor();
   }
}
 
Example 20
Source File: MixinGuiNewChat.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
@Inject(method = "drawChat", at = @At("HEAD"), cancellable = true)
private void drawChat(int p_drawChat_1_, final CallbackInfo callbackInfo) {
    final HUD hud = (HUD) LiquidBounce.moduleManager.getModule(HUD.class);

    if(hud.getState() && hud.fontChatValue.get()) {
        callbackInfo.cancel();
        if(this.mc.gameSettings.chatVisibility != EntityPlayer.EnumChatVisibility.HIDDEN) {
            int lvt_2_1_ = this.getLineCount();
            boolean lvt_3_1_ = false;
            int lvt_4_1_ = 0;
            int lvt_5_1_ = this.drawnChatLines.size();
            float lvt_6_1_ = this.mc.gameSettings.chatOpacity * 0.9F + 0.1F;
            if(lvt_5_1_ > 0) {
                if(this.getChatOpen()) {
                    lvt_3_1_ = true;
                }

                float lvt_7_1_ = this.getChatScale();
                int lvt_8_1_ = MathHelper.ceiling_float_int((float) this.getChatWidth() / lvt_7_1_);
                GlStateManager.pushMatrix();
                GlStateManager.translate(2.0F, 20.0F, 0.0F);
                GlStateManager.scale(lvt_7_1_, lvt_7_1_, 1.0F);

                int lvt_9_1_;
                int lvt_11_1_;
                int lvt_14_1_;
                for(lvt_9_1_ = 0; lvt_9_1_ + this.scrollPos < this.drawnChatLines.size() && lvt_9_1_ < lvt_2_1_; ++lvt_9_1_) {
                    ChatLine lvt_10_1_ = (ChatLine) this.drawnChatLines.get(lvt_9_1_ + this.scrollPos);
                    if(lvt_10_1_ != null) {
                        lvt_11_1_ = p_drawChat_1_ - lvt_10_1_.getUpdatedCounter();
                        if(lvt_11_1_ < 200 || lvt_3_1_) {
                            double lvt_12_1_ = (double) lvt_11_1_ / 200.0D;
                            lvt_12_1_ = 1.0D - lvt_12_1_;
                            lvt_12_1_ *= 10.0D;
                            lvt_12_1_ = MathHelper.clamp_double(lvt_12_1_, 0.0D, 1.0D);
                            lvt_12_1_ *= lvt_12_1_;
                            lvt_14_1_ = (int) (255.0D * lvt_12_1_);
                            if(lvt_3_1_) {
                                lvt_14_1_ = 255;
                            }

                            lvt_14_1_ = (int) ((float) lvt_14_1_ * lvt_6_1_);
                            ++lvt_4_1_;
                            if(lvt_14_1_ > 3) {
                                int lvt_15_1_ = 0;
                                int lvt_16_1_ = -lvt_9_1_ * 9;
                                Gui.drawRect(lvt_15_1_, lvt_16_1_ - 9, lvt_15_1_ + lvt_8_1_ + 4, lvt_16_1_, lvt_14_1_ / 2 << 24);
                                String lvt_17_1_ = lvt_10_1_.getChatComponent().getFormattedText();
                                Fonts.font40.drawStringWithShadow(lvt_17_1_, (float) lvt_15_1_ + 2, (float) (lvt_16_1_ - 8), 16777215 + (lvt_14_1_ << 24));
                                GL11.glColor4f(1, 1, 1, 1);
                                GlStateManager.resetColor();
                            }
                        }
                    }
                }

                if(lvt_3_1_) {
                    lvt_9_1_ = Fonts.font40.FONT_HEIGHT;
                    GlStateManager.translate(-3.0F, 0.0F, 0.0F);
                    int lvt_10_2_ = lvt_5_1_ * lvt_9_1_ + lvt_5_1_;
                    lvt_11_1_ = lvt_4_1_ * lvt_9_1_ + lvt_4_1_;
                    int lvt_12_2_ = this.scrollPos * lvt_11_1_ / lvt_5_1_;
                    int lvt_13_1_ = lvt_11_1_ * lvt_11_1_ / lvt_10_2_;
                    if(lvt_10_2_ != lvt_11_1_) {
                        lvt_14_1_ = lvt_12_2_ > 0 ? 170 : 96;
                        int lvt_15_2_ = this.isScrolled ? 13382451 : 3355562;
                        Gui.drawRect(0, -lvt_12_2_, 2, -lvt_12_2_ - lvt_13_1_, lvt_15_2_ + (lvt_14_1_ << 24));
                        Gui.drawRect(2, -lvt_12_2_, 1, -lvt_12_2_ - lvt_13_1_, 13421772 + (lvt_14_1_ << 24));
                    }
                }

                GlStateManager.popMatrix();
            }
        }
    }
}