Search in sources :

Example 41 with Minecraft

use of net.minecraft.client.Minecraft in project minecolonies by Minecolonies.

the class EventHandler method onDebugOverlay.

/**
     * Event when the debug screen is opened. Event gets called by displayed
     * text on the screen, we only need it when f3 is clicked.
     *
     * @param event {@link net.minecraftforge.client.event.RenderGameOverlayEvent.Text}
     */
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onDebugOverlay(final RenderGameOverlayEvent.Text event) {
    if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
        final Minecraft mc = Minecraft.getMinecraft();
        if (mc.gameSettings.showDebugInfo) {
            final WorldClient world = mc.world;
            final EntityPlayerSP player = mc.player;
            IColony colony = ColonyManager.getIColony(world, player.getPosition());
            final double minDistance = ColonyManager.getMinimumDistanceBetweenTownHalls();
            if (colony == null) {
                colony = ColonyManager.getClosestIColony(world, player.getPosition());
                if (colony == null || Math.sqrt(colony.getDistanceSquared(player.getPosition())) > 2 * minDistance) {
                    event.getLeft().add(LanguageHandler.format("com.minecolonies.coremod.gui.debugScreen.noCloseColony"));
                    return;
                }
                event.getLeft().add(LanguageHandler.format("com.minecolonies.coremod.gui.debugScreen.nextColony", (int) Math.sqrt(colony.getDistanceSquared(player.getPosition())), minDistance));
                return;
            }
            event.getLeft().add(colony.getName() + " : " + LanguageHandler.format("com.minecolonies.coremod.gui.debugScreen.blocksFromCenter", (int) Math.sqrt(colony.getDistanceSquared(player.getPosition()))));
        }
    }
}
Also used : IColony(com.minecolonies.coremod.colony.IColony) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) Minecraft(net.minecraft.client.Minecraft) WorldClient(net.minecraft.client.multiplayer.WorldClient) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 42 with Minecraft

use of net.minecraft.client.Minecraft in project Minechem by iopleke.

the class RenderHelper method setScissor.

/**
     * Start a GL_SCISSOR_TEST
     *
     * @param guiWidth  {@link net.minecraft.client.gui.GuiScreen#width}
     * @param guiHeight {@link net.minecraft.client.gui.GuiScreen#height}
     * @param x         xPos to start scissor
     * @param y         yPos to start scissor
     * @param w         width of the scissor
     * @param h         height of the scissor
     */
public static void setScissor(int guiWidth, int guiHeight, float x, float y, int w, int h) {
    Minecraft mc = Minecraft.getMinecraft();
    ScaledResolution scaledRes = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
    int scale = scaledRes.getScaleFactor();
    x *= scale;
    y *= scale;
    w *= scale;
    h *= scale;
    float guiScaledWidth = (guiWidth * scale);
    float guiScaledHeight = (guiHeight * scale);
    float guiLeft = ((mc.displayWidth / 2) - guiScaledWidth / 2);
    float guiTop = ((mc.displayHeight / 2) + guiScaledHeight / 2);
    int scissorX = Math.round((guiLeft + x));
    int scissorY = Math.round(((guiTop - h) - y));
    GL11.glEnable(GL11.GL_SCISSOR_TEST);
    GL11.glScissor(scissorX, scissorY, w, h);
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) Minecraft(net.minecraft.client.Minecraft)

Example 43 with Minecraft

use of net.minecraft.client.Minecraft in project Pearcel-Mod by MiningMark48.

the class GuiPearcelGenerator method drawGuiContainerForegroundLayer.

