Let’s add some inventory capability to our block entity oh All right we find ourselves in intellij once more and in this tutorial we’re going to be adding some proper sighted inventory well i guess capabilities to our block entity now this is shall i say like a little bit more complicated than it has to be because mainly because of the get capability Method over here and the site but i will explain as we go along so the first thing we need to make sure that is that in the item stack handler that we hopefully have in our block entity we’re overwriting another method and that is the is item valid method now this in This case is going to return a switch statement and it’s going to switch the slot over here and what we’re going to do is we’re just going to say k0 is going to be let’s say stack dot get item equals mod items.xercon.get for the time being then We’ll just duplicate this then we have case one we have case two and then we’ll also just get a default case which is just going to call the super in this case so super dot super dot is valid item slot and stack there you go in slot One we wanted to be able to add a raw zircon and then here in slot 2 which is the output slot we actually want to make sure that we can’t actually put anything in there so we want to put in false actually and there you go So this is the is item valid method in the anonymous item stack handler that we want to overwrite just to sort of recap let’s take a look at the gui one again once again so this is of course slot zero in which we can now put in a zerkon Doesn’t quite make sense because this slot should be something where you know you can add stuff to tank over here but for the time being i want to make this a zircon because i basically want this in the next tutorial when we’re going to add the energy stuff and i want the Zircon to also generate some energy just so that we have this as an example in this case then the raw zerocoin of course going in here should make absolute sense and then in the bottom one we can’t actually insert our anything ourselves only the well basically the blockade itself can insert Something there but the actual player cannot and why do we want to have this well we’re basically going to use this in our well in a map for our craziness now what i’m going to do is i’m going to add a new class in the entity package This is going to be the wrapper actually the wrapped handler and i will copy over the entire class over here this is of course as always available to you in the description where you’ll get a preposter an individual just as well also very important this is by nope Noppy from their libx library over here license should be totally fine so just make sure that if you’re using it that you give proper credit over here and then everything should be okay this is just going to make this a heck of a lot easier so what we’re going to need to do Is we’re going to need to make a map inside of the german fusing station block entity now i already have this prepared and i will copy it over you are going to like completely you’re going to fall to the floor if you see this and I’ll try to explain it best i can and that will just bear with me basically all right so we’re going to copy this over and you’re going to say what the frick is this insanity and first of all i agree with you second of all there Pretty much is no other way of doing this easily sadly um the general idea is the following when we are inside of the get capability method this direction here actually denotes the world direction that we’re looking into okay so because the issue at the moment Is or the i mean the one issue that we have to deal with basically is if we sit down at the gem infusing station we’re rotating it around right via this facing property we’re rotating the actual block entity around based on the direction we’re looking into when we put it down Therefore this direction here actually mismatches with the direction of the block entity because the block entity rotates and of course you know north is always going to be north and this is the world direction this with a little bit of a switch here is going to make sure that we’re Always using the same direction we’re basically normalizing the direction from the block entity to the world direction so we’re just rotating it around so that it matches up again so then north is always going to be the top side of the of the block entity and south is always The side that’s facing you when you set it down and east is always the right side and west is always the left side that is the general idea with down and up of course being the top and the bottom of the cube in this case and then The wrapped handler here what does that do well we have two different uh craziness over here so in the wrap handler we have a buy predicate first of all a predicate of integer and then a buy predicate uh that’s insert what does this do well the first one Right here so this one right determines whether or not we can actually extract something from a particular slot this saying i basically is the slot id and we’re returning if i is equal to two then we can actually extract something from the bottom of this particular block The same goes for south for example so from the bottom and the bottom i guess you can actually extract something from slot two that’s the general idea then from north for example here you can actually extract something from slot one once again let’s remember this is slot One you could extract something if we’re on the top of the of the block entity right and then you can extract from slaughter one you can also insert into slot one right here you actually get the index as well as the stack that you’re trying to insert into there and we’re Just saying hey is this particular stack valid for this particular slot this of course then calls the method that we have made right here and this basically then makes sure hey can we actually insert this into the particular slot now if this is still a little bit too Complicated for you there is just no other way of saying it then there might be a little bit of more java knowledge needed for this uh while this is pretty crazy to look at and it might take you know a little bit longer for you to sort Of completely wrap your head around this because it actually took a lot for me as well because this is not the easiest thing but once you understand it hopefully you’re going to sort of be able to apply this as well now what do we do with this map well What we’re going to do is we’re going to go into the get capability method over here and i will once again copy over the entire thing that we’re going to need we’re basically going to replace this and let’s see the first thing we’re going to check is whether or not the Side is null just in case and then we’re just going to you know give it the lazy item handler and we’re not even gonna like do anything else with this then we’re gonna say hey is this site even contained in the map because of course What we can see we have down north south east and west but we do not have up in this case then what we want to do is we want to say hey you know what the in the up direction we don’t even want to go into this that’s the general idea then We want the local direction now this is the actual facing of the block entity this right here right changes depending on what way i’m looking at and setting down the actual block so this now we need to bring in alignment with this side the way that we’re first of all Doing it is a if we’re up and down right then we’re just getting the direction handler gets side this basically only happens when we’re down because up is not actually in there but i’ve just added it nonetheless and then we’re just getting the normal side because up and Down always work regardless of how it’s rotated because of course we’re only rotating around the y axis and then up and down are always the same while when the other things we actually want the local direction for default this would be north right and then east south and West and we have to rotate the the side of the world based on the local direction so when we’re when the local direction is north then we want the side to be the opposite so basically rotate around by 180 degrees and then when it’s east we want to go clockwise south we Just want the normal side and then when the local direction is west we want to rotate counter clockwise once again this is pretty much just a case this was mostly a case of trial and error to figure out what exactly i have to put in here so that this works Once again i just can recommend play around with this try it out all of the code is available to you in the description below this is sadly how you know complicated it has to be um maybe there’s going to be some other way that you can do it but this is basically the Best way that i found that this works and this will now allow us to well i mean use hoppers for example also all sorts of other mods basically and we’re actually going to add another mod to our project over here to basically test this with and we’re Going to add mechanism here because well i mean i like mechanism and also it’s it has pretty much everything we need for the continued stuff as well so what we’re going to do in the build.gradle file we’re going to first of all add the maven for curse forge so this is this One of course maven right here and then we will add the following line and that is the runtime only fgd of and then curse maven mechanism this is the project id on the curseforge page and this is the well basically the id when you hover over the download you can Actually take a look at the well basically the number or the file basically that you want to have downloaded and then you just go to the little elephant reload gradle and once again this can take anywhere from a few seconds all the way to um maybe even a Minute or so depending on how fast your internet connection is on all of that let me just make sure what uh what are we doing here we’re at two four seven i think this should work the um the ji version but we’re gonna get an error if It doesn’t work anyway so that’s going to be totally fine so if we have to change something there then we can do that after we start overall though this should be all of the different things that we need so once the gradle build over here has been run through we should Be able to try this so you can see both successful in 31 seconds and in theory we should be able to try this now and this should now work this way like i said quite complicated when you look at it i should just suggest looking at it a Couple of times maybe rewinding watching the part again trying this out as well this is insanely important just try it out try some different values hopefully you understand it and hopefully when i now show you it in the game you now also understand it so let’s go into the game And see if it works or it finds us in minecraft again and first of all you can see mechanism has been added to this particular project here so that’s pretty good but we can also use hoppers in this case so let’s just take a new gem infusing station here and let’s set It down so this would be now the right side and this is the north side so in theory right what we should be able to do if we take a look at this again um we should be able to insert into index one over here so we should be able if we put Into this hopper raw zerocoin it should insert into this particular actual slot that’s perfect if we do it here we should be able to insert into this slot over here let’s think about this again this is the east direction right uh sorry the west direction sorry Left right the left side and we should be able to either export from index 0 and index 1 and we can also insert into index 0 and index 1. so if we put in to this right if we just get a few of those out there we should be able to also Import here and because this is not valid for this it actually doesn’t insert it into the this slot in this case if we put this in we can actually see it now puts it into this slot so it works exactly how we want it to let’s just do the following let’s also try Something like this let’s get a chest over here and let’s try to well if i put in the let’s just put these in there again and if i put a hopper beneath it right so this would be the down position this would be this one right here we Should we can extract the position 2 over here and we can’t insert anything so in theory slot 2 which is of course our output slot this would be this one right here you should see the zircons appear in this particular chest and there we go they are being Immediately taken from the hopper and immediately put into the chest so pretty much also exactly how you would expect it to and then from the top well nothing works from the top and we can also see this when we’re actually using some transport pipes over here they are actually where are they there They are so this is mechanical pipe nope this is the logistic transporter pipe there you go so we can see it actually does connect here but it does not connect there because there is no basically item connection in that instance and we can also transfer it out From well this direction so if we get a configurator and another chest over here just so that it has a let’s just extend this a little bit there you go and if we were to open this up then you can see now the these ones are actually being pumped Out as well so everything working exactly how you’d expect it to exactly how we want it as well and that’s absolutely amazingly awesome and it just is one of those things that is kind of sometimes you know really stupid to properly implement but the it’s just Going to i mean save a lot of headache for the player and it’s just gonna be really really nice if this is also added for your own mod like i said can be quite complicated just play around with it try out a bunch of stuff also test it Inside of the world then you get a more feel for it and then hopefully you’re going to understand how to do sighted inventories for your block entity right and that concludes this tutorial right here i hope you found this useful and you learned something new and i’ll See you all in the next tutorial so yeah Video Information
This video, titled ‘Minecraft 1.19.2 Forge Modding Tutorial | SIDED INVENTORIES | #24’, was uploaded by Modding by Kaupenjoe on 2022-08-30 13:59:53. It has garnered 5968 views and 92 likes. The duration of the video is 00:13:19 or 799 seconds.
In this Minecraft Modding Tutorial, we are adding sided inventory support to our Block Entity!
== SUPPORT ME ON PATREON == ▶️ https://www.patreon.com/Kaupenjoe
== ASSETS & DOWNLOAD LINKS == GitHub Repo: https://github.com/Tutorials-By-Kaupenjoe/Forge-Tutorial-1.19/tree/24-sidedInventories Gist: https://url.kaupenjoe.net/yt408/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