Jump to content

LocalPlayer attribute


LuccaPossamai

Recommended Posts

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);
    }

 

 

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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