Posted October 14, 20214 yr 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); }
October 14, 20214 yr 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.