Search in sources :

Example 1 with StateStartup

use of pokefenn.totemic.tileentity.totem.StateStartup in project Totemic by TeamTotemic.

the class GameOverlay method renderHUD.

@SubscribeEvent
public void renderHUD(RenderGameOverlayEvent.Post event) {
    if (event.getType() != ElementType.ALL)
        return;
    Minecraft mc = Minecraft.getMinecraft();
    mc.mcProfiler.startSection("totemicHUD");
    if (activeTotem != null) {
        if (activeTotem.isInvalid() || !(activeTotem.getState() instanceof StateStartup || activeTotem.getState() instanceof StateCeremonyEffect))
            activeTotem = null;
    }
    if (activeTotem != null) {
        int w = 117;
        int h = 30;
        double texW = 128;
        double texH = 64;
        float hudX = (event.getResolution().getScaledWidth() - w) / 2 + ModConfig.client.ceremonyHudPositionX;
        float hudY = (event.getResolution().getScaledHeight() - h) / 2 + ModConfig.client.ceremonyHudPositionY;
        Tessellator tes = Tessellator.getInstance();
        BufferBuilder buf = tes.getBuffer();
        FontRenderer font = mc.fontRenderer;
        GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_ENABLE_BIT);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GlStateManager.pushMatrix();
        GlStateManager.translate(hudX, hudY, 0);
        // Background
        mc.renderEngine.bindTexture(hudTexture);
        buf.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
        RenderHelper.addQuad(buf, 0, 0, 0, w, h, 0, 0, w / texW, h / texH);
        tes.draw();
        int barW = 104;
        int barH = 7;
        if (activeTotem.getState() instanceof StateStartup) {
            StateStartup state = (StateStartup) activeTotem.getState();
            Ceremony cer = state.getCeremony();
            String locName = I18n.format(cer.getUnlocalizedName());
            int nameX = (w - font.getStringWidth(locName)) / 2;
            font.drawString(locName, nameX, 1, 0xC8000000);
            GlStateManager.color(1, 1, 1);
            mc.renderEngine.bindTexture(hudTexture);
            buf.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
            // Note
            RenderHelper.addQuad(buf, 1, 10, 0, 9, 9, 16 / texW, 48 / texH, 8 / texW, 8 / texH);
            // Clock
            RenderHelper.addQuad(buf, 1, 20, 0, 9, 9, 0 / texW, 48 / texH, 16 / texW, 16 / texH);
            float musicW = state.getTotalMusic() / (float) cer.getMusicNeeded() * barW;
            float timeW = Math.min(state.getTime() / (float) cer.getAdjustedMaxStartupTime(mc.world.getDifficulty()), 1.0f) * barW;
            // Music bar
            RenderHelper.addQuad(buf, 11, 11, 0, musicW, barH, 0, 32 / texH, musicW / texW, barH / texH);
            // Time bar
            RenderHelper.addQuad(buf, 11, 21, 0, timeW, barH, 0, 32 / texH, timeW / texW, barH / texH);
            tes.draw();
        } else if (activeTotem.getState() instanceof StateCeremonyEffect) {
            StateCeremonyEffect state = (StateCeremonyEffect) activeTotem.getState();
            Ceremony cer = state.getCeremony();
            String locName = I18n.format(cer.getUnlocalizedName());
            int nameX = (w - font.getStringWidth(locName)) / 2;
            font.drawString(locName, nameX, 1, 0xC8000000);
        }
        GlStateManager.popMatrix();
        GL11.glPopAttrib();
    }
    mc.mcProfiler.endSection();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) StateStartup(pokefenn.totemic.tileentity.totem.StateStartup) StateCeremonyEffect(pokefenn.totemic.tileentity.totem.StateCeremonyEffect) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) FontRenderer(net.minecraft.client.gui.FontRenderer) Minecraft(net.minecraft.client.Minecraft) Ceremony(pokefenn.totemic.api.ceremony.Ceremony) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with StateStartup

use of pokefenn.totemic.tileentity.totem.StateStartup in project Totemic by TeamTotemic.

the class WailaTotemBase method getWailaBody.

@Override
@Nonnull
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
    TileTotemBase tile = (TileTotemBase) accessor.getTileEntity();
    if (tile.getState() instanceof StateSelection) {
        String selectors = ((StateSelection) tile.getState()).getSelectors().stream().map(instr -> I18n.format(instr.getUnlocalizedName())).collect(Collectors.joining(", "));
        currenttip.add(I18n.format("totemicmisc.selection", selectors));
    } else if (tile.getState() instanceof StateStartup) {
        Ceremony ceremony = ((StateStartup) tile.getState()).getCeremony();
        currenttip.add(I18n.format("totemic.waila.ceremonyStartup", I18n.format(ceremony.getUnlocalizedName())));
    } else if (tile.getState() instanceof StateCeremonyEffect) {
        Ceremony ceremony = ((StateCeremonyEffect) tile.getState()).getCeremony();
        currenttip.add(I18n.format("totemic.waila.ceremonyEffect", I18n.format(ceremony.getUnlocalizedName())));
    }
    return currenttip;
}
Also used : Ceremony(pokefenn.totemic.api.ceremony.Ceremony) Collectors(java.util.stream.Collectors) IWailaConfigHandler(mcp.mobius.waila.api.IWailaConfigHandler) I18n(net.minecraft.client.resources.I18n) ItemStack(net.minecraft.item.ItemStack) List(java.util.List) StateCeremonyEffect(pokefenn.totemic.tileentity.totem.StateCeremonyEffect) IWailaDataAccessor(mcp.mobius.waila.api.IWailaDataAccessor) StateStartup(pokefenn.totemic.tileentity.totem.StateStartup) StateSelection(pokefenn.totemic.tileentity.totem.StateSelection) Nonnull(javax.annotation.Nonnull) IWailaDataProvider(mcp.mobius.waila.api.IWailaDataProvider) TileTotemBase(pokefenn.totemic.tileentity.totem.TileTotemBase) TileTotemBase(pokefenn.totemic.tileentity.totem.TileTotemBase) StateStartup(pokefenn.totemic.tileentity.totem.StateStartup) StateCeremonyEffect(pokefenn.totemic.tileentity.totem.StateCeremonyEffect) StateSelection(pokefenn.totemic.tileentity.totem.StateSelection) Ceremony(pokefenn.totemic.api.ceremony.Ceremony) Nonnull(javax.annotation.Nonnull)

Aggregations

Ceremony (pokefenn.totemic.api.ceremony.Ceremony)2 StateCeremonyEffect (pokefenn.totemic.tileentity.totem.StateCeremonyEffect)2 StateStartup (pokefenn.totemic.tileentity.totem.StateStartup)2 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Nonnull (javax.annotation.Nonnull)1 IWailaConfigHandler (mcp.mobius.waila.api.IWailaConfigHandler)1 IWailaDataAccessor (mcp.mobius.waila.api.IWailaDataAccessor)1 IWailaDataProvider (mcp.mobius.waila.api.IWailaDataProvider)1 Minecraft (net.minecraft.client.Minecraft)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)1 Tessellator (net.minecraft.client.renderer.Tessellator)1 I18n (net.minecraft.client.resources.I18n)1 ItemStack (net.minecraft.item.ItemStack)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 StateSelection (pokefenn.totemic.tileentity.totem.StateSelection)1 TileTotemBase (pokefenn.totemic.tileentity.totem.TileTotemBase)1