@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
    //Energy Bar
    this.mc.getTextureManager().bindTexture(new ResourceLocation(Reference.MOD_ID + ":textures/gui/gui_pearcel_generator.png"));
    this.drawTexturedModalRect(145, 72 - getProgressLevel(51), 180, 21, 21, getProgressLevel(51));
    String s = this.te.getDisplayName().getUnformattedText();
    this.fontRendererObj.drawString(s, 88 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752);
    this.fontRendererObj.drawString(this.playerInv.getDisplayName().getUnformattedText(), 8, 75, 4210752);
    if (this.te.getField(2) != 0) {
        this.fontRendererObj.drawString("Time Left: " + (this.te.getField(2) / 20) + "s", 36, 36, 4210752);
    }
    if (this.te.getField(0) >= this.te.getField(1)) {
        this.fontRendererObj.drawString("Energy Buffer Full", 36, 23, 4210752);
    } else if (this.te.getField(0) < this.te.getField(1) && this.te.getField(2) > 0) {
        NumberFormat format = NumberFormat.getInstance();
        this.fontRendererObj.drawString("RF/T: " + format.format(this.te.getField(3)), 36, 23, 4210752);
    } else if (this.te.inventory[0] == null) {
        this.fontRendererObj.drawString("Insert Fuel", 36, 23, 4210752);
    }
    if (this.isMouseOver(mouseX, mouseY, 144, 19, 166, 72)) {
        Minecraft mc = Minecraft.getMinecraft();
        List<String> text = new ArrayList<String>();
        text.add(this.getOverlayText());
        net.minecraftforge.fml.client.config.GuiUtils.drawHoveringText(text, mouseX - ((this.width - this.xSize) / 2), mouseY - ((this.height - this.ySize) / 2), mc.displayWidth, mc.displayHeight, -1, mc.fontRendererObj);
    }
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) ArrayList(java.util.ArrayList) Minecraft(net.minecraft.client.Minecraft) NumberFormat(java.text.NumberFormat)

Example 44 with Minecraft

use of net.minecraft.client.Minecraft in project RFToolsDimensions by McJty.

the class SkyRenderer method renderClouds.

