Java 类net.minecraftforge.client.event.RenderGameOverlayEvent.Post 实例源码

项目:Wizardry    文件:HudEventHandler.java   
@SubscribeEvent
public void renderHud(Post event) {
    ScaledResolution resolution = event.getResolution();
    int width = resolution.getScaledWidth();
    int height = resolution.getScaledHeight();
    EntityPlayer player = Minecraft.getMinecraft().player;

    ItemStack stack = BaublesSupport.getItem(player, ModItems.FAKE_HALO, ModItems.CREATIVE_HALO, ModItems.REAL_HALO);
    if (stack == null || stack.isEmpty()) return;

    if (event.getType() == ElementType.EXPERIENCE) {

        HUD_TEXTURE.bind();

        GlStateManager.pushMatrix();
        GlStateManager.color(1.0F, 1.0F, 1.0F);
        int right = ((width / 2) - (100 / 2)) + 145;
        int top = height - 17;
        emptyManaBar.draw(ClientTickHandler.getTicks(), right, top);
        emptyBurnoutBar.draw(ClientTickHandler.getTicks(), right, top + 6);
        GlStateManager.popMatrix();

        CapManager manager = new CapManager(player);

        GlStateManager.pushMatrix();
        GlStateManager.color(1.0F, 1.0F, 1.0F);
        int visualManaLength = 0;
        if (manager.getMana() > 0)
            visualManaLength = (int) (((manager.getMana() * 100) / manager.getMaxMana()) % 101);
        fullManaBar.drawClipped(ClientTickHandler.getTicks(), right, top, visualManaLength, 5);

        GlStateManager.color(1.0F, 1.0F, 1.0F);
        int visualBurnoutLength = 0;
        if (manager.getBurnout() > 0)
            visualBurnoutLength = (int) (((manager.getBurnout() * 100) / manager.getMaxBurnout()) % 101);
        fullBurnoutBar.drawClipped(ClientTickHandler.getTicks(), right, top + 6, visualBurnoutLength, 5);
        GlStateManager.popMatrix();
    }
}
项目:Skills    文件:DebugHud.java   
public static void DrawDebugHud(Post event)
{

        if(SKSettings.showDebug == false) return;
        DebugHud.instance.DrawStat(event);
        DebugHud.instance.DrawSkill(event);
        DebugHud.instance.drawSkillDiff(event);

}
项目:Skills    文件:DebugHud.java   
public static void drawSkillDiff(Post event)
{
    Vec3 look = Minecraft.getMinecraft().thePlayer.getLookVec();

     lookingAt = null;

    BlockPos blockLoc = Minecraft.getMinecraft().objectMouseOver.getBlockPos();
    try{
        lookingAt = Minecraft.getMinecraft().theWorld.getBlockState(blockLoc);  

    }catch(NullPointerException e)
    {
    }

    if(lookingAt != null)
    {
        lookingAt = Minecraft.getMinecraft().theWorld.getBlockState(blockLoc);
        if(lookingAt.getBlock() == Blocks.air) return;

        ScaledResolution res = event.resolution;            
        SkillTrackerData tracker = SkillTrackerData.get(Minecraft.getMinecraft().thePlayer);

        if(SkillDifficulty.hasBlockDifficulty(lookingAt) && tracker != null)
        {
            SkillDifficulty skdiff = SkillDifficulty.getBlockDifficulty(lookingAt);
            if(skdiff == null) return;

            SkillTreeBase skill = tracker.GetSkillByID(skdiff.skillType);
            if(skill == null) return;

            double chance = skill.getChance(skdiff);
            double gainS = skill.DebugFormula(Minecraft.getMinecraft().thePlayer, chance, skdiff,1);
            double gainF = skill.DebugFormula(Minecraft.getMinecraft().thePlayer, chance, skdiff,0);
            Minecraft.getMinecraft().fontRendererObj.drawString( lookingAt.getBlock().getLocalizedName(), res.getScaledWidth() - 130 , res.getScaledHeight()/2 + 20, Color.WHITE.getRGB());
            Minecraft.getMinecraft().fontRendererObj.drawString( "Skill Type: "+ skdiff.skillType, res.getScaledWidth() - 130 , res.getScaledHeight()/2 + 35, Color.WHITE.getRGB());
            Minecraft.getMinecraft().fontRendererObj.drawString( "Success Chance: "+ MathHelper.round((float)(chance*100),0) +"%" , res.getScaledWidth() - 130 , res.getScaledHeight()/2 + 50, Color.WHITE.getRGB());
            Minecraft.getMinecraft().fontRendererObj.drawString(  "Gain Chance S/F: ", res.getScaledWidth() - 130 , res.getScaledHeight()/2 + 65, Color.WHITE.getRGB());
            Minecraft.getMinecraft().fontRendererObj.drawString(  MathHelper.round((float) (gainS*100),0) +"% / "+ MathHelper.round((float) (gainF*100),0) +"%" , res.getScaledWidth() - 130 , res.getScaledHeight()/2 + 80, Color.WHITE.getRGB());
        }



        //System.out.println(lookingAt.getBlock().getLocalizedName()+ ">>><<<<");
    }
}
项目:GimmeTime    文件:RenderClockHUD.java   
@SubscribeEvent
public void onRenderGameOverlayPost(Post event) {
    if (event.type == ElementType.ALL) {

        Minecraft mc = Minecraft.getMinecraft();
        FontRenderer fr = mc.fontRenderer;
        Profiler p = mc.mcProfiler;
        p.startSection("gimmetime-hud");

        switch (ConfigHandler.analog_digital) {
            case 0: // None
                break;
            case 1: // Analog
                p.startSection("clock");
                RenderUtil.drawClock(32, 34, 24);
                p.endSection();
                break;
            case 2: // Digital
                p.startSection("clock");
                drawString(TimeUtil.getTime(), 1, 1);
                p.endSection();
                break;
            case 3: // Both
                p.startSection("clock");
                RenderUtil.drawClock(32, 34, 24);
                drawString(TimeUtil.getTime(), 64, 1);
                p.endSection();
                break;
        }

        if (currentAlarm != null) {
            p.startSection("alarm");
            String title = currentAlarm.getTitle() + " - " + TimeUtil.getAlarmTimeString();
            drawString(title, (event.resolution.getScaledWidth() / 2) - (fr.getStringWidth(title) / 2), (event.resolution.getScaledHeight() / 2) - (fr.FONT_HEIGHT + 4));
            String closeHint = StatCollector.translateToLocalFormatted("hud.alarmAlert.close", GameSettings.getKeyDisplayString(KeyHandler.INSTANCE.clock.getKeyCode()));
            drawString(closeHint, (event.resolution.getScaledWidth() / 2) - (fr.getStringWidth(closeHint) / 2), (event.resolution.getScaledHeight() / 2) + (fr.FONT_HEIGHT - 2));
            p.endSection();
        }

        p.endSection();

    }

}
项目:MyMod    文件:RenderClockHUD.java   
@SubscribeEvent
public void onRenderGameOverlayPost(Post event) {
    if (event.type == ElementType.ALL) {

        switch (ConfigHandler.analog_digital) {
            case 0: // None
                return;

            case 1: // Analog
                RenderUtil.drawClock(
                        (!TimeUtil.isPM() || ConfigHandler.am_pm) ? 31 : 37,
                        34, 24);
                break;

            case 2: // Digital
                Minecraft.getMinecraft().fontRenderer.drawString(
                        TimeUtil.getTime(), 1, 1, ConfigHandler.color);
                break;

            case 3: // Both
                RenderUtil.drawClock(
                        (!TimeUtil.isPM() || ConfigHandler.am_pm) ? 31 : 37,
                        34, 24);
                Minecraft.getMinecraft().fontRenderer.drawString(
                        TimeUtil.getTime(),
                        (!TimeUtil.isPM() || ConfigHandler.am_pm) ? 62 : 74, 1,
                        ConfigHandler.color);
                break;
        }

        if (currentAlarm != null) {
            Minecraft.getMinecraft().fontRenderer
                    .drawString(
                            currentAlarm.getTitle()
                                    + " - "
                                    + TimeUtil.make2Digits(currentAlarm
                                    .getHour())
                                    + ConfigHandler.separator
                                    + TimeUtil.make2Digits(currentAlarm
                                    .getMin()),
                            (event.resolution.getScaledWidth() / 2)
                                    - (Minecraft.getMinecraft().fontRenderer.getStringWidth(currentAlarm
                                    .getTitle()
                                    + " - "
                                    + TimeUtil
                                    .make2Digits(currentAlarm
                                            .getHour())
                                    + ConfigHandler.separator
                                    + TimeUtil
                                    .make2Digits(currentAlarm
                                            .getMin())) / 2),
                            (event.resolution.getScaledHeight() / 2)
                                    - (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT + 4),
                            ConfigHandler.color);
            Minecraft.getMinecraft().fontRenderer
                    .drawString(
                            StatCollector
                                    .translateToLocalFormatted(
                                            "hud.alarmAlert.close",
                                            Keyboard.getKeyName(KeyHandler
                                                    .getKeyBinding(
                                                            KeyHandler.KEYBINDING_CLOCK)
                                                    .getKeyCode())),
                            (event.resolution.getScaledWidth() / 2)
                                    - (Minecraft.getMinecraft().fontRenderer.getStringWidth(StatCollector
                                    .translateToLocalFormatted(
                                            "hud.alarmAlert.close",
                                            Keyboard.getKeyName(KeyHandler
                                                    .getKeyBinding(
                                                            KeyHandler.KEYBINDING_CLOCK)
                                                    .getKeyCode()))) / 2),
                            (event.resolution.getScaledHeight() / 2)
                                    + (Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 2),
                            ConfigHandler.color);

        }

    }

}