Jump to content

Recommended Posts

Posted

Hey, so all I want to do is add a slider (like minecraft does for the FOV and such) to my Gui and use it for my own purpose. I just can't figure out what to do. xD

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

Actually, I can't use THAT one because it relays on GameSettings to work. I did find the GuiSlider class but, don't really know how to use it. See, I need it to set a value (like lets say 10) then take that value to be able to purchase 10 of that item.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

Actually, I can't use THAT one because it relays on GameSettings to work. I did find the GuiSlider class but, don't really know how to use it. See, I need it to set a value (like lets say 10) then take that value to be able to purchase 10 of that item.

 

I'm not saying to use them exactly, but rather copy the code to make your own version.  So if you copied the GuiOptionsSlider class then instead of passing a GameSettings.Options enum you can make your own enum (or if you only have one slider, maybe none at all).

 

But GuiSlider can also be a reference.

 

The first thing to do when trying to copy similar code is to change the field names to something meaningful -- you'll have to do some detective work to figure that out sometimes.  For example, in GuiSlider the constuctor parameters have names like p_i45536_2_ but if you match things to the call with the super constructor to GuiButton you'll see that these parameters represent the button id, x, y, width, height, name, etc.  So rename all the fields in your class so that they are easy to read and understand.  For example, I think field_175227_p represents the slider positions (from 0.0 to 1.0).

 

This slider needs to be put on a GUI, so you'll need a custom GuiScreen where you add the button.  Then, in the actionPerformed() method of that GUIScreen you would react when your slider button is acted on.

 

When the slider is acted on, you're going to want to change a value somewhere that the rest of your code can process.  Since most processing needs to happen on the server, you generally should send a packet.  So if someone selected 10 on the slider and you wanted that to mean buy 10 diamonds, then you would send a custom packet that when received by the server would put 10 diamonds into the player inventory.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

It's kinda funny because cpw made a GuiSlider class so you can easily implement it. xD Thanks for the explanation though. :P

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

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.