@SideOnly(Side.CLIENT)
public static void renderClouds(GenericWorldProvider provider, DimensionInformation information, float partialTicks) {
    GlStateManager.disableCull();
    Minecraft mc = Minecraft.getMinecraft();
    TextureManager renderEngine = mc.getTextureManager();
    float f1 = (float) (mc.getRenderViewEntity().lastTickPosY + (mc.getRenderViewEntity().posY - mc.getRenderViewEntity().lastTickPosY) * partialTicks);
    Tessellator tessellator = Tessellator.getInstance();
    float f2 = 12.0F;
    float f3 = 4.0F;
    RenderGlobal renderGlobal = mc.renderGlobal;
    double d0 = (CloudRenderAccessHelper.getCloudTickCounter(renderGlobal) + partialTicks);
    double entityX = mc.getRenderViewEntity().prevPosX + (mc.getRenderViewEntity().posX - mc.getRenderViewEntity().prevPosX) * partialTicks;
    double entityZ = mc.getRenderViewEntity().prevPosZ + (mc.getRenderViewEntity().posZ - mc.getRenderViewEntity().prevPosZ) * partialTicks;
    double d1 = (entityX + d0 * 0.029999999329447746D) / f2;
    double d2 = entityZ / f2 + 0.33000001311302185D;
    float y = provider.getCloudHeight() - f1 + 0.33F;
    int i = MathTools.floor(d1 / 2048.0D);
    int j = MathTools.floor(d2 / 2048.0D);
    d1 -= (i * 2048);
    d2 -= (j * 2048);
    renderEngine.bindTexture(locationCloudsPng);
    GlStateManager.enableBlend();
    GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
    Vec3d vec3 = provider.getWorld().getCloudColour(partialTicks);
    float red = (float) vec3.xCoord;
    float green = (float) vec3.yCoord;
    float blue = (float) vec3.zCoord;
    float f8;
    float f9;
    float f10;
    if (mc.gameSettings.anaglyph) {
        f8 = (red * 30.0F + green * 59.0F + blue * 11.0F) / 100.0F;
        f9 = (red * 30.0F + green * 70.0F) / 100.0F;
        f10 = (red * 30.0F + blue * 70.0F) / 100.0F;
        red = f8;
        green = f9;
        blue = f10;
    }
    f10 = 0.00390625F;
    f8 = MathTools.floor(d1) * f10;
    f9 = MathTools.floor(d2) * f10;
    float f11 = (float) (d1 - MathTools.floor(d1));
    float f12 = (float) (d2 - MathTools.floor(d2));
    byte b0 = 8;
    byte b1 = 4;
    float f13 = 9.765625E-4F;
    GlStateManager.scale(f2, 1.0F, f2);
    float cr = information.getSkyDescriptor().getCloudColorFactorR();
    float cg = information.getSkyDescriptor().getCloudColorFactorG();
    float cb = information.getSkyDescriptor().getCloudColorFactorB();
    boolean randomColors = information.isPatreonBitSet(Patreons.PATREON_KENNEY);
    VertexBuffer renderer = tessellator.getBuffer();
    for (int k = 0; k < 2; ++k) {
        if (k == 0) {
            GlStateManager.colorMask(false, false, false, false);
        } else if (mc.gameSettings.anaglyph) {
            if (EntityRenderer.anaglyphField == 0) {
                GlStateManager.colorMask(false, true, true, true);
            } else {
                GlStateManager.colorMask(true, false, false, true);
            }
        } else {
            GlStateManager.colorMask(true, true, true, true);
        }
        for (int l = -b1 + 1; l <= b1; ++l) {
            for (int i1 = -b1 + 1; i1 <= b1; ++i1) {
                renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR_NORMAL);
                float u = (l * b0);
                float v = (i1 * b0);
                float x = u - f11;
                float z = v - f12;
                if (randomColors) {
                    //                        cr = (float) ((u % 10.0f) / 10.0f);
                    //                        cg = (float) (((u + v) % 10.0f) / 10.0f);
                    //                        cb = (float) ((v % 10.0f) / 10.0f);
                    cr = x % 1.0f;
                    cg = (x + z) % 1.0f;
                    cb = z % 1.0f;
                }
                if (y > -f3 - 1.0F) {
                    renderer.pos((x + 0.0F), (y + 0.0F), (z + b0)).tex(((u + 0.0F) * f10 + f8), ((v + b0) * f10 + f9)).color(red * 0.7F * cr, green * 0.7F * cg, blue * 0.7F * cb, 0.8F).normal(0.0F, -1.0F, 0.0F).endVertex();
                    renderer.pos((x + b0), (y + 0.0F), (z + b0)).tex(((u + b0) * f10 + f8), ((v + b0) * f10 + f9)).color(red * 0.7F * cr, green * 0.7F * cg, blue * 0.7F * cb, 0.8F).normal(0.0F, -1.0F, 0.0F).endVertex();
                    renderer.pos((x + b0), (y + 0.0F), (z + 0.0F)).tex(((u + b0) * f10 + f8), ((v + 0.0F) * f10 + f9)).color(red * 0.7F * cr, green * 0.7F * cg, blue * 0.7F * cb, 0.8F).normal(0.0F, -1.0F, 0.0F).endVertex();
                    renderer.pos((x + 0.0F), (y + 0.0F), (z + 0.0F)).tex(((u + 0.0F) * f10 + f8), ((v + 0.0F) * f10 + f9)).color(red * 0.7F * cr, green * 0.7F * cg, blue * 0.7F * cb, 0.8F).normal(0.0F, -1.0F, 0.0F).endVertex();
                }
                if (y <= f3 + 1.0F) {
                    renderer.pos((x + 0.0F), (y + f3 - f13), (z + b0)).tex(((u + 0.0F) * f10 + f8), ((v + b0) * f10 + f9)).color(red * cr, green * cg, blue * cb, 0.8F).normal(0.0F, 1.0F, 0.0F).endVertex();
                    renderer.pos((x + b0), (y + f3 - f13), (z + b0)).tex(((u + b0) * f10 + f8), ((v + b0) * f10 + f9)).color(red * cr, green * cg, blue * cb, 0.8F).normal(0.0F, 1.0F, 0.0F).endVertex();
                    renderer.pos((x + b0), (y + f3 - f13), (z + 0.0F)).tex(((u + b0) * f10 + f8), ((v + 0.0F) * f10 + f9)).color(red * cr, green * cg, blue * cb, 0.8F).normal(0.0F, 1.0F, 0.0F).endVertex();
                    renderer.pos((x + 0.0F), (y + f3 - f13), (z + 0.0F)).tex(((u + 0.0F) * f10 + f8), ((v + 0.0F) * f10 + f9)).color(red * cr, green * cg, blue * cb, 0.8F).normal(0.0F, 1.0F, 0.0F).endVertex();
                }
                int j1;
                if (l > -1) {
                    for (j1 = 0; j1 < b0; ++j1) {
                        renderer.pos((x + j1 + 0.0F), (y + 0.0F), (z + b0)).tex(((u + j1 + 0.5F) * f10 + f8), ((v + b0) * f10 + f9)).color(red * 0.9F * cr, green * 0.9F * cg, blue * 0.9F * cb, 0.8F).normal(-1.0F, 0.0F, 0.0F).endVertex();
                        renderer.pos((x + j1 + 0.0F), (y + f3), (z + b0)).tex(((u + j1 + 0.5F) * f10 + f8), ((v + b0) * f10 + f9)).color(red * 0.9F * cr, green * 0.9F * cg, blue * 0.9F * cb, 0.8F).normal(-1.0F, 0.0F, 0.0F).endVertex();
                        renderer.pos((x + j1 + 0.0F), (y + f3), (z + 0.0F)).tex(((u + j1 + 0.5F) * f10 + f8), ((v + 0.0F) * f10 + f9)).color(red * 0.9F * cr, green * 0.9F * cg, blue * 0.9F * cb, 0.8F).normal(-1.0F, 0.0F, 0.0F).endVertex();
                        renderer.pos((x + j1 + 0.0F), (y + 0.0F), (z + 0.0F)).tex(((u + j1 + 0.5F) * f10 + f8), ((v + 0.0F) * f10 + f9)).color(red * 0.9F * cr, green * 0.9F * cg, blue * 0.9F * cb, 0.8F).normal(-1.0F, 0.0F, 0.0F).endVertex();
                    }
                }
                if (l <= 1) {
                    for (j1 = 0; j1 < b0; ++j1) {
                        renderer.pos((x + j1 + 1.0F - f13), (y + 0.0F), (z + b0)).tex(((u + j1 + 0.5F) * f10 + f8), ((v + b0) * f10 + f9)).color(red * 0.9F * cr, green * 0.9F * cg, blue * 0.9F * cb, 0.8F).normal(1.0F, 0.0F, 0.0F).endVertex();
                        renderer.pos((x + j1 + 1.0F - f13), (y + f3), (z + b0)).tex(((u + j1 + 0.5F) * f10 + f8), ((v + b0) * f10 + f9)).color(red * 0.9F * cr, green * 0.9F * cg, blue * 0.9F * cb, 0.8F).normal(1.0F, 0.0F, 0.0F).endVertex();
                        renderer.pos((x + j1 + 1.0F - f13), (y + f3), (z + 0.0F)).tex(((u + j1 + 0.5F) * f10 + f8), ((v + 0.0F) * f10 + f9)).color(red * 0.9F * cr, green * 0.9F * cg, blue * 0.9F * cb, 0.8F).normal(1.0F, 0.0F, 0.0F).endVertex();
                        renderer.pos((x + j1 + 1.0F - f13), (y + 0.0F), (z + 0.0F)).tex(((u + j1 + 0.5F) * f10 + f8), ((v + 0.0F) * f10 + f9)).color(red * 0.9F * cr, green * 0.9F * cg, blue * 0.9F * cb, 0.8F).normal(1.0F, 0.0F, 0.0F).endVertex();
                    }
                }
                if (i1 > -1) {
                    for (j1 = 0; j1 < b0; ++j1) {
                        renderer.pos((x + 0.0F), (y + f3), (z + j1 + 0.0F)).tex(((u + 0.0F) * f10 + f8), ((v + j1 + 0.5F) * f10 + f9)).color(red * 0.8F * cr, green * 0.8F * cg, blue * 0.8F * cb, 0.8F).normal(0.0F, 0.0F, -1.0F).endVertex();
                        renderer.pos((x + b0), (y + f3), (z + j1 + 0.0F)).tex(((u + b0) * f10 + f8), ((v + j1 + 0.5F) * f10 + f9)).color(red * 0.8F * cr, green * 0.8F * cg, blue * 0.8F * cb, 0.8F).normal(0.0F, 0.0F, -1.0F).endVertex();
                        renderer.pos((x + b0), (y + 0.0F), (z + j1 + 0.0F)).tex(((u + b0) * f10 + f8), ((v + j1 + 0.5F) * f10 + f9)).color(red * 0.8F * cr, green * 0.8F * cg, blue * 0.8F * cb, 0.8F).normal(0.0F, 0.0F, -1.0F).endVertex();
                        renderer.pos((x + 0.0F), (y + 0.0F), (z + j1 + 0.0F)).tex(((u + 0.0F) * f10 + f8), ((v + j1 + 0.5F) * f10 + f9)).color(red * 0.8F * cr, green * 0.8F * cg, blue * 0.8F * cb, 0.8F).normal(0.0F, 0.0F, -1.0F).endVertex();
                    }
                }
                if (i1 <= 1) {
                    for (j1 = 0; j1 < b0; ++j1) {
                        renderer.pos((x + 0.0F), (y + f3), (z + j1 + 1.0F - f13)).tex(((u + 0.0F) * f10 + f8), ((v + j1 + 0.5F) * f10 + f9)).color(red * 0.8F * cr, green * 0.8F * cg, blue * 0.8F * cb, 0.8F).normal(0.0F, 0.0F, 1.0F).endVertex();
                        renderer.pos((x + b0), (y + f3), (z + j1 + 1.0F - f13)).tex(((u + b0) * f10 + f8), ((v + j1 + 0.5F) * f10 + f9)).color(red * 0.8F * cr, green * 0.8F * cg, blue * 0.8F * cb, 0.8F).normal(0.0F, 0.0F, 1.0F).endVertex();
                        renderer.pos((x + b0), (y + 0.0F), (z + j1 + 1.0F - f13)).tex(((u + b0) * f10 + f8), ((v + j1 + 0.5F) * f10 + f9)).color(red * 0.8F * cr, green * 0.8F * cg, blue * 0.8F * cb, 0.8F).normal(0.0F, 0.0F, 1.0F).endVertex();
                        renderer.pos((x + 0.0F), (y + 0.0F), (z + j1 + 1.0F - f13)).tex(((u + 0.0F) * f10 + f8), ((v + j1 + 0.5F) * f10 + f9)).color(red * 0.8F * cr, green * 0.8F * cg, blue * 0.8F * cb, 0.8F).normal(0.0F, 0.0F, 1.0F).endVertex();
                    }
                }
                tessellator.draw();
            }
        }
    }
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.disableBlend();
    GlStateManager.enableCull();
}
Also used : TextureManager(net.minecraft.client.renderer.texture.TextureManager) Minecraft(net.minecraft.client.Minecraft) Vec3d(net.minecraft.util.math.Vec3d) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 45 with Minecraft

