Hello guys and welcome another minecraft Mon tutorial in today’s episode we’re going to be going over how to do a custom chest so let’s get started this might be a two or three part series and it’s going to involve making the chest itself you can contain that in GUI as Well as a tile entity special renderer so let’s get started with the block today so we’re going into block in it and to declare a new block public static final block copper chest or whatever you want to call this can be any type of storage block this equal to a new then Block and the name of your thing so block call the chest to me and then we are going to declare the name copper chest so now I’ve declared the block we’re gonna actually create block class create a class and put it wherever your blocks are I have mines or blocks in This instance but you might have it somewhere else like object blocks and this is going to extend block container we haven’t declared a constructor and have string name in there and we are going to declare that the name we set the on localized name to name set The registry name to name and then set the creative tab we also need a super off of the material using so super material and then choose whatever material you want since it’s copper for me I’m gonna do metal or iron you can bend author add a few other declarations Like hardness resistance harvest level and sound type if you want then you need to add this to your list of blocks and your list of items that we’ve done in the previous blocks and items tutorial so block in it top blocks dot add this And item in it dot items dot add a new item block this and you make sure that the register name is set we’ve got a set registry name to name make sure everything is imported by clicking ctrl shift uh no and also if you want to Search for any function like I was doing for item block there you do ctrl + space it’s an out on the constructor there’s something quite a few functions is quite class since we are opening a GUI we need the on block activated function which is called when you right-click on the block So on block I have to rate it if the world is not remote seas and estimation marks a not world in dot is remote then we do player in dot open GUI we get the instance of our mod so main innocents and then in reference you need to create This an integer here I accidentally already crazy I forgot to remove it for my code earlier but public static final int GUI underscore and then the name of your GUI on to open so mine is GUI copper chest and then since I already have a couple Of the GU eyes I declared – – but you can declare this as any number you want as long as it doesn’t conflict with other GU eyes so and where it says mod GUI ID in this open GUI function put reference dot GUI and then your GUI name The world here is called world in and then the x y&z are paws get it as paused or get Y and POSCO get said and return true it will always return true as you will always right-click on the blocked they can never return false but it can’t Open the GUI if the world’s remote the next function is the break block function since the chess we need to make sure that all the blocks drop on the floor or all the items inside of it drop on the floor whenever we break it firstly we need to declare our tile Entity this thailand’s t we will do in the next tutorial but tile entity copper chess call it tile entity and it’s equal to open brackets then copy this towns to come chess text somebody inside the brackets then world in gets tile MC for the position this will be underlined Read the taylors t other you don’t actually have this yet next inventory helper does drop inventory items for the world the position and a tile invent island see and then super dot break block as we need to let it run all the normal functions as well next inside This class we’re going to have the on block placed by function and we use this file setting the custom name so if stat command dot house display name we declare the tile entity tile entity tile and T equals world in get tile entity for the position control Ship so to import talents T then another statement if tile entity is an instance of tile entity color chest we can copy that again then open brackets twice paste that in there again and then put tile entity dot set custom name – static adopt get display name obviously again This is all going to be read and aligned as we do not have the tile and steer talking of the talents T we need to declare that we have one so create new talents T return new talents decal chest just copy and paste that in there again And then the next function is get renders height all the points and after this are going to be out rendering and the way it looks and since we are going to have in the chest opening animation we need to return in unblocked rendered height adopt entity block animated then There’s to be finally three more functions is full block returned false is full cubed return false the final one is is opaque cube and once again we return false and that is the block pass done and sure hopefully all the errors from the walk in it should go away Obviously the block class will still have some errors though next week I need to go into our GUI handler and we’re going to have to declare a new GUI in here so if ID is equal to and the reference ID we mentioned earlier by the way if You don’t have a GUI handler we created one in the furnace tutorial series so you can go and find a GUI video there and you will see when we created this then we are going to return a new and then we’re going to this is in server You declare the container element and in the client you declare the GUI itself so container copper chest will come back to the parameters in their limit and then copy this paste it into client and change it to you GUI copper chest in this episode we’re going to create in The container so I’ll just asked on that create that I’m gonna put it in dot blocks dot container it’s going to extend container from net but my inventory and we are going to need to declare a couple of things an integer called private final int number owes Referring to the number of rows in the chest and also private final and then the tile Anstey again thailand’s take copper chest and that’s the chest inventory we are then going to open up the container cover chest and in here we need the players inventory from inventory player we need the chest Inventory from the tile and city which we use copy and paste from the variable and we need the entity player itself we need to declare that this dots chest inventory is equal to chest inventory so that the variable is equal to the variable inside of decadent shorter this Tottenham Rose is equal to chest inventory divided by nine you should always keep your chests in rows of nine as I came in some graphical glitches when trying to do wider 9 and then at the start of this constructor we need to open up the chest inventory chest inventory dot open inventory for The player we then need to add all the slots so for int I equals 0 and I if less than the number of rows plus plus a height then the number of columns for int J is equal to 0 J is less than 9 as Have we always need to keep this at 9 + + J this is two for loops that’s gonna go and create all of the slots so then this dot ad slot – container a new slot chest inventory as this is gonna be the chest inventory slots J plus I times 9 8 + J times 18 18 plus I times 18 and that is all the slots controls of dota imports flopped net dot minecraft inventory to slot and that should make that error go away if you’ve watched the finish tutorial you can copy all the inventory slots from the previous and Tutorials but for every one new here I’m going to go and write them down again so for int y equals 0 Y is less than 3y + + for int x equals 0 X is less than 9 X + + this dot add Sox container new slot in The player inventory we have x + y times 9 plus 9 8 + x times 18 and then 175 plus y times 18 at least in my GOI is live at you might need to change a couple of your hover of a slot gives the expedition and y position you might have To change a few of those added em numbers on there to make just lots of line with your GUI but we’ll mess around with that in the next episode then finally the hot bar for in x equals 0x last a 9x plus plus this dot as sorts of Container a new slot in the player inventory x 8 + x x 18 and then for me it’s just a null number 233 again you might have to move this number around to make it a line and that’s all the slots at it there’s a couple more functions in The container here firstly can interact with we call upon between the tie lines t I was going created that yet but returned VIX adults chest inventory dot is usable by player and in the player in then on container close keep the super then below that we also need chest Inventory dots close inventory player in and they’re finally transfer stacking slot this is a bit different to the furnace one but I will leave it all in the description that you’ve got being pasted in as it’s quite long so there it is contrast retail copy item stuck in Bottom stack basically it goes through and sees if it can move any of the slots in or out from your inventory or the chest and make sure that the certain items merged with the onto the chest when you add them into the chest and the final one is a public Thailand’s to top A chest called gets chest inventory just returned this what it has to inventory and basically contended done this way I’m going to end this video so I’m gonna come up we’ve done here today we have created the block and this block here has its own tireless tea we’ve declared it’s animated so we Can go on to create the talented special renderer in maybe the next episode maybe a PUD after that depending on how long it takes and we’ve said that it’s not gonna be a full block we’ve made sure when we braved block all the items drop on the ground and that we right-click on It we open the GUI and over in the GUI here actually one last thing we can do here we’ll add the say pop player dot inventory tile entity copper best world gets silenced t oh sorry a new block pause XY says and then player itself it’s saying it’s got over here because Doesn’t know what talents to cover chest is we plate that next but here it’s seen when we right-click on this GUI and it sees the reference of GUI chest it’s going to come to the GUI Handler and it’ll see these two so it’ll open the container that we’ve just created and The GUI that will create in the next episode and the container we’ve created all of the slots where our inventories gonna go I’ve made my 9 by 8 but I just like I make it as because I want because we have this num rows thing here all Depends on what number we put inside of the chest inventory this here should happen to be get and size inventory divided by 9 and so we’re getting the size of this inventory here which we can change to any number and then it will divide by 9 and figure out how many rows But I’ve designed a GUI to fit 8 and 8 rows and 9 columns so we have all of those that in this function here and this is the normal player inventory and we’ve set up a system where that when we shift-click some items into the chest it Will merge with any of the items that are in the chest already so and forth I’m gonna have to end this episode here as it’s getting quite long we will come back and fix all these errors in the next episode so thanks for watching my name’s been Harry and goodbye Video Information
This video, titled ‘Custom Chest (Part 1) – Minecraft Modding Tutorial 1.12.2 – Episode 30’, was uploaded by Harry Talks on 2018-07-21 16:05:51. It has garnered 10536 views and 118 likes. The duration of the video is 00:17:02 or 1022 seconds.
Welcome to the Custom chest series, which will involve containers, gui’s and a tile entity special renderer. transferStackInSlot: https://pastebin.com/9vG76D1K
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