Jump to content

[1.7.10][Solved] Rendering items on HUD positions horizontally mirrored


Recommended Posts

Posted

So I have quite a weird situation as far as I can see - the positions of items around my circle are mirrored to where they should be, so when you select one thing you actually get the result above/below what you selected.

 

Hopefully this is clearer with the pictures below:

ENi7a7x.png

Gh07klU.png

 

The first image shows how each item is switched (note the ones at the end i.e stick and emerald are in the correct places) and the second shows the order in which they should be in.

 

Here is the rendering code:

double radiansPerSector = 2 * Math.PI / sectors;
double offset = 0;
if (inventoryContents.length % 2 == 0) offset += radiansPerSector / 2;

for(int i = 0; i < inventoryContents.length; i++) // Draw icons
{
double radians = offset + radiansPerSector * i - Math.PI / 2;

double itemX = this.ITEM_RADIUS * Math.cos(radians) + centreX - 8; // 8 = offset for texture centre
double itemY = this.ITEM_RADIUS * Math.sin(radians) + centreY - 8; // TODO Switch 8 for constant

this.renderItemIntoGUI(minecraft.fontRenderer, minecraft.getTextureManager(), inventoryContents[i], itemX, itemY, true);
}

 

If you need to see anything else, I'll stick it on. Any help is appreciated.

I have no idea what I'm doing.

Posted

After fiddling around with many combinations of numbers, I've managed to get it to work.

 

I've changed the offset and radians algorithms.

 

double radiansPerSector = 2 * Math.PI / sectors;
double offset = 0 - Math.PI / 2;
if (inventoryContents.length % 2 == 0) offset = 0 - Math.PI / 2 + radiansPerSector / 2;

for(int i = 0; i < inventoryContents.length; i++) // Draw icons
{
double radians = 0 - (offset + radiansPerSector * i);

double itemX = this.ITEM_RADIUS * Math.cos(radians) + centreX - 8; // 8 = offset for texture centre
double itemY = this.ITEM_RADIUS * Math.sin(radians) + centreY - 8; // TODO Switch 8 for constant

this.renderItemIntoGUI(minecraft.fontRenderer, minecraft.getTextureManager(), inventoryContents[i], itemX, itemY, true);
}

I have no idea what I'm doing.

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.