But now is the fun somewhat complicated stuff like I said these tutorials fairly advanced public void draw screen and five in part 1 in part to float par three now the first thing we’re going to do is we’re going to draw the background so in texture equals MC dot render Engine dot get texture and now the texture file is exp log GUI dot PNG so type that out this method it’ll tell the rendering engine of Minecraft to get the texture and then I’ll return an int oh yeah I now MC that render engine that fine texture texture so basically on These two lines we tell the rendering engine to get a texture and then we tell it that are going to we want to use that texture right so if you’re making your custom GUI with a new background texture you would just replace this with whatever your texture name is and now After that gl11 dot GL color for F I believe yes and now we’re just going to have one point 0 1 point 0 1 point out I’ll make sure you have an apt after that when I last one point 0 F adds another one all right this tells OpenGL That we want to use all colors turn every single color on basically and now a a bunch of variables after that int X size equals 196 into y size equals 90 this is just the GUI size depending on your GUI and whether you want it centered or not you can have to change These this is basically the size of my GUI and x equals with / exercise / 2 and y equals height minus y size / to this is just going to make a RG our texture i should say centered and now draw textured model modal wreck that i’d even Know I don’t even know how to pronounce that but don’t worry about it and then pass an X comma Y comma 0 comma 0 comma excise comma Y sighs now you guys might not know what you’re actually doing here but this is drawing a rectangle at Position X the okay i should say you’re drawing a textured a basically a textured image at position X comma Y with a width of excise and a height of why sighs and then it’s going into the texture and starting at position 0 comma 0 so yeah that’s a mouthful but Basically all this is doing this whole code right here is basically drawing our GUI centers that’s all that it’s doing hopefully I didn’t confuse anyone I’ll then after that super that draw screen let’s have it pop up for us right for you feel like typing draw screen I just Click enter and a semicolon at the end of that and then we’re going to type draw and chant info and now obviously we don’t have that method yet so click on create method and then save and then now this is a whole crazy bunch of stuff that I’ve actually taken most Of it from the actual minecraft rendering and this method right here we’re going to draw the XP bar as seen you know on a regular minecraft hood it’s going to draw the XP bar you know the percentage this percent bar and it’s going to draw the current level that it Has so draw GUI title without a shadow because it doesn’t do that we don’t want to shout out a shadow font render earth dot drawstring experience log and now this is your X so with divided by 2 minus 90 this is just up with the position of the string this is how I Want it you could I’ve changed this around a little bit to make it work but you can always change it and now comma 0 x 36 36 number 36 now this is the color of a this is the color that this string should be I’ve used a tool online to Figure out what I wanted it to be basically that’s basically how you do that you could Google online and figure out the hexadecimal value of the color that you want for the string that’s really all that that is and now we’re going to add another comment drawn Shan’t level this is the hole and shame at level drawing this is just the level to just draw that one string that looks kind of fancy we need a whole bunch of lines of code honest it like I get like I said before this is basically taken from minecraft itself string s equals That do quotations plus XP level this is just creating I mean creating a string from that int so int I equals with MJ equals height / 2 + 13 int I 3 equals i- font renderer like get string with is divided by 2 this is making it centered like i said before Now in k 3 equals J minus 38 this whole bunch of code you really don’t need to know this is just for a basically this mod right here because it’s really complicated for drawing a the level font render that drawstring I’ll let’s erase All of that so s comma I 3 + 1 comma K 3 comma 0 let’s copy and paste that because we’re going to be doing this multiple times s comma I three minus one comma K 3 comma 0 now paste it again I three comma K 3 + 1 comments hero paste It again I 3 i’m like a 3-1 count 0 guess you guys are feet out of pattern now font render that drawstring i 3 i’m a k 3 comma 0 x0 I mean 0 x 8 0 FF 20 and now that’s it we’ve drawn the level And now we need to actually draw the enchantment bar so draw and Shimon bar gl11 we actually need to do this again oh you can just copy from up there we need to tell she opengl that we want every single color gl11 doc CL fine texture flash GUI Oh everyone gl11 fine texture gl11 dot GL on a sport texture file texture on underscore 2d comma MC that render engine get texture / cui / icons dot PNG some reason it doesn’t like that now I forgot a parenthesis all right so now we’re going to actually draw it so int j 5 equals i divided by 2 minus 91 and I 6 equals I / 2 + 91 and in l 6 equals XP bar cap XP level now this is basically drawing the progress on the current level this is a function that minecraft uses if l 6 is greater than 0 so that Means if we have a more than zero experience on the current level car c equals / 266 and j ay equals int experience times float c plus 1 like i said before this is just the formula that minecraft uses draw it into i 9 equals J minus forty four then we’re Going to draw the texture draw texture rectangle j 5 comma I nine comma 0 comma 64 I’m c comma five it’s a mouthful but i forgot to be in that yeah okay now if j 8 is greater than 0 j 8 series and 0 draw textured rectangle say five comma I 9 comma 0 I was 69 got my j 8 comma 5 Video Information
This video, titled ‘Minecraft Modding Tutorial Episode 4: Finishing the Experience Log GUI’, was uploaded by OneShotZeroKills on 2012-07-31 00:01:14. It has garnered 202 views and 4 likes. The duration of the video is 00:10:57 or 657 seconds.
This is part four of my modding tutorial series.
There is going to be one more episode on the Experience Log.
Currently the Modding Tutorial is for Minecraft 1.2.5 (ModLoader).
In this episode, I finish working on the GUI class. You will see how to render/draw the GUI image to your screen and how to draw text. The Experience Log is a new item (similar in texture to that of a book) which allows you to store experience. When right clicked, the item opens a GUI where the user can deposit/withdraw experience.