Search in sources :

Example 11 with Minecraft

use of net.minecraft.client.Minecraft in project PneumaticCraft by MineMaarten.

the class ClientEventHandler method tickEnd.

@SubscribeEvent
public void tickEnd(TickEvent.RenderTickEvent event) {
    if (event.phase == TickEvent.Phase.END && FMLClientHandler.instance().getClient().inGameHasFocus && PneumaticCraft.proxy.getPlayer().worldObj != null && (ModuleRegulatorTube.inverted || !ModuleRegulatorTube.inLine)) {
        Minecraft mc = FMLClientHandler.instance().getClient();
        ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
        FontRenderer fontRenderer = FMLClientHandler.instance().getClient().fontRenderer;
        String warning = EnumChatFormatting.RED + I18n.format("gui.regulatorTube.hudMessage." + (ModuleRegulatorTube.inverted ? "inverted" : "notInLine"));
        fontRenderer.drawStringWithShadow(warning, sr.getScaledWidth() / 2 - fontRenderer.getStringWidth(warning) / 2, sr.getScaledHeight() / 2 + 30, 0xFFFFFFFF);
    }
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) FontRenderer(net.minecraft.client.gui.FontRenderer) Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 12 with Minecraft

use of net.minecraft.client.Minecraft in project PneumaticCraft by MineMaarten.

the class GuiCoordinateTrackerOptions method actionPerformed.

@Override
public void actionPerformed(GuiButton button) {
    Minecraft mc = FMLClientHandler.instance().getClient();
    CoordTrackUpgradeHandler coordHandler = HUDHandler.instance().getSpecificRenderer(CoordTrackUpgradeHandler.class);
    switch(button.id) {
        case 10:
            mc.displayGuiScreen((GuiScreen) null);
            mc.setIngameFocus();
            coordHandler.isListeningToCoordTrackerSetting = true;
            HUDHandler.instance().addMessage(new ArmorMessage("Changing Coordinate Tracker coordinate...", Arrays.asList("Right-click the desired coordinate"), 90, 0x7000AA00));
            break;
        case 11:
            mc.displayGuiScreen((GuiScreen) null);
            mc.setIngameFocus();
            switch(coordHandler.navigateToSurface(mc.thePlayer)) {
                case EASY_PATH:
                    HUDHandler.instance().addMessage(new ArmorMessage(I18n.format("pneumaticHelmet.message.coordinateTracker.routeFound"), new ArrayList<String>(), 90, 0x7000AA00));
                    break;
                case DRONE_PATH:
                    HUDHandler.instance().addMessage(new ArmorMessage(I18n.format("pneumaticHelmet.message.coordinateTracker.harderRouteFound"), new ArrayList<String>(), 90, 0x7044AA00));
                    break;
                case NO_PATH:
                    HUDHandler.instance().addMessage(new ArmorMessage(I18n.format("pneumaticHelmet.message.coordinateTracker.noRouteFound"), new ArrayList<String>(), 90, 0x70FF0000));
                    break;
            }
            break;
        case 12:
            coordHandler.pathEnabled = !coordHandler.pathEnabled;
            break;
        case 13:
            coordHandler.wirePath = !coordHandler.wirePath;
            break;
        case 14:
            coordHandler.xRayEnabled = !coordHandler.xRayEnabled;
            break;
        case 15:
            coordHandler.pathUpdateSetting++;
            if (coordHandler.pathUpdateSetting > 2) {
                coordHandler.pathUpdateSetting = 0;
            }
            break;
    }
    updateButtonTexts();
    coordHandler.saveToConfig();
}
Also used : CoordTrackUpgradeHandler(pneumaticCraft.client.render.pneumaticArmor.CoordTrackUpgradeHandler) ArmorMessage(pneumaticCraft.client.render.pneumaticArmor.ArmorMessage) ArrayList(java.util.ArrayList) Minecraft(net.minecraft.client.Minecraft)

Example 13 with Minecraft

use of net.minecraft.client.Minecraft in project PneumaticCraft by MineMaarten.

the class HUDHandler method render2D.

