Jump to content

[1.10.2] Issue Drawing Gui to Screen


abused_master

Recommended Posts

Hey guys, me again

Iv pretty much fixed almost all my problems except this 1 that just keeps bugging me.

In my gui I have this method:

    @Override
    protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
        mc.getTextureManager().bindTexture(Pulverizer);
        drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
        
if (pulverizer.storage.getEnergyStored() > 0) {
            drawTexturedModalRect(guiLeft + 9, guiTop + 8, 177, 3, 14, 42);
        }
    }
}

Basically I'm checking my TE if the power stored is greater than 0, and if it is to draw a part of the gui on the screen that is not being drawn by the method above it. The problem im getting though is it crashes when i right click my block in game with the crash:

http://pastebin.com/mZ74ADVC

When i trace the crash it takes me to the if (pulverizer.storage.getEnergyStored() > 0) line

im not sure how that has anything to do with it

 

Link to comment
Share on other sites

Debug your code. You have an object that is not null.  These are very easy to find.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Debug your code. You have an object that is not null.  These are very easy to find.

Not null? Of course those are easy to find.  ;D

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Debug your code. You have an object that is not null.  These are very easy to find.

Not null? Of course those are easy to find.  ;D

 

Derp. Distracted and such.  I probably retyped half the post twice.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Debug your code. You have an object that is not null.  These are very easy to find.

Huh, silly me, i forgot to initialize the variable

Thats that, but now to the draw method, im inputting energy from ender io CapacitorBanks

so it has the energy, i have tested that earlier, but its almost as if this isnt reading the energy stored:

        if (pulverizer.storage.getEnergyStored() > 0) {
            drawTexturedModalRect(guiLeft + 9, guiTop + 8, 177, 3, 14, 42);
        }

Link to comment
Share on other sites

Normally you have to have the server update a client on "custom" data. Inventories and such are handled nicely thanks to Containers. But any other variables that are stored in a tileEntity, Capability, etc. You will need a packet to send to the player with the info. I can help you understand packets if you wish. But there are quite a few documents around already that does a good job explaining them.|

 

EDIT:

 

That is i'm understanding that the "Amount of Power" is not showing correctly and it's not a "No picture is drawing" aka "Power = 0" when machine does indeed have power

 

EDIT2:

Is it a drawing issue, or Information issue?

Link to comment
Share on other sites

I dont believe i need packets as i remember a mod i was making as a test in the beginning when 1.10.2 came out, i had it set to get the amount of energy stored and do stuff based on how much is stored.

 

Now to clarify thing up a bit, the issue im seeing is its not reading the amount of power stored, i know it IS storing power as i have done some tests to make sure of that. in the GUI class im telling it to check how much power is stored, max power storage is 50k, if the power stored is greater than 0 then draw the part of the image im telling it to.

Link to comment
Share on other sites

I dont believe i need packets as i remember a mod i was making as a test in the beginning when 1.10.2 came out, i had it set to get the amount of energy stored and do stuff based on how much is stored.

 

Now to clarify thing up a bit, the issue im seeing is its not reading the amount of power stored, i know it IS storing power as i have done some tests to make sure of that. in the GUI class im telling it to check how much power is stored, max power storage is 50k, if the power stored is greater than 0 then draw the part of the image im telling it to.

Look at how the vanilla furnace syncs it's info it does so with its container.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Yeah that's an information issue then. See when you save and load a world the server knows what all the data is. But when a client (player) joins pretty much everything is a clean slate. Why TileEntites and Capabilities need packets to update a client(player) because vanilla MC doesn't handle custom data for us.

 

But if you're just looking for "as long as it's got some power" you could have the block/tileEntity output a redstone signal? that should auto-sync between server and client and you could go off of that.

 

But i'm 99% sure you will need the server to send some data to the client so the GUI can work correctly.

 

Pre-Edit:

@Animefan8888 I didn't know you could use a container to also transfer additional information.

Link to comment
Share on other sites

Yeah that's an information issue then. See when you save and load a world the server knows what all the data is. But when a client (player) joins pretty much everything is a clean slate. Why TileEntites and Capabilities need packets to update a client(player) because vanilla MC doesn't handle custom data for us.

 

But if you're just looking for "as long as it's got some power" you could have the block/tileEntity output a redstone signal? that should auto-sync between server and client and you could go off of that.

 

But i'm 99% sure you will need the server to send some data to the client so the GUI can work correctly.

 

Pre-Edit:

@Animefan8888 I didn't know you could use a container to also transfer additional information.

The listener system. It is why when you create a GuiContainer you pass a container.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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.