Hello guys and welcome to the first part of the ng tutorial series in today’s episode we’re going to be going over some of the basics means to know for each of our different ng blocks which in this series we’re going to go via a generator a storage and also Implementing it in two different machines that we may have already created such as a custom furnace or other type of machine Silesia status the first thing we’re going to do is create something called an energy storage this is not the energy storage block but is in fact something that or anything that Has energy requires us obviously anything with energy needs to be able to store the energy and this is the thing that has all the functions used when storing receiving transferring energy and such for Jordi has a built him one what we are going to be making our own One that has a couple extra functions in it so inside our tutorial mod package create a new package called Hendri and we’re going to create the class of custom energy storage this is going to extends the normal for general storage so extends energy storage from net amount of forage to energy and what We’re going to do is we’re going to get a lot of the functions and super off of them so call ctrl and click on this and you storage word it’ll take you into the class and we’re going to take four of the constructors so copy them and paste Them into our custom energy storage hover over and click change the constructor on each one and instead of this change it to super in this final function here I’ll have to copy the previous one but changed the zero to the words Angie so basically we’re using the same phone Just before with receive extract receive energy Andrus extract energy we’re just going to return the super we also need to get and restart get max and you stored can extract and can receive everything he returns to super and now we are going to create to our own Functions this is the reason why we created our own class in the first place as a lot of the energy stuff requires you to use n BTS which are minecraft way of storing data inside of blocks so we need our own two functions for read from MBT and right to MBT so public void read from MBT the MBT tagged compound called compound and right to MBT public right to MBT and also n BTS had compounds called compound firstly in right to MBT we are going to set if we hope go back As the NGO storage class there are these four variables energy capacity max receiving max extract we are going to write them all to the MBT by using the function compound dot set integer the string value of the Nate the same name so energy and the value and this got Energy do this for each of the values in the region bTW we are going to set each of these values to the MBT values that we just set it’s basically when we leave the game it will write to MBT then we rejoin the game it will read from MBT So this dot ng equals compound dots get integer energy that we just wrote in the right to MBT so do the same for each of the other ones and we’re going to call these functions later so that is the custom energy storage and we’re going to use that to implement energy into any Block all the energy stuff is mostly going to be done inside of the tile entity apart from some things in the GUI so I’m going to create a custom tile entered here to explain to you how this will work to implement energy we’re going to be using the capability system The for scape build system note editorial tile and city called tile entity an energy tutorial in the coming episodes we will Utley and blocks and I will show you how to do that but this is going to extend Talon city and every block that we use energy with Will also implement I tickle as icicle it makes sure it’s the net demand after u tilde are suitable that function will have the update function and that is something that runs every tick and we need to be checking the energy value to see if the increased or decreased every Single tick and also changing and modifying the mg so to actually get the energy we’re gonna needs to be using capabilities forage has a built-in capability called energy which what grant be using and there’s two functions that we need get capability but this will only run the function has capability returns true So firstly in-house capability if capability is equal to capability energy dot energy then return true else was going to return the sukkah so we’re saying that it has the energy capability and it can use some of the stuff I can kick hip ability if capability equals capability angry dot energy we are going To return this T here just means not an object any object so return T and then we’re going to return that end your storage this start storage which is something we haven’t created yet when using energy we will create a custom energy storage so privates custom energy Storage storage and then we equal it to a newer one version to it and we can use any of the functions the capacity if you just want to set a certain amount of energy in the storage such as like a hundred thousand and you don’t care About how much can go in or out max transfer will mean that the in or out value that you set will be the same for both in and out this third one you can set different in and out and this fourth one will have any some amount of Energy when you place it for now I’m just going to use the first one I don’t care how much can go in there out at one time you can set this to any value you want I’m gonna put ten thousand and then here in the update function we can Manipulate the amount of energy in the storage you can do this storage don’t receive Angie and the amount of energy it can receive so let’s say 100 so it’s going to receive 100 energy whatever unit you want per tick and for the most part this simulate will always Return false as we actually want to do what we’re writing you can also do this sort of storage dot extract energy so we could say 200 and so we could do something like when our furnace smells an item it wants us to it wants to reduce by 200 energy or while it’s Smelting it does 200 every tick whatever you want to do you can manipulate energy using the storage so that’s the mIET this tutorial is the basic instruction to energy in the next tutorial we are going to be going over an energy generator so if you’re looking forward To that leave a like down below and subscribe so you’re notified when I upload the next part tutorial it’ll probably in a few days so thanks for watching mine has been hairy and goodbye Video Information
This video, titled ‘Energy/Electricity Basics (Capabilities) – Minecraft Modding Tutorial 1.12.2 – Episode 33’, was uploaded by Harry Talks on 2018-08-18 17:41:23. It has garnered 8756 views and 150 likes. The duration of the video is 00:09:26 or 566 seconds.
Welcome to the first part of the Energy series. In today’s episode, I help you to understand the basic concepts while working with energy.
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