private void render2D(float partialTicks) {
    Minecraft minecraft = FMLClientHandler.instance().getClient();
    EntityPlayer player = minecraft.thePlayer;
    ItemStack helmetStack = player.inventory.armorInventory[3];
    if (helmetStack != null && minecraft.inGameHasFocus && helmetStack.getItem() == Itemss.pneumaticHelmet) {
        ScaledResolution sr = new ScaledResolution(minecraft, minecraft.displayWidth, minecraft.displayHeight);
        GL11.glDepthMask(false);
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glPushMatrix();
        GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
        GL11.glColor4d(0, 1, 0, 0.8D);
        CommonHUDHandler comHudHandler = CommonHUDHandler.getHandlerForPlayer(player);
        if (comHudHandler.ticksExisted <= comHudHandler.getStartupTime()) {
            // blockTrackInfo = null;
            gaveEmptyWarning = false;
            gaveNearlyEmptyWarning = false;
            RenderProgressBar.render(sr.getScaledWidth() / 2, 10, sr.getScaledWidth() - 10, 30, -90F, comHudHandler.ticksExisted * 100 / comHudHandler.getStartupTime());
        } else {
            if (comHudHandler.helmetPressure < 0.05F && !gaveEmptyWarning) {
                addMessage(new ArmorMessage("The helmet is out of air!", new ArrayList<String>(), 100, 0x70FF0000));
                gaveEmptyWarning = true;
            }
            if (comHudHandler.helmetPressure > 0.2F && comHudHandler.helmetPressure < 0.5F && !gaveNearlyEmptyWarning) {
                addMessage(new ArmorMessage("The helmet almost out of air!", new ArrayList<String>(), 60, 0x70FF0000));
                gaveNearlyEmptyWarning = true;
            }
            if (GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade.coreComponents").checked) {
                for (int i = 0; i < UpgradeRenderHandlerList.instance().upgradeRenderers.size(); i++) {
                    IUpgradeRenderHandler upgradeRenderHandler = UpgradeRenderHandlerList.instance().upgradeRenderers.get(i);
                    if (comHudHandler.upgradeRenderersInserted[i] && GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade." + upgradeRenderHandler.getUpgradeName()).checked) {
                        IGuiAnimatedStat stat = upgradeRenderHandler.getAnimatedStat();
                        if (stat != null) {
                            stat.render(-1, -1, partialTicks);
                        }
                        upgradeRenderHandler.render2D(partialTicks, comHudHandler.helmetPressure > 0F);
                    }
                }
            }
        }
        // render every item in the list.
        for (ArmorMessage message : messageList) {
            message.renderMessage(minecraft.fontRenderer, partialTicks);
        }
        GL11.glPopMatrix();
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDepthMask(true);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        if (comHudHandler.ticksExisted <= comHudHandler.getStartupTime())
            minecraft.fontRenderer.drawString(CommonHUDHandler.getHandlerForPlayer().ticksExisted * 100 / comHudHandler.getStartupTime() + "%", sr.getScaledWidth() * 3 / 4 - 8, 16, 0x000000);
    } else if (helmetStack == null) {
        messageList.clear();
    }
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) IUpgradeRenderHandler(pneumaticCraft.api.client.pneumaticHelmet.IUpgradeRenderHandler) CommonHUDHandler(pneumaticCraft.common.CommonHUDHandler) ArrayList(java.util.ArrayList) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) IGuiAnimatedStat(pneumaticCraft.api.client.IGuiAnimatedStat)

Example 14 with Minecraft

use of net.minecraft.client.Minecraft in project PneumaticCraft by MineMaarten.

the class HUDHandler method renderWorldLastEvent.

@SubscribeEvent
public void renderWorldLastEvent(RenderWorldLastEvent event) {
    if (!GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade.coreComponents").checked)
        return;
    Minecraft mc = FMLClientHandler.instance().getClient();
    EntityPlayer player = mc.thePlayer;
    double playerX = player.prevPosX + (player.posX - player.prevPosX) * event.partialTicks;
    double playerY = player.prevPosY + (player.posY - player.prevPosY) * event.partialTicks;
    double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * event.partialTicks;
    GL11.glPushMatrix();
    GL11.glTranslated(-playerX, -playerY, -playerZ);
    ItemStack helmetStack = player.inventory.armorInventory[3];
    if (helmetStack != null && helmetStack.getItem() == Itemss.pneumaticHelmet) {
        if (((IPressurizable) helmetStack.getItem()).getPressure(helmetStack) > 0F) {
            CommonHUDHandler comHudHandler = CommonHUDHandler.getHandlerForPlayer(player);
            if (comHudHandler.ticksExisted > comHudHandler.getStartupTime()) {
                GL11.glDisable(GL11.GL_TEXTURE_2D);
                for (int i = 0; i < UpgradeRenderHandlerList.instance().upgradeRenderers.size(); i++) {
                    if (comHudHandler.upgradeRenderersInserted[i] && GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade." + UpgradeRenderHandlerList.instance().upgradeRenderers.get(i).getUpgradeName()).checked)
                        UpgradeRenderHandlerList.instance().upgradeRenderers.get(i).render3D(event.partialTicks);
                }
                GL11.glEnable(GL11.GL_TEXTURE_2D);
            }
        }
    }
    GL11.glPopMatrix();
}
Also used : CommonHUDHandler(pneumaticCraft.common.CommonHUDHandler) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 15 with Minecraft

use of net.minecraft.client.Minecraft in project PneumaticCraft by MineMaarten.

the class MainHelmetHandler method getAnimatedStat.

@Override
@SideOnly(Side.CLIENT)
public IGuiAnimatedStat getAnimatedStat() {
    if (powerStat == null) {
        Minecraft minecraft = Minecraft.getMinecraft();
        ScaledResolution sr = new ScaledResolution(minecraft, minecraft.displayWidth, minecraft.displayHeight);
        powerStat = new GuiAnimatedStat(null, "Helmet Pressure: ", "", powerStatX != -1 ? powerStatX : sr.getScaledWidth() - 2, powerStatY, 0x3000AA00, null, powerStatLeftSided);
        powerStat.setMinDimensionsAndReset(0, 0);
        powerStat.openWindow();
    }
    return powerStat;
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) GuiAnimatedStat(pneumaticCraft.client.gui.widget.GuiAnimatedStat) IGuiAnimatedStat(pneumaticCraft.api.client.IGuiAnimatedStat) Minecraft(net.minecraft.client.Minecraft) SideOnly(cpw.mods.fml.relauncher.SideOnly)

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