use of net.minecraft.client.Minecraft in project RecurrentComplex by Ivorforce.

the class GuiHider method hideGUI.

public static boolean hideGUI() {
    if (!canHide())
        return false;
    Minecraft mc = Minecraft.getMinecraft();
    hiddenGUI = mc.currentScreen;
    if (hiddenGUI == null)
        return false;
    mc.displayGuiScreen(null);
    ITextComponent reopen = new TextComponentString("/" + RCCommands.reopen.getName());
    reopen.getStyle().setColor(TextFormatting.GREEN);
    reopen.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + RCCommands.reopen.getName()));
    reopen.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, ServerTranslations.get("commands.rcreopen.run")));
    mc.player.sendMessage(ServerTranslations.format("commands.rc.didhide", reopen));
    return true;
}
Also used : HoverEvent(net.minecraft.util.text.event.HoverEvent) ClickEvent(net.minecraft.util.text.event.ClickEvent) ITextComponent(net.minecraft.util.text.ITextComponent) Minecraft(net.minecraft.client.Minecraft) TextComponentString(net.minecraft.util.text.TextComponentString)

Aggregations

Minecraft (net.minecraft.client.Minecraft)100 ItemStack (net.minecraft.item.ItemStack)17 ScaledResolution (net.minecraft.client.gui.ScaledResolution)15 EntityPlayer (net.minecraft.entity.player.EntityPlayer)15 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)10 ResourceLocation (net.minecraft.util.ResourceLocation)8 ArrayList (java.util.ArrayList)7 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)7 FontRenderer (net.minecraft.client.gui.FontRenderer)6 WorldClient (net.minecraft.client.multiplayer.WorldClient)6 World (net.minecraft.world.World)6 Tessellator (net.minecraft.client.renderer.Tessellator)5 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)5 Block (net.minecraft.block.Block)4 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)4 IRenderHandler (net.minecraftforge.client.IRenderHandler)4 SimplePageView (com.almuradev.almura.feature.guide.client.gui.SimplePageView)3 SideOnly (cpw.mods.fml.relauncher.SideOnly)3 Field (java.lang.reflect.Field)3 GuiScreen (net.minecraft.client.gui.GuiScreen)3