Hello guys and welcome back to the microphone tutorial into episode we’re going to be creating our GUI and after today we should have a working furnace so let’s get started go and create the GUI class GUI sintering furnace and it’s going to extend GUI container we’re going to have A few variables firstly private static file resource location cold textures and all caps is equal to a new resource location reference Ammannati plus : textures GUI sintering furnace dot PNG the PNG is required this is just telling this GUI class where the GUI texture is stored there is also going to be a Private final inventory player called player and private final tile entity sintering furnace called tile entity we are going to open up our constructor and have those same properties inside of the constructor as well inventory player player and tile and C centering furniture talents T and inside of here We will set those two variables to our and variables into our constructor so this top player equals player distal tail entity equals tail and C and the GUI want something to soup off its supers off of the container so super new contain the sintering furnace we input Player and tile entity into there there are two layers we’ll have to draw draw a container foreground layer and draw container background layer the foreground layer is going to contain our text that we put on top of the background and the background is going to contain our textures as well As the arrows and the fire so firstly for the foreground layer string which I’m going to call tile name is equal to this tile entity dog get display name doctor gets unformatted text this dot font renderer dot draw string tile name then for the x-value open some brackets This excise / to take away this dot font renderer dot to get string whit tile name / – and then I found with my GUI I needs to add 3 to this value so what this is doing here well firstly we have the actual string it wants to draw its Then getting the middle of the GUI and it’s also getting the middle of the name and then that’s where it’s going to draw it but my GUI and needs to off it offset it slightly so I’ve added 3 pixels to move it 3 pixels to right so it doesn’t Interfere with my slots for your DUI you may want to have this value something different so that it fits in correctly the y is going to be a normal value at with 8 for me and the color this is the minecraft binary value used for alt text Inside of GUIs four two one zero seven five two and that’s what text will be used in all minecraft duis you can obviously change this color if you want I’ve been on showed you a binary color before and how to get there you can just type in binary color crater and find That number or you can do it in hexadecimal as well the other string we need to draw is the inventory so this dot font renderer drawstring this dot player get display name don’t get on fire to text mine is a specific specific location and on the X-axis 122 and then for the y axis it’s this dot y sighs – 96 + 2 this may seem like a bit stupid mine’s 96 + 2 as this can be just simplified to minus 94 this is the way that minecraft does it in the default code so we live without this and The color is 4 – 1 0 7 5 2 so we are drawing the name of our block which will be sintering furnace and we’re going to draw the inventory text then for the background layer when I set the background just be white so GL States state manager docked color spell American way you want one point 0 F 1 point 0 F 1 point 0 F 1 point 0 F this is just a completely white color we then do this dot M C so minecraft dots get texture manager dots bind texture textures so it’s setting currently the Texture manager is going to want to draw our textures so we’re telling the retails location where the texture is and we’re then going to draw the background this drops draw textured modal rec we do this dot some GUI left this GUI top 0 0 this excise this got Why size we’re now going to create two private functions private int get burn left scaled in pixels and this is going to calculate how much burn time is left so this one is to do with the fire animation and it’s going to calculate how many pixels off the Fire animation it should be showing so int I equals this tile entity get field one if I equals zero I equals 200 returned this tile entity get field 0 multiplied by pixels divided by I and then private in get cut Kroeger scaled in pixels int I is this tile entity Don’t get field to entry equals this tile entity get field 3 return J is not equal to 0 and I is not equal to 0 if it is true and pop question mark I multiplied by pixels divided by j or just 0 if Thailand sintering furnace dot is Burning Thailand’s T in its k equals this dot to get burn left scaled 13 as that’s number of pixels how tall this fire animation is is 13 you can see down here this dots draw textured metal records this toxin GUI left plus 8 this and dots and GUI top plus 54 plus 12 Minus K so these two values if you hover over jaw hits the middle Rex is int X and int Y so where this is stored on here for me it eight pixels in the mean exactly nine pixels in but when I was messing around with it it looked a bit wrong so I’ve Changed it to eight pixels in so what what you want to originally do is measure how far away this is but if it if it’s obviously off or you think it looks a bit weird or incorrect then obviously you adjust the values accordingly like this is nine I’ve Changed it eight and then this is also 55 down but I’ve changed 54 and 12 minus K it’s just showing how much for it to draw texture EPS and texture Y is where the texture is stored 176 this value and the y of this is 12 minus K again as is Like selecting how much of its draw then the width of it is always 14 and the then this height is K plus 1 and then below this we’re gonna have int L is this get cook progress scaled 24 as on our GUI this is 24 long it slightly goes To the right and the left of the bar as you can see here 24 long this dr. draw textured modal records this dots of GUI left plus 44 so for me if located is located 45 inwards but as I said before I just as a few Values so it’s 44 for me this dot some GT right top plus 36 176 for the texture X 14 then L plus 1 as this is going from left to right and then 16 as it’s always a permanent height and that is the GUI done we are drawing the text we are Drawing the background image and we are drawing our animations for the GUI we need a GUI handler so go into your handles package and create a new class called GUI handle it implements IG UI handler and has two functions get a server GUI element and get client do route GUI element For the server if I D is equal to referent dot GUI centering furnace return new container sintering furnace but player inventory and for the tile entity you want brackets Thailand sintering furnace then world get tile entity new block pause X Y and Zed control shift so to import block pause Then copy this into the client accept it returns a new GUI sintering furnace control structure to import that eientei seing the same parameters then go into registry Handler and inside of init registries you want network registry dot instance dot register GUI handler main dot instance and new GUI handle well Thing we might as well creates a tile entity handler as well create a function public static void register tile entities inside of here put game registry dot register talents T tile entity centering furnish top class and its key will be sintering underscore furnace and think all this in the on Block register as the talents they need to be registered after the block if we put it in size with pre in it registries then it will be registered before the block and would crash the game we need to bring in the GUI texture putting it in resources assets hm Textures and create your new package called GUI and I’m gonna paste in this texture so now in my tutorials have we have this untextured block here we place it down and open up the GUI and we find we have the sintering furnace text the inventory text we have two inputs we Have a fuel input and we have an output here I had to quickly check what I put for my recipes and it smells the animations move and we have a colo here it’s melted we have our animation slowly ticking downwards we have the arrow that works and everything is working thanks for Watching guys man has been hairy and goodbye Video Information
This video, titled ‘GUI (Furnace Part 5) – Minecraft Modding Tutorial 1.12.2 – Episode 20’, was uploaded by Harry Talks on 2018-02-17 21:19:53. It has garnered 18348 views and 180 likes. The duration of the video is 00:13:23 or 803 seconds.
Welcome to the final (required) part of the furnace tutorial, where we create our GUI (graphics user interface).
Links GitHub: https://github.com/HarryTechRevs/MinecraftModding/tree/HarryTechRevs-1.12.2-Tutorials Discord: https://discordapp.com/invite/xwg8zQJ Playlist: https://www.youtube.com/playlist?list=PLiDUvCGH5WEUEV9nc0Ll2pzUFmSFc21uR Subscribe: http://tiny.cc/sub2harrytech Twitter: https://twitter.com/harrystechrevs