Let’s add a block entity renderer to our block entity all right we find ourselves back in the telly once more and in this tutorial we’re gonna be adding a block entity renderer to our block entity so this is going to be very interesting indeed if you remember the way that the block Entity looks like there is a little bit of a tray in the middle of the block entity and what i basically want to do is when there is an item inside of this slot i wanted to display that and when there is an item in this slot i want to Display that one so just like rendering it in the world so when you look at the block you can see what item is in there at the moment that is really awesome and it actually isn’t too crazy to implement so in our entity package we’re gonna right click new package called client And then instead of there we’re going to make a new java class and this is going to be the gem infusing station block entity renderer absolutely not a crazy name for a class at all it’s just going to be an interesting one and this will implement the block entity renderer Of type gem infusing station block entity we’ll hover over this implement the render method over here very important that we have this and then we’ll also need a public gem infusing station block into the renderer instructor with and this is also very important block entity renderer factory that context Called context over here as its parameter this is extremely important make sure that this is done correctly well and then what we’ll do is the render method this is basically where all the magic happens let’s first of all get the first few lines over here and then i will explain the first thing That’s going to happen is we’re going to see that we don’t have a get render stack method inside of our block entity so that’s is what we’re going to create right now in the german fusing block entity and we’re just going to take this and actually move it up all the way i Want this like you know fairly high up let’s just actually put this below the inventory uh you know it doesn’t really matter where it is let’s be honest as long as you find your way through your block entities you’re going to be totally fine so the get render stack Method what is this going to do well i’m just going to copy over the contents because they are pretty much self-explanatory the general idea is that if the second slot here so this slot right here is empty we’re going to just return the for the contents of the First slot and if it’s not empty then we’re going to return the second slot that’s literally all it does it just basically you know gets the contents of these slots now the issue with this is however the following and this is really the the big thing these are not going to Be available on the client unless we open it up or we once again do some custom networking to actually synchronize this once again we will need a custom packet over here once again it will be copied over and once again it is as always available to you in the description Below get up a positive individual just as well you can see we just need a set inventory method we’re going to do the same thing we’re going to create that method and move it all the way up you know we don’t need to move it all the Way up but let’s just be you know we’re just going to be fine here there you go so the set inventory method literally just goes through the inventory that we’re having here right so this particular that’s actually going to be called inventory there you go so we’re Going to basically get the size of the inventory over here and then just loop through and setting each of the different contents here for well basically the client right so this is literally just needed so that we set this for the client this is always only Called on the client as it is always only called right here let’s register the packet as well so this is going to be the item sync and this is going to be called the item sync item sync like this though yeah there you go exactly and This then got the item sync and this is the item stack sync s2c pack there you go so that is now registered and that is fine that is okay and that we can now basically call this now the question is where do we call this because the inventory doesn’t Really have a method over here it’s just a list you could of course make a wrapper and do something like you know where you change this but what we can just do is we can just override the mark dirty method and use that instead we’re going to just use the mark dirty method And we’re just going to say hey you know if that you know if that is like if we’re not on the client right so this is actually very important then what we’re just going to do is we’re just going to get the size of the inventory We’re going to write all of the item stacks in there we’re going to get the position and then we’re just going to send the item sync packet over here and then just in case we’re also going to make sure that we call super mark dirty just in case you know There’s any other stuff that needs to be done i think that that does make a lot of sense so now of course you know on final commits and stuff like that with the energy then this will also be called but i think that that’s totally gonna be Okay and i think that’s gonna be fine so now after this is synchronized we have access to the stack that we’re going to render now overall this is pretty much just uh you know more or less trial and error where i just tried out a bunch of Scales a bunch of translations like the position basically and then just rotating around in a certain degree then we have a switch this is going to look like this so basically depending on the facing over here we’re just making sure that it the actual item itself rotates With the block that’s literally all that this does nothing too crazy and then we just want to render the item and then pop the matrix stack and we also need to get the light level over here that is just a custom method that it just makes sure that The light the the actual item when it is rendered isn’t like black or dark right and last but not least we just need to register this in the tutorial mode client class it’s going to be the block entity renderer registry actually this one right here that register passing in modblock entities.geminfusingstation And then the gem infusing station block entity renderer colon colon new and that is going to be everything that we need for this to work that’s literally all that there is to it all of the code is always in the description below get up a positive individual just As well so let’s go into the game and see if it works all right we found us back in a minecraft again so let’s just see let’s just put a raw tanzanite in here and there we go we can actually see it render right here that’s perfect and Now it turns into a well normal tenderness that’s exactly what you would expect basically so this slot takes precedent right so basically there you go and then it turns into the other one so if you take this out you can see it always uses the this slot if there’s Nothing in this slot this is already really awesome and i can tell you block entity renderers can do all sorts of crazy things right the render method is basically where all the magic happens and i mean this is really cool and it just adds this little bit more detail Like a tiny touch to your block entities that are just going to look absolutely stunning but that’s going to be for this tutorial right here i hope you found this useful and you’ll learn something new and i’ll see you all in the next tutorial so yeah Video Information
This video, titled ‘Minecraft 1.19.2 Fabric Modding Tutorial | BLOCK ENTITY RENDERER | #27’, was uploaded by Modding by Kaupenjoe on 2022-09-07 13:59:46. It has garnered 3527 views and 53 likes. The duration of the video is 00:06:48 or 408 seconds.
In this Minecraft Modding Tutorial, we are adding a custom BLOCK ENTITY RENDERER to Minecraft 1.19.2 using Fabric!
== SUPPORT ME ON PATREON == ▶️ https://www.patreon.com/Kaupenjoe
== ASSETS & DOWNLOAD LINKS == GitHub Repo: https://github.com/Tutorials-By-Kaupenjoe/Fabric-Tutorial-1.19/tree/27-blockEntityRenderer Gist: https://url.kaupenjoe.net/yt416/gist
== TIMESTAMPS == N/A
== 25% OFF FOR GAMING SERVERS == ▶️ https://www.bisecthosting.com/Kaupenjoe
== TAKE A LOOK AT MY COURSES WITH COUPON CODES == ▶️ NEW Forge Modding with Minecraft 1.20.X: https://url.kaupenjoe.net/CourseForge120X ▶️ Learn Forge Modding with Minecraft 1.18: https://url.kaupenjoe.net/CourseForge118 * ▶️ Learn Fabric Modding with Minecraft 1.18: https://url.kaupenjoe.net/CourseFabric118 * ▶️ Complete and Roblox Lua Game Development: https://url.kaupenjoe.net/RobloxCoupon *
== SUPPORT ME ON PATREON == ▶️ https://www.patreon.com/Kaupenjoe
== SOCIALS == Discord: https://discord.com/invite/yqxykanpWf Personal Twitter: https://twitter.com/Kaupenjoe
Instagram: https://url.kaupenjoe.net/tutorials/instagram Facebook: https://url.kaupenjoe.net/tutorials/facebook Twitter: https://url.kaupenjoe.net/tutorials/twitter TikTok: https://url.kaupenjoe.net/tutorials/tiktok Written Tutorials: https://url.kaupenjoe.net/tutorials/blog
== LICENSE == Source Code is distributed under the MIT License. Additional Licenses for other assets can be seen below or in the accompanying CREDITS.txt on download.
== ADDITIONAL CREDITS == Outro Musik by Kevin MacLeod: “That’s a Wrap” Kevin MacLeod (incompetech.com) Licensed under Creative Commons: By Attribution 3.0 http://creativecommons.org/licenses/by/3.0
== AFFILIATE DISCLAIMER == * Some of the links and other products that appear in the video description are from companies which I will earn an affiliate commission or referral bonus from or are my own products. This means that if you click on one of the product links, I’ll receive a small commission or additional kickback without any additional cost for you. This helps support the channel and allows me to continue to make videos. Thank you for the support!
== HASHTAGS == #Minecraft #MinecraftModding #MinecraftTutorial #Kaupenjoe