Posted March 31, 201510 yr 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. 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.
April 1, 201510 yr If you look in the initGui() method of the GuiOptions class you can see how it creates a slider (by creating a new GuiOptionsSlider instance). Check out my tutorials here: http://jabelarminecraft.blogspot.com/
April 1, 201510 yr Author 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.
April 1, 201510 yr 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/
April 1, 201510 yr Author It's kinda funny because cpw made a GuiSlider class so you can easily implement it. Thanks for the explanation though. 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.