Jump to content

[1.10.2] Can't return NBTTag data


PigeonDamigion

Recommended Posts

So I'm making a UI for my mod, that shows stats that are returned from the NBTTag data of the player, right? Well, the problem is it doesn't seem to work at all, cause all it returns is null.

Also, I'm basically brand new to modding, so please tell me if some of my code is redundant/useless

 

@Override
     public void drawScreen(int mouseX, int mouseY, float partialTicks) {
         Minecraft.getMinecraft().renderEngine.bindTexture(texture);
         int centerX = width/2 - guiWidth/2;
         int centerY = height/2 - guiHeight/2;
         GlStateManager.pushMatrix(); {
             GlStateManager.enableAlpha();
             GlStateManager.enableBlend();
             GlStateManager.color(1, 1, 1, 0.7F);
             drawTexturedModalRect(centerX, centerY, 0, 0, guiWidth, guiHeight);
         }
         GlStateManager.popMatrix();
         drawString(fontRendererObj, "Stand:", centerX+5, centerY+10, 0xFFFFFF);
         drawString(fontRendererObj, "STR:", centerX+5, centerY+50, 0xFFFFFF);
         drawString(fontRendererObj, "END:", centerX+5, centerY+65, 0xFFFFFF);
         drawString(fontRendererObj, "SPE:", centerX+5, centerY+80, 0xFFFFFF);
         
         EntityPlayer player = Minecraft.getMinecraft().thePlayer;
         NBTTagCompound persistTag = player.getEntityData().getCompoundTag(player.PERSISTED_NBT_TAG);
         NBTTagCompound jojoTag = persistTag.getCompoundTag("Jojo");
        
         switch (jojoTag.getInteger("Stand")) {
         case 1:
               String strength, endurance, special;
               String Stand = "Killer Queen";
               strength=String.valueOf(jojoTag.getInteger("Stand_str"));
               endurance=String.valueOf(jojoTag.getInteger("Stand_end"));
               special=String.valueOf(jojoTag.getInteger("Stand_spe"));
               
               drawString(fontRendererObj, Stand, centerX+40, centerY+10, 0xFFFFFF);
               drawString(fontRendererObj, strength, centerX+30, centerY+50, 0xFFFFFF);
               drawString(fontRendererObj, endurance, centerX+30, centerY+65, 0xFFFFFF);
               drawString(fontRendererObj, special, centerX+30, centerY+80, 0xFFFFFF);
               break;
           case 2:
               
               break;
           case 3:
               
               break;
           default:
               System.out.println("ERROR: you fucked up with the Gui data");
               System.out.println(Minecraft.getMinecraft().thePlayer.getEntityData().getInteger("Stand"));
               
               String none = "None";
               drawString(fontRendererObj, none, centerX+40, centerY+10, 0xFFFFFF);
               drawString(fontRendererObj, "0", centerX+30, centerY+50, 0xFFFFFF);
               drawString(fontRendererObj, "0", centerX+30, centerY+65, 0xFFFFFF);
               drawString(fontRendererObj, "0", centerX+30, centerY+80, 0xFFFFFF);
               break;
           }
        
         super.drawScreen(mouseX, mouseY, partialTicks);
     }

Link to comment
Share on other sites

2 hours ago, PigeonDamigion said:

         NBTTagCompound persistTag = player.getEntityData().getCompoundTag(player.PERSISTED_NBT_TAG);

I am pretty sure these don't get synced to the client.

You shouldn't be using this anyway, use capabilities.

 

2 hours ago, PigeonDamigion said:

GlStateManager.pushMatrix(); {
             GlStateManager.enableAlpha();
             GlStateManager.enableBlend();
              GlStateManager.color(1, 1, 1, 0.7F);
             drawTexturedModalRect(centerX, centerY, 0, 0, guiWidth, guiHeight);
         }
         GlStateManager.popMatrix();

There are no reasons whatsoever to push/pop matrix here. You are not changing the matrix in any way.

If you change the GL state to something change it back when you are done.

If you are enabling blend then specify the blend profile too.

 

Why are you modding for 1.10.2 anyway? It's outdated, use 1.12.2.

  • Thanks 1
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.