Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I've created a "IIngameOverlay", to that overlay I'm trying to get an specific attribute value of the player, but always return 0.0. Someone can help me?

Spoiler
public static final IIngameOverlay ESSENCE_HABILITY_DURATION = OverlayRegistry.registerOverlayTop("Player Mod Hability", (gui, mStack, partialTicks, screenWidth, screenHeight) -> {
        if (!Minecraft.getInstance().options.hideGui && gui.shouldDrawSurvivalElements())
        {
            if(PlayerEvolution.onEffect.containsKey(Minecraft.getInstance().player)) {
                gui.setupOverlayRenderState(true, false);
                new PlayerGUI().renderPlayerHability(gui, mStack, screenWidth, screenHeight, Minecraft.getInstance().player) ;
            }
        }
    });

 

Spoiler
private void renderPlayerHability(Gui gui, PoseStack matrixStack, int screenWidth, int screenHeight, Player jogador){
        int x = (screenWidth / 2) - 91;
        int y = screenHeight - 55 - (10 * (jogador.getArmorValue() > 0 ? 1 : 0));

        System.out.println(Mth.floor(jogador.getAttributeValue(Attributes.ARMOR)));
        System.out.println(Mth.floor(jogador.getAttributeValue(ModAttributes.INTELLECT)));

        Minecraft.getInstance().getProfiler().pop();
        Minecraft.getInstance().getProfiler().push("expBar");
        RenderSystem.setShaderTexture(0, ICON_LOCATION);
        EssenceHabilities habilities = PlayerEvolution.getPlayerHability(jogador);
        int typeBar = habilities == null ? 0 : habilities.getCategory().getCategoryId();
        EssenceSyntonizerTier tier = PlayerEvolution.lastSyntonizerTierUsed.getOrDefault(Minecraft.getInstance().player, EssenceSyntonizerTier.NONE);
        int maxDuration = EssenceHabilitiesHelper.calculateDuration(habilities, jogador, tier);
        int duration = PlayerEvolution.onEffect.containsKey(jogador) ? PlayerEvolution.onEffect.get(jogador).getDuration() : 0;

        int i = (int) Math.round((( (double) duration / (double) maxDuration) * 102D));
        gui.blit(matrixStack, x, y, 43,6 + (typeBar * 10), 102, 5);
        gui.blit(matrixStack, x, y, 43,1 + (typeBar * 10), i, 5);

        Minecraft.getInstance().getProfiler().pop();
        RenderSystem.enableBlend();
    }

 

Exactly in this method, the value return 0:

Spoiler
public static int calculateDuration(EssenceHabilities hability, Player player, EssenceSyntonizerTier tier){
        double playerIntellect = player.getAttributeValue(ModAttributes.INTELLECT); //0 - 100
        double percentGain = 1 + (playerIntellect / 80);
        int duration = hability.getDuration() + ((tier.getId() / 3) * 50) + ((tier.getId() / 10) * 50);
        return (int) (duration * percentGain);
    }

 

 

that's because the client doesn't know the value, it's only stored on server and the client will get it when the server update the value to the client 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.