Hey what’s going on guys turtlebirdie here and welcome back to another minecraft modding tutorial for version 1.18 in this tutorial we are going to be covering the blitz method so this is something i should have explained a little bit better late earlier in the series when i covered these screens However i wanted to just cover it in a little more detail as yeah i very lightly brushed over it so as you can see here we’re using the blitz method to sort of uh state the how it will draw essentially so first of all it takes in a pose stack Now i haven’t even explained what a pose stack is so i’ll try my best to explain it and it’s a little hard to explain so essentially it’s a matrix and well yeah i mean that’s that’s it so it holds the rotation the translation and the scale does it hold anything else Wait let me check so you have for example mole pose um which is what allow you it allows you to rotate it basically you just pass in a quaternion so to get a quaternion by the way use a vector 3 f and then you can choose the different Axis so for example xn would be counterclockwise on the x-axis xp would be clockwise on the x-axis yn would be counter on the y y p would be normal on the y and then you got z n which is negative on the z and z p which is positive on the z So for example x p and then you do rotation degrees or of course rotation which is in radians and rotation degrees and you could do 90 degrees for example now if you ever choose to modify the post stack you first of all must make sure you do it before you draw Anything so if i do it here that’s not going to do anything what we actually need to do is do it before our blitz so it’ll rotate it and then it will draw it with that rotation however there’s two more things we need to do we need first before we ever modify the Stack we need to make sure we push the pose and that will just basically create a new um i don’t really know how to explain it but a new slot in the uh stack of changes i guess is a good way and then afterwards after you’ve done your drawing you need to do Stack dot push pose and that pushes it out the stack ready for the next changes to take place essentially i’m going to remove that though because we don’t need to do that let’s now talk about these first two parameters here so these are two integers and these Represent the x and y position that we are drawing our blitz so okay let me let me step back a little bit let’s talk about what blit actually means so blit basically means to copy um pixels from one place to another so in this example we are trying to copy Pixels across from our texture into the game on the screen and yeah that’s what blip means basically it’s actually quite simple um so we are just specifying the x and y position on the screen that it will actually draw now this left pause this is where it gets a little confusing Because we’re setting left pause to zero so you might think why is it not drawing on the left side of the screen and that is because basically vanilla handles it so vanilla will set this left pause to something else based on the screen size um And it sets it to where sort of the left position of the screen is essentially and then we use the top pause so that is the exact same concept that is the top of where your gui is drawn and then we have these two integers here And as you can see we have these set to zero so are these integers you may be wondering essentially these integers represent the texture x and the texture y or the uv so this is the starting point on your texture of where it will draw from so um for example Let’s say you had your gui all right let me open paint just a simple paint thing to try and show you so let’s say this is your gui um right so this is your gui you have all your fancy stuff in there and yet this is the actual texture of your gui so Yeah yeah yeah let’s let’s put it up here so the texture of your gui is like that right so let’s assume that this was 256 in total and this is the sort of actual part of your gui so for this your texture is starting at zero zero the sort of first pixel Of your texture that you want to draw is at the zero zero position and so as you can see we pass in zero zero now let’s assume you wanted to move that position to here right now the top left position so the place that you want to start drawing it for from Is now 18 by 16. so instead you put in here 18 16. it’s fairly simple we then have these two integers right here so this is the actual width and height of what you want to draw so this may be a little deceiving because you might think this is the size of the Texture it’s not the size of the texture this is the width and height of what you actually want to draw so for example in here you can see our width and height that we want to draw because we want to draw this whole black box is 460 by 450 so we would put 460 450 or we would actually set that up here as you can see we set ours to 176 and 168 that’s the size of what we want to draw and um yeah now something i should mention about that is this blit method that we’re using right here Is built assuming that your texture is the size 256 by 256 if your texture is not 256 by 256 this will draw weirdly scaled now if you wanted to have it be a different size so for example this texture here is 800 by 600 if you wanted to draw it with that image Size you would say 800 600 so you can add a extra two integers to provide that texture width and extra height there is also if we go in here we should be able to see there’s actually a lot of different methods but i believe there is one with another integer Yeah i don’t know what that one does but there’s a few more um you probably won’t need those ones because i’ve never used them um but yeah so you can have that but i’m going to leave these two interests out since our texture is 256 by 256. Now let’s try and use this in practice let’s show um a little more and give it a actual example of where we use this so i’m going to open our screen this is the poop storage screen and first of all i’m actually going to move the integer that we drawn in the Last episode so i’m going to move that to about here which is 107 by 12. so right here 107 by 12. there we go that will now draw that at the right place fantastic now let’s actually go ahead and what we’re going to want to do is we’re going to draw This right here and we’re going to want to draw that into here based on the amount that is stored in here so first of all let’s come back into eclipse okay no no first of all we’re going to want to find out the height of this area right so i know that the Height is 62. so we’re essentially going to want to map our number from 0 to 64 to 0 to 62. and that’s a little complicated to do and i’m going to show you two ways of doing it so let’s get the integer first so final int scaled height is equal Desktop menu or we can just say count is equal to count and what we can do is divide that by 64 divide by 64 f you need to make sure it’s a float because otherwise we’ll have some um rounding issues and times that by 62 so that is the height And cast that to an inch of course and that will essentially get us the value from 0 to 64 to 0 to 62. now thankfully someone on discord called bastie has given me a fantastic method which calculates this for us so i’m going to plot this in here And this just maps a number just like what we’re trying to do here but it uses a simple method to do it so we’re going to keep that integer cast since we’re still going to need that and we’re going to say map number now what we’re mapping is the count And we’re going to map that between the range min so the range min we’re starting at zero that’s the lowest the count can be and the highest the count can be is 64. and the result minimum the minimum that it can convert to is zero And the maximum it can be is 62. so that’s sort of the height now we can just draw it so first of all as we did before we need to set the shader i’m going to copy this from down here and plonk it in there in fact let’s Create a method to do this for us just a very simple method so a public static void we’ll call this a set texture uh we’ll actually call it uh bind texture and we’re just gonna plug that in there and let’s just call bind texture and we’ll put that down here as well There we go now now that we’ve binded the texture we can blit so we’re going to call that blit method and we’re going to pass in the stack now we’re going to want to get the left position so we’ll just for now put this dot left pause Then we’re going to want the top position so we’ll put this top pause for now we’ll change these all in a second then we’re going to want the texture x and the texture height of where we’re going to start texture x and texture y for now we’ll put zero zero we’ll change Those in a second and then we’re going to want the width and height so i’ll put zero and we know that the height is the amount or um the scaled height okay let’s go and modify these values so we’re going to want to find the position at the bottom And as we can see that is 118.74 so let’s come back into eclipse let’s go plus 1 18 and for the top position we’re actually going to want to put 75 and the reason is because otherwise um there’s some weird sort of offsetting when translating between them obviously You can mess around with these values maybe 74 would work for you but i just found that 75 works and 74 didn’t what for whatever reason um and from this sort of height that we’re drawing it at or the y position we’re going to want to negative the amount or I keep calling it the amount i mean the scaled height so the reason we’re negative in the scaled height is because we want to draw it in a way if we come back into paint.net we essentially want to draw it so that it is drawing from the bottom and going up So we can pass in that value and that will draw it in the correct way basically and then we need the texture x and the texture y now if we come into paint.net this is of the actual texture that we’re drawing of course which is this part down here So the bottom left is 176 and 61. so let’s go 176 61 and i just figured out why that was 75 because i accidentally put 62 in here before but that is 60. i know that’s that’s right 16. two is that all right hold up i see so right so that’s 62 high But this bottom part here is one because this top y is zero i see right so what we can actually do then um we can put 61 yeah then we’re gonna want the simple um we’re actually going to want to negative the amount here so we’re actually going to do negative scaled height So that it starts at the correct position i’m just going to leave it at 62.75 i don’t trust that i got that right we can mess around with it when it’s actually in game though yeah and then we’re going to want the actual width of what we’re drawing so if We come into here and check and come over here we’re drawing to a 30 area so it’s 30 wide okay fantastic now we’re going to want to move this because this is um you know this is going to draw in front of the font we don’t want that so let’s remove that And we’re gonna draw it before all of the font drawing and we can just move this count variable to there great great and i’m actually going to move this left a little bit so we’ll go um we’ll go 105. okay let’s now try and run the game and we’ll see What is up and if it works here we are we are in the game let’s open our gi here we are we have our number zero if we put in one you can see it doesn’t draw anything because at that scale it’s it rounds down to zero essentially And if you put one in you can see it starts to draw some and it will go up and up and up and up as you can see the number is increasing at the same time and as we put more in you can see it fills up fantastic And obviously that stays when we close and reopen gui it also stays when we close and reopen the game of course i mean why wouldn’t it wouldn’t really make any sense if it didn’t we can just double check anyways just to just to double make sure that it’s not Going to act all weird on us here we are that’s fine so yeah fantastic i mean that’s it what can i say what can i say um so yeah i hope you guys did find this tutorial useful i know it’s a very short one a very basic one but i just wanted To try and explain that concept a little bit since i really did um brush over it in the screen tutorial um i wish i didn’t brush over it so much um yeah so i hope you guys did find this tutorial useful if you did please do be Sure to smash your face into that like button and poop on it as well because poop and subscribe if you really enjoyed i really found it useful please do be sure to share it and uh yeah i’ll see you guys in the next tutorial goodbye D me Video Information
This video, titled ‘1.18 Minecraft Forge Modding Tutorial – Explaining ‘blit”, was uploaded by TurtyWurty on 2022-01-25 18:00:11. It has garnered 2328 views and 60 likes. The duration of the video is 00:21:33 or 1293 seconds.
In this video, I explain the ‘blit’ methods in some detail, showing a practical example of where it can be used properly.
In the next tutorial, I will be covering Block Entity Renderers (BERs), showing how you can render something in the world using your block entity.
mapNumber method: https://pastebin.com/YP4uMYBF (Credits to Basti#6248 on discord for this handy method!)
Join my Discord Server, to receive support with your modding related questions: https://discord.gg/jCTnnhxc7J My CurseForge where you can find my released mods: https://www.curseforge.com/members/realturtywurty Github Repository: https://github.com/DaRealTurtyWurty/1.18-Tutorial-Mod Check out the trello: https://trello.com/b/6lLTY9js/118-modding-tutorials