Let’s make a proper cited inventory for our block entity oh right we find ourselves back in intellij once more and in this tutorial we’re going to be looking at the inventory both insertion as well as extraction of our block entity because right now if you were to take a hopper for example And well try to put something into this particular block entity what’s going to happen it’s just going to put this into the first slot or slot with index 0. just for completion’s sake let’s actually take a look at the current way this is working then we’ll implement something which is going to look Absolutely insane to you i i can already i’m already telling you it’s gonna look quite crazy hopefully i will be able to explain this to you and then we’ll see the end result at the end so let’s go into the game and see how it works right Now all right so we find ourselves in minecraft again and let’s just see so this is of course slot zero this is slot one this is slot two now if i were to imp you know use a hopper i would of course want my raw tanzanite to go into this slot However if i were to put this in here you can see it’s just putting this into the first slot now you might say well obviously that would be the case because we’re putting it on the left side no or on yeah on the left side of the block no No that’s not how it works that is way more complicated it basically just looks for the first slot and inserts it there and even worse right if we were to yeah let’s say the tanzanite i’m like ah you know what i want to do is i want the you Know the finished tanzanite right to be output like this well let’s just put it in here and what you’ll find is that well no that that also doesn’t work it’s just going to well output basically from the first slot and this is going to be Output at the very end so as you can clearly see the way that this currently works is absolutely terrible and not at all what we need especially this is just with hoppers imagine with cables or some sort of item transport system from any other mod that would break the system Completely so we’re gonna have to do something very very crazy hopefully you will be able to understand it but let’s just go back to the code and see how we can basically fix that so the way that i want this to work is that we will be Able to insert into this slot from the left this slot from the top and the right end of the block basically and to output for on the bottom as well as output on the south side or the bottom side like not the downside right that’s pointing down but like the The side that points to the you i hopefully know what you what i mean basically anyway that’s the general idea and to do this we actually don’t have to do crazy things in terms of methods however the methods themselves are going to look um yeah quite crazy actually Like they are going to look freaking insane let’s just put them like right here we want to get the can insert method override that one as well as the can extract method now what we’ll get in the in both of those methods is the slot that it’s trying to insert or extract From or to the stack that it’s trying to insert or extract as well as a side now the side here is really the well main issue let’s say because the side here is not as you would might expect right so the direction itself by the middle of One click you can see down up north south west east you might be like oh that’s i mean that’s really easy then you know we can just say north and if if the slot is this one then we just import it into there and stuff like that yeah Sadly that’s not how it works because these directions are world directions meaning that when we set down the block whatever face is actually facing north doesn’t matter the what only matters is that the direction is north so we can we’re rotating the block around but that doesn’t matter to this direction And that really is the issue that we have to deal with now i have i have a solution for this once again this is something where you will have to try this out if you have any type of different way of your own you know custom entity over here you Have multiple slots you have different slots they are in like different places you’re like maybe you have two on the left side and you want to import stuff like that you will have to try this out and once again there is some java knowledge needed for this otherwise you Just you’re not gonna like understand what to even do even with java knowledge you might be like i don’t quite understand this that’s fine let’s try and explain this so first of all the first thing i’m going to do is i’m going to get the first two lines here from the Can insert method now all of the code is of course as always available to you in the description below get a preposter and individual just as well and you can see we’re first of all going the local direction what does that mean well basically i want to get the facing of This particular block right because remember back to the block model tutorial right where we actually rotated the block around this is now where this comes in right because as we rotate the block around the side changes right to in which we basically wanted to import it into so we Want to keep this in mind and well i mean think about this so this is the local direction and then we also just want to return a false on up and down because i don’t want anything to be inserted from the down direction as well as the up direction that’s just why i’m Doing this and now what i want to do is i’m just going to have a little bit of comment here right so if we’re inserting from the top right so this would be the north side quote unquote then we want to insert into one so this one right here If we are on the right side then we want to insert into one also this guy and then if we’re on the left we want to insert into zero which is this one that should be fairly self-explanatory in that sense and now i’m going to show you the code that is Responsible for for making this work and you’re gonna say what the frick is this so it’s going to be a return statement a switch statement basically and this is it now the first thing they’re going to say is what is this absolute insanity okay so let me try and break this down For you basically we’re going through all of the directions that the local direction can take this is basically always going to be north because we’re already filtering through um up and down in theory actually this should not be the case this is also going to return up and down but it Shouldn’t matter because the only issue that you might get is that when we’re taking the side over here and it’s not something that can be you know opposite or clockwise rotated because obviously up can’t really be like rotated clockwise that doesn’t make any sense um so keep that in mind but this Should work in theory this should be fine and uh it shouldn’t have no errors in that moment um but we can take a look at that in any way so what happens here if we are if the local direction is north then basically what we’re going to take is the side that the World is facing get the opposite of that and if that is north then we can insert into slot 1. now how did i calculate this i got to be honest i this is more trial and error than anything else basically yeah it’s pretty much trial and error Saying that a site that we’re trying to im to get from is basically always the site in the world coordinates so this is the world coordinate site we’re going to get the opposite of that and that if that is north then we should be at the top of The um this should be the top basically if the local direction is also north that’s very important this is why we have the switcher statement and if then the slot is one then we can insert into it you can also in theory because we’re also getting the stack here filter Through what you actually want this to be inserted into so we can say for example stack dot get item and then this has to be mod items that raw tanzanite for example but you can also filter what can be inserted into this by doing something like this do remember that you Will have to do this for each of those lines now once again in theory you know we could probably extract a method over here make this a little bit simpler to read and all of that that’s fine i wanted to basically give you this as the full you know Full like frontal assault in this case because it is quite crazy and then let’s think about east so now we’re wanting to insert something on the well actually let’s continue with this one first sorry so the default one right so once again this is the north side and Then we’re inserting into the one exactly like this now on the right side we want to insert into one as well this is once again the side opposite that stays the same if this is east now now we’re on the right side of the block Right we still want this to be able to insert into slot one and then once again side opposite on the north if the local directions north then we’re looking for the west side which would be the left side of the block and here we can then insert into slot zero the same thing Goes for all the other ones the only thing that rotates here when the local direction rotates is the side also rotates around right so the so the side that we’re looking at uh from the world perspective we’re basically rotating the world around with this and then keeping the direction here The direction in this case like that we’re trying to do is always the you know top right left things like that that is the general idea here hopefully this is somewhat understandable once again i cannot suggest enough playing around with this this will open up way More if you try to change this and then see oh this is how the behavior changes this is how the behavior changes highly recommend doing it in in debug mode as well and then maybe doing some hot swapping in that instance now interestingly enough a very similar Thing happens in the can extract method i’m going to just copy over the entire method in this case and once again this is all available to you if the site is up of course we’re not going to insert anything if it’s down we don’t even have to care about any of the local Directions because down is always going to be the same side no matter how many times we rotate it around the y-axis of course right that should be fairly sensible here we’re just saying hey if the slot is then 2 we can extract it and then if it’s not down then we’re once Again entering the switch statement and doing the same thing right you can see the north one we’re getting the opposite and then we’re looking at south which is the bottom one night not the one that’s the down but the bottom one and then east as well so we could in theory also Export or extract the item from the right so this would also work we could in theory extract it from the right now that actually doesn’t work it neither works from the right nor the bottom it only works from the down direction because of course hoppers only like Extract from on top of them basically um but if you were to have you know another mod basically installed that adds some sort of conduits or item things that if you can basically you know export items out of it out of something then extract them then that Would also it should in theory work yeah so those are the crazy things as i’ve said this looks quite crazy when you really think about it it’s not that complicated it’s just that you have to get it like once right and once you understand roughly what is happening here then You’re gonna be like okay now i know what’s going on so i highly recommend if you need to watch this again i probably like encourage you to do so i also encourage you to just go to the description get a repository take the can insert and the can extract method Put it into your own block entity and just play around with it um what i will not do is let’s say you’re coming out uh you’re coming over here and you’re like hey so i got like you know like six different slots listen you’re gonna have to figure this Out on your own this is one particular example hopefully you can work off of this uh and hopefully this is understandable now let’s go into the game and just for sanity’s sake see that it actually works in game as well all right he found us back in minecraft And let’s just try and set the german fusing station down now the first thing right on the left side in theory we should be able to insert into here so let’s go this is of course the behavior that we had absolutely before so this is no you know nothing crazy but now from The north side right because we set it down and this is you know not really the north side this is actually pointing to the south but in theory it should now insert into here let’s see if that is the case and indeed it is the case Exactly how you would expect it to and that is absolutely awesome same thing goes if we are actually trying to get something out you can see this is no longer pumping out it is actually outputting the items from the well the output slot basically and the same thing Should happen here so i believe what we should actually be able to do is insert into the output slot on that side let me get rid of this guy uh this is the output slot one right uh no actually it is not that’s also good Uh and then the oh of course we can we can export from the output slot there that that is fair um and then that is pretty much everything now from the top we actually can’t insert anything now it’s also not going to crush the game which is that’s pretty good Of course but yeah that is pretty much the general idea so you have one example of a well particular um german fusing station one particular block entity and once again this is the general idea right we set this down into this direction now if we were to rotate 180 Degrees now this of course now right this face here becomes the top side now of course right this is no longer the top side now in this instance in the with this example i will admit that the example of the block entity it is definitely not as cited as it Could be but you can always tell that this is the right side by looking at this you know the little bit of a blacker area right here because it doesn’t have this on the left so then you already know or you always know which one is the right side hopefully And then that will basically clue you in and once again from the top we can insert right here that is the general idea hopefully this was somewhat understandable to you but in theory this should all be compatible with any type of other mod that you might add and that Has some sort of item transfer pipes or something like that as long as they use the as long as they use the sided inventory interface then this should in theory all work fine so that is how you can make sided inventories right but that would be it for 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.1 Fabric Modding Tutorial | SIDED INVENTORY | #24’, was uploaded by Modding by Kaupenjoe on 2022-08-29 13:59:47. It has garnered 3425 views and 50 likes. The duration of the video is 00:13:20 or 800 seconds.
In this Minecraft Modding Tutorial, we are adding sided inventory management to our custom Block Entity!
== 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/24-sidedInventories Gist: https://url.kaupenjoe.net/yt407/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 * ▶️ Unity 2D Game Development: Beginner Unity C# in Unity 2020.3: https://url.kaupenjoe.net/UnityENCoupon * ▶️ Minecraft Modding for beginners (1.16): https://url.kaupenjoe.net/MCCoupon * ▶️ Complete and Roblox Lua Game Development: https://url.kaupenjoe.net/RobloxCoupon *
== 1 MONTH SKILLSHARE FOR FREE == ▶️ https://www.skillshare.com/r/user/kaupenjoe *
== 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