Jump to content

Recommended Posts

Posted

I need some help. I want a block to display a gui when right clicked. The GUI is the ending game cutscene, but i'll be editing to my advantage(different words), but i cant seem to get it to work. Im in 1.5.1, and I'm not using a tile entity. Because, mojang didn't, and I'm using that class, so, yeah.

?Here is my code.

Main mod file(PortalBallMain)

 

  Reveal hidden contents

 

 

 

BlockOpener(the block that opens the gui.

 

  Reveal hidden contents

 

 

GUIOpening(the gui)

 

  Reveal hidden contents

 

 

HELP!

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Posted
  Quote
and I'm not using a tile entity. Because, mojang didn't, and I'm using that class, so, yeah.

Then explain your code:

  Quote
if (tileEntity == null || player.isSneaking()) {

            return false;

}

  Quote

If you guys dont get it.. then well ya.. try harder...

Posted
  On 4/28/2013 at 12:26 AM, Mazetar said:

  Quote
and I'm not using a tile entity. Because, mojang didn't, and I'm using that class, so, yeah.

Then explain your code:

  Quote
if (tileEntity == null || player.isSneaking()) {

            return false;

}

Well, thats me trying to open it.

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Posted

1. Do you understand what the code I quoted is doing??

Since you are not using a tE it seems to be quite weird for it to be there.

 

2. As he said above you need an GuiHandler it's a forgewiki page about Gui's and containers, if you learn that then skipp the tE and container (use GuiScreen) u should be good.

  Quote

If you guys dont get it.. then well ya.. try harder...

Posted

Yeah, i read that post. I just could see how to work out the container/tE, its been a while since ive coded in java.

I'll look again and see if i can delete the code for the container and tE, but what do you mean by use GuiScreen, im already extending that. Do you mean instead of the tE?

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Posted
  On 4/28/2013 at 11:11 AM, Mazetar said:

1. Do you understand what the code I quoted is doing??

Since you are not using a tE it seems to be quite weird for it to be there.

 

?

  Quote

If you guys dont get it.. then well ya.. try harder...

Posted

Well my question was if you understood what the code was doing..

 

And you're first response was "Well, thats me trying to open it."

When the code is not showing player.openGUI but the code before that, and your statement did not tell me what the code actually is doing.

So do you know what these lines are doing? They explain why your program isn't crashing without a GuiHandler.

 

  Quote

If you guys dont get it.. then well ya.. try harder...

Posted

wait? So, if i add a tile entity, that dosnt render anything to the screen, it might work?

And yes, i know what the code is doing somewhat, its trying to load up a tile entity, but not finding one, so it just returns null, and moves along.

Did I just Have a breakthrough? ;D

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Posted
  Quote
And yes, i know what the code is doing somewhat, its trying to load up a tile entity, but not finding one, so it just returns null, and moves along.

if (tileEntity == null || player.isSneaking()) {
            return false;
}

 

No that's not what "return false" means.

When it says return it means, it will stop reading that method and return some value back to the caller.

This means that since you NEVER will have a tileEntity it will allways be NULL and therefore it will always read the "return false" line.

 

Therefore it will not crash when trying to open the GUI because it never tries to open your GUI since this line is NEVER read:

player.openGui(PortalBallMain.instance, 0, world, x, y, z);

 

 

Do you now understand why I nag about that little line? :)

  Quote

If you guys dont get it.. then well ya.. try harder...

Posted

I'm sorry but before you that I need you to explain to me, one thing:

 

What do you think the java keyword 'return' means?

  Quote

If you guys dont get it.. then well ya.. try harder...

Posted

send back variable(usually true or false) to caller.

Also, i tried returning true on the return statement between the tileentity crap and the player.openGui, and it didn't work.

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Posted

That's not the only thing it does mate.

 

You need to study some more programming basics before you continue with your modding :)

Else you will never get anywhere because the things you are having trouble with right now are at the core basics of programming.

You're time is much better spent learning Java, since if you learn the java basics now you will be able to create mods a lot faster when you understand what you are doing and aren't causing crashes every line you write :)

 

If you want I can give you a nice list of places to seek java knowledge, among'st them both short videos on every topic and a free university lecture on Java basics (this one you really should spend time on, it's awesome!)

So do you want to learn some java mate? :)

  Quote

If you guys dont get it.. then well ya.. try harder...

Posted

Well then you have forgotten the basics mate :)

 

Here: http://see.stanford.edu/see/lecturelist.aspx?coll=824a47e1-135f-4508-a5aa-866adcae1111

 

I find this to be one of the best sources for basic programming education. There you get all the lecture notes, handouts and assignments a real student of the class would get and you get everything for free! :D

  Quote

If you guys dont get it.. then well ya.. try harder...

Posted

i read up on return statements, and i still cant open my gui. I'm about to give up for a week. Can you stop being vague and just tell me! I's so simple, the tile entity draw things on screen that cant be interacted with, the gui renders things to the screen that can. All I'm trying to do is open a stupid gui! What do i do! I made a chest 2 months ago, but that had a tE! I also lost that file on my old computer!

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Posted

I told you that you needed to learn java, beacuse:

 

1. a TileEntity DOES NOT draw things on the screen.

 

2. you didn't understand return statements.

 

3. the Gui does not only render things you can interact with..

 

4. You don't have a GUI Handler as said earlier and you where given directions to go to the forgewiki to learn more about GUI's!

 

 

I said above that you needed to learn java and I believed that you understood that, well I guess you didn't I'm sorry if this seems rude and unhelpful but if you're not willing to learn Java and programming principles you got nothing to do inn here! As this board description states you are EXPECTED to know the basics of java and you don't!

 

There are several people here who could have replied to your questions above but chose not too, because the answer would be "learn some java" and people tend to rage at us when we tell them to go learn java which is the ONLY way to actually learn programming!

 

So I'm sorry you don't like the fact that I want you to learn Java, I'm not sorry that I do however as the alternative is you spending two weeks doing things that would have taken you 10 minutes when you know the basics! If you don't want to learn programming, don't want to learn modding then that's fine by all means, but then why are you here at all then? O.o

 

 

TL;DR:

You don't even grasp the basic concepts of Java and I told you above to learn it so here's a even less vague answer:

LEARN PROGRAMMING FUNDAMENTALS! LEARN TO CRAWL BEFORE YOU RUN!!!

  Quote

If you guys dont get it.. then well ya.. try harder...

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.