Modding By Kaupenjoe: Minecraft Modding for beginners (Version 1-16-X) | Kaupenjoe (Nico) | Skillshare
Search

Playback Speed


1.0x


  • 0.5x
  • 0.75x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 1.75x
  • 2x

Modding By Kaupenjoe: Minecraft Modding for beginners (Version 1-16-X)

teacher avatar Kaupenjoe (Nico), CS Student, Nerd and Educator

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

    • 1.

      Introduction to the Course

      1:55

    • 2.

      IntelliJ & Java Download

      0:40

    • 3.

      IntelliJ & Java Setup

      3:28

    • 4.

      (Java) Datatypes in Java

      6:32

    • 5.

      (Java) How to Read Java Code

      3:39

    • 6.

      (Java) The Main-Method

      2:52

    • 7.

      (Java) Using println to output things in Java

      6:31

    • 8.

      (Java) Integers and arithmetic operators

      7:37

    • 9.

      (Java) Booleans and comparison operators

      3:54

    • 10.

      (Java) Booleans and logical operators

      3:43

    • 11.

      (Java) Strings and String-Methods in Java

      13:43

    • 12.

      (Java) Casting Variables

      5:38

    • 13.

      (Java) Integers and Math-Methods

      6:46

    • 14.

      (Java) If and Else Statements in Java

      8:36

    • 15.

      (Java) The Ternary operator in Java

      3:35

    • 16.

      (Java) The Switch Statement

      2:49

    • 17.

      (Java) While Loop

      4:25

    • 18.

      (Java) For Loop

      3:45

    • 19.

      (Java) Break and Continue

      2:34

    • 20.

      (Java) Arrays in Java

      10:06

    • 21.

      (Java) Multidimensional Arrays in Java

      7:43

    • 22.

      (Java) The (Array) List

      8:02

    • 23.

      (Java) HashMaps in Java

      6:00

    • 24.

      (Java) For Each Loop

      3:24

    • 25.

      (Java) Java Methods

      8:07

    • 26.

      (Java) Method Overloading

      3:12

    • 27.

      (Java) Classes and Objects in Java

      11:40

    • 28.

      (Java) Public, Protected and Private

      2:30

    • 29.

      (Java) Getters and Setters

      3:26

    • 30.

      (Java) Packages

      2:28

    • 31.

      (Java) Inheritance

      7:13

    • 32.

      (Java) Static and Non-Static Methods

      3:54

    • 33.

      (Java) Polymorphism

      2:42

    • 34.

      (Java) Abstract Classes and Methods in Java

      3:52

    • 35.

      (Java) Interfaces

      7:58

    • 36.

      (Java) Enums

      4:43

    • 37.

      (Java) Exceptions & Try and Catch Statement

      6:40

    • 38.

      (Java) Java Lambda Expressions

      10:02

    • 39.

      (Minecraft) Forge Installation and Setup

      11:06

    • 40.

      (Minecraft) Note on using Minecraft 1.16.5

      2:48

    • 41.

      (Minecraft) Create our first Item

      10:31

    • 42.

      (Minecraft) Create our first Block

      9:47

    • 43.

      (Minecraft) Theory: Going in depth into our Classes

      15:40

    • 44.

      (Minecraft) Our own Custom Creative Tab

      3:43

    • 45.

      (Minecraft) Create a new Recipe

      5:46

    • 46.

      (Minecraft) Block Drops with Loot Tables

      5:01

    • 47.

      (Minecraft) Create a new Food Item

      8:05

    • 48.

      (Minecraft) Create a new Set of Tools

      21:03

    • 49.

      (Minecraft) Events in Minecraft Modding

      23:17

    • 50.

      (Minecraft) Add Tooltips to Items

      8:29

    • 51.

      (Minecraft) Create a new Set of Armor

      14:27

    • 52.

      (Minecraft) Creating Stairs, Buttons, Pressure Plates and Fences

      18:16

    • 53.

      (Minecraft) Mod Configs

      11:55

    • 54.

      (Minecraft) Exporting your Mod

      4:44

    • 55.

      (Minecraft) Use Github for Source Code examples

      6:16

    • 56.

      (Minecraft) Use GitHub as a Version Control System

      8:52

    • 57.

      (Minecraft) Current Forge and Minecraft Version (1.16.4)

      3:40

    • 58.

      (Minecraft) Current Mappings

      3:25

    • 59.

      (Minecraft) Advanced Loot Tables

      5:45

    • 60.

      (Minecraft) Custom Crops

      15:41

    • 61.

      (Minecraft) Custom Fluids

      17:15

    • 62.

      (Minecraft) Clean up and Refactoring

      10:45

    • 63.

      (Minecraft) Custom Block Models (Including Blockbench)

      23:50

    • 64.

      (Minecraft) Creating a new Tile Entity

      15:44

    • 65.

      (Minecraft) Create a Custom GUI

      42:18

    • 66.

      (Minecraft) Ore Generation in the World

      13:08

    • 67.

      (Minecraft) Creating a Custom Tree

      23:50

    • 68.

      (Minecraft) Creating a custom Mob

      30:18

    • 69.

      (Minecraft) Making our custom Mob spawn inside the World

      16:25

    • 70.

      (Minecraft) Creating a custom Biome

      49:58

    • 71.

      (Minecraft) Sound Events and Custom Sounds

      10:55

    • 72.

      (Minecraft) Creating custom Enchantments

      20:42

    • 73.

      (Minecraft) Data Generators for Items and Blocks

      23:18

    • 74.

      (Minecraft) Data Generator for Loot Tables and Language

      21:42

    • 75.

      (Minecraft) Data Generator for Recipes and Advancements

      29:27

    • 76.

      (Minecraft) Tile Entity Fix and Capabilities

      22:56

    • 77.

      (Minecraft) Creating Custom Commands

      24:10

    • 78.

      (Minecraft) Making our own Dimension

      28:13

    • 79.

      (Minecraft) Creating a Big Chest Tile Entity

      51:25

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

1,213

Students

8

Projects

About This Class

Did you always want to create a Minecraft Mod? This course will teach you how to make your own Minecraft Mods! You will not only learn the programming language Java, but also the Minecraft Modding API to make your mods compatible with every other Mod in Minecraft: MinecraftForge

In this course I will teach you the first steps by introducing you to Java. Even with no experience you will be able to make Mods at the end. You'll learn all how to make Blocks, Items, Tools and Weapons in Minecraft. You will also learn to create different types of Events. 

With a bit of creativity and applying the lessons you get from this course, you might just make the next Minecraft Mod hit! 

This course is accessible for complete beginners. Even if you have never programmed in your life! The only requirement is that you own Minecraft and are vaguely familiar with the Game and some popular Minecraft Mods or even Minecraft Modpacks.

The entire Source Code will be available so you can follow along everything I do in the videos. 

If you have any questions or suggestions, also feel free to contact me here. I'm happy to help you learn to Code in Java and make your own Minecraft Mod. 

Please note that this class is for 1.16.X. 1.17+ is not supported with this class! 

DISCLAIMER: NOT AN OFFICIAL MINECRAFT PRODUCT. NOT APPROVED BY OR ASSOCIATED WITH MOJANG. 

Meet Your Teacher

Teacher Profile Image

Kaupenjoe (Nico)

CS Student, Nerd and Educator

Teacher

I am Nico - also known as Kaupenjoe - I have a Master's Degree in Computer Science and teach Game Development through many different classes. Mid-2020, when I became a bit disillusioned with my job, I set my sights to something different. Multiple people have previously told me I was good at teaching things.

With some of my prior YouTube Video making knowledge I was able to make my first courses. The Minecraft Courses in particular made a huge impact on students and myself and allowed me to teach full-time with courses and other supplementary methods.

I hope you will also join me and allow me to help you learn Programming, Modding or Game Development. As a hobby, side-hustle or as a promising career, it is an amazing and fulfilling field and I'm so happy to have y... See full profile

Level: All Levels

Class Ratings

Expectations Met?
    Exceeded!
  • 0%
  • Yes
  • 0%
  • Somewhat
  • 0%
  • Not really
  • 0%

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. Introduction to the Course: All right, welcome to this most extensive course on Minecraft modelling here on skill share. And in this course, we're going to learn everything from creating blocks and items over to tools, armor, and even tile entities. So this is a selection of things that we're actually going to learn about and create here, we're going to create some copper based things. So copper or we're going to create copper blocks and ingots. We're gonna create a copper wires. And we're also gonna make it sure that this response inside of the world to world, Jen, We're gonna create tools from them and armor. We're going to create our own custom crops and how to make sure that they display properly and how all of that works. We're gonna create our own custom fluid. In this case, this is oil. And of course a tile entity, like I've already said, this tile entity will have a custom GUI and this also will have a custom functionality. In this case, we're going to create diamonds, which we're going to have it so that diamonds actually create energy. And then those diamonds can be, this energy can then be transformed into emeralds by using copper wires. Were also going to create our own custom tree and have this custom tree generated inside of the world. And last but not least, and we have our own custom tab. And inside of here, we're actually also going to be able to spawn mobs that we did ourselves. So customer jobs, we're also going to be added to the game. These also can spawn in side of the world. And we are also add a spawning, or that is what's to come in this course. I'm hoping that it is of interest to you. And I am looking forward to seeing you inside of the course. And they Yeah. 2. IntelliJ & Java Download: Or are there are two things that you need to download for this class. The first one is the open JDK, which is simply the Java language, so to speak, so that you can use it and program with it. And very important that you use the JDK eight. So choose this version and then choose the JVM hotspot. Just click on Related to release and then it's going to download. And another thing we also want to download IntelliJ idea. And this is very important that you use the community version here. This is free and open source, no login or anything required. And this is gonna give us enough power to do anything that we wanna do. And both links are in the top of the project description. 3. IntelliJ & Java Setup: All right, welcome to this first lecture on how to set up Java and the IntelliJ idea. Now, when you start intelligence for the first time, this is the window that you are going to be greeted with. And we simply want to click on New Project because we want to create a new project. Important, make sure that you choose. Java appear at the top left. And then when it comes to the project SDK, we want to select the Open JDK that we have downloaded previously. Now, here I already have the one-point a Java version in here. It might be that it is down here for you. It should automatically find it and you should just be able to select it. If that is not the case and you've still installed it, you can click on this add JDK button and then search for it wherever you have. Put it. So wherever you've installed it in the directory and just click OK there. If that does not work, so you don't find it. You can always also downloaded from here by choosing adopt Open JDK and then selecting the 1.8. Oh, that's very important that this is the version that you select, right? And then you just click download on in whatever location you want to install it into. And then that would also work fine, right? So with that selected, next, we actually check this box. So create project from template because we do want to have the command line app as a template. This simply means that it's going to generate for us a little helper, let's say that is going to make us start way quicker than if we don't have this generated automatically. We can click next again. And in this window, we actually have to specify the project name and the location, as well as the base package name. At the base package name is usually a domain reversed. So for example, for Google.com, red it would become dot google, right? And for our purposes, for me, I'm going to do com.com Joe, or you can do basically whatever you want. Or VR. This is definitely the convention to do it like this. So too, do the calm dots and then a name or net dot or whatever might be the case. Something that's also very important to mention is that this is in lowercase, a base, base package and all packages and the names are all in lowercase. And so let's just click finish and then let's see what happens. So this is gonna do a bunch of stuff. And then as you can see, it has already generated some things for us. We can now expand this here to the left. And then if we expand the source folder, we can actually see that here is our KM.com job package. There are two things that I want to mention. That is once here in the options menu. Sometimes it might be that flattened packages is on the other hand, it's gonna look a little something like this. It's gonna look a little weird and this might turn into an issue. I do advise to turn flat packages off for the purposes of this entire course. And yeah, and that's basically it. This is basically the, the, what you need. And if this setup has been done, then you can follow the Java course to a T. And yeah. 4. (Java) Datatypes in Java: So welcome back to the Java introduction. And in this lecture we're gonna talk about datatypes. Now. What are data types? It's basically a way of storing information. And of course there's different types of information, right? So this is going to be more theoretical approach to explaining the datatypes. And then we're going to later see, OK, what can we do with them? How can we manipulate them? How are they sort of interchangeable? And we're just gonna go through them and see what we can see. So first things first, there are a number types. And number types should make sense. There are two main number types, I would say that's an integer and a float. An integer is a whole number. And in this case, it's the nominated with the, with the word int I-N-T. Then you get the name of the variable and then you assign it a specific value. So right now in a number, 42 is written in there. And I've also added a common tier, so integer or whole number. And you can store anything between these two numbers. So minus 2 billion to 2 billion in there. And then there are floating point numbers. These are basically four decimal numbers, not quite. So the floating point numbers or floats are stored in scientific notation. And these, in this case the floats or precise, or 7 decimal point precision or seven numbers of precision. So in this case we have four numbers. And if we were to add three more of them would have, of course have seven numbers and any number after that actually gets cut off. So this is why were rounded up or down. Yeah, so that's important to know. If you have a float that's longer, that's actually going to might cause some issues. Now, as you can see down here, there are also other types of number types are other variable types that can be used. So a bite, for example, is only one byte or eight bits. You've maybe heard that before. And it can only store numbers from minus a 128127. So this is for very tiny numbers. That's why I've written the variable name as tiny number. And a short is a small number. It can store numbers from minus 32 thousand to about plus 32 thousand. And then there's also a long, which is for really large numbers. And as you can see, this is like insane amount of numbers you can or not amount of numbers, but the range of numbers you can store in there. So you can store from, um, I gotta because I'm not sure, nine quadrillion idol, I don't know what it is, but it's it's a large number, usually, in my estimation and in my experience, it's very rarely seen that one uses along. It's most likely that a, an integers used in almost any case. Because when does it really happen that you get numbers that are bigger than this? It's not very often the case. So in general, I would argue that these two are the most important. Another one which might come in useful is the double. And as the name here suggests, is actually a more precise number. So this actually has 15 decimal point precision. So this one can have 15 places until the 16th place gets cut off or rounded. So instead of only having the seven with the float, the double can actually have a few more, right? So this is the number types. Then we have Booleans or basically the logic type. This is for our testing conditions. And so we can have a boolean, right? So the name also boolean. The name of the variable in this case is this is this course grade, and it's equal to true. Booleans can store either true or false. So this is also sometimes shown with a one or a 0. And then we can also write, for example, is this HTML. And we say, No, this is false because this is Java. And then there are characters. So a single character is a char, CH, AR, and it can store a single character. This, however, can also include special characters like commas, dashes, and spaces. Those are all characters. So for example, we can simply write something like this. And it's not going to throw an error because a space is a character of I'm going to put two spaces in and it's going to throw an error because that's two characters. So that's basically a single character, a char. Now if multiple chars next to each other, then what we're going to use is a string. A string here stores a sequence of characters. So in this case it stores helloworld. This is something that you see very often, especially in beginner programming courses or anywhere where you're going to start to program. Hello World is sort of a thing that, that's sort of the first thing you try to output as a variable. So to say, Hey, hello world, I have now started programming. This is me. And very important to know. So a character is basically written with these single quotes surrounding it. And then whatever character you want inside of it. And a string is written with double-quotes. And everything inside of those double-quotes is basically part of the string. It's also very important to note if you want to have a double quote inside of this, you can actually use a like a backslash year. And this one can then be used to create a, a double quote inside of your string if you want to. And this is also used for all sorts of other things inside of a string. Yeah, so those are the main data types that we're going to be using in this course. And those are also, I think, ones that are the most prevalent ones that are used basically always. And that was it for the lecture on datatypes. And yeah. 5. (Java) How to Read Java Code: All right, welcome back to the Java introduction. And in this lecture we're going to quickly talk about how to read code. So if you've never read code anywhere, we're actually going to look at a few examples here. And the first two things are comments. So a one line comment is just done with two slashes. And a multi-line comment is done by doing a slash and then a star and another star and a slash. And what that's gonna do is it's gonna create a multi-line comment. Now, a declaration of a variable is simply the type of the variable and then the name of the variable. And then ending the line with the semicolon. If we then assign a value to that variable, that would be simply doing the name of the variable, then the equals operator, also the assignment operator named Simon operator. And then just the value that we want to store in that variable. Once again, ending the line with a semicolon. This is basically what we're gonna do. Always in every time. We, when we have a statement, we're gonna end that with a semicolon. Then we have initialization, which is simply the Declaration and the assignment at the same time. So in this case we're going to declare an integer x and we're going to immediately assign it the value of ten. Sometimes we maybe want to access variables or methods of an object. What are, what are methods or what are objects? We're going to talk about that in later lectures. But just so you know, we do that with a dot after the name of the variable. So when we have the string here, if we do S dot and we're going to get suggested a whole bunch of methods that we can call. And those methods do things that like I said in later lectures we're gonna talk about. But it's very important that you use the dot operator. It's not quite an operator, but it's a dot after the name. And when you see the open and close parentheses after something with a dot, this is always a method that is called. And when you don't have it, then this would be a variable. However, in this case the variable doesn't exist, so it shows an error. But if there are no parentheses afterwards, then as a variable, if there are parentheses, then it is a method call right in here as a short little addendum at the end. This is a code block. It can be described as a code block. And if we hear initialize a variable inside of this block than outside of it, it is not coming up you recognize, right? So here we say, oh, integer l is equal to 0. And here we say, hey, i is equal to L plus two. That is now work because outside of this block, L doesn't exist. So this works for both classes, methods, and also just these V flowing blocks of code, which I, I've rarely seen this one you use just like that. But it is very important that between the curly brackets, if you initialize something than outside of the curly brackets, it is not non-existent. There's a few, like speciality is in special rules. But in general, they are not accessible outside of that. And yeah, that is just a quick short summary of how to read code and yeah. 6. (Java) The Main-Method: All right, welcome back to the Java introduction. And what we're gonna talk about now is what this thing means. So this is also called the main method. And as you can see, I have written a comment here that says code goes here. And what does that mean? So the core code goes between the curly brackets, two in this one and this one. They're also highlighted when I hover over them or take them, take the cursor over them. And basically what happens is that everything in this main method is executed from top to bottom. So something written here, it's going to be executed first. And when I go down here, this one, this one is second, for example, right? So first this one is executed, then this one is executed and is very simple, basically from top to bottom. And this is true in the main method. And we're going to see that it's not always true that it's simply linear or from top to bottom. You know, you can have, let's say, branches that are going to change the flow of how the program operates or how the program evaluates and executes. But in general, you need a main method in your Java program because that's what's going to be called, that's what's going to be executed. And that's where basically most of the, not most of the code, but you know, some of the code goes that it is executed. And in this introduction, Most of the code in the beginning especially is gonna go into this main method. Because that's basically the way we can, that we can use the we can program and then have it execute, right? So what all these names mean? So public static, void. We're going to slowly discover what these terms mean. Right now. What I want you to do is sort of blank this out and just say, okay, we're inside the main method. And this is where our code gets executed. What all this, all this other stuff means. We're going to talk about this. Definitely. It is going to come in later lectures. But right now, the main thing is main thing. See what I did there, okay, now the main thing is that whatever it is in the main method that's going to be executed, that's basically the only thing you need to know right now. In all of the other things you're going to see written here, the organ to be explained. But with time, because we first need a few extra components that we learn in order to really understand what the other things mean. So, yeah, that's just a short idea about what the main method is and why it's important and why. It says, hey, code goes here. And yeah. 7. (Java) Using println to output things in Java: Welcome back to the Java introduction, and this time we're actually going to write some code. Now what we want to do in this lecture is we want to output something to the console. So first of all, we want to output a string. And what we're going to write is system.out.print, LN, print Ellen just stands for print line. And then we're gonna do a, an open bracket. And what's gonna happen is it's going to automatically generate the end. And then we're gonna to quotation marks and we'll put in hello world. So what we wanna do is we want to output Hello World. Now we end the, the, basically the instruction with a semicolon. That is normally how you end a instruction. And well, it doesn't throw any arrows. So we're just going to start this and see what happens. So I go up to the right here to this Play button basically and say run the main, We're gonna do this. And then what's going to happen is we're going to see right here, Hello world. What a beautiful thing. You've just maybe if you've never executed a program before, and this was the first time, congratulations. I know this may this is not meant to be patronizing. I actually mean it. This is definitely more than most people GET with this because programming, while the first steps might look easy, you know, the more you do it, it's, it's, it has some depth to it and, you know, doing the first step and then also committing to taking something like this, a course like this. That's great. It's really, it really is good. So, okay, let's talk about a little bit about what is happening here. So right now here we are outputs, outputting out. Putting a string is a string, as I've said in the data types video, a string and the helloworld strings, basically the first thing you want to output. Now we can also output different things. So we can also save, for example, output print line 42, right? And let's, let's run that one. And then it's gonna output 42. So this is just outputting an integer. So out, oh, oh my lord. Outputting an int term, right? This is outputting an integer that we can basically output any datatype we want also. And that's what we're going to see later. Our own data types basically. And then what happens if we want to output a Float? How about that one? We're going to do that system out print line. And as you can see, it already has a lot of suggestions here. And we can actually go down these suggestions and say, hey, I want to output a float so we can just hit enter and it automatically does stuff for us. And then maybe when we want to do the float, we're gonna write something like this. And that's also going to work. Let's just run that 155.32. And then the last one is maybe we want to actually have a variable. So maybe we weren't Int. We're going to call that output me. And it's going to be 1137, of course. And then what we're gonna do is we're gonna do system.out.print line. And then we're gonna put in, oh, nope, that's not what we want. We want to output, output me. And as you can see, as soon as I write out, it already says, hey, do you maybe want to output the variable output me and I say, of course, so we're going to enter and auto completes and then run the main method again. As you can see now, it outputs whatever is written in this variable, output me. Yeah, so this one would be out putting a variable, variable in the seas, integer, Right? Yeah, so this is basically output, how you output something, a string and integer float variable. In this case. In this case this is an integer variable, but it can be any variable you want a string variable, a float variable, a short along a char. And yeah, this is the output method. So system.out.print line is short addendum to this is as there's also a system.out.print, right? And what happens if I do this? Let's say I want and then output a thousand. And if we then do this, first of all, nothing's going to happen. But now the interesting thing is if I put a 1000 again, then all of a sudden, what is this? So print line basically adds a line break at the end of the print output and print does not. This is why usually it's preferred to use print line simply because then you can just have multiple print lines below each other and they're not going to interfere with each other. Now this one, that's going to be really interesting if you expect to times a 1000 instead of, you know, the bigger number. So that's very important to keep in mind why print line, why I used print line and YB should use print line instead of a print, right? And as a short little addendum here, you can also print out multiple things. So what you can do is, for example, when you write system out print line, you can, for example, make a string. So as an example, rewrite output variable. And then we go behind the string and we do a plus. And then for example, the output, MY variable. And this also works, and this works in whatever way we want. So for example, we could also then say, maybe we want to, this output variable that we have just output is kilograms or pounds, or it's maybe yards or meters rate. Then we can simply add something behind it as well. And then when we output this, they are written together. Now here in this case, a space would probably be pretty smart. And then the output actually looks kinda decent. And this works with either just the variables in between or you could also do it with strings in theory. Now this, in this case, it doesn't really make any sense to do this. You can also just make it one string. But if you want to put variables inside of there, that also works very useful and actually like very easy to use. Yep. 8. (Java) Integers and arithmetic operators: All right, welcome back to the Java introduction. And now we're gonna talk about integers and arithmetic operators. So what does that mean? It basically means, okay, what can we do with integers in this case? And how can we manipulate them? So the first thing of course that we can do is we can add rate. So if we have, let's say a, in addition, we want to add first, second, or we're going to write this first. And then we're gonna do a plus symbol. And then second, whether enters once again with a semicolon at the end. And now in addition, there should be stored a 300. Makes sense, we can actually check this. Output, this, let's say. And then we're gonna output addition. And we're going to run this. As you can see, 300 is in addition, as we have thought about, okay. We can also say maybe what we want is another sum where we actually want to have, you know, not it add two variables, but maybe something else. So we have, for example, we take addition, that's 300 and plus 200 or 2200 plus 500. That also works. We can add multiple things in the same line, not an issue. And then I'm just going to copy this. And I'm going to put in some here and we're gonna see that that's a 1000. Yes, of course, that's great. So now we're going to have 1000 in some 300 and addition and 1000 and some. That's great. What else can we do? Well, maybe you want to actually subtract something. So we're going to have first minus second. Interesting. Now what's that going to yield? Well, that should yield a minus a 100. Okay. Is that an impossible? Of course. That's not an issue. We're going to just have another print line. We're gonna print out sub just to see what's in there. And we see that this is minus a 100, no issue whatsoever. There's good. What else can we do? Well, maybe we wanna multiply something. Seems like it makes sense. Let's multiply first. And that's, that should then yield a 400. And we're going to just check that as well. Just to be sure. Hopefully math hasn't changed yet, but I don't think so four times 100 is still 400. Greet. And then the last, let's say easy thing or thing that you probably know from school is divide. So we're just going to divide second, divided by first. This should be a two. And then we'll check this again. And we're gonna see what that does. It is indeed a too, that's great. Now there's one more thing that we can do here that's probably a little bit different. And that is basically the modulus or the remainder, right? So we have remainder. So if we take 25 of two, so this is 25 mod, modulus or mod2, then this should yield a one. And the reason why this is a one is if we want to divide 25, so 25 divided by two doesn't work right? But what happens is that, what number could we add to the remainder in order for it to be divisible by two. And that would of course be a one. So let's just check that the remainder here. Is one and it is, it is a one. And then if we just check another remainder for example, and let's just run a 115 then modulus ten, for example, this would be a five. I hope it's 5F. I'm pretty sure it's five. Because what, what's going to happen is we can actually divide a 110. Let's just 11 times ten, right? But then 155 is going to be the remainder, right? This is basically the remainder operator, also called modulus. And it can actually be helpful. So for example, the modulus two is incredibly great because you can just check, hey, is this equal to 0, right? So is modulus two to 0, then you know that you have an even number. Or if you want to check for one, then you know that you have an odd number. So this is why the modulus operator is really good. And now sometimes maybe, you know, we have this sum. And maybe what we want is tsunami. We have an integer that we call I and that's what we wanna do is we basically want to have plus one to this. So what we can do is we can say, well, i is equal to i plus one. That works totally fine. And now two is written in IE. It's also possible to do this a little bit, even easier. And that's going to be if you do i plus equals one. Because now it's basically going to do the job of adding itself as well. So this is basically the same as this. So these are equivalent. And now it's going to be written a three. Because remember, here we have a two, right? We'd go from top to bottom. So in this line we have a two written in i, and now we have a three written on i because we added another one. Now this, by the way, holds can be any number, of course what you want. And so that's not an issue. But we can go even, let's say, easier for incrementing and decrementing. So incrementing and decrementing is basically adding or subtracting a one. So we can just do i plus, plus or I minus, minus. And that's immediately going to do then hear a four. And here we are going to have a three again, because in this case we're actually going to subtract from the A1. And yeah, now this way of writing is very helpful because we can also do different things. So we can also have reasonable minus equals. We can have times equals, we can have divide equals, and we can also have the modulus equals. So this one is really, this one's really good. I'm going to actually put that down here. Well, no, then everything is going to change. So let's keep it there. And that's just going to do another one. So the I plus equals ten. And this one's gonna be a 13, right? And we have different types of things we can do here, like short ways of writing this. It's great whether or not you use it in the end. It doesn't really matter. It has all to do with the readability of the code rate, how easy you're going to see the code, and how easy it is to understand the code. Because what I do believe that this is not as understandable as this. Like OK, I'm just going to add one to i and I'm going to write it into I. And this one of course, does exactly the same thing. I think is a little easier to read. But at India, at the end of the day, you could total free to use either one of those. But it is important to know that these things exist because maybe sometimes you're going to read a quote from another person. And if they only use this one, this type of an add or subtract, then you're gonna have an issue if you don't know these things. So that's why I just wanted to mention this. There are other things other ways to do this and yeah. 9. (Java) Booleans and comparison operators: All right, let's continue with the Java introduction and let's look at the boolean and comparison operators. So for example, we can initiate lies a boolean with the keyword Boolean. And then for example, we just call it a b. And inside of it, we can either write true, true, or false. That is the only thing that goes inside of a Boolean, either true or false. And we could imagine something like in a game, for example, a 2D platformer. Probably, you know, suddenly like Mario, probably all of you have seen something like that. And we could imagine a Boolean that is, that asks, okay, is Mario right now on the ground or is he not on the ground? And this Boolean could, for example, be called, is grounded. So this is something that is a little more concrete than just having a boolean called B or C. And in the case that Mario jumps, obviously, I think it's pretty clear that is grounded would be false. And as soon as he touches the ground again, it is, it is grounded would be true. So this is one example where a Boolean could be very useful. But there are also things you can do with booleans that are very interesting. So as I said, the inside of a boolean, you can either store a true or a false. Now, once you can also do if we, for example, have a boolean x, you can also store. You can also look at expressions and see how they evaluate. So for example, I could compare something. So I can compare two to, let's say five and say, well, the question here is, that is being asked is to, is to smaller than five. And then the answer is, well, is this true or is this false? Of course this in in this case would be, excuse me, it would be true that you go. And then inside of x, true would be stored. Now we could also do something like maybe say y, and then we have ten is bigger than 50. And this will of course be false because ten is in fact not bigger than 50. And those are some of the things that we can do. These are comparison operators. And there is, there are some other ones, for example. So there's smaller than, bigger than, there is bigger or smaller or equal and equals itself. So this one, for example, would look like something like this. Boolean. B is equal to, and then we would have a 100100. And this one doesn't, this is not the assignment. Assignment is a single equal signs and two equals signs means, means, hey, is this equal to each other? So there's a 100 equal to a 100 in this case, yes, therefore, this is true. And then there's another one which is unequals, but also gonna take a look at that one. So if we then have, for example, 50 unequals, 51, this would in fact be true because 50 is not 51. So this returns true if both sides are not equal to each other, just right there behind it, unequals and this is equals, right? So those are some of the atmosphere as well. Those are some of the comparison operators and Booleans which you can use. And how we, how are we going to continue with the booleans? We're gonna see that in a later lecture. But this is a very good foundation to have in order to understand what's coming next. And so yeah. 10. (Java) Booleans and logical operators: All right, let's continue with the Java introduction. And in this lecture we're going to look at booleans again, but this time we're going to also look at logical operators. So last lecture we ended up with this, and this lecture we are going to look at three types of operators. Three operators we can use. We're going to look at the and operator, which is going to be two ampersands science. We're going to look at the or operator, which is going to be two of those vertical lines. And we're going to look at the not operator, which is simply going to be an exclamation mark, right? So let's see the first one. So this is once again stored in a new boolean. So we're just gonna call this one Boolean B2. For example, with these operators, we can chain different Boolean expressions together. So for example, we can do x and y. So in this case, it is asked, okay, what is the result from x and y? The and operator needs for both expressions to be true, right? So if x is true and if y is true, then the entire statement is true. Now in this case, we know that y is actually false. And therefore we actually know that this is gonna be false, right? This is the and operator. The. Then let's look at another one, for example, B3, which is going to store it in v3. And this is going to be the OR operator. So the or operator, let's say for example, we will, we are going to say is grounded or, or be, read b appear, is grounded or B is going to be true. And the reason why it's going to be true is because if one of the variables or one of the expressions is true, then the entire statement is true, right? Because we're asking, okay, is grounded or B. And if either one of them is true, then B3 is also going to be true. This is the or operator. And then the last one before is going to be the NOT operator or the negation. And this is simply writing the exclamation mark and then whatever, for example, Boolean type you want to have, and this basically inverts it. So this will turn this true into a false. And this is the not operator. We've already seen this sort of with the unequals operator here and here. And this one simply flips or inverts whatever is written in the variable. Or also, for example, if I write not true, this would simply also be false. So those are both of both things that work and very important. You can also chain those together, I mean, infinitely basically. So you can say B2 and B4, or b3, e3, and x, or beef before again, well, that makes no sense. Or why? Or C, for example, right? So this would now look hideously complicated. There are some mathematics you can use in order to basically look at what you can, you can simplify it, right? So this is a, basically a function. You could possibly simplify this if there is interest, I can definitely show you a few of those tricks and tips and what you can use. Just a right a question or ask me. And I will be sure to also make electron that if there's enough interest for it. Yeah, so that was basically it for the Boolean and the logic operators. And yeah. 11. (Java) Strings and String-Methods in Java: All right, welcome back to the Java introduction. In this lecture, we're gonna talk about strings and string methods. So first of all, we're going to talk about string. So we have a string right here. It's called Sentence and written helloworld. This course is wonderful. Great. Now maybe what we want to figure out is how long is this string? So how many characters are there? That's not an issue. We can immediately, by the way, also print that out. And that's going to be, so let's say we say length is, and then you do a plus in order to then output this. So we're going to have sentence, sentence dot length. And this is then going to output, basically the entire thing is going to output the length of this string. Let's just call this. And we're gonna see length is 38. Interesting. Basically. We have 38 characters in this string is pretty good. So that's a good thing to know that we can figure this out, dot length and then the parentheses. This is by the way, a method call. It's basically something like, you know, the main method we talked about, the main method. And these are methods that we can do on our individual strings that we have. And here's some more that are quite useful for some things. So I'm going to copy those over. Usually I don't like to do this. However, in this case, I think that it is, it makes most sense because always running the print line and then the method doesn't seem to be that, you know, valuable. But I am going to explain. So basically maybe we want is the sentence to be all uppercase or lowercase. And we can use the method to uppercase or lowercase. Now this should be self-explanatory. We're just going to run this and we're gonna see no shouting. And then we have everything in uppercase, if we whisper than with everything to lowercase. So even the things that were capitalize, the words that will capitalize before are now not, not capitalist. Now what is also very important to know, and I'm going to demonstrate this by just pulling out the sentence itself afterwards, is that when we do this, the sentence is not changed. The variable sentence does not change. When you call, for example to APA or to lower. It actually basically creates a new string which has the changes that you want. For example, do putting everything to the uppercase, there's a new string. So if you want to then either change the sentence itself, then you have to save that into the variable again, something like this. So sentence equals sentence dot to uppercase. Then sentence of course, would become uppercase. Otherwise, sentence itself is not changed. Quick note, because that's kind of important, right? Maybe when we want to find out is hey, so where in the, in this sentence is the word course found, right? That is called the index of and what we then call Actually you know what, let's put them in one line, please. Okay. And what we're going to call here is going to be sentenced index of and then we just pass it course. So we're going to write in the parentheses course. I'm gonna write this out just to make it a little bit clearer. So we write sentence index of. Then you can see that we have integer string, we want is a string. So we basically wanna ask, okay, where in this sentence, wherein the sentence is the following, spring found and what we're going to write pores. And then if we run that one, we're going to find that the word course is found at position 18. Okay, why is that important? Well, it's not necessarily important, but it's important that, you know, okay, we can look at first of all, how long a string is. And then here we can actually look, okay, where is a particular part of the sentence? Where is it written? And we're going to see soon enough what we can do with basically well wherever the index office. But first of all, we're going to be like, well, you know what? I actually don't want to say hello world, you know, I actually wanna say hello students. And that we can use the replace method. So then we use sentence dot Replace. And there we put two strings and we're going to look at this once again. So we're gonna do replace. And there we have the idea. This is written in char sequence. Don't worry about that. It's basically a string. So we're gonna say replace. And we're going to say, well, we want to replace. This is the target. So this is what we want to replace world. And then we do a comma and then says, well, what the replacement, what do we want to replace a width in this case, I'm gonna do students. And if we then output this one, we're going to see that now it says, hello students, this course is wonderful. So we've replaced every instance of the word, word world with the word students. Now very important, this does replace all instances of the word. Just so, right. So this one, I'm going to write this again, replaces all, all instances of the word, right? Just so you know that. And I believe that is also written here. So you can always, if you don't know something, you can always hover over it. And it's gonna give you a giant like so much information, it's incredible. So for example, here, as you can see, we can see replaces each substring of a string that matches the literal target sequence with a specific literal replacement sequence. Now this is like incredible, incredibly complicated speak for basically saying, hey, every time world is in the spring, it's going to be replaced with whatever you put in here. That's all that means. So that's, that's basically the translation to normal English, I guess. And so maybe what we want to see, hey, like we have a string here. So let's say we're going to have a string, we're going to make a new string. And we're going to say, hey, is there something in there where we can ask that? And this is basically, we can put that into a Boolean. We could say, hey, this string is not empty. And now of course in this case, yes, it is empty because this string is empty. Sentence would not be empty. But I want to just show this. It is indeed empty. That is not what I wanted. I wanted to print a line B. Thank you. So, and then we're going to do this. And this is going to be true because he asks, hey, is this ring empty? Yes, it is. And we can also have this in here. So we have our string s, And we're going to just put in the quotation marks without anything inside them when you see that S is empty. And that is indeed still true because nothing is written in S. So maybe what we want to know is what a string starts with, ends with. And this is exactly the name of the, of the methods we can use. And that is starts with and ends with, starts with an nth root. And right now, here we are asking, okay, does the string sentence start with an h And does it end with an a? And of course it does start with an H, but it does not end with an a. And then if we just do this and we will see true for this one, and then false or ends with. And this is also a string, right? So we can have multiple characters again in there. And we're gonna say, Hey, doesn't start with, for example, hello, or does it start with how the, and of course it doesn't start with howdy, right? So this one of course now would get false. Alright, so this is basically how you can use the starts with and ends with methods. We can also ask, well is something inside of the the string. So we can say, hey, does this string contain, for example, World, right? And I'm going to copy this over again. So this is basically the contains method. And we're going to ask, okay, does so sentence contains World, true or false? It is in fact true. Because it includes world. Now, you might be like, Wait a second, didn't replace world with students. Aha. Once again, Yes, we did that. But just like with the uppercase and lowercase, what happens is that we actually have a new string created here. So sentence does not get changed. Once again, very important to know. I think I'm not sure if every single string method is, doesn't change the string, but I believe so. I believe that every method that you can call on a string does not actually change it, it creates a new string. So this is very important to know and that, you know, sometimes and I speak of experience here. It has led to some headaches sometimes when you think, well, why didn't you change and you realized 30 minutes after checking everything and checking your code. Oh, of course, I have to. Actually, basically I have a new variable and, and save that as well. That's why in this case, the contains world is actually true. Then maybe you wanna say hey, so we have an, another thing. So maybe we wanna say hey, OK. So the char, so the character at the tenth position, what is that? I want to know that we can see that this is AD. Now if we look at the string, this is most likely the D from world. Yes, of course it's a different world because here we would already be at like 0.30 or something like that. So this is why this is, this is also called the index. Then this would say as an index of if we write here index of d. Then we can look up and we can see here the word, in this case cores, of course it's not, right. I want to see D. So let's, let's actually do it properly this time. What we're going to see is the word D is found at position ten. And here we looked at char at position ten. And lo and behold, it's also d. So this is basically how they are related with each other. And I think that that's pretty good. I think that's pretty good, right? Alright, so we've learned a lot about what we can do with strings and their methods, but there's still a tiny few things that we can do. And one of those things, for example, is we can take a substring. So maybe we don't want this Hello World in year. Maybe we only want this course is wonderful. And will we can then use, is we can use the substring method. And how does the substring method work? Well, what we're gonna do is we're basically going to take this index rate. So as we've established, the index is basically the where we are in the string. So we're gonna take the 12th position. And then this is the beginning of the substrings. So the new string we want to create, and the last one, so this is also an integer, is the last position we want to go to. In this case, we just want to go to the end of the string. And that is why we can just take the length. Because of course the last character inside of the string is going to correspond. So the position, the index of the last character is gonna correspond with the length of a string is exactly going to be the same. Because if you count 1-2-3 and an up, then you get to say, okay, this string is this long, and obviously this is the last position. Therefore, this is position equal to its length. So we're gonna just do this and look what is going to come out off. Okay? And what's going to come out is we have now a space bar or a space. And then this course is wonderful. Now, the way we can get rid of the space is obviously just do a 13 is over 12. But this is going to be perfect because this is going to lead into another one of the functions that we're going to look at. And it is going to be trimmed. And trimmed does very easy. At the beginning and the end of the sentence or the string. It's just going to any white space. So any, you know, any space, basically it's going to just remove. That's it. That's all it does. Trim. In my experience. Probably useful sometimes, but yeah. Yes. So in summary, those are basically the methods I wanted to show for strings. So there's a lot of them, and there's quite a few more which are not always as useful. Or sometimes they are. But I think that this is basically a good overview to know. Okay? What can we do with strings? What are the, what are some of the methods that we can use to basically manipulate them and basically play with them a little bit. And yeah. 12. (Java) Casting Variables: All right, welcome back to the Java introduction. And in this lecture we're gonna talk about casting. So as you've probably seen, if we have an integer and this is going to be alone. So we are going to get a loan of $750 just for the sake of argument. And then obviously we're going to have an interest rate. Interest rate. And in this case the interest rate is going to be 5.25%. And we're going to save this as a float, of course, because an integer cannot save the decimal points. And so we have to do this. And now what we can do, interestingly enough as we can then say, okay, interests than lone times the interest rate. Oh, no, not intra, inter integer but interest rate. And that's just going to work. Because in this case, yes, this is an integer and this is a float. And if we then just output all of this, we're going to say, hey, what is the interest that actually showed? But it's going to be a crazy yeah, it's 39.375. So $39. And in this case, I would argue probably $0.38. So we're gonna round up. And this works because the integer is basically on the flight converted, so to speak, to a float. And that just works. Now of course, if we say int, that's not going to work because he's going to be like no, that doesn't work at this. This is a float, this work. And this is why this net that needs to be a float. We can basically convert this. We can force converted, so to speak. If we write float in front of it in parentheses, and then this one is treated as a float. Now here is an integer, but now in its entirety it's treated as a float. This is already what happens, right? But this is, in this case, it's, it's pretty good at this works on the fly, right? So we don't have to think about it. How about we have a, an example where it actually is a port. So when we have an index, we're just gonna call it x. And there we have 50.5, f plus 20. Let's say 235 or F sharp. Now this is going to be, doesn't work because this is an, this is a float, is a float, but we want an integer number issue. What we can do is we could just say hey int. And this is all also. And then he's gonna treat both of those numbers as integers. But what we can see then, let's actually, it's actually putting a six-year that's going to be more interesting. So we're gonna output the x. And what we're going to find is that it's 70. And then we're going to think for a second. We're going to be like, wait, a 20.5.6, this should be 71.1. But it's not right, because what happens is if we have a float and we cast it to an integer, right? So this is basically the taking the float and basically, you know, interchanging it to a, to an integer. Then what's going to happen is everything after the decimal point is just going to be cut off. We're just going to completely ignore this, right? So this is basically the casting from an, from a float to an integer. Basically means that you lose information. Mainly what is written after the decimal point. Oops, sorry. What is written after the decimal point, right? So that is why the, when you cost, you have to be careful about sometimes losing information. So in this case, from a, from a float to an integer, that's gonna lose information from an integer to a flowed. Well, you're not going to gain information because the integer didn't have a like something after the decimal points stored. But now you can use it as such. And so this is basically an instance of just, well, basically it's not really implicit casting in this case because he can just handle this. But this is the explicit casting. So this is where we're like, okay, this needs to be treated as an integer. And I just wanted to highlight this costing. And how you do it is simply by before the variable, you just write in parenthesis, whatever data type you want this to be cost to. Now some costs things don't work. So for example, if I'm like, let's do an int y and we say 50 plus. And then we went to cost helloworld. What does that even mean? Rate, you cannot cast a string to an integer. Because what would you do? Now, interestingly enough, and I'm just gonna mention this year, maybe we want to ask a character that works, that does work. And the reason why that works is because characters in the background, so to speak, are basically stored as integers. And so this is going to work, but a string that makes no sense. So this was a very short overview of casting. And as always, if you have any questions, feel free to ask them and I'll respond and get to them. And yeah. 13. (Java) Integers and Math-Methods: All right, welcome back to the Java introduction. And in this lecture we're gonna talk about a little bit about integers again and math methods. So we're going to be using math, I know, but don't worry about it. It's not gonna be crazy. So first of all, we're going to output something and we were going to output this Math.min acts. And then we're gonna do x and y. So this is obviously going to output 225 because the maximum of those two is 225. That makes, I hope that makes sense. And then basically completely analog to that, we can just use min and this then will output a 100. So this is a very easy way to basically say, okay, what is the maximum? What is the minimum of two numbers as maximum, minimum? Then maybe we want to actually have the square root of something. Now this is going to be something that's going to be complex, right? No, we're just gonna do math, square root, so SQRT. And then we're gonna put in, for example y. And this is going to be yielding 15 because the square root of 225 is 15. We're going to just look at this. We're going to run this and we're going to see, as you can see, two hundred twenty five, hundred and fifteen. Now, you will also note this is a decimal point has been added. Hmm, why is that? Because square root, if we actually hover over it, we can see that this is a double. So this returns a double value, and it also expects a double value. But we can also just pass it in an integer because that's going to be fine. And Yep, so this is actually a double value. Now, as we have seen in the last lecture, we can actually cost this to an integer. And then what we're going to see is we're going to just have 15, for example. So if we know that the whatever square root we're going to take is going to be fine. It's gonna be a whole number, then that's fine. But just in case, who knows? If we deal with a lot of negative numbers, maybe with negative people as well. But in this case with negative numbers, we can use absolute, the absolute value. So the absolute value of minus 5 thousand is obviously just 5 thousand. So it's going to take whatever is. We're basically going to remove the minus the negative sign. That is all. And if we want to round up or down, we have some options for this. And those are the options that are usually used for this. This is the ceil function. So if we have 22, for example, for something like this, 22.413, the ceil function is then going to round it up to the nearest integer. So this is going to be a 23. And if we have the floor function which is exactly the opposite, then we're going to have the same number. Then what we're gonna do is we're going to actually round down to the nearest integer regardless of whether or not the rule with, well, if it's a five and more than we're going to round up. No, the seal will always round up to the nearest integer and floor is always going to run down to the nearest inch. As you can see, this is 23 and this is 22. Note once again, this does return a double in this case and in both cases. So. Sometimes that can lead to different results. We can also always constitute integer because this is always, always going to return an integer value in the sense that it's always going to be something with nothing after the decimal point. And then possibly, you know, we've, we've done the square root, but I mean, let's be honest. We also maybe want to have something to the power of something. So we're going to have the Math.pow, which is of course the best and funniest thing to have. And what we're gonna do is we're going to have a ten to the power of two. So basically this is going to be ten to the power of two. And I hope we all know what this is. Of course, it's a 100. But just like that, rather, the last method we're going to talk about when looking at the math function is going to be something that's really interesting and important for web programming in general. And that's going to be the random methods. So math dot random. And now what is method random do? Well, it basically generates a number between 0 and 1.00. So we're just going to, let's just run this. So it's going to be 0.64 and craziness. And then we're going to, how about we run this again? And that's going to be 0.907. And again it's going to be different. If we then maybe want to have a different number, what we can do is, so for example, if we want numbers between 0 and something else will be due as well. Give me something like this times let's say a 100, right? And this is going to be a float. I believe we can just do an integer actually. And then we're going to have 50. And then we can cast all of this into an integer. And then we have an easy way to go from 0 to, from 0 to a 100 and that, so if we just cost the entire thing into an integer, now, the reason why I cast the entire thing into an integer instead of just doing random. Because if I, if I don't cost if a cousin into integer, then it's always going to be basically a 0. So that's not going to be really useful to me. But in this case, we then have an integer and that's always going to be different. 58, well that's going to have 41 more. 98, well that's pretty good. Right? And that's the random functions of each time that's called, we're gonna get a different number. And that's really useful for all sorts of stuff. You know, if you maybe want to, for example, program a game than random, things are really important. Now this is also gonna be, he's gonna say this, this is pseudo-randomly. Don't worry about it. As long as you don't do anything crazy with the random thing, like decrypt, encrypt something or something like that, then it doesn't matter. The pseudorandom, if that's something that interests you or that you want to have a little bit of more information off, then feel free to ask me and maybe I'll provide a little short, you know, like site video, site lecture on that. But in general, it doesn't matter for our purposes. This is random. This is just a random number that gets generated and yeah. 14. (Java) If and Else Statements in Java: All right, welcome back to the Java introduction. In this lecture, we're gonna talk about if and else statements. And in previous lectures we've already seen a booleans and comparison operators and how they're related to each other. And now we're going to see, okay, how can we use those in order to basically change our program or change how a program works. So the first thing we're gonna do is we're going to use an if statement. And the if statement basically asks whatever is in the parentheses, okay, is this true or is this false? So if, if this is false, then we're going to execute some code. And then we're going to see what that entails. So for example, we might ask, well, if x is bigger than y or greater than y. And I'm gonna do, I'm gonna put in two curly brackets. And everything in those curly brackets. Everything here, right, in here is executed. Executed, okay? Yes, they go if true, right? So if this is true, if this expression, whatever is in the parenthesis, and it can be a really long expression, but it can be x is bigger than y and, or all of that. As long as it's a Boolean, basically in there, then, and if that's true, then this is executed. So we can, for example, in this case just print out maybe something like x is bigger than y because that is definitely something that happens if, if this is the case. Now maybe what we want is we actually want the exact opposite case. So maybe you want to say, well, if this is true, then we're going to do this. But if it's not the case, so if it's not true, then we maybe when something else and then you go else is exactly the right word. Because then we can just add an else here. Again with parentheses and, or with a, with a curly brackets rather. And in there, now here, everything right? So if we just put this in here, here, everything executes. If false, right? If this, this statement basically is false, then the else statement executes. And then we can write, for example, we're just going to copy this over x is not bigger than y, right? And as we can clearly see, x is a 100 and y is 1000. So obviously this expression is false. And what we would expect here then is to see this one printed out. So we wanted to see X is not bigger than y. Print it out. We're going to just run this and see what happens. And this is exactly what we're going to see. X is not bigger than y. Great. This is all would also always great. Or an, a good idea when you write some code and you expect something, just run it. And if you don't get what you expected, I mean, obviously it's sometimes there's a buck in there or sometimes there's just maybe you've, you know, mistyped something, always a case or could be the case. And so that's always great. Just run it. Think, okay, I'm expecting this. If it comes out, that's really good. Now, this is a little bit longer than may be necessary. So what we can do is we can also write if and then we have a boolean here. This is a good course, and we're just going to write this in there. And then I'm just going to put the cursor behind the parenthesis, and I'm just going to press Enter. And you see the carrot basically in dense immediately. And I'm just going to write one line here, the print line enemies can say, yeah, pretty good. So this is basically, so it's course good. If it is, then I'm going to print out, yeah, it's pretty good. And you can see I'm not getting any errors. And I don't have the curly brackets. Why is that? Well, you can have one line after an if, then else statement That's going to be executed. And then it doesn't need to be, well, it doesn't need to take in so much, so much space rate. You can of course also put the curly brackets on top. But of course in the beginning of the course, I've already talked about why word that I preferred like this. That's obviously a completely personal choice basically. And it doesn't change anything about the code at all whatsoever. Right? So this is, in this case, we have this in one line. Now we cannot do another line that's going to be executed. So as soon as we have two lines that we want to have executed in an if statement, it doesn't work anymore. Now, I want to say something to the Boolean thing, right? So in this case the boolean is true, right? So this one is just like if it's good. And this is basically a, an abbreviation of the question is good course equals true, right? And sometimes some people, and sometimes it makes sense, I'm just going to just copy those over. Yet it's still pretty good. I say it this way. So first of all, he's going to market and he's gonna be like a, this is, of course this is true, whatever. And you can also just write the Boolean here. Sometimes some people prefer to write it like this to make it a little bit more explicit. To say, Hey, this is, if this is true, then we're going to go forward. Because maybe, you know, think about it like this. No, no, we have 32 lines of code right now, 700 lines of code. And you go through, and at some point you're just going to read something like this. And if the, if the variables are not named properly, right? Then we're going to run into a huge issue because usually, you know, the boolean variables, if they start with is or has or something like that, works like this, then you can most easily spot them, right? You can easily see how this is a Boolean. And of course you can always hover over it, see what it does, what it is. Some people use this. Some people don't. Also preference, right? This is just a preference. I just wanted to show that both of those things are totally valid. Both work. And the most important thing is in the end, when you write the code, that you can read it, right? This is the most important thing. So whatever version you would, you prefer personally or that it's clearer to you, use that one. And then as the last thing. So we have seen if and then an else statement. But we can actually do it even more. Let's say for example, we have an under like this. So x is smaller than 50 and we're going to print out x is smaller than 50 just for the sake of argument. And then we're going to be like, well, let's do an else statement. But actually I want to ask something more specific. We can actually after the else, we can just put another if, right, so then we can say OK, if it's bigger or equal to 50, and if x is bigger or smaller than a 100, then what we're gonna write out is basically in this case also what we've written there. But we could imagine something, something executing. Well, we wanna see if X is exactly between 5000 and then we would maybe it's for, so for example, this one good, good idea would be, you know, maybe a great rate, percentage grade. So if you are 50, you under 50. Well, sadly, you didn't you didn't pass the grade. Here. You pass the grade and then maybe in a 100 year I hey, you made it really well, right? So that's something that works. And yeah, and then of course, you could leave it like this or you can even put another else there. And in this case then it would be just a 100. Well, in this case a 100 more, bigger or equal, of course, like this, yes. And this way you can basically just go through multiple questions, multiple if statements and x. Well, if, if this is true, then do this. If it's not true, then he goes to the L state, then the program basically goes to the else statement. And it's like okay, else. And then he's like, oh, okay. If and then that is going to be executed. If that's the case, if not else. And then this production. And so this is basically the little overview of if and if else statements. And yeah. 15. (Java) The Ternary operator in Java: Alright, let's continue with the Java introduction. In this lecture, we're gonna talk about the ternary operator. And first of all, the first thing that comes to mind is, oh my God, that sounds crazy. Complicated. Gotta bounds is not complicated at all. So here for example, we have an integer that's a great read. So for example, your grade on a test or an exam is going to be 69. And then we might have a boolean that's passed, right? And that is just a Boolean that signifies, okay, do you have you passed the test or not or of the exam or maybe the entire course. And of course what we can do is we can say, hey, if the grade is bigger or equal to 15, then we're gonna just be passed is equal to true. And then we do else passed as equal to false. That works perfectly fine. However, in this case, we have actually used four lines of code. And of course it's readable. And that is great. However, there would be another way to do it. And the other way to do it, I'm going to quickly just get rid of this. And the other way to do it is the ternary operator. And then we can basically write this in one line. So ternary operator is of course from derived from three. So there's three parts to this. The first part is the Boolean states, right? So what we want to know is, well, if x is bigger or equal to 50, then of course we have passed. Then what we're going to write it as a question mark, then whatever we want to have returned, if it's true in this case true, then we're going to write a, a colon, and then we're going to write false. So basically whatever happens if this does not come to us, of course it's not x, sorry, that's great. And this basically already is everything in this line. The same thing happens with the if else statement. Now sometimes this is not conducive to good code because you can't read it as clearly. However, sometimes with simple things like this, it should become pretty obvious what's happening here. And, but however those can be, you know, you can also put another ternary operator inside the nozzle ternary operator and so on. And at some point it just gets crazy, crazily complex to read. Any anyway. So this is one of the things that is possible and it doesn't only have to be Boolean here, right? You can do whatever you want. So you can have, for example, an integer number. And we could say something like, well, you know, if the grade, for example is exactly a 100, then maybe something that we want to have in the number is like nine. And then if it's not a 100, so if it's anything but a 100, then maybe we want like a 100-year what, whatever it might be, whatever this is, whatever logic that's behind there, you know, like I said, of course you can also have an if statement. If grade is equal to a 100, then number is equal to nine. Else number is equal to a 100 in this case. And so you can, this is basically just a, another way to use if statements. But in one line, very important that you've seen this because this is definitely used in many programs and it is probably also useful sometimes where the if statement will just take up too much space, too much space and isn't very complex. So that's the ternary operator for you. Yeah. 16. (Java) The Switch Statement: Alright, Java introduction. We've seen two ways in which we can basically say, hey, if this is the case, then this is the case, then this either with if and else statements or with the ternary operator over there's a third, well, choice we have, and that's the switch statement. And for that we're just going to type in switch. And then in the parentheses we're gonna type in the, basically the variable we want to evaluate. Let's say it's only gonna type in x. And then we need for this to work. Parentheses or not parentheses, again, curly brackets and the curly brackets. Now we are going to write basically cases, right? So we have to explicitly say state each case we want. So for example, if x is ten, then what happens, for example, is we want to system out, print line x is certainly right. Sure. Now what we want to finish on here is break is just a keyword we would need to use at the end of the line. And that is basically the switch statement. Now, obviously we're going to have more cases than this because one case just doesn't make any sense. We're going to have another print line where, for example, Access 20. And then once again, do not forget the brake, otherwise it will not work. Now, what happens, for example, if we say, well, OK. Now x is ten. This is executed rate. Okay? We have excess 20. This is executed also great. But what happens if x is neither ten or 20? We can have a, another keyword that is default. And this is written like this. And then we have basically so system that out and then everything is executed if it's exactly not any of the other cases mentioned. And then you just say, I don't know, right. Because you don't know what it is. Well, you could know, but you chose not to let say in a switch statement. So the switch statement is useful definitely for specific cases. It's not a very useful if you want to have, say, a range of numbers, as we've seen before with, for example, the grade you have. And then if you were to use each case, you know, you get like a grade scaled, say from 0 to one, that is from 0 to a 100, let's say. And then you're like, okay, is 0 case one, case two, as, just as it's Madden's, it, that's not a good idea. How will the switch statement, like I said, can be really useful in certain circumstances, as is with a lot of those things in Java, basically. Yeah, that is the switch statement basically in a nutshell. And yeah. 17. (Java) While Loop: All right, let's continue. So in this lecture we're gonna talk about the while loop. What if we want to have a piece of code that we want to run, you know, x amount of times for example, or if a certain if a certain statement or if a certain criteria is met, condition is met, then we want to stop using or stop executing this code. How can we do this? Well, one of the ways we can do it is with a while loop. So we're just going to type in the keyword while. And then we're going to add in the parentheses a condition. So a boolean condition, basically, in this case, what we're going to say is, well if or while x is smaller than ten. And then we're going to add the curly brackets once again. And in those curly brackets, everything in here is going to be executed while x is smaller than ten. So it's very helpful that this sometimes really reads just like a sentence or instruction, right? So while x is smaller than ten, whatever's in there, execute, execute, execute. He's gonna do this over and over and over until this condition is no longer met. Now, if we were to run this, let's say, let's say I'm gonna do this one out dot print line, and then we're going to say x. So we're just gonna put out whatever excess, right? So now what is, what was gonna happen is it's gonna put out 555 till the end of time, right? Because nowhere in this program does x ever change. Now that would be a really bad idea. Then we would have an infinite loop. And an infinite loop, it's always a bad time. So we're not gonna do that. We're not gonna use that because this might actually crash the program. But what we're gonna do is we're going to just increment x right here. And by doing that, what's going to happen is we're going to actually output 56789. And then the while loop will end. We're going to look at this and we're going to run this and we're gonna see 56789. We output those numbers that were in x. So basically what happens here is where we write five into x. Then we're gonna say, okay, while access more than ten, do all of this, execute this. So what happens then is x is equal to five. It is definitely smaller than ten. Therefore, we're going to print it out and then we're going to increment it. Now it's six and it checks again, hey, is it's more than ten. Yes. Then we're gonna print out six and then we're going to increment it now it's seven and then it's eight and then is nine. And then when it's ten, right here, is going to check, hey, if it, is it smaller than ten is going to know it's not smaller than ten, it is ten. So that's, therefore it is not smaller than ten. So we're just going to jump out of the loop. That's it. Yeah, so there's another type of loop, basically, almost the same as the y loop and that's the do-while loop. And there we're gonna write du. And then we're just going to put whatever we want in there. And then we're going to write the while word of the while keyword after the curly brackets. And then a condition in there. Very important, this one has to actually be ended with a semicolon line. So what happens here is whatever the condition is, the do, while it's not a loop that do. Whatever's in the brackets of the Duke keyword that is going to be executed no matter what, one time, right? So even if all of a sudden we say x is equal to 1000, obviously not smaller than 50, right? This is still going to be executed one time and then he's gonna be okay. Is it smaller than 15 and he's gonna be like No. Okay. And I'm not going to repeat this. So if we do this, as we can see, we actually do output 1000, even though x is not smaller than 50. Because what the do while loop does is it's going to execute the do part of the loop once and then it checks the condition. And that's basically the gist of the do-while loop. Yeah. And that's a short overview basically of the while and the do-while loops. Yeah. 18. (Java) For Loop: All right, let's continue with the Java introduction. And in this lecture we're gonna talk about the four loop. This is another type of loop next to the basically the while loop. And the for loop is incredibly useful to, for example, iterate over something a certain number of times. How we're going to read this as we're going to write for. And then we're going to write in the parentheses int. And then you can just use any name. But usually you start with IJ KL. That's sort of the nomenclature we use. Sometimes X and Y can also be used, but this is usually how you write it. So int i equals 0. Then we're gonna do a semicolon. And then we're going to basically ask, OK, whatever's written here, this is a Boolean statement once again, right? And as long as this is true, the for loop goes through. So the for loop is going to a loop. And then we're going to do another statement here. And this is going to be an increment in this case. And then we also need, of course, the curly brackets. And this is the entire four-loop rate. So we first initialize a variable i to 0. Then we're gonna say, okay, as long as i is smaller than five, we're gonna execute what's ever in the for loop, and then we're going to increase i by one. Now in this case, we could also increase y by I by two, or three, or eight, or 16 or 55. It doesn't matter. But usually we want to iterate from 0 to four in this case. So what we're going to see is we're just going to output this outer dot print line. And then when we're just going to output i, because why not? And I'm going to see, and then you can see we're going to output 01234. Now the first question might be, well, wait, why didn't we output five? And why did we output 0? Well, the for-loop starts when we initialize this. Alright, so this is the initialization. Then it's going to check, hey, is i less than five? Yes. Alright, executives, right? We're gonna output this. Therefore, I is at the moment of execution. And then it outputs 0. Then we're going to increase i and we add. We ask again, hey, is it still less than five? Sure. Alright. And then we're gonna do this until this is no longer true. And when that's no longer true, the loop is gonna break basically, and we're going to be outside of the loop. And by the way, also generate this like sort of automatically, which is great. You're just going to type in four i if you are using the IntelliJ ID as well. And then as you can see, it's like create iteration loop. We're just going to hit enter, bam, everything already there. We just need to basically choose a number or a variable here that it checks. So let's say for example ten. And we can now also do it the other way around. So in this case we're just gonna do ten. And then we're gonna say if it's bigger than 0, we're going to continue and we're going to actually decrease something, so we're going to decrement it. And this way we're going to actually count down from ten to one in this case. So, as you can see, a for-loop, very interesting to use. And I would argue a little bit more control than the while loop. At least that's how I picture it sometimes, right? So the for loop is basically more controllable while loop. That's at least my conceptualization. You know, it could be different for you, but yes, so this was just a short overview of the for-loop and yeah. 19. (Java) Break and Continue: All right, this is just a quick addendum basically for two keywords, break and continue. They are important for loops. And in this case, we're going to look at our example for the for loops lecture and we're going to look at what the break and continue actually do. So lets say for example, we want to not counted five, but let's say to ten for example, in this case to nine of course, because ten is not included. But yeah, so we're going to count from 0 to nine. And then we say, we're just gonna put an if statement in here. And we're saying, okay, if i is equal to two for continue, right? And so with that now does, is, if i is four, we continue. Now. What does continue me? Continue means that whatever happens afterwards is not executed, but it's going to jump immediately into the, into this part of the for loop. It's going to increment, decrement or whatever it does to the eye. And then it's going to continue. So here we expect to see is we expected output 0 to three, then skip the four and output five 59. Just going to delete this, not to clutter our output. None, one are going to run this. And as we can see, absolutely what happens from 0 to three, then it's going to skip the four and then five to nine. Now, as I said, there's another one and another type of keyword, that's the break keyword. And we've already seen that in the switch statement, but I didn't really explain what the break keyword means. I just said, OK, this is basically, we need this. And what the break keyword does is in whatever scope we are. So in this case, we are in the for loop scope, right? So everything between here is the scope basically. And whatever scope we are, we're going to break out of this. So it doesn't matter what i is, what, whatever it is. As soon as break is called, where out of the for loop. So in this case, what we're going to see is we're going to see 0123 and that's the, that's it. Nothing more. So we're going to call this. And as you can see, we only count to three because as soon as I was for we're gonna, we're breaking. And if we call the break keyword, then we get out. We break out of the for loop, so to speak. Yeah, that's just a little short addendum basically to the two keywords. And yeah. 20. (Java) Arrays in Java: All right, let's continue with the Java introduction. And in this lecture, we are going to talk about areas. Now areas is a, I wouldn't say complicated matter, but it's gonna be hard to grasp in the beginning. So it is possible that you might have to watch this lecture twice, or if there are any questions, feel free to ask them. This is a crucial thing to learn. And I wanted to just quickly tell a short story when I learned areas. And the thing was I said, well, I never need areas. I'm not going to need them because first of all, I didn't understand them right first time we had this in class and I was like, I'm never going to need arrays, whatever I'm gonna do it my way, right? Of course that's completely the wrong approach. The even if it's not useful in that, you know, maybe it isn't useful, but you should still want to understand it. So that's just a quick little story from my life. And so quite important to understand areas at least. And this is what we're going to try with this lecture. So first of all, what we see here is we have three strings. So these are basically imaginary emails from students, let's say, for example. And in this case we only have three. We could of course have more. And now the first thing that comes to mind as well, I mean, we want to write the emails and then maybe tomorrow like send mails. Somehow. I don't know how but maybe it works. No, it doesn't work. We can iterate over this. We can't like say student underscore i, that doesn't work. So this is sort of clunky and we can't really use this. So we would have to actually do send each email like in one line. And then if we have a mean of 1000 students or something like that, then sending this e-mail is, I mean, that's gonna be a ridiculous, right? That's not going to work. What is it gonna work however, is if we use an array, an array is, you can basically think of this as a list, right? Or yeah, basically as a list. And we're just going to initialize one. So we're going to write a string. So this is a string array, so a list which contains strings. And I'll just call this student males. And then we're going to just write this in. So we're going to have curly brackets. And in those curly brackets we're going to basically say what each of the elements of the list is. So the first one in this example, it would be Jonah gmail.com. And then we're going to have July at gmail.com. And in the end, the last one is Ryan at gmail.com. And then we're gonna end with a semicolon. And now this one here, we have now initialize basically a, a string array, right? And this string array, the first element is John at gmail.com, then July at gmail.com, and then Reiner geometrical. So if I'm going to output this, we can just look at it, right? So we're going to say print line. And then the way we output things as we're going to have student mails. And then we need the brackets here again. And in those brackets we're going to basically write the index of which ever we want to put out. So for example, we are going to write a one. And now what you probably expect is that John at gmail.com has output and we're just gonna see if that's true. It is not true. Now, why is that not the case? Because in areas we start to end most often in computing computer science programming, we're going to start at 0. So we actually want 0 here. And then if we run this, then we're going to see that it outputs John at gmail.com. So this is actually the, basically it is the first entry, but in this case it will be the 0th entry, or its index is 0, but it is the first entry. But it's index is 0. Here. If you're hearing this for the first time, it might be a little confusing. Just remember, usually when we have lists and strings and these things, let's say the arrays then B start to count at 0. This is also often why the for-loops or initialized with a 0, right? The integer and the for loop is initialized with a 0 so that it helps with this counting. And so basically, we can just do another one. Let's say for example, we have an integer array which is going to be some numbers. And instead of explicitly telling him, ok, this is, this is what's written in the array. We're just going to write new. And then it already says integer array with a bracket. And then it's going to say, well, it's going to put the carrot like in their cursor in there, right? It's going to be okay. What am I supposed to do here? You have to actually write in what the size of the area is going to be. So let's say, for example five. And I'm gonna end this with a semicolon. And now this array can only have five entries. Now to that point, this area can only have three entries, right? We cannot append onto the array. There are workarounds for this later down the line, but in this case, we cannot do this. So if we say student mates three, right? He's actually already going to see it. Hey, array is out of bounds. So the compiler here and the IDE is smart enough to be like, yeah, oh no, no, this doesn't work. We can still do it. And then we're gonna get an arrow, as you can see, exception. And that's means every index out of bounds, because index three doesn't exist, right? 012 and three doesn't exist. And we also cannot actually add the third or fourth one there. In this case, we say, well this one, this sum number array, it can have five entries. And I'm just going to quickly copy something over. So we're just going to populate this some number right here. And what we can do. So this is basically the way you would then say, okay, I wasn't the first entry or the 0th place, right. The 0th index to have some number. This is basically how you assign this, right? So you take it almost exactly the same as you would get the whatever is written in the array, right? You write the name of the array variable than the brackets. And then inside of the brackets you give whatever index you want. And this case you can just assign it a new one. This also of course works if it's already something written in there that is no problem. And to basically sort of, you know, golf go full circle. We had this issue a, We wanted to send the emails or at least, you know, put your output them. And we're just going to grab the same, the same for-loop from up here. And we're just going to be like OK, easy enough. We're just going to system.out.print line. And then we'll say student males. And we're going to use the i here. And the I of course, takes on whatever the number here is. So it's going to just loop through student male 0123. Remember is not touched basically. So as soon as I X3, this quarter is no longer executed. And if we executed now, we're going to see we have John July and Ryan and John we have twice because remember, we're going to put this out here. So don't don't worry about that one. And yeah, so this is one of the things that we can do. And a short little thing I also have mentioned is maybe, you know, Ryan has actually stopped going to class and now we only have John in July. And if we then use this, what we are going to have is another arrow, because this one is now the for loop is no longer sort of valid for the student males. But we can actually work around this if we do student males, dot length is even like the IDE is smart enough to be like, oh, I think this is what you want. Yes. Student males dot length is basically the length of the array. So it represents the length of the array. In this case, it's going to be two, right? So 12. This is the length of the amount of things in the array. The index is different from the length, right? So you always need to think about basically the index. The maximum index is always length minus one, right? So that makes sense. I hope because if we start to count at 0 instead of one, we basically shifted one into the negative slope speak, right? So while this is the first element has index 0, and this is the second element and it is index one. Like I said. This can be a little confusing at first. I definitely advise to, you know, look at this in, you know, calm and, you know, maybe really watch this once or twice or even three times. Because sometimes it is not the easiest. I will answer any questions you have. Feel free to ask them. And yeah, I hope that all in all, this has been enlightening for the array. How it works, a little bit of what you can do with it, and how it makes some things incredibly easy. Yeah. 21. (Java) Multidimensional Arrays in Java: All right, let's continue. So in this lecture, we're gonna talk about the multi-dimensional array or multidimensional arrays. Well, the first thing that probably pops into your mind is, Oh my God, I had so much issues even understanding areas. Maybe. What are you talking about? Multi-dimensional areas, that's ridiculous. Okay, let's quickly think about this one by one, right? So we can have an array. And we could imagine that array. This is just numbers. And we could just have this RAB, for example, every number on the number line, right? So this would be in principle a one-dimensional array rate. Just as a line is one-dimensional, right? You can have one number and it can basically express wherever you are on that line. I think that hopefully that is sort of understandable. And I think the best way to conceptualize that is with the number line. And now the addition of another dimension is basically when you have graphs in school, when you do the functions and the f of x and all of that jazz, you know, it's usually not a very, you know, it's not a topic that's like easily digested sometimes, but you've probably all seen it. Now. An even easier way to think about like two-dimensions, for example, is basically with a table. A table is nothing but two-dimensions, right? If you have multiple columns and multiple rows, then you have multiple dimensions. So we can, for example, do a two-dimensional array in that we, you know, we do the normal area, we write it into another bracket and then another bracket. And then we're just going to name this some numbers, for example. And the way we initialize this one is, well, you know, we have an array, basically, right now this is an empty array. And inside this array, so to speak, we have another array, but not only one but multiple ones. So let's say for example, we have this one is just some numbers here. Let's say 25. And then this could be, for example, the first row. And then we could have another row right here. We could have 5,505 thousand for example, right? So this might seem hopeless. Little, a little weird, that looks weird. Don't worry about it. We're going to see and we're going to look what this means. So we're gonna just print out the, the first one. So we're gonna say 0. Now, what does the 0 do? Let's just print this one out and see what happens. If we print this one out. We're gonna see a bunch of garbage. Why is that? Well, that's because the, this actually prints out the array. And the array can't easily be. Displayed in a print. That's fine. That's not an issue. Now, what is this 0 actually do? So what are we selecting basic? We're selecting the first array here, right? So if now we write the three, what would we expect to put out the 25, right? Remember we start at 00123. So if we call this, we would expect the 25. This is what we expect. And let's see if our expectations met. Of course it is 25. So with the first bracket, you basically selecting which array you want to select. And with the second bracket, you choose which element in this bracket, where in this array you want to select, right? So if we, then for example, they're just going to copy this one. And we're going to say, well 12. Then what happens is we are going to get 5 thousand, right? Because now we have selected the, this one, this array here, and the, the element with the second index, so 012. So this would be 5 thousand. As we can see, it is 5 thousand. Now what's really great? Good, and what's really great actually is. In this case, this is a two-dimensional array. Usually it doesn't like, you can, of course have three-dimensions and even more. At some point, it gets a little, it gets hard to handle, right? So three dimensions we of course can still maybe visualize. And then as soon as it's four, we're going to run into some issues. And usually I think that in my experience, you know, one-dimensional and two-dimensional arrays are basically all we really need in most cases. So what we're gonna do is we're going to have a, a for loop that we're going to call x here. And then we're going to say some numbers dot length. And then inside of that, we're going to have another for loop for i. And this is going to be y. And this one. Now there'll be a really interesting, we're going to actually have this. So we're gonna have some number x dot length, hmm. Interesting. How does that work? Well, in this one, we're actually going to iterate over the entire array. So we're gonna say, okay, how many areas does the airy have inside of it? Two in this case. So we're going to have this length is two. And this length depends on what area we choose, right? Because this one has length of four and this one has a length of three. So if we just output this, I have a prepared the output here because that's going to be easier to read. So basically have an X and Y coordinates, so to speak. And then we can output these numbers. So if we just do this and we're going to see that no 00 is ten. That matches perfectly. 01 is 15, then 2025, or 03. And then we move to the next area, so to speak, right? The next error here. And this is then the index one. And inside of the second array, the first element with index 0 is 50. So this is basically a way to use multidimensional areas. And once again, same with the normal areas. In the beginning, it can be a little hard to wrap your head around. Okay, how does this really work? The two things that are most important there is just try for yourself, try out a few things and always go with, okay, what am I expecting to output here? And what am I expecting to happen here? And if it does happen, that's great. If it doesn't happen, think about, okay, why did that happen now? And that's number one. And number two, if there's any issue or, you know, your are progressing with anything or something, you know, you have an issue. Always feel free to ask. I've always tried to answer the questions that come in. And yeah, I hope that the multi-dimensional arrows are at least a little bit clearer. And yeah. 22. (Java) The (Array) List: All right, let's continue with the Java introduction. In this lecture, we're gonna talk about lists or ArrayLists. So remember the array where we had students, males, in particular was a string array. And we had multiple values of a certain type, in this case string, like I said. Now, there were a few disadvantages that we had. We had to specify how many values we want to have saved in that array. And if we couldn't add any. Now, this is where lists come in and lists are way easier in that sense to use. There are more dynamic. And so what we're gonna do is we're just going to type list. And then the first thing that appears, the first suggestion was simply going to press Enter and then something up here appears. This is a package that is important. Like we have our own package right here, right? This is my package, communist cotton joule. This is my own package. And this is a package that is now imported so that we can use this class, so that we can use the list, right? And both classes and packages are gonna be discussed in a later lecture. Very important is just that this is in here. If it's not, by the way, then you're going to see that the list turns red and you can just hover over it and you can just click here on import class and then make sure to select the java.util one. And then it gets, it gets imported and then no issues whatsoever. We're gonna do those angled brackets and we're going to make a list of string. We're just gonna call that males. And now we want to make a new list. And now in here we actually get ArrayLists suggested. This is why this is called array list or list. And we're going to choose airy lists in this case. Then something else gets imported here, namely the ArrayList. Now the idea is that you could of course, also do make an ArrayList that works totally fine and would work. However, a lot of things that are used in Java actually return like these, let's say basic lists. But in the background, an ArrayList is saved. Now this has something to do with interfaces and polymorphism. Those are very large words that we don't want to really think about right now. We're just going to think about, okay, when we want a list, on the left side, we make list and then on the rights that we make a new ArrayList. Usually this is what the IDE suggests one way or the other. So It's not that difficult to just think about. Now. As you can see, we haven't actually specified how many items we want in that lists, how many values we want to have in males. This is because we don't need to. Because what we can do is we can do males dot add, and then we can simply add new males. So let's say, for example, we're going to add up John at yahoo.com is maybe John changed his mail and then just going to add a few more was also add July and Ryan, and then maybe also maria. Right? This is how easy it is to simply add a few more. Datapoints or few more values to that list. Now, let's just see what happens when we, when we output that list, right? So let's just output that, output males. But it just like that. Let's run that and let's see what happens. And what we're actually going to get is we can actually see each of the values in that list clearly written out, which is very good to immediately see, OK, what's actually in that list. And now the first question that comes to mind is, well, how are we going to access each individual member? And that is going to not going to work with the, with those brackets that we used before, but actually with a method that is called gatt. Very easy. In here we just write the index. Once again, the index is the same as with the array storage with 0 and then counts up. So the first element is John at yahoo.com, which has an index of 0. Now, maybe you would want to remove an item, which is actually actually before we move an item, how about we change an item? Well, if we wanna change the item, we just do mail stop, set. And then we have to first specify the index. Let's say John actually change his email address back. So then we actually want to have Jon dot gmail.com again, right? So this simply changes the first, the first element to this, what we are given the string. So John at gmail.com, and if you want to remove something, so let's say we want mails dot remove, sublist that. Then we can specify, hey, at what index room, something maybe one, maybe July has stopped being a student or something like that. Another important thing is how to get the size of the list. Now I specifically say size because this is one, this is also the method, what it's called. It's simply males dot size. And this returns the size. It's the same with length for the array. Now, maybe we are actually like it's a new year. All of the other students are gone. Let's just clear the entire list, right? And then this is simply going to clear the entire list and then it's empty. Now let's just add a few more things here. I'm just gonna quickly copy something over because that's a little bit easier. So we're just going to add E at yahoo.com, ATF in general, random or let's say. And what we're gonna do now is we're going to use collections dot sort in order to sort this. Now this is going to be really good because we can do is literally just write collections.sort elections by the way, also import something up here. This is because I mistyped something, don't worry about I want. And this is a Java util collections. And this allows us to actually sort this right here. So what we're gonna do is we're gonna just output this once before and once after about that. Let's do it like this. And then we're gonna see what happens, right? So first is e a t f d, and now it's a D, E F T. So we actually sorted in alphabetical order. Isn't that great? Now I have one more thing to actually say about lists and ArrayLists. So we made a list of strings, right? Let's just do something like that. Just for the moment. Now, this works. If I want a list of integers, this is not going to work because it's gonna say type argument cannot be of primitive type. So you recall that we have integers, we have the boolean double. All of those are primitive types. And now we all, we need to use the wrapper classes for that, right? And those are simply the name of the type spelled out and started with a capital M. So in this case it's just integer. And then this works the same as with any other integer at all. It's just something that we have to think about. And if we want to use a double, we can use double. If we want to use a float, we can use a float is just written a little bit differently. And this is in the nomenclature, is a wrapper class. And what else was there? Float double. Yeah, boolean is the same one. Big with caps letter in the beginning. There was just something I wanted to say just so that, you know, yeah, and that would basically be a short-term introduction to lists and ArrayLists. So, yeah. 23. (Java) HashMaps in Java: All right, let's continue with the Java introduction. In this lecture, we're gonna talk about HashMaps. Now, a HashMap is, let's say similar to a list. However, it's even better in some ways than a list. So we're just going to write HashMap again. And then it's going to, as you can see, important other package, like I said, packages will be discussed in more detail later down the line. Now, a HashMap also has the angular brackets, but now we're gonna put in two things. In this case, we're going to put in two strings, so string and then comma string. We're going to call this one capitals. And then we're gonna do New HashMap and then finish that with a semicolon. Now, what's happening here? So basically, the idea of a HashMap is in comparison to an array or a list. In the array list to get an item out of that, we needed to put in the index, right? In this case, we can actually have a specific key mapped to a specific value. That's why, that's why it's called map. And I'm just going to quickly copy over a few examples of what we're going to put in there. So the method to call in order to put another key value pair, that's what it's called. So Mexico is the key. And Mexico City in this case, would be the value. In order to put that in, we use the method put, right? And if we're just going to quickly, I'll put this just for the sake of simplicity. So there's less just put capitals. And let's see what happens here. So as you can see, what happens is USA equals Washington DC. We get Mexico, Mexico City, we get France equals Paris, Germany equals Berlin. So we can see that the, there is a relationship between the key and the value. I'm just going to quickly write a comment over here so that it's basically a key maps to a specific value, right? And this is also called a key-value pair. So the key value pair is, in this case, we have specified it to be a string to a string. So we give him a string. So we give the HashMap a string, and we get a string and return. Now this could be an integer. Then we have basically implemented something very similar to a, to a, an ArrayList, but not quite. So for example, the integer keys we could have, could, for example, be student ID, right? And then what we were turn is, for example, the name of the student. This would be then the student ID to student name map. And this is something that we want to think about when we use the map, right? So it always maps a key to a specific value. Now, let's say we, for example, want to print out the capital of Germany. Then what we do is we get. So we use the method get and we put in the key, they're indoors or written key and the key is Germany. And if I write that, then we're gonna get Berlin. Because that's exactly sort of the answer, right? So you can also think about it as the key is sort of an answer and that your value is the other way around. Sorry, the key is the question and the value is the answer to that question, right? So in this case capitals, okay, what is the capital of Germany? That's Berlin rate. And this is also something we can think about. It is possible, just like with the every lists, that we can simply remove an object. In this case, maybe we want to remove France. Here once again, we put in the key, right? And we can also print out, if we want to do that the, the size of it with capitals dot size. Then we can see after we've removed France, we have three items in there. Now when other special thing is, there is a special sort of loop to loop through HashMaps. And I'm going to show that quickly so that as you can see, he already sort of says, for each guy wanna foreach loop. Now the way he formats this is absolutely hideous. So we're just gonna do it on our own. So we're gonna do four. And what we want is a string S. Then we do a colon, and then we say capitals dot keyset. Now. And we're gonna do curly brackets as well. So we have that. Now here. It's very important. S is now a key rate. So S goes through every key that is in the HashMap. This type of four loop is called a foreach loop for each. And in the next lecture we're gonna talk about this in a little bit more detail. But I just want to show you, I'm just going to copy this over again because it's just an output. There is a plus that's missing. And we're just going to look at this, what that does. So if we do this, we can see that in S, we have each time of the loop, we have USA, Mexico, in Germany, each time written in there, right in S, because that's always the keys. Those were our keys, right? Remember France was deleted from the list or from the HashMap. And so we go through USA, Mexico, in Germany. And then we actually do capitals dot get s. And in the get method, like I said, you put in the key and then you get out the value. So, right, so that's sort of an overview for the HashMap, right? Where we can map a specific key to a specific value. And it is quite useful for all sorts of things. And yeah. 24. (Java) For Each Loop: All right, let's continue with the Java introduction. And in this lecture we're going to talk about the for each loop or a for loop for collections. And in the last lecture we've already seen the, this type of loop for the HashMap. I'm going to just look at how it looks, for example, for the ArrayList, right? But first of all, let's remind ourselves, okay, a string, a string array, right? A string array, for example, just, we have names in there. For example, we have Johnny, Johnny, Johnny the ego, and we have Martin, and maybe even something like George. And that's it. Right? George. Written like that. Thank you. So we'll have three names in there. And we remember that the way we can iterate through that one is just take a normal for-loop, take names dot length, and then for example, just print them out. So printout, system out print and then we're going to have names. And then I like this. This is something we've already seen for the arrays. Now the big questions, ok, and we also do it for an ArrayList for example, or other collections. Now, we can of course, use exactly the same method which we used for the areas for the ArrayList. Because we can go with the indexes, indices and put that unlike output them. But that's not quite the best method or the only method. Because we can also use the for-each loop. Now will be right there is, instead of initializing an integer, we're going to actually initialize whatever datatype we have inside of the array list. So in this case a string, which is going to give this an S name S. We could also name this, for example, male because we know that males are in there. So we're just going to call this mail for example. And then we make a colon. It can do it with or without a space between, it doesn't matter. And then we wanna give the name of the variable of the collection. Now in this case we can do males and then just have a system out, print line of Mail, for example. And then when we do this, we're going to see which is output all the males of older males in the ArrayList. Interestingly enough, this we can also do with the names, right? So we can also say name, and then we can say names. And we can also output, use a foreach loop for the array, right? As you can see, it does exactly the same as it does here above. Because this basically is also a collection, a collection, basically sort of a broad term for lists and array. All of those data structures. But yeah, so this is the, for each loop, really powerful. If you're working with lists and maps and even arrays. It is sometimes easier to use this loop, the for each loop, sometimes it's easier to use. A normal for-loop. Really depends on the situation. But yeah, that's basically the for each loop. 25. (Java) Java Methods: All right, so in this lecture, we're gonna talk about Java methods. Now, we've talked about the main method before, right? Where we put all our coding. We talked about string methods. We, we've seen a few methods for collections, mainly the hashmap and the ArrayList. And now we're gonna talk about in general terms a method. And we're going to sort of show this by implementing the factorial. So the factorial of a number is just, for example, if I have a factorial of a number, right? So for example, like four or something like that. We would write this as four exclamation point. And this is simply four times three times two times one. And we're actually not going to take four, we're going to take five because that's an even better example. I've, and this then is going to be a 120. Now, why is this important thing, its mathematical thing? And I, we might actually have a factorial. We do not have a factorial here implemented, so you couldn't even use that. So if we really wanted this, we actually would need to implement this. So let's say we have a number and we have a factorial, right? We're going to initialize that. You're, And in this case our number is going to be five. Now, the first thing we do for the factorial function, let's say is we're going to set factorial to the number itself. And then we're going to implement a very interesting loping looking for loop, right? We're gonna initialize i with number minus1. And I should be bigger or equal to one, i minus minus. So actually going to count down backwards. And then factorial is going to be times equals i. Now, when you look at this for the first time, you're going to be like, what the hell is going on here. I don't even though I don't even know what this means. Okay, let's quickly go through this and think about this. So factorial in the beginning of the loop, factorial and number are exactly the same that both five, okay? Then we initialize i num minus one. So i is going to be four for the first time. So in the first time the loop goes through, we're actually going to times five, times four. All right, that's pretty good. Then the loop finishes and we are going to decrease i, which is now a three. And the check is basically, hey, when we get to the one, then we're going to stop because we don't want the 0 because if we multiply by 0, everything's gonna be 0. That's not going to be good. So we basically just count down, we in factorial with each loop. First, we have inside of it saved five times four. That is five times four times 35 times four times three times two. And then five times four times three times two times one. And then it's done. And we got the factorial out. So we're just going to do system out, print line. And we're gonna, just gonna say something like Turiel is. And we're going to write a plus. Well, let's see what happens. And indeed it is a 120. That's great. Now. That's really good. But let's say I want to actually like have this in this part of the program. And then I'm going to write like a 100 more lines of code. And then I would have this again and again and again, again and again. So then I would have to copy this part always. I would always have to change the number and maybe sometimes I'll forget to change the number and then calculate something else. That's, that's not really a good thing. And that's why we can write our own method. So until now, we've always been inside of the main method and now we're going to step out of it. I know scary thing, but don't worry, we're going to be fine. And we're going to write public. Public. We're going to play right? Static and an integer, int and then factorial. And inside of the parentheses we're gonna write in number. And now the big question becomes, what is this? And what do we get an error? I'm going to explain that soon enough. So first of all, like I've already said in the beginning of the course, the public and aesthetic don't interests us right now. That's just what we need at this point in time. It will be explained very soon. Now the integer is simply whatever this method returns, right? We've already seen a few methods with, for example, the strings, and they always return a new string. And so in this case, it would return an integer. This is the name of the method. And then we have parameters inside of the parentheses here, which are basically has to be given in order for this method to work, right? Okay? And then we're going to simply copy this over because that's not that interesting. Which is interlock initialized. Interesting. Okay, that's extends. And oh, what happened there? Okay? So the initialize a number, an integer factor, and that's going to be introduced lesser number, exactly like we did here. And then want to go through exactly the same loop. We just don't have the curly brackets and then we're going to return fact. And now, as you can see, the arrow is also gone. There was an error here. It's gone because now we have actually returned an integer, right? So in order to return something from a function, we need to use this return keyword and then whatever variable we will return. And now we can also return five. So we can also return something like that's set in stone. But that doesn't really make sense because whatever we put in here, it's always going to be five. Doesn't really make sense. Now if we just copy this and use the same method, but instead of just taking this variable, we actually take this function, right? We can double-click and then it's going to say, hey, I want a number here. I'm going to say OK, five, right? And then it actually has a five inside of it. And then we're going to see factorial is a 120 as well. And now the great thing here is that we can just call it for like six as well for seven. And it's one line, right? This is very often the case. When I would say when you use a code, the same code twice, might be okay to just be like OK, I only need this twice. Let's just copy this code, paste it there. But normally, as soon as you copy like big chunks of code, it's sometimes you have me probably see just right now, I've, I've copied the print line and paste Sadat. That's not that bad because that's one line. As a specific thing that happens, I can't really write a function that makes this less than that. But if I basically would copy like 1020, even five lines of code, that's a really good indication that you should probably basically take the, take the code you wanted to copy and put that into a function, and then use that function. That's a very, very good like heuristic to use in order to know, okay, when should I use a function and we're not or a method, sorry, a method, method and function is basically a synonym, right? It's interchangeable. When we, when we want to use a method that's some that's a good read juristic. I just wanted to point that out for just a second so that you know, yeah. And that's basically a, an example for a Java method that we can write outside of the main method and that we can then call whenever we want to. Yeah. 26. (Java) Method Overloading: All right, so in this lecture we're gonna talk about method overloading. So we've already seen a single method basically. And in this example, we have a method that implements basically multiply. Now, obviously that's not the best example, but I will just show you on a very like, on a very easy example so that you can simply grasp the concept. Okay? So we have this multiply method that we can call. We can give it two integers as parameters, and then it's going to execute. Let's see. And of course it returns the correct answer. Now, I can have the same. And if I have another method, and I'm also going to call this multiplying. Right? Now. I'm also going to have int a and in B. That's not gonna work because now we have the same method twice. However, I can overload the method so that I can do this if I put in another parameter, for example, or a different type of parameter, or different number of parameters, right? So I can put it into C here. And all of a sudden that mistake or that error is gone. And then I can just do some of that. It is a times b times c. Then if we look at this, if we write multiply, multiply, then we actually have two things that are suggested for us rate to method signatures is the term. And so we can take this one and then we can say, well, I want, for example, five times, two times four, right? And he just does it. He knows which one to use because he knows how many parameters are taken for what type of function, right? And then we can, for example, also do something similar with float. So we can also say multiply, multiply this. And there's a float, a, float b. And he's not going to have an issue with that one as well. And we're gonna just gonna return this one. And then if we call this one, so for example, if we then say a system, Upsilon, system out print line, we say multiply. Then, now we get three things we can get, we can get suggested, yeah, and here we always see the return type, right? So and those two, it was integers. On this one it's a float. That makes sense. So I'm just gonna double-click that and then we give it two floats. So for example, 3.512.4, F, That's float. And then when we run this, we see that everything works perfectly fine. Even though all three methods have exactly the same name. What's the difference? The difference is in the number of parameters or the types of parameters right here, the type is different and here the numbers different. And this is basically this what's called method overloading, really important and can be incredibly useful for so many things. Yeah. 27. (Java) Classes and Objects in Java: All right, let's continue with the Java introduction. And in this lecture, we're gonna talk about classes and objects. And the first thing we're gonna do is we're going to go into here our project folder. We're gonna go into our source and then whatever package we have, you know, whatever you named it. And then we're gonna do new and new Java class. So I'm actually going to create a new file. And this file, in this case, we're going to just call fruit and makes sure that class is selected here. And I'm going to hit enter. And there we go. And I'm going to just zoom in a little bit. And now we have a new class, public class fruit in our package. And so what have we done right now? So we have created a new class. When we go back here, we have two tabs. Right now, the main Java class and the fruit class. We've briefly talked about the main method, but now we can also look at the main class. In this case, the main clause is simply for us, sort of like a dummy class, just so that we have the main clause, a main method in somewhere, right? So that's somewhere. We have the main method that is started at the start of the program. But the fruit class that's a little bit different. So in the fruit cross right now, we actually want to a create objects out of that. Now what does that mean? Well, let's think about, first of all, a fruit. What, what does a fruit half? Well, maybe a fruit has a name. That makes sense, right? So an apple, banana, orange, mango, those are names for fruits, okay, that, that could be something now it could also have a possibly sugar content because maybe you want to live healthily and you want to know, okay, what's the sugar content of a particular fruit? And then also to maybe look at somebody else, the color, right? So those could be three attributes of a fruit. And this is exactly what this class attributes. So these are variables that are associated with a particular class, in this case, fruit, right? Because those exactly mapped to attributes that a fruit might have. Now, there also might be many, many, many more. That could be length, width, height. You know, there could be all sorts of attributes that a particular class or object has. But in this case, we're just going to stick with these three right now as an example. Now, what can we do with this? At this point, we can actually do something and we can actually create a new fruit. So we're going to just type in fruit and then we actually see that immediately gets suggested. And we're gonna create a new fruit, and we're gonna call it a banana. This is going to be new fruit. And I'm just going to quickly explain what's happening here. So this is just as normal a variable as you can see, right? Because for example, int x, exactly the same, just that the data type right now is fruit instead of integer string and the others we have seen. And then we assign it immediately, a new fruit. Now what does that mean? Well, the new keyword is used to create a new object. And in this case, we create a new fruit object. Now this looks a little weird. Maybe. This is what is called a construct up. Now in this case there's nothing in the parenthesis, so no parameters are given to the constructor. So the, and this is the default constructor with nothing in it, right? No arguments are passed or no parameters are passed. But what we can already do is when we go for a banana ready, you're already suggests this. And then we can access the three attributes that we have specified and declared in the fruit dot Java class in the fruit class. So for example, the name, we can now set this to, for example, banana. And now a banana dot name. This is how you access. This has the name banana. But this seems a little bit clunky. Because now when I want to continue and I want to set, you know, the sugar content to Illinois 15 and so on and so forth. I have to do all three attributes, and maybe I have to do 20 attributes if there's even more. And this is why we can actually have not only a default constructor, but also our own constructor or custom constructor so to speak. So for that we write public and then the name of our class, in this case fruit and just parentheses. And it's basically like a function without a return value. Rather, the return value is the name of the class itself. Now in the, in the parentheses, we're actually going to write all of the things, the related problems. Don't worry about that. We're gonna get to that in a minute. This happens and I will explain this in short while. Now we're just going to almost basically copy the names because what we can do is we can write this dot name equals equals name. And then we can write this dot sugar content equals sugar content and this dot color equals color. This is often how I do it because the naming here is the same as the naming in here as so the attributes of the class have the same name as the parameters in the constructor. And you can then specify, okay, I actually want this attribute here. When you use the, this, the, this keyword. Because this keyword basically says, hey, I want this object, this class, whatever is this. So this yet, right? And then the name He is or the IDE is smart enough. The compiler is smart enough to know, oh, yeah, this, this is it, this is what it means by name. And this is what you mean when you say this.name, you reference the class itself. Now why do have begun a related problem? We can actually click on this. And we're going to see that is going to be like, hey, we expected three arguments because right now. The constructor that we use here, the default constructor is no longer valid because we have declared our own constructor, right? Because before when we had this no related problems. I mean, no related problems. Thank you. Because basically what happens implicitly, something like this has created, sorry, this one. So this one, a default constructors always in the background. However, if we then sort of override this by making our own constructor, then the other one is deleted, sort of speak. Or it's not no more implicit, we have to actually explicitly do that. So if we then create this one, that's totally fine, then it works. So that's a very important thing to note, that the default constructor is only sole valid so long as Until you create your own custom constructor. Or you can also just explicitly stated as well. And then it works. Right? So let's then maybe make another fruit. Let's make an apple, an apple, new fruit. Let's actually take our other constructor and immediately pass all of the the attributes that we want. So the name is going to be Apple sugar content, it's going to be ten. And that the color is red. And as you can see very nicely, the actually, the IDE intelligent actually already gives you the names of the parameters, which is incredibly useful. And that's why I always suggest, you know, sticking with the good variable names. Most likely the same as the attributes because then, you know, because if this was n SCC, I mean, you know, if you look at this in like three months, you have no idea what SC stands which was sc. Then you have to go look. And remember these are three parameters and three attributes on the fruit. I mean, we could imagine maybe 20 or 30 attributes, and then they're all named NSC b0, b2. That's ridiculous. So make your variable names as expressive as possible. And, yeah, and then let's just see a, maybe a printout. That would be a nice idea. So an apple. And then we can, for example, say an apple dot name. So let's just print that out and see what happens. Apple dot name is an apple dot name is Apple, right? How about we print out the sugar content? So our content is ten. Beautiful. So in general, a class, so in this case, a fruit class can be used to, to condense data into a single object, right? If a banana or an apple. And it can then be retrieved in this way, or also in other ways, which we're going to see in later lectures. But all in all classes and objects are a very important part of Java because java is an object-oriented programming language, right? Oop, object-oriented programming language. And this is sort of an essential part of the entire structure. And this is also why it's very important to understand it. We're going to continue to talk about different things with classes. So things that have to do with classes and objects and what to do with them. But it's important that you have the foundation ready. So once again, if there's anything that you have not understood or have any questions, feel free to ask. And also if there's anything that you think that might be added, you know, if you say, well, I mean, I've heard about this topic somewhere, but you haven't done it. Feel free to ask me as well. And either if I think that I have maybe missed that or it's an important topic as well. I will do another lecture on that. Just, just be sure to ask and I will get back to you. But it's important that this is another one of those things like arrays, that is really important to be understood, right? Objects and classes. They are a foundational thing to understand, right? 28. (Java) Public, Protected and Private : All right, welcome back the Java introduction and we find ourselves back at our classes and objects. However, this time we will talk about access. What does Access mean? Well, let's take a look at our fruit class. So in the beginning of the, the attributes we've already, we've always written public, public, public. And why is that? Well, first of all, you don't necessarily have to write public in front of it because by default it is always public. However, I personally, this is just once again a personal choice, a personal preference. I write public in front. Just so it's like absolutely clear. There are two other things that we can write. We can first e.g. private, and we can also write protected. Now what do those mean? Well, first of all, public means that this variable or this attribute is accessible by any class ever anywhere basically. So as soon as I have this fruit dot Java file, right, I can access this string, string the color. Okay? So what is protected than mean? Well, protected means that it can only be accessed in the same package and from subclasses and superclasses. Now what are subclasses and superclasses? We will learn in a later lecture. But it's not actually going to be that late because this is something that we're going to have very soon actually. However protected is then going to be talked about in a little bit more detail. And private, this is, I think the one that is most important almost. This means that this variable can only be accessed in the fruit class itself. So this, this attribute can only be accessed in fruit itself. So only in this, which is around marked. Nowhere else can this be accessed. Hello. First thought that comes to mind is also the related problem because right now here we have a dot, a banana dot name. And it's like, Okay, we can't do this now because name is private. So he's like, hey, as a private access doesn't work. It doesn't work. I cannot access it. Sugar content. I can access even though it's protected. But we are still in the same package. And how would we fix this? We fix this with getters and setters. Getters and setters we will look at in the next lecture. 29. (Java) Getters and Setters: All right, let's continue with the Java introduction. And in this lecture we're gonna talk about getters and setters, like already mentioned in the last lecture. How are we going to solve this problem that we cannot access this private attribute name? Well, no issue. We're going to look at how we're gonna do this. So first of all, we're gonna do is for demonstration, we're actually gonna make all three attributes private. And then in the first, for the first attribute, the name, I'm going to show how the getters and setters are done manually. And then for the other two, I'm actually going to show a very neat trick that is going to allow us to generate them automatically. So we want a public function that is going to return nothing so void. And we're going to name this set name in, in the parentheses. So as a parameter we're going to pass a string called name. The function's gonna do this dot name equals name. And that is not right. This is how we want to do it. All right? But the name of the method, in this case, the center is going to be set in small, so in lowercase. And then the first, the first char author, first character of the name of the variable is going to be uppercase, right? And then to the getter, the geta is gonna be also public, but this is going to return whatever the variable type is, the data type, in this case string. And then we're going to get name and no parameters have to be given. And this we will just return name. And this is how easy it is. Setname, getName. That's it. And now what we can do, instead of doing name, we can actually do getName. And all is fine. This will then return Apple in this case. And here we can do the same thing, setName. And then we just pass it banana. And it's done. And then it sets the name to banana. Now maybe we don't want other classes to set this. Then of course we don't need a setter, but in this case we actually will want both. And how can we have this trick that it generates automatically? Well, we just right-click and then we have this show contexts actions. We're going to click on this. And then here we see create a getter and setter for sugar content. We're going to click this and immediately it's gonna create exactly what we want. Basically exactly what we have done here. Just with the sugar content. We can do the same for color. We're gonna just right-click show contexts, actions, create getter and setter for color. And then he also does a getter and setter for color. Exactly those same way we have written it. Just that it gets generated automatically, which is far easier, especially if you have an insane amount of attributes that it's gonna be nice. And then we can just be set shorter content 15. And everyone's happy, there are no more errors. And it works. And this is the beauty or the magic of getters and setters. So, yeah. 30. (Java) Packages: All right, let's continue with the Java introduction. And in this lecture is gonna be a short lecture where we're going to talk about packages. So we've already seen that our own package here, it's basically like a folder, right? So in our package right now we have the fruit class and the main class. And you have to think about it as a folder in a directory. That's basically all it is. And if we then import something, you've already seen that. So e.g. we have imported java.util, util dot a realist. This is something we've imported when we were talking about ArrayLists. And then this allowed us to use the ArrayList in this case. And there were other things like the HashMap, where we also had to import utility for the HashMap. So the java dot util is basically the name of the package. And the HashMap is a class because this is the one we have actually worried created objects from. So how can we maybe make this a little bit easier? Well, we can actually say instead of just importing the array list and the HashMap, we can actually do a store and then it's going to import everything from this util package. So now we have the HashMap, HashMaps and nothing gets imported with the ArrayList. And nothing gets important because all of the things that are in Utah are actually going to be important with the stars so we can replace that. And the entire package is that important, right? So basically that is all that is to be said about packages. There's nothing particularly crazy about them or strange. If you have maybe some packages or libraries from other people that you download it, then you might have to look into, okay, where is something? But usually this gets imported automatically. And if it doesn't, you can always do it explicitly and manually. But usually it gets important automatically. But that is just a very small thing I want to say about packages. Yeah. 31. (Java) Inheritance: Alright, let's continue with the Java introduction. And in this lecture, we are going to talk about inheritance. Inheritance, a very interesting subject. And for this, we're actually going to create a few more classes. First, we're going to create an animal class. An animal that makes sense, right? What does it have? Well, maybe we have, is we have a protected string and that's going to be the species of class, right? So this is the species of the animal. So whatever switches that we have a bird, you know, crocodile. And this is all we're going to right now, right in the animal class. But now we want to have something that is an animal. But that's a little bit more specific. So possibly we could think about is a dog. That's a good idea. Let's create a class dog. Now. How is this dog related to an animal? Well, I mean, dog is an animal, right? So how can we, how can we relate the dog class to the animal class? Well, behind the class we write extends and then animal. And in this way, the dog now is also an animal. This is what is called inheritance. So dog inherits from animal. And we can also say is, dog is a subclass of animal. And animal is the superclass. Superclass is basically the cluster that's above. The dog. And dog is a subclass of animal because it is in quote unquote below the animal in inheritance. So maybe what the, an animal can actually do Is a few things maybe an animal can actually run. We're going to have a method that is called run and it's just going to print out this start. Species is running. That's, that's all it does, right? And then maybe we have a second-class. So I'm going to be run, that's going to be maybe eat. Then it's just going to print out of this such species is eating. Okay? That's, that's all that an animal can do in our model right now. Now the dog will, it can adopt, do. Well, first of all, what we're gonna do is we're going to make a constructor for the dog. That's gonna be this species. And then the first thing that you're going to think maybe is, wait a second. We haven't even declared species in dog. Exactly. But dog has also an animal. So everything that an animal can do, a doc can do as well. That's an also all the attributes it has. The dog has as well. So all attributes that the animal class has are accessible in the dog as long as it's public or protected. If it is private, then only this class can access it, like we've already discussed. So now let's just create a new dog. So maybe dog, Fluffy is a new dog. Now what can fluffy do? Well, fluffy can run and fluffy can eat, right? Because the, because this, these are classes, these are methods, sorry that an animal can do. And because Fluffy is a in an animal, because dog inherits from animal, fluffy can do all the things that an animal can do. So he can run and he can eat. Let's just start this and see what happens. So dog is running and dog is eating. That works. No issues whatsoever. That's pretty good. Now, what's something else that a dog might can do? So might do and can do is bark. That makes sense. Well, let's do a system out. Print line of maybe Wolf, Wolf, I like it. And this is all fine and well. But maybe we actually want a cat as well. So let's create a new Java class that is going to be a cat. The scat also extends animal. And in here we will have the same constructor is this species is equal to cat. And then a cat can do a public void meow. And we're going to also system out, print line meow. Right now are everything is complete. So we'll let fluffy bark here. Fluffy can bark because he's a dog, not because he's an animal. And when we make a, an object, that is gonna be the cat. So we're going to call her whiskers, let's say this one hat. And then whiskers, of course, can run as well. Whiskers can also eat. And whiskers cannot bark, but whiskers can meow. And then let's see what happens here. Dog is running, dog is eating, woof, woof, cat is running, cat is eating and meow. So here we have seen that a dog, the class dog, inherits from animal. And the class Cat also inherits from animal. And then every method that the animal can do in this case. And also all of its protected and public attributes are inherited by the subclass, in this case, dog and cat. And this can extend down how ever many levels you want. So in theory, we could e.g. have another class, Chihuahua, which extends dog. And then a Chihuahua is both a dog and an animal. We can change this however much we want. In this case, one level is probably enough. Now this is the, let's say the basics of inheritance. There are few more interesting things that we can do and change and have happened. And we're gonna look at those in later lectures. But this is the basics of inheritance, also a very important topic in Java and in, in programming in general. Also a very powerful tool. And yeah. 32. (Java) Static and Non-Static Methods: All right, let's continue with the Java introduction. And in this lecture we're gonna talk about the static keyword. So we're going to solve the mystery. What does this static keyword mean? And for that, we're going to go into our animal class. And any here, we're actually going to add a new attribute, which is going to be a public static integer. And we're going to call this num animals. And we're going to set it to 0 in the beginning. And what does this integer now do? Like what is special about it? Nothing has really changed. So let us think about just creating a new animal, right? So new animal, just like that. And then maybe we could just print out the new static integer. So we're gonna do a and the first thing we're going to notice is that it doesn't actually come up in the suggestion. That's a little weird, right? So if we do num animals, we're actually going to get this highlight and it's going to be like, hey, this is actually not the best way to do this. Because how we access this, the static variable is actually not with an instance, so with this object, but with the class itself. So what we're going to type is if we're gonna type the class name Animal dot num animals. So this is actually accessed with the class name, not an object or the instance of that class. So when we run this, we're going to see that this is 0. And you could possibly imagine that what we want is something like, well, each time I make a new animal, what we're gonna do is we're going to increase that number of animals so that we know how many animals are currently in existence, let's say. So we're just going to sort of hijack the default constructor. And in it we're just gonna do num animals plus, plus. So we're just going to increase the, this integer each time we create a new animal. So after we have done this one in num animals, A1 should be written. Let's see. And of course a what one is inside over num animals. Now this would be a static static attribute or a static field. Now, we can actually also do a static function or method, sorry, static method. And what we're gonna do is we're going to actually do something that is used quite often as a static method. And that is going to be to generate an animal, right? And then we're just going to return a new animal. So for example, maybe we don't actually want people to use the constructor. Maybe we want to do all sorts of other stuff. And then we have this static method where we can basically create a new animal. So what we can do is, let's say we have animal b. That's going to be not new animal, but that's gonna be animal, dog generate animal. And that simply returns a new animal. And if we print out the num animals after that, we're going to have to. Because inside of this method, ie, the construction was also called. So the static keyword, you can also think of, think of that as sort of a global variable. Because no matter how many or what animal I have, the num animal has nothing to do with a specific animal, right? It, the only change in this variable really, is that it increases with each animal. But it's not different for a and b, right? So this is sort of a global variable and not specific to a certain kind of object that is instantiated. So yeah, that's the static keyword. And yeah. 33. (Java) Polymorphism: Alright, let's continue with the Java introduction. And in this lecture, we're going to talk about polymorphism. Now, the first thing is, it sounds incredibly complicated, but it's actually really easy. Once you understand it. We're going to go into the animal class again. And we're actually going to change this to is eating something because we want to hijack the eat method right now. What we're gonna do is we're actually going to create a new method in both the dog and the cat. So there's gonna be a public void, eat. And this then is going to be System.out, print out e.g. This start species is now, or it's eating a steak. Because a, maybe a dog is eating a steak and that the cat is maybe drinking some milk. I like it. That's pretty good. Okay, now, what do we expect here when we, when we call the eat functions? Well, let's just see what happens. What's going to happen? This dog is eating a steak and cat is drinking some milk. So what happens is the Eat function of the animal is going to be cold, but the Eat function of the dog, and as you can see there, eat in class animal overwrites, right? So this, this class, this method here in this class. So they eat, actually overwrites the heat in the animal class. Because this one is closer to what we have declared here. So this is basically, this is all that it is to polymorphism. So the same methods on a super and a subclass of the superclass being in the animal, and a subclass being the dog and the cat, right? You can have the same method on both of them and have them be completely different. In this case, It's not that different, but they could be completely different. And yet we can have both of them. And the access is always on the subclass. So on the one we have specified here. But polymorphism, it's actually very simple. The same method on the super and a subclass. You can declare them completely differently. They can do completely different things. And it can still have both of them, right? That was it for polymorphism. So, yeah. 34. (Java) Abstract Classes and Methods in Java: All right, let's continue with the Java introduction. And in this lecture we're gonna talk about abstract classes and methods. So what is an abstract class or an abstract method? Well, we're gonna see by making this one a, an abstract class. So we're going to have public abstract class animal. And what does this do now? Well, an abstract class cannot have an instance. Because when we think about it, an animal, well, what is an animal? Well, I mean, you have to specify what type of animal you want, right? So you have a dog is an animal, a cheetah is an animal. But for example, a computer is not an animal, right? So an abstract class can have implemented methods, and it can also have abstract methods. So right now, what we're gonna do is we're actually going to have this one, the IJ method, the abstract. And then we don't want to specify anything here, so we don't want to declare it. We won't basically leave it unimplemented and genuinely just have this public abstract void eat. Now the good thing is that both our dogs and our cats already implemented this eat method method, right? And as you can see here with this new symbol here, which basically means are this one is an abstract method that the subclasses, so animal as the superclass subclasses that inherit from Animal have to implement right? Now we can also delete this. And then immediately we see, hey, you have to have this method implemented. Then we can, for example, say implement methods. And it says IID. So yeah, sure. We don't need the override, certainly in this case, but we can also just go back to what we had previously and that everything is fine. Now if we go in here, now, what we're going to have is in this case, the animal can still be created as an object if it's a cad. However, if we have an animal a, oh, sorry, an animal a, and we want to make a new animal. And it's gonna be like no, that doesn't work because an abstract class cannot be instantiated. Which simply means that we cannot have an object of this class. We cannot create a new class with this. So in this case then as well, the abstract class can both have the abstract methods which are unimplemented, but have to then be implemented by all of the, all of the subclasses. But we can, as you can see, also the run method which is implemented and which the dog and the cat can just also call. Alright, so we're just going to run this once again. And as before, everything works perfectly fine. The dog eating a steak, the cat is drinking some milk. That's still works perfectly fine and is still perfectly valid. The thing I'm with an abstract class is simply that we can have these unimplemented methods which are, which can be really useful. And also we can't have an instance of this class, which when you think about it doesn't really make sense because what is an animal? And animal is just the concept when we talk about and this is an animal. I mean, it makes no sense when you think about. And so yeah, this is abstract classes and methods. So yeah. 35. (Java) Interfaces: Alright, let's continue with the Java introduction. And in this lecture we're going to talk about interfaces. So what does an interface? Well, first of all, we're going to create one. So we're gonna go to New and then Java class, and then we're going to select interface. And this interface we will call a talk. I talk about interfaces is, this is usually how you would name an interface. So you either have a uppercase I in the beginning or you end the name of the interface with interface. This is one of two ways. I prefer the I in front than it is usually very clear. So what is an interface? An interface is basically almost like an abstract class, right? So if we go back to the animal right here, this was an animal. This is what an abstract class in this case. And we had an abstract method here, each which was implemented by the subclasses for animal. But we also had this run method, which actually was, we actually had something in there that we didn't have to necessarily implement. And we could use the this class from the method from the Animal class. Now this does not work in interfaces. Interfaces actually sort of only have quote unquote abstract methods. So we cannot implement anything inside of this. If we e.g. have a void talk method, this make sense, then we can't actually do anything in it, right? We can't say print and then do something like Hey, talk, right? That doesn't work. Because as you can see here, interface, abstract methods cannot have a body and this is the body. So we can actually implement anything. They always have to be declared. They can only be unimplemented methods. So e.g. we might have a voyage talk. Maybe. Actually, let's, let's keep the void talk right now. That might be the most interesting thing. So what can we do with talk, right? So the idea here is that the Bell run, e.g. we could imagine maybe a RPG, right? So again, we can go around and you can talk to people, but you can also maybe talk to certain objects. And that's not really a talk, then it's more like a mummy. The character says something, but this is an interesting conceptualization for it. So we could imagine maybe even that we have a dog that in our RPG right now in our imaginary RPG, that we can talk to this dog. And that's all great. But right now this one extends animal. How can we then add the at the interface? Well, we'll just write implements and then we do. I talked about now we're gonna get a big arrow here because we actually have to implement once again, the talk method. Same with that. It was with the abstract animal one. And we're gonna do Implement Methods. It's gonna be Talk, Yep, when implement this and everything is great again. So then what we can do is we can say e.g. the system.out.print line. So we declare something in this. We actually implement something in this talk method. So e.g. we could say, this dog really likes you, really likes you. See, there you go. And now what we can do is we could say, well, we can go with, we can create a new dog. So e.g. let's do fluffy again, might not fluffy. There you go. Which is a new dog. Then fluffy can talk. That's not an issue. Let's do that one. And let's go with this. This doc really likes you, That's kinda nice. However, maybe as this person going around, right? So I have this RPG character and I want to talk to maybe there's 100 different classes that can talk to me. There's might be a dog or a cat. There might be a human being, right? Another person, another character, an NPC. They might be plants or trees that I want to have an interaction with. And then this of course, doesn't work because I don't know what classes this interface are implemented in, right? I just know, okay, I know that as soon as something is an attackable, I can talk to it. So what I can then say is, Okay, I want and I talk about, and that's gonna be the dog. And that's gonna be a new dog. Because the dog is both a dog and an animal. And an I talk about right now. And so if I then go with dark dot, I can e.g. not bark because right now dog is maybe not the best name for it. Let's just say a, a dark shirt or esco with fluffy again, why not fluffy? But we know that i Fluffy, Fluffy is a walkable. And then we do fluffy and then fluffy can talk. And if we then run this, it's actually going to say this doc really likes you because this is a dog. But we're just concerned with we have an eye Taco Bell. We don't actually care what sorry. We don't actually care what's written in here. We don't care if it's a dog, a planned, a cat, an NPC. We just know, okay, this isn't attackable. This is definitely an eye Taco Bell. And whatever happens here, right, Whether it's not, like I said, it's a dog or a plant. We know that the talk method is always implemented on this I talk about. So basically, you could also imagine the interface as being something like a, like a blueprint for a certain thing. In this case, we actually use it to have a very specific method implemented on a lot of different things, right? So like I said, we could also imagine having this on the fruit or on the cat, or on all sorts of other things. And it can implement the interface, then it is able to be e.g. interacted with. Now of course, there's a lot of different things that you would need to do in order to facilitate that. That is just an example here. For the interface. Interfaces can be really, really powerful. And another note here is in this case we have actually extended this dog, extends animal so that we have a, we have inheritance and also we implement a interface. Now, we can have multiple interfaces implemented on a class, but we cannot have multiple, multiple classes a class extends from. So this is also very important to note, we can have 1,000 different interfaces, basically, having this implemented on a class node. You have to, however, implement every declared method inside of the interface in the class that implements it. So that's very important to note. Yeah, that's a very short introduction here to interfaces. Once again, if there are any questions, feel free to ask and I will respond to them. And yeah. 36. (Java) Enums: All right, let's continue with the Java introduction and this lecture. It's gonna be a quick one. We're gonna talk about enums. So enums, what are enums? Yams are very interesting data structures that we can use to well basically model some interesting things. So there are two ways we can implement enums. So first thing we're gonna do is actually in a class. In this case, we're just going to do it in the main clause. And we're going to implement an enum called difficulty. How we implement this is by reading enough, then the name of the basically M is short for enumeration basically. And we want to have ENUM than the name of the enum and then curly brackets. And in those curly brackets we're gonna write whatever things we want to basically enumerate. And we have easy difficulty, we have medium difficulty, and we've heard difficulty. And that is it. This is how we declare an enum. And now this is basically a data type that we can use to create new objects of the type difficulty. So right now we can do difficulty if we're even something like game difficulty, right? To be completely. So when we think about a game, for example, we can have a game. You'll be an easy, medium or hard mode. And then what we can do is we can have difficulty game difficulty, evil to difficulty dot. Now the great thing is that the values of this enum are actually written as easy, medium, and hard. So we don't have to worry about something like, you know, you can think about a difficulty having 01234 and you're like, okay, what is what is difficulty? One would have difficulty for maybe, you know, in four months when you come back to the project, you don't remember, but difficulty, easy. That's easy to remember. And this also works, you know, you can make if statements with it, you know, game difficulty equals and then you can say difficulty easy. And then you can do something, you know, you can be like, hey, the difficulties easy. So maybe the player has more health or more armor or the enemies have less attack, things like that. And the enums here are really good because not only are they easily, easily implement, implementable and also easily changeable, right? So we can easily say something, well, let's do a horse as well, and nothing changes. We may just have to have another if statement or another case in our switch statement that we want. And yeah, so this is one way to have this enum and implemented. We can also make a new class. And there we can choose an enum. And for example, we can make something like, I don't know. Maybe let's say take difficulty. And now we're actually going to delete this one. We're going to delete this difficulty. And here we have a public enum, and this works the same way. So we have easy, medium, hard. And then Horace for example. And this works just the same. So difficulty, if his new difficulty, sorry, not new difficulty, that's ridiculous. Of course difficulty, for example, easy. And that's it. So this is basically the same as here, just in here it was part of the main class. And possibly then what you would do is you would have to access it by always have a main.out difficulty. This is sometimes, it's better to have this in its own file. Sometimes it's better to have it in side of a another class. That is, I would say mostly preference. But also situational awareness is very important. They are depending on how often it's used in other classes. And if your class name as long, you know, it can get pretty long. You can get pretty long statements from that. But yeah, this is an enum very useful for a lot of things. And yeah. 37. (Java) Exceptions & Try and Catch Statement: Alright, let's continue with the Java introduction. In this lecture, we're going to talk about exceptions and try and catch. Now, what does an exception and what are we trying and catching? We're going to look at this very soon. So first of all, I've prepared here an integer array. And what we're gonna do is we're just gonna do system out print line and then we're going to say numbers. And then two. Now this of course doesn't work because there is no number of index two in this array. So if we run this code, we get an exception. Now, this exception simply means that the, the array is out-of-bounds. And why, what does an exception? Exception is basically an error rate. That is, that doesn't have to crash the program. So if in this case the program would crash, if we have something like this. So e.g. oh, sorry. If we have something like HelloWorld maybe written in here, right? So we'd write Hello World. Then everything after the error is not or the exception in this case is not cold. Okay, that's fine. Now, we're gonna do is we're going to actually implement our own quick little method here, which is gonna be a public static float. And that's going to divide, it is going to divide a by B. And we're just going to return a divided by b. Now, as some of you might know, if you divide by zero, that's a very bad idea because that doesn't work. And we can check for this in advance. So we can say, Hey, if b is equal to zero, then throw new and then exception. And then in this exception, we can actually write some things. So we can e.g. you cannot divide by zero. Right? Now it's going to throw us an error. Because what it actually wants to know is that this method throws an exception, right? So here we actually have to write throws exception, exception. There you go. Then everything works fine. Because it needs to know, hey, this divide method actually can throw an exception. This is very important. So if we then try to use it, so let's say e.g. we want to divide ten by five, something like that, right? And it's gonna be like eight. Doesn't work because we've not handle this exception. What about this exception? It's like okay, so we then actually also want to throw an exception for the main method, just so that is all clear. Now if we do this right now, this is just going to work because it's just going to return a two because nothing happened to you. Or if you're going to do a zero in there, then all of a sudden we throw an exception. And that exception, we thrown exception. And it just says you cannot divide by zero. That's really the interesting thing about it. But what's even more interesting is this. So we can actually encapsulate this by a trial and error statement, right? So we can stop throwing this exception for the main method and actually say, well, okay, let's try this, the keyword try and then curly brackets. And then we have catch. And inside of this we're going to have exception e because this is what we want to catch and this is what we're going to try. So we're going to try and divide here, right? So we're going to just quickly format this. Very nice. So we can have multiple ones, Let's say e.g. 10/5, 40/4, and then 22/0. Now this is going to be, this is going to just work. This is going to be two, this is going to be a ten, and then this is the exception. Except, there you go. Let me catch this exception. We can actually output this, right? So we can say system out dot print line. And we could say E, e.g. right. So it just outputs the exception. And then afterwards maybe what we wanna do is system.out.print, line dot, and then helloworld. Right? So let's see what happens here when we run this. Well, what's going to happen is we're going to do this. We're going to print out two, we're going to print out ten. And then the exception happens, right? You cannot divide by zero. But because we put it in a try and catch statement, what came afterward? Afterwards, actually still executed, right? And this is really the power of the try and catch one. Because if we wouldn't have first try and catch it or caught it in this case, then this one would not have been called this method in this case. But it has been cold because we've made it safe to call. So when an exception is thrown, we can try and catch it. That's why it's important to know that in a specific method throws an exception. Because if you know what this, then we can always put it in a try and catch statement. And then even if there is an exception thrown, we can still continue in the program doesn't just crash. That's like one of the most important things. But we still get the possibility to print out the error of the exception in this case. And we still get to know, okay, What happened here. So that's really a great way to basically make sure that the code is solid and that the program doesn't just crash. Because think about it like this. If every time that something bad happens to the program, some exceptions thrown. Every time that that happens, the program pressures. We would have many programs that would crash constantly because they can always be something that happens. And especially if you take user input, you might ask the user, hey, give me a number to divide, right? So e.g. the calculator, right? I say, well, 22/0 BAM program crashes. That's not what we want. That's why we can catch the exceptions before they can crash the program. So yeah, that is something for exceptions and try and catch and yeah. 38. (Java) Java Lambda Expressions: All right, let's continue with the Java introduction. And in this lecture, we're gonna talk about lambda expressions. Now, I've already prepared basically the entire Java file here because this is a little bit more complicated. And I want to just go through some of the examples I have written here. And we're just gonna go through the code one-by-one. This is also available as a resource. This particular code, because it's more important that you understand it rather than you see me write it out. I think that that's more appropriate in this case. So first of all, we have a list of integers right here, and we just add a few numbers. And what we can then do with a lambda expression, for example, is we turned this into a stream. So we do number start stream, right? This just turns it into a stream of numbers. And then we can use something called the map function. And the map function actually takes in something that looks really weird, right? So this one in this case would be a function, right? So we talked a lot about methods, and now we talk about functions. And a method is basically something that belongs to an object or a class. And a function is sort of like a free-flowing method, so to speak. So it doesn't belong to a particular class. And in this case what we want is we say, okay, so when we use the map method, what happens is that it takes a function and this is the function. And it applies this function to each of the members or each of the, each of the stored values in this list, in this case. So basically each of the numbers, right, is going to, so it's basically like for-loop. In this case. It's gonna say OK for each of the numbers, right? We're going to say, okay, this is irate. Now, this is i, this is i, this is i, this, I wanna do that. And we're just going to call i plus equals four. So what should happen when we think about it like this? And then the rest here is just to list. So we just write that back into numbers. So when we call this here, we just expect, you know, a 10021069420. And then here we expect all of those numbers but added four. So we're just going to call this and we're going to look at the first two lines right here. And as you can see that E, every value inside of the list, we added four to it. And that is a really easy way to do it in basically one line of code, which is amazingly efficient when you look at writing code. Now, the bigger and bigger the the collection scat or your lists get, the more you should be careful about the lambda expressions are usually, there's usually shouldn't be an issue. So there's a lot of different things you can do with this. But we're going to look at right now is functions as variables, right? So this is something that is insane. There are five things that I want to talk about right now, which is once suppliers, when consumers call doubles runnable and then functions. And so we've seen an example of a function right here, but we're going to first start with suppliers. So a supplier is basically a variable which has stored in it, a function which has stored in it. A function with no parameter but a return value, right? And we could write this, for example, like this, right? Open parentheses with nothing in it. So there's no parameter. And then you have this arrow and then x. So here we declare a supplier, I just call it supplier, and then this is equal to this expression. This would be a lambda expression, and this is basically a supplier. So a supplier, like I said, has a return value, in this case an integer value, and returns ten. If you want to know what the supplier the supplier has to supply to us for, let's say, then we just use the get method on the supplier itself. So when we look at the third row right here, we have a ten that is returned by using the get. And this is great because in this case we can actually store a function inside of a variable rate. So the supplier here, we could also pass to a method and we could do stuff with it. That's, that's the, the possibilities are almost endless, right? When you think about it. We also have a consumer and a consumer has a parameter but no return value. We could write this like this. X goes to nothing. So in this case we have a consumer that is, has a string value. And this is then written like this. So this S goes to e function here. And then we can do consumer dot except and then just pass a string. In this case it's HelloWorld. And if we run this, then we see helloworld. But we could also pass anything that we really want in here. So that's a great way to use that. Then there is a callable. Now a callable has no parameters but a return value and it throws an exception. So that is why we, in this case, we have actually surrounded by a try and catch statement. Because if we don't, if we just do this, then it's going to be like at the exception to the method signature. But we don't want maybe our main method to have the throws exception. This is why we're like OK, just do try and call. Now this, in this case does nothing because we throw an exception. And I think he catches this before. And yeah, this would be a callable. So callable, it's basically the same as a supplier, but it also throws an exception. Could be useful sometimes really depends on what you're doing. Next thing. A runnable. A runnable is a function with no methods and no return values. So in this case, the runner-up also could be written like this. And then the runnable is just the open parenthesis with nothing in it. And then just doing something. And it can be run by just doing the run, calling the run method. Very easy. This is the similar to just a normal void method, right? A more void method. And this is just the, let's say the function part of that. And then lastly, we have the function which has parameters and the return value. So you can think about a function like an, a mathematical function rate. If you have f of x, then obviously the access something you pass to the function and then the y you get back is something that is the, the, the result basically, right? So here we have x, y, this is how we can write it. And in this case, the function has a double as an input and a double as an output. We get, we put our in and we get out. Basically, you know, this would be a function two, so this would be pi, this is the radius rates. So this is just an example. And we can use system out, print line and then just do the function dot apply with a ten for example. And we could apply this. So let's just run this quickly. And as you can see right here, we had Hello again, Hello world again, runnable. That worked fine. And then this one just returns 31.41 and so on and so forth. Because it just calc, because just times ten this but once again, we can put any double in here with that we want. And yeah, so this is a very short overview and a very summary for some of the things that lambda expressions can do along the expressions go way, way, way deeper than that. Even. So, just the functions we can call on collections are numerous and insanely deep and sometimes really useful. And even those, the suppliers and the functions as variables, even there, there are even more types of them. But I restrict myself to these five because in my experience I think that these five are mainly the most important ones. Not necessarily most important, but the most used. And, but it also always depends on what you do right? Now, the big thing is that you don't really need to use lambda expressions. If you have a program, you start from scratch and you don't use any third person or third-party extra packages or something like that. You don't really need to use them. You could, in theory do everything else without this. But it's very important to at least look at and some things that you might wanna do, especially if you work with code that others have written. So other packages, then they might use these lambda expressions and then it's very important to have at least seen this and to then maybe be able to recall. So yeah, that's a very short introduction. Once again, if there's any questions, feel free to ask and I will answer them. And yeah. 39. (Minecraft) Forge Installation and Setup: All right everyone, welcome to the Minecraft course. And the first thing we're gonna do is we're going to download Minecraft 4j. So you're going to go to the web address files dot.net. The link is of course available as a resource here. And you're gonna download the newest, the Recommended Download right here. In this course, we're gonna do 1.16.3. And the recommended version right now is 34.1 is 0. We're going to download the SDK here, so we're going to just click on OK and we have to wait a couple of seconds. And then right here is Skip button. We're just going to click that. And then a ZIP file is going to download this zip file we're going to put into a directory of our choice. I've already prepared a directory here. So we're just going to quickly do something, some magic like this. And we're gonna put this in here. Now we have our forge one port and 1.16.3 m dk in our, in our directory. And we're going to simply extract here. For that you need either when RAR or or some other program. I'm sure you have that already. And if not, please feel free to ask any question. I can then direct you or you can just Google Vin rar, WIIFM RAR, right after everything is extracted, we can actually delete the zip file here. And the first thing we have to do is open up intelligence, right? If you open intelligence for the first time, then you're gonna get this. Welcome to intelligence. If not, then you can simply go to File on the top-left and just import or open. And what we're gonna do is we're going to open more import. Now. We're already here at our Minecraft directory and we're going to import the build.gradle file. And what we're gonna do is we're going to just open as file right now. And as we can see, a file has opened. Once we have the build-up Gradle file open, we actually have to change a few things. And in here we actually have to specify R package. And this is going to be calmed up Colton joe dot MC course for me. So the mod ID in this case is going to be Mc course. And one other thing we have to change here is example mode. And what we're going to right there, what we're gonna do there is we're going to just going to press Control R. And then we're gonna change the example mod2 to MC cores and we're gonna do replace all and then save with once again Control S this time. And then everything should be set up the way it's supposed to be. Don't worry if there's any errors or something in here. We're going to fix that soon enough. What we're gonna do is we're gonna go to file and close project. And now this one actually is here in the history, can actually just X out of that. And now we can actually import the entire project. So now we're gonna go to import and we're going to once again click on the built or Gradle file. But now we will open as project. That's gonna do a bunch of stuff here, can actually just click background and then it's gonna start everything in the background. Don't worry if there's some errors here. We're all gonna fix those right now and one after another. Right? So. First things first, let's actually go up here to Minecraft and open this folder up, and then open the source and then the Java one and the resources as well. And as you can see, some things are starting to happen here. Like I said, this can take about a minute or so depending on how fast your computers. But while this runs in the background, we actually can change a few things already. And this is in the resources and meta in folder. There's a match dot HTML file. And this file, we can actually change a few things. So first things first we're going to actually comment out some things. So the issue tracker, you can see that some of those are optional and some of those are mandatory. And some of the optional ones we're actually going to just comment out. So in our modern d mod ID, we're going to once again write Mc course. Then we have the display name. This is going to be Mc horse. And then we won't have a updated JSON URL. We won't have a display URL and we won't have a logo right now. The rest is just gonna be kept as it is. We're going to once again save this with Control S. And then this file is also updated. You can close that now and just wait until this is done. Right? So I right now have a checkmark and everything works fine. There could be a point where something doesn't work is the best thing would be to just ask me and ask a question and I will get back to you very soon. However, the first thing you could try is you can go to the terminal and you can type in Gradle, Gradle w slash less, stop. Try this 1 first and then rebuild it. You can do this by going to the Gradle file. And up here is a little elephant with a flag that this reload sign. And if you, if you click that one, then it's gonna reload. And if it then still doesn't work after you've, you've typed this one enter and then something's going to happen. And then if it then still doesn't work, then of course, feel free to ask a question but try that first because that was an issue that I had definitely when first setting this up. Right, that there's a chance that your packages look something like this where they all have the names in one row, let's say, and then separate it with a dot. To counteract this, you can go here to project to this Show Options menu. And then flattened packages should be unchecked. And then compact middle packages should also be unchecked. Then once you create the asset folders which are going to create just after this, this just in splice right now, then they should be shown correctly. There were a few students who had this issue, and I just wanted to splice this so that you are not going to run into that issue as well. Right? So the only thing that we're gonna do now is we're just going to set up a few things. So we're going to create a few folders and we're going to quickly change some things right here. So the first thing we're going to change is the example modes. We're going to open this. And of course this is not the name that we chosen. So actually going to replace this by just right-clicking, Refactor, Rename. And we're going to rename this to, let's call it EMS MC CourseSmart, because that's going to be Ahmad. In here goes our Mat ID. So this is going to be Mc course all written together. Now, I would advise to just do basically copy, not copy, but to program along with me. And then after you've learned the basics of what, how you can create a block and how he crew create an item and so forth. That uses then actually create your own mod. I would encourage that if you don't wanna do that, that's fine as well. You can also just follow along and create your own model immediately. Then here we actually wanna change this package. So we want to change this to come cotton j2. And then this one is mc course, right? It's gonna be, I would like that we're going to move that to package. And then it's gonna, he's gonna create a new package here for us. And we can then also just delete this example folder. And everything is setup here as it should be. That's great, right? So let's look at the folder structure right now. We're going to create a few photos. Now in future lectures, we're actually going to create even more folders. But right now, the folders we're gonna create our for things like blocks and items, and they are textures, a little bit of language stuff. So display text basically. So the first thing we're gonna do is we're gonna go to the Resources folder. I'm gonna create a new directory and we call that assets. Now in that assets directory or more directories go actually in that 1. First, your a folder goes that has the name of your Mat ID, right? In our case here, mc cores and in that folder, for more folders go. The first one is going to be Bloch states. And then the next one is going to be lang l, n, g. And then another one, which we're gonna call modals. And then the last one here is going to be textures. Now inside of the models folder, we're also gonna create a folder called Block. And another folder, we're going to create a cold item. In the textures one we're going to do exactly the same thing, a folder called Block and a folder old item. And that is basically the setup for now. Right now as we needed. Like I said, we're going to add more photos in the future, but this is like a basic structure that we're going to need for, let's say the next few lectures. And yeah, so if everything is setup and if everything works fine, what we can do is we can go up here to Gradle, and then we can go to Tasks. Fg runs, and then this run client double-click that one. And then a lot of stuff is going to happen. And if everything works fine that microsoft Minecraft is actually going to start and we can well, we could plate theory. So it starts on the wrong monitor. Sorry. But that's not an issue. And it's gonna yeah, right. Now as you there you go. And let's see what happens. Of course, are there it is. The soothing sounds of micro music, which I'm immediately going to turn off because usually, especially in these courses, maybe not the best study to have a music running in the background. And if we go tomatoes here, we can actually see that our MOD MC CourseSmart is in here. This is just some placeholder stuff that we could place we could replace later. But yeah, it actually has Armand loaded and everything works. And yeah, I think that that's quite good. And this is basically all the setup we're going to need right now. That's all that needed to be done for this moment in time. And yeah. 40. (Minecraft) Note on using Minecraft 1.16.5: All right, welcome back to the Minecraft course. And in this lecture I just want to quickly mention that if you are using one 605 in probably above, however, 165 right now is the main issue. You will have to change your mappings channel. It should look like this. So mappings channel official and then version one 605. And inside of the build window here you should also get that this is licensed by the Microsoft Corporation because those are the official mappings that Minecraft and morphogen use. And this will not really be compatible with the course material that follows this. Because some methods, actually a lot of methods and attributes and variables are completely, have a completely different name. And therefore you will need to change this to exactly this right here. This might not be the newest version of the mappings. When you see this video, however, you can either check or go into the resources, into the class description. And there you should find under fairly high up 165 mappings. You can then just copy it and then paste it in. Make sure too low to the Gradle changes up here. And then it should take a little while, build everything. It might take a little longer for you if you do it the first time. And then once you get the tick and everything is successful, make sure that inside of your normal MOD file. So when we do this, this should be the MC course MTT file. I just set up a new 165 repository. That's why this is an example model. In this case, you will have to have an error here. Simply delete this line or delete the entire method, doesn't matter. However, the error here with the options, you can just leave that line and everything will work from that point onwards and you can follow the class almost to the t. I believe that most of the other mappings should then work. But that is very important. If you don't do that, then you will not be able to properly follow the class. It really doesn't matter because the mappings channel is, I wouldn't say better necessarily, but it is simply what we are going to use for this class. So just so you're aware and just so you know that that's the case. Yeah. That was it actually, and that was it for this lecture. I really implore you to do this. Otherwise, I will simply refer you to this lesson if you haven't changed it. So yeah, that was it. Good luck and have fun on the rest of the course. So yeah. 41. (Minecraft) Create our first Item: All right, welcome back to the Minecraft course. And in this lecture, we're going to create a new item. So first things, first we need to do a few things. And the first thing that we're gonna do is we're actually going to create a public static final string here, which we're gonna call mod ID. And that is simply going to be our motto ID. And then we can actually replace it up here as well. So we can just write Mc Corps motto mod ID. And because this node ID is actually going to be used in a lot of different places inside of our model. So what needs to happen is we actually want to create a new package. And that is going to be in, inside of our MC course package. We're just gonna go new package. And we're going to call this item. And inside of there, we're gonna create a new Java class, and that is going to be cold. Naca is just more items. You can basically call it whatever you want to, but it should have some resemblance to more items, my items, registered items, something like that, just so you know, okay, this is the class where I register my atoms. And now we're going to write some code and I'm going to, first of all explain as I go along and then in a little bit more detail throughout. So it's going to, we're going to create a public static final registry object of type item. And we're going to create is going to be copper ingots. So we want to add maybe covered to the game. This is just something I thought off right now. And if something is read, we can just import it. This is important to make it net dot Microsoft dot item. And that's going to look a little funky, but don't worry about it. And we actually need a another thing before we can do this. And that is going to be a registration. So we've actually jumped the shark here. And what we're gonna do is we're going to actually go back and make another package, which we're gonna call Util. And in there, and we're gonna create a new Java class, which we're gonna call registration. Sure. And that registration, we actually first have to register r or we have to place a deferred registry. So we're going to use deferred registries here. And that has happened before. We can actually do the items, but don't worry about it. We will, we can do this. So we're going to have a public static final. And this is going to be a different register of type block. So this is for the blocks of course. But Let's do it right now already so that we have it. Also import the class blog. And then do a deferred Register, dot create, porch registries blocks. And then we need RMC, course id, the ego. And then we can do basically the same thing. We can basically just copy this and replace the entirety with items and items so we can just do. And then here it's items. And then we simply need a public static void register, function or method rather, which is going to have an event bus. And what we're going to talk about that 11 second. This is going to be a FLM FML Java model loading contexts dot get, dot get, mod event bus. And then it's simply going to simply, both of the deferred registers are going to register with that event bus. And in this case, it's going to be items. And then bam, and in this case then all of the items are registered. And we then simply need to call that in our constructor down here. So we're just gonna do registration, registration, DOT, register, their ego. And now we can actually do the item. That's yeah, because now we actually wanted to call registration that items, right? So we want to call this the first register that we actually created. We want to register a new item, which is going to be copper Ingrid. Now, this is, this is the name of the, basically the item ID so to speak. And that is always lowercase. And in between words there's underscores instead of spaces or something like that. And then it's going to take a supplier. So that's simply a, a lambda method which is going to supply a new item. So we're gonna create a new item. And to create a new item, we actually need to specify properties. In this case, what we're just gonna do is we're only going to specify the item property, the property group, so that we can actually see it in creative mode. And this is just going to go into, let's say, a materials for the sake of right now. And I actually want to have this be indented a little bit differently. They go, that looks a little bit better. And then we also need a public static void register function with nothing in it just to call it. So that e, so that everything is gonna work out fine. So let's do Mott items DOT register. And then the item is actually going to be in-game already. Just like that. Let's just look at it. And then we will, of course discover that there's a little bit more to it because, you know, you might have noticed that we haven't actually added a texture, for example, which of course is going to be needed. Otherwise, it's gonna look a little weird. And I can promise you it's going to look a little weird. So let's just create a new world. We're going to do a creative world and peaceful and I'm just new world, that's fine. Okay. Alright, here we are in Minecraft. Isn't that beautiful? And let's see. So this should be an miscellaneous or belief they would go item by Mc coerce copper, Ingrid, aren't those beautiful copper and he's not really, is it? No. Not, not really. Okay. So we are going to have to fix a few other things or it's properly in the game, bulges in the game nonetheless. So the first thing we need to do is we want to go into the lung folder here under resources assets than our motto AD MC cores, and then the length folder. And we're gonna create a new file, which we're going to call Yan underscore us and dot JSON, JSON. And that is going to be formatted like this. We need those curly brackets. And then inside of, inside of the quotes, we're going to do item MC cores, Harper, ingot, and then a colon. And then covering. This is basically the name that we want to have displayed inside of the game. And then we're going to go into the models and into item. And in here we're going to have, have a file that is named exactly like the like the the name of the item that we specified, right? So copper underscore ingot and dot JSON once again. And this is going to have something like this. This is going to be parent, an item slash generated. And then we're gonna specify the textures. So don't textures a curly bracket and then layer 0. See pores. Hold an item slash copper ingots. There you go. So the main takeaway here is that the, here we specify the textures. This is basically the most important part. And we can have basically multi-layered, multi-layered items. We're not going to worry about that right now. This is however, the important way of how to write it. And then actually the only thing we need is a texture. And now I've actually prepared a texture on my other screen. I'm going to put that over into item and I'm gonna say, yes, this is the texture I've prepared. And in theory, note also that the name of the texture here. First of all, it needs to be a PNG file. In my case, I have a 16 by 16. It shouldn't be bigger than 32 by 32. But, you know, there might be ways to get around that. But in this case, I advice to always make 16 times 16 textures because that's also the sites of the textures of the normal micro textures. And the name of the file is going to be exactly the same as the name we have specified in our mod items right here, right? So this is always the, basically the item ID. This is everywhere we go, basically it's going to be the same. And in theory, if everything worked, let's hope it did. Then we're going to see, and hopefully it's going to work already. But I am fairly certain that everything is going to be fine. Now. Not actually my, my my idea here is that I'm actually not going to cut out if I maybe made a mistake and we're just going to cut in and show you where I made it because I think that sometimes, you know, you make a mistake, I make a mistake somewhere and then it's better for you to see up there was a mistake. And then you can learn from that. But actually we don't even need to do that because here it is our copper ingots. In our game. It's called copper angered and it looks pretty good. I like it. Looks kinda nice. Yes, that was all we had to do to create an item in Minecraft. If you have any questions, feel free to ask them. And but that was basically it. So yeah. 42. (Minecraft) Create our first Block: All right, welcome back to the Minecraft course. And in this lecture, we are going to create our new block, right? We're going to create our own block. And it's going to be a little bit more complicated than the item, but not by much. So the first thing we're gonna do instead of r mod ID package. So our MC course package right here, we're gonna create a new package. And this is gonna be called block. And inside of that package, we're gonna create a new Java class, and that is going to be more blocks. Here. We're going to have some fun. So maybe we want a copper block that goes with our copper ingots that might be useful. Now first we need to have sort of a helper method. And I'm going to write that and explain as I go along, it's gonna look a little bit crazy at first, but don't worry about it. So this is a T extends blog and we actually need to import that. Oh, sorry, wait, we go lock. And then this is going to return a registry object of type T register. And it's going to have perameters, string, name, and supply on quickly. Model a little bit ago, Supplier T, And the name of block, right? Okay, here we go. We also need to import the supplier class here from Java Util. And there we go. And then inside of this we're going to create a new registry object of type T. This is the one we're going to return. So I'm going to call this to return. And now we're actually going to go for registration dot blocks, register, name, and block. And the reason why we do it in this function is actually because we also need to register an item for this for each block. So we're gonna do registration dot items not register. And this is going to be the same name. And then we actually, instead of creating a soul, returning a new item here, we will actually create a new block item. And this is just going to be returned to return dot get. And then we need a new item, dot properties. Those are the same as with the item. So in this case, we will only do group right now in order to have it sorted into a group in the creative tabs. So this is going to be building blocks. This is block, so that does make sense. And then we're going to return, to return. And this is our helper function. So basically takes in a type. So it basically has a type of block that we need to supply here. And then it returns a block. We're just gonna, we're just gonna use it simpler than just fool around here. So we're gonna do registry object. So once again I've registry object, the sum of type block. There's gonna be a copper block. And now we're just going to call register because that will return a registry object for us. And this is going to be copper block. And then we also need to do the supplier. And that's going to be. A new block in this case. And now we actually have instead of block properties with epsilon rocked up properties, properties dot create. Now we need to specify a material first. Now, thinking that this is a like a copper block, this is probably Material dot iron. And then behind that, we can actually specify even more properties. So for example, we can do hardness and resistance, which is going to move that to the next line here. And that's probably going to be like, let's just do something like 310. And then we're gonna do sound is going to be a sound type.me. Yep. Very good. Okay. And then that is done. Now that's also, by the way, something for the items as well. You can just behind group, you can add even more items, right? There is something that so for example, rarity, max damage, Mixtec size, and all sorts of other things that we can do here. Now, if I'm not mistaken, I need a, another PABA, public, static, void, register, an empty function. And then if I'm not mistaken, this should already be enough to have it in here. So more blocks that register. But before we're going to look into the, into Minecraft, how it looks, we're actually going to do the texture properly this time and go through it. So the first thing that we're gonna do is we're going to open the yen US Jason again in our length folder. I'm going to add this. So this is going to be the loc dot AMC course on copper wire. Sorry, copper wire. What am I talking about? That is that is a spoiler. That's a that's a big spoiler. Copper wire. It's of course copper block. Yeah. And that's actually already it. We're going to also need to supply something in the models. This is a new file and that's going to be copper block dot JSON. And I'm quickly going to copy this over. That's a little bit easier. And it's going to be, so instead of the parent being item, item generated, this parent, it's actually blocked cube all. And then the tech in the textures one we actually have it's sort of layer 0. We have all. This is basically to specify that all sides are the same texture. We can of course also use different textures for different sides, but that's something for another lecture. And then we also need the Bloch states. So this is going to be hopper block dot Jason. And I'm also going to quickly get that over here. And that just basically refers back to the model file we have just created. However, we actually need to create a nother file in models and that is under items. And that's going to be also the copper block. Jason. This is why I said it was a little bit more complicated than just the normal one because there's a few more steps to creating a block. So MC, worse block slash copper block. And that should be it. I believe so. Now we just need to refer the or I need to quickly put that one in here. We're gonna do that. This is my texture for the copper block. And in theory now everything should work fine. That is, well, all right, let's just run microwave and see if that works. So we have the Bloch states, we have the models, black models, item and the texture. And we've also set the lang. So all in all that should work already I believe. Let's see if I'm correct or not. Right. Asco single-player New World. Let's go in there and let's see what we can see. So a covering or is of course still there. And then in the building blocks down here, there it is, the copper block. You can place it. And we can also throw it around if you want. Yeah, that's great. That is amazing. So this is actually so like I said, it's a little bit more complicated than the item, but it's not crazy complicated yet. And yet this is basically how we add a roadblock into Minecraft. And after this, there is a little short assignment where you actually add another item and another block to Minecraft. You can either do your own or you can just do the one I provide. I provide two textures. And you actually should add copper wire and a copper or to the game as well. And I, so I, I advise to do the assignment sort of blind, basically copying everything we've done up until this point and then doing that without watching the video. However, of course it's free for you. I just advise you to do it. And then the next lecture, I actually will have all of that already inside of the game. So the copper wire and the copper or are already going to be in there. So if you don't do that, you might be behind. I will quickly touch on that in the next lecture. However, just so that you are where the assignments are always carry over into the lecture afterwards. So, and the assignments are always going to be part of the next lectures that come after that. Yeah, that was basically all I wanted to say. Once again, if there are any questions or if you have any arrows of any kind, feel free to ask me and I'll try to help you as soon as I can. And yeah. 43. (Minecraft) Theory: Going in depth into our Classes: Or I just as a quick note that this lecture is just to go a little bit more in-depth in to the classes we have already created. So the modes, items, the mod blocks and the registration and the main class. And this is a very theoretical lecture. So if that doesn't interest you, you can skip it. There's nothing too crazy or important that is being set here. It's just maybe to solidify a little bit of some of your knowledge and that is basically it. So you can skip it if you want to. All right, welcome back to the Minecraft ores and I'm here from the future. Well, basically, I had a question a student asked that said, hey, can you maybe go a little bit more in depth in both the main class and also Registration mod items. What are we doing there? I'm just typing this often. I'm not really understanding what I'm doing here and this is basically the lecture for this. And so first of all, we're going to go through the MC CourseSmart class and look basically almost at each of the lines here. So the first is this annotation, of course is add mode and then the mod ID. This is very simply. So that orange basically understand, OK, this is the main class for this mode with the study that we have, then of course, you're actually initialized as a string, simply mc course. Or maybe you have chosen a different name. But it's the same idea. And also very important, it's also written here. The value here should match an entry in the meta in Tamil. We've actually done this. I believe in the first lecture here on when we started with the Minecraft and the fortune selection, right? Right then we have a reference here to the log for j logger. Now, actually very easily explained. So log for J is simply a, an external library that forge uses in order to log some of the things happening well, either in-game or during initialization and so on. And the log for j is just a really excellent library to do this. That it really has no bearing on anything happening in game or anything really. So this is just for debugging purposes and for outputting things to the console, let's say, yeah, right next we have the constructor. So this is simply a normal constructor, like in any other Java class. It's just for our model class. Of course here we have our three register methods that we're actually calling for the registration, the MOD items and the MOD blocks. This is of course self-explanatory in the way that we've done this. Now we're actually going to go through three of those classes as well. But let's first of all look through the entire mc multi-class. So next come these four interesting method calls that are a little bit weird and could be like, okay, interesting. So this looks like a crazy setup, let's say. So first of all, we do this FML Java loading contexts that get dot-dot-dot mod, mod event bus ad listener. And then we put it in this weird thing where we write this and then. A two, you know, two colon and then an a method name here, right? This, this all seems a little weird. But to explain it in the simplest most terms, basically, what Forge does is Forge has different stages for setting up certain things, right? So in the setup for example, usually what you would do in here would be something like a put in the configurations and maybe put in sum. What else declaring capabilities. So there are different things that you do in different stages, which makes sense of course. And what we do with this hole here is simply say, okay, hey, this method should be called when it's time for the setup, and this method should be called when it's time for enqueuing IMC is and then processing IMC. And then in the end, this should be old when it's time for the to-do declined stuff. And this is basically what do the entire thing here means, right? So getting the loading contexts, getting Mode, Event, bus, adding listeners is simply a way of ensuring that certain things happen at certain times. Because if we have multiple modes and they just initialize whenever they want, you know, some initialize the recipes in the beginning, some initialize the recipes at the end. It's all madness. That that doesn't really work. That's why forage streamlines this by using these listeners. And they're, the only real things that interests us is the first one and the last one. The ones in the middle were actually like the entire thing. We're never going to talk about the entire course because those are inter mod communication. Which means this is, these are methods for communicating with other mods. And because we're only building one mod here in this course, we're not actually gonna go into that at all. So it is actually possible to delete this. And I actually am like deleting this end both of the methods in a later lecture in the advanced section. Just to note, this will stay there for the length of the, let's say the, I think it's the beginnings of the Minecraft modding. But you could already deleted if you want to. But you don't have to. Of course, you can just let it stay like it is and nothing would change. Now the setup and the client stuff are actually things that we're going to use. Now later in the advanced section, we're actually going to look at a different way of doing the Client stuff. But for the purpose of this, we're going to keep it like this. And yet this is basically what these constructs mean here. Right next, as the comment already says, write register ourselves for server and other game events we are interested in. This simply means that we actually get access to what we have down here, V subscribe events, which we're gonna see more of later down the line. And this is simply to register ourselves once again in terms of events that happen. Right then of course we have the two methods that are being called to add listeners. Then we have a action as M subscribe event where we have on servers starting. So this is, this happens only when the service starts. And then down here we actually have register events. Now this is a method that we actually have deleted or will delete in a future video. Now, I'm not a 100% sure actually, but this should just be gone. Same with the server storage in this case. Because once again, in future lectures, in especially the advanced lecture, we're actually going to go through and clean up and refactor a little bit of the code. And in there we're also going to discover a new way or a different way of doing the client and server side separation. But this is sort of a basic overview of the main MC CourseSmart class. And yeah, let's next look at the registration class, right? So inside of our registration class, we have the two different registers of type block and of type item. And then we have this register method where we actually registered this as well. So let's just think about it first of all, up here so that differed register. So one thing you can do, if ever you feel stuck, you can also just hold the Control key and hover over any class or any method, and then just click it. And you will actually be immediately while the class will immediately open. And as you can see, there are some things in here that might help. So the commons are actually in there. And so we can actually see, OK, what is this? So the different register is a utility class to help with managing registry. Maintains a list of all suppliers for entries and registers them during the proper register event. So as you can see, we almost already have the answer of what this does write. It simply has a list of all the suppliers. And this is something we're going to see in the mod items, right this year where we registered something. This is where we had a supplier for a new item and a new block, for example. And this is exactly what the third register keeps track of. And then simply makes sure that the game knows about, hey, these are the blocks I have, these are the items I have. And this is where the deferred registers come in. So they basically are therefore making sure the game knows about these things. And what I can just quickly show you, for example, is if we have a new deferred register here, and we're just going to quickly all this, whatever. And we're gonna look into differed register that create. What we can see here is port registries dot. And these are all of the types of registers that we can actually look at it. So we can make new potions, we can make new fluids, entities, we can make new tile entities. And some of those, of course, are also things that we're going to add later down the line in later lectures. That's basically the idea behind the different register is simply just a list or let's say a record of all of the things we want the game to know about. And in this case, we define these by the type that we want to know, that we want to register, right? So first we say a, this is a register for blocks. So let's say a list of block. It's not quite a list, but let's think about it like that. So we have all of the blocks we want to define, and then we have all of the items we want to define them. In the future. We're going to add way, way, way, more types that we want to define. And then each time we're going to create a new deferred register. And now this register method here, as you can see, there is something. Eerily similar to this one right here. And that is exactly what we had in here, right? So we actually already also have this, we've seen this before, right? This is simply the FML Java loading contexts dot get, dot-dot-dot event bus, dot-dot-dot listener. And instead of doing the atlas learner, what we're actually going to do is we're going to do willing, flip this around. So we're gonna take this event bus and then say blocks register and then give the event bus in. Now this does basically exactly the same thing as the other way around. We're just gonna do it in this way. Because, well means simply this is the way that it's supposed to be done. And this then, while this deferred registers, when we go into the mud items and say, hey, this is the third register, this is where we have the list in the deferred register now knows about it. But then forge also needs to know about these different registers. And that's why we register those with the event bus in the register method here inside of the registration class. Now, going forward into the mod items, we've already thought about it a little bit, right? So the registration dot items register simply is calling the register once again. And in this case we simply say eight. So we want to register this inside of the items different register. And we of course need to take supplied the supplier. And this is what then happens, is also need to create a new item for this. And this basically then makes sure that it is, is known by the game, but can also be given a new item properties here. And of course, in this case we only give it an item group would of course add even more. Right? And then why do we use the registry object type here? Well, I'm into boated bluntly. It's basically simply the return type of the register method here from the deferred register write. And we can also see down there, it adds a supplier to the list of entries to be registered, returns a registry object that will be populated with the created entry automatically. So basically does all of the job for us automatically so that we can use this copper ingots are examples of its registry object. So we can actually use it. Well, anywhere in the, in the model where we want to, we need to use it, right? So we have a reference, a static reference to this item already in place. Well, we haven't referenced to the registry object, but it is as good as the item because we can simply get the item by using.gov, for example. And this is sort of the reason why we use the registry object here. The Y we have this register method is simply has to do with the way that when you have static, when you have static members on a class and you haven't called a method on it yet. Then there's some weirdness with the, with the loading, with loading in the different order. So it's, it's, you know, this actually needed. And when it comes to the MOD blocks, Well, this is, I mean, almost exactly the same thing, but we have Registry object once again, just this time with blocks, right? And down here we have, we made another method. Now, this might also be a little bit confusing at first, but I do believe I have explained it in the blocks. And the blocks one, maybe not good enough. So the idea here is simply that instead of calling the blocks dot Register method directly, we're actually going to put this all inside of a private method. Because we also, in addition to the block, we also want to register the item that belongs to that block, right? Which is an Block item. Of course. Now, to do this, we simply say, hey, let's just do this in this register method because that's way easier than writing this first and then writing the second each time you make a block, we can just say, well, let's just refactor that into a method. And this is why this method is in year. And it looks a little bit different versus the MOD Items class, right? That sort of rounds this off. I hope that this was sort of useful to you. I understand that there are some concepts which were of course a little bit more advanced may be thrown in here. And so this is sort of an extra explanation video. I hope it's clear it up at least a few things. And going forward, I hope that other lectures are more illuminating, let's say anyway, if there are any questions though, concerning this, so concerning anything else, of course, this was a little bit more theoretical, let's say in nature. And we just went through the, the classes a little bit. But yeah. So if there aren't questions, of course, feel free to ask and I'll be shorter S1. And yeah. 44. (Minecraft) Our own Custom Creative Tab: All right, let's continue with the Minecraft course. And as mentioned in the last lecture, I have already added the Copper or, and the copper wires into the game. And be sure to, if you haven't done that, actually be sure to look at the last lecture. Or you can also find a text file in this lecture with all of the things that you needed to add and the classes they need to be added into. And yeah, just make sure to follow that and that into the game cuz that's gonna be important now. But however, in this lecture we're actually going to create our own tab. So our own tab in the menu, in the creative menu. And this is actually not that hard. So what we're gonna do is we're gonna create a public static final item group, which we're gonna call, let's say of course tab. Let's do this course tab. And this is simply going to be a new item Group. And then it's going to automatically generate a whole bunch of stuff here. Inside of these parentheses, we're going to have the name. So this is going to be worse tamp, let's say. And then here it actually once a, an icon. So this is an item stack that we return and we will simply return a new item stack. And we're going to do the mod items that let's do the copper wire dot get. So we're actually just going to return our copper wire. And in here we also need a semicolon at the end. And then we've actually already created, now to use this, we actually need to go into our motto blocks and Ahmad items and change the group here to our new group that we've created. So MC CourseSmart dot Course tab. And then in here as well, MC dot-dot-dot Course tab. We're just going to copy this over and put it in here as well. So now both are ingot and our wire and also our block and our or, or all we also always and every item that we create afterwards is always going to be inside of our own tab. And we can of course create even more tabs. But in our case, I think one tab is going to be enough for the purposes of this course. We're not going to create 1000 items. And we're gonna keep it, you know, maybe in three digits. No, I'm just kidding. Of course. We're not going to create that many items or blocks. Yeah, let's see if that actually worked and how that's going to look inside of our game. So first things first, you know, our block and our Ingrid are still there. And then we actually can see that we have a second page here. And up here, we can actually see that that is working. Now. There is actually item grouping dot Course tab is not yet localized, but our items and our blocks are all there. So that's great. But we actually still need to localize this. And this is of course happening in the EN us, Jason. And that's also not that difficult. We just going to do item Group dot Course tab. And that's going to be the Course tab, and that's it. And then this is localized and that is basically all we need to do for the so that when you hover over it, you actually get a different different text displayed. Yeah, and that is it. This is actually how easy it is to create a new course tab and a new item group. So, yeah. 45. (Minecraft) Create a new Recipe: All right, let's continue with the Minecraft course. And in this lecture, we are going to actually create a new recipes, right? So we're going to create our own recipes. And they can be whatever we want, whatever you can imagine. But first of all, we need to create a few new folders. And the first folder is inside of the resources folder, we need to add a directory, which is gonna give me called data. And then this, in this directory, we actually create the MC course directory again. So this is basically the name of your mod ID. So the AID. And inside of that we have a recipe, recipes, recipes, so plural folder. And inside of that goes E, goes the recipes. So for example, let's say we want to create a recipe for the copper block, right? Copper blog.js Jason. And basically how it's the way, in this way, this is structured, is basically with the type of recipe. So in this case, this is going to be a shaped recipes, so crafting shaped. And then we need to specify a pattern. Now this pattern looks like this. No, it's actually those brackets. And then this pattern is basically three strings. And you usually want to write them like this, because then it gets easier to imagine. And then we will actually have a pattern. So let's say XXX, XXX, XXX. And this is basically your crafting table, right? So this is the first row, second row, third row. And if we then leave, for example, this one empty, this would then mean that the middle part of the middle of the, of the crafting, the table is actually empty. At that point. We're actually going to do XXX all around. And now we actually need to specify what this is. So we actually need to specify a key, once again here with curly brackets. And then we want to specify, okay, what is X, o, what is x? And x is an item. And in our case, this is mc course. Worse. Hopper ingot, right? Because that actually makes sense to have nine copper ingots make a copper block. But where do we specify the copper block? We'll, we'll specify that in the result down here. And that's going to be another item. And that's going to be Mc, worse. So this is our MOD ID again, and then the name of this item. And that has already it. When it comes to creating a shaped recipe. We're going to take a look at that. We will actually take a look at the shapeless recipe as well. So we're going to create a new file and that's gonna be the copper ingot dot JSON. So basically the, exactly the other way around. So here we actually type, once again a type and that is going to be Minecraft rafting, shapeless this time. And then we can specify group, but we don't need to, so we're just going to keep this empty right now. And then it has actually pulled in ingredients. And in here, we have such a thing. And now I don't know, nueve formatted it so weirdly, but OK. And then they're going to have items in it. So item and then MC, course, copper block. Another reason why we want this to be shapeless is basically because we want it to be able to put it anywhere in the crafting table. In a four by four, in a three by three, whatever a crafting table we have and still have it, return that. And that is going to be a result of the item MC course Copper in it, right? And then we can actually specify how many. So we can specify count nine in this case, right? Because we need a nine to craft a couple block. And then we can use nine. And then we use a copper block to get the nine back. So this, you can, by the way, every time you do a result, you can do it like this as well. So you could in theory say count ten and you would get ten copper blocks from it. Of course, that doesn't make a lot of sense. So this actually should work. Now, totally fine. Let's try it. Let's run and we're going to see each other in microwave once it has loaded. So yep. All right. Now we're in Minecraft and I've already set down a crafting table and we're going to see if this worked. So if we fill this up, you can actually make a copper block. And we can also put the cover block in and get the nine ingots out. And this is by the way, also added here. So this works totally fine. And the shapeless one actually means that, like I said, we can put it in wherever we want to. And we can also, if we are in no, sorry. This way, if we're on survival and we can actually put it in here and also get the nine pieces out, no problem whatsoever. So yeah, that's basically how you can create new recipes. And once again, after this, there is a very short assignment that shouldn't be that complicated where you actually have to create two of recipes of your own. Like I said, it shouldn't be that crazy or that some difficult. And yeah. 46. (Minecraft) Block Drops with Loot Tables: All right, welcome back to the Minecraft course. And in this lecture, we're gonna talk about loot tables and what happens when blocks get destroyed and they should drop items. So in our mock blocks, we have two blocks right now, the copper block and the copper or block. And what we want to create basically is some sort of system where when we break the copper block, the copper or block, then it actually drops the item. Now how we do this is with loot tables, and this is actually not that hard. We're gonna create a new folder here under data MC cores. And this folder, this directory is going to be called loot underscore tables. And then inside of that directory, we're going to create another directory, and that's going to be called blocks. And inside of there, we're going to create a new file, and that is going to be copper underscore or so. Once again, our name here, Jason. And I'm quickly going to copy over something that already have prepared and then we're going to quickly talk about. So the first thing that we specify as basically the type that we want to return. And then we have to create sort of or rather the type that is that has been loot table so to speak. So we destroy a block, right? And then we return something else. Now. Then we have to specify a pool. And this pool is basically, in a sense, we roll, in this case one time. And then you can, for example, a place certain trans to having something be dropped. And in this case, we're just gonna roll 1s and we're going to say, well whatever happens, it's always going to drop a copper or item type, right? So here we specify, hey item. So this is an item, copper war. That is basically the magic right now off the block drops. We're just going to look at this for a second and I'm gonna see what that brings. This gonna start microscope. And here we are in our world. Now, let's actually switch to creative mode and give ourselves a few copper block coupled or blocks. And also get a nice pig acts with which we can mine this. So let's just lays down these locks and then actually changed back to survival mode, no, survival mode, a ego. And then we can mindless and put all 0s or actually drops comparable or blocks. So we can just mind this out. And there we go. Now with the copper blocks itself, they don't drop anything because they don't have a LU table associated with them. And that is also something that is to be done as an assignment. It's a very, very small assignment. It is basically just changing one variable in the JSON file and adding that. I will however add as well. This is very important. Every time. Let me just quickly close out of this. Every time we add a new item in the MOD blocks or a new block in the blocks class. In the future. I will not specify like I will not specify specifically like add a new Lu table. I will just let this basically do is between lectures. Because for our purposes, the LU tables for the blocks are not that difficult. And it is basically just copying the file, changing of like basically just the name. And then that's it. This is why every time we will add another block, I will not I will not record why how I add the LU table. I will maybe quickly say you need to add that new table yourself. However I will. When you download the changes so that when you can look at the changes for each of the lectures, you can actually see that I have supplied the LU tables for all of the blocks as well. However, I will not specifically recorded because I don't feel like that's going to get any value out of it. See me copy and paste something in, and then changing one name. Doesn't seem to be that big of a deal, right? Yeah, that is basically all that there is to adding a loo table right now and to adding a block drop. So yeah. 47. (Minecraft) Create a new Food Item: All right, welcome back to the Minecraft course. And in this lecture, we're going to create our own food item. So to do that, we're going to create a new class inside of our item package. And that is going to be a new Java class cooled copper Apple. That's the best thing I came up with, if I'm absolutely honest with it. And this is going to extend item. And then we're gonna create a new constructor here with nothing in it. And we're going to simply return our actually we're going to do super, thats even, even better. And inside of here, we're gonna do a new properties. So this is basically the same item properties that we did inside of our mod items right here. But we're just gonna do it right here because we also want to specify a few other things. Because this is, well, this will be considered a food item and therefore, we actually want to do this year. So we're going to first of all do something like we're going to do dot group, no group. And this is just gonna be Mc course, Course tab again. And now we want to add the food property here. Inside of here we're gonna create a new food data builder. And there's food build are basically allows you to bunch together a bunch of properties as well. It's same with properties, but in this case, we actually want to create food properties. So for example, maybe hunger five. And then let's just formatted a little bit differently. There you go. And then we're going to do saturation 1.5. And then we're gonna do an effect. So that's going to be interesting. The effect is basically any potion effect we can put in any potion effect for that we need a supplier of a, of an effect instance. So we're just gonna do new effect instance. Instead of here, I think blowing might be the best one. This is the duration and this is the amplifier. So we're just gonna do a one. We're going to zoom out a little bit and be a little bit small probably, but hopefully still readable. And then after the effect instance, here we're going to create, we're going to write in a float probability. And then after the effect duck-billed, I'm going to also put that next line. And then this close, and that's it. There we go. Corporate Apple. That's basically all we needed to do to have this be a food item. Now of course, we also need to register this in our mod Items class. So we're gonna do final, static, final than register, registry object, you know the drill item. And this is going to be the copper apple. And this is going to be registration dot items, DOT register. And now we're going to do the copper, copper, copper at Apple. And then this is instead of returning a new item, we're actually going to return a new corporate Apple, and that's it. So we're not actually going to pass anything in because we've already done this here. Now of course, what we could do is we could also give the constructor a properties perimeter and then pass it in and then do it like that. I have to be honest, this works totally fine as well. You can however change it if you want to or you can also experiment a little bit. This is also something I have to mention is extremely important. I just experiment with a few things. If you think why, why is this done like that? Then maybe try it another way and maybe it's going to work or maybe it's gonna throw an arrow that hopefully then tells you why. Maybe the approach that you thought of didn't, doesn't work or maybe you have to change something. It's very important to just experiment from time to time. Okay? But there are a few other things of course, that we need to add. So we need to add, of course, our nice texture. So we're going to add texture, but here we're going to quickly copy this over. Yep. And then we're going to also add the JSON for model. This is gonna be a new file. This is going to be the copper apple dot JSON. And then I'm going to quickly copy this over because we've seen this a few times now. Looks, it shouldn't be a surprise. And then we, and then we just need to add this in here. And we're actually going to do that. And then I have this one here. Item.name scores dot copper. Apple is going to be copied. Apple. Right? Now. We could also immediately add the recipe, but we don't need that right now. Let's, first of all, to start Minecraft and see what we have in there. And as another note for this experimentation, or really, I really think that is an important thing to do. Well, Minecraft starts here. I'm just going to mention this. Just experiment a little bit. Like, I think it's good if you go through the course once, what an experiment. And there's a few other lectures where I'm going to talk about this a little bit, in a little bit more detail, especially at the end. But the experimentation, this is like how you really like, really learned the absolute ins and outs in the end. Because there are sometimes maybe special things that you wanna do that aren't covered here. And they will go corporate apple. And now what we can do, we can actually, let's go back to survival, then eat one. We can actually eat it. And that is probably because we don't have any hunger. So let's actually are easy. Otherwise, you won't build ourselves up a little bit, take some damage and then, and then let's see. All right, so that's, that should, at some point in our hunger. Going. There we go. Okay. And now what can we do? If we did? Now we actually haven't gotten the 50% chance now, because it's only a 50% chance to get to the glowing effect. It's very, very important because that's what we specified. I am going to show that it once again. And we've actually gotten it. And let's hope that we get it. Let's see, there we go. Now are glowing. Isn't that great? Nice, right? So this is basically how you add a food item. Now I actually want to quickly go back because we, this was in the corporate Apple and that's right here. Write the probability right down. So this affect instance. And it's, so it's actually the effect itself. We actually have to specify a probability. Now this is 50%, right? 0.5 was just 50%. If we put in one, then it's going to fire all the time. Now for, like I said, I've put in 50%. We could, for example, imagine that this could be somebody that's configurable, right? So we have a config file, which we're also gonna talk about in a later lecture. And we could then maybe say, well, per default it would be 50%, but maybe someone wants it. Hey, I actually wanted a 100% of the time. I want to have the glowing effect when you eat it. So that's gonna be a interesting thing to consider. And that is basically how you add a food item. It is not that different from just adding a normal item. In this case, it's just adding this food property to the item. And yeah. 48. (Minecraft) Create a new Set of Tools: All right, welcome back to the Minecraft course. And in this lecture, we're going to create our own tools. So this is going to be interesting definitely. And also it's gonna be a little bit tedious because we're going to basically do a very similar thing five times over. However, I'm going to go through creating a shovel, a sword, pickaxe, Ho, and an ax. All in this lecture. And well, I guess we'll just start. So in the mud items we're going to create a nother registry object. So a news public static, final registry object of type item. And the first one we're going to just try is going to be the copper shovel in this case. So and this is going to be registration dot items register and then give it the name copper underscore shovel. And this is going to be a new shovel item in this case. Now, we actually need to supply it a item tier here. And before we can continue with this, we actually need to add a new item tier for our mode because it doesn't make any sense. So what we could do, I can just show you so we can do item tier. And then we have Woodstock another write, iron, gold, and diamond. But that maybe, you know, we want our completely own items here because, well, I mean, why be beholden to the other stuff we can create completely from scratch, our own thing. So we're going to do that in our map items completely at the bottom, below the register function. We're gonna create a public enum, and that is going to be called the mart item here. And this is going to implement the very nice interface of items here. And then we're going to implement methods. Now those are the methods that we're going to implement. Those are also the different things that we need to specify. So that's basically the first thing in this class we're gonna do is we're gonna get copper. So this is basically the enum copper. And then we're gonna specify also what type of return values it has for each of those different variables, which we're now going to create. So this is going to be private final int harvest level, right? So this is basically what you can mine in the end. Then you're gonna create a private final int max uses. This is how often you can use it. So the, so basically the durability of the, of the tool. And you're going to have a final float. Efficiency. This is basically the speed modifier. How fast we can actually mind something. The attack damage is going to be, well, the attack damage funnily enough. And then we have an int, which is Incheon teachability. This is just how good of an transmits you can put on there. And then we're going to have an in gradient which is going to be repaired. A repair material, actually material. And that is that specifies what type of material we can use in order to repair these types of items or this yeah, this item. So we get a bunch of arrows here. Not worry, what we can do is we can just, now, after we've specified all of those, you can actually hover over them and say Add constructor parameters. And now we can just select all of them. So we can just select one or Shift and then select the other one, right, like this and that it is going to select all of them. Then we're gonna say, okay, and this is all fine. Just say refactor. And now we actually have a new constructor created here that already has everything in it, which is really good. And now this one, of course, we need to specify a few things here, but that's not to worry. So that's the first thing. So maybe harvest level, we're gonna do two. Max uses a 150. I'm just going to put some numbers in. The list will be deficiency to 0.5. We're going to have no attack damage on its own. And interpretability is going to be like a 15, so not too bad. And then we're gonna create a new ingredient, actually, excuse me, the ego. This is going to be ingredient and this is going to be from stacks, new item stack. And then this is going to supply the mod items start covering because cup and then dot GET very important. Just to create an item stack, we actually need to have an item provider in this case. And this is done with using the get method here on our item. Yeah, this is basically we'll need to do to specify copper. Now, for example, if we have a, oops, if we have a maybe another in a future, maybe we want to add, you know, aluminum ALU minium. Well that's going to rile up some people, aluminum or aluminium. And then we can, for example, have something new, very important. Then we don't enter this one with a semicolon, but with a comma. Because this is basically still an enum. That's just, you know, as a side note basically. But Yeah, right now we're going to keep it at copper. And now we actually also need to return those those variables here. So we can actually do return harvest level, then return efficiency, return the attack, damage, the harvest level, the enchant ability, and right here then the repair material, right? And that is all we need to do for our motto here. Like I said, you can add as many years as you want. You know, you can add copper and then maybe zinc and aluminium and all sorts of other things you might want to add. In this tutorial, we're just going to add oranges lecture. Specifically, we are going to just add COP. Okay? So let's then go back here and then actually say mod item tier dot copper. And that is the beauty of what we've done. Instead of having to use the iron or other things, we can actually use our own. Now, so we're gonna do 00 for this and then we're going to quickly go to new item properties? No, definitely not that I don't know what he's doing here. Item.name, properties, please. Thank you. And this is going to be this yeah, actually, yeah. Default macs damage is going to be a 150. And then we're going to add a tool type. This is Lake. The most important thing there is is going to be a tool type dot shovel, of course, and the level is going to be two. And then at the end we're going to add a group. And this is going to be our, of course, our own tab. And that is already ID. Now, this attack damage at this speed modifier or basically just, you know, how, how fast you can hit something and how much damage it does. I would say that a shovel in this case doesn't do that much damage. And we're actually going to complete the shovel and then we're going to add the other ones afterwards. So just that we have this done. So to add the shovel, we of course need to also do this in here. Alright, so we actually know this is under item, but I'm going to break this off from the main group because this is like a special item. Let's say this is going to be the copper shovel, and this is going to be the copper shovel rate. And then inside of our items models, we of course need to have that as well. So the copper underscore shovel db.json. And this is going to look something like this. Just a quick second that there we go. This is it, right? As you've already seen, this item generated. And then in the layer 0, we're just going to have m scores item, flash, copper shovel. And then we of course need to supply the texture as well. We're gonna do that. I'm just going to quickly copy this one over 2p. And yes, of course. And then we have the copper shovel in there as well. And then the shovel itself should already work perfectly fine. Let's see. And let's see what that is. Now. The big thing definitely was the mock tier, getting that done. And then the others are basically a little bit of copy and pasting the same code that we already have, right? We just create different types of objects. So we're gonna create a sword item, pickets item, and so on. So that is all that is really needed there. So let's see what happens here when we go in here. So first of all, switch to creative mode. And let's see. Aha, there is. So we actually have this. This has not been Oh, did I put an items instead of item? Item MCQs, copper shovel. Well, I forgotten l at the end, so that's the reason why that is not working, but that's okay. So let's see and let's see if we can actually mind some dirt with us. And yes, we can. Definitely much faster than it's not much faster, but it's a little bit Foster. And let's see sand. Yeah. Sanders definitely faster than with a hand. And we can also see that this has an attack damage of 100 in tech speed of four. So actually the textbook is quite high. All things considered. Okay, so, but it's not very effective as a, as a tool for killing people. Killing people. I mean, killing other Minecraft players or mobs in this case, but yeah, but it is, it is working. So we can actually use this to mine out items. And as you can see, it also has a durability. So this will break just as the others will also. But what we can also do is we can just quickly look at, for example, if we know that's not what I want. I actually wanted a an anvil. Sorry. That's what I wanted an anvil. And I will do is we can look at this, we can put it in here. And if we then put in our copper ingots, we can actually repair this. This is basically what we specified with the ingredient there. And this is, this is also working perfectly fine. So that's pretty good. We're gonna save that and then quit the game here. First of all, we're going to fix this one because that is just that it's just embarrassing. Yeah. And then basically the rest is a little bit of copying and pasting. So we're gonna just bobber gonna go through this together because, why not? And then we're going to have a hopper sword. This is going to be a item. And then you actually have to specify, well maybe it to here. And this is by the way, not a float about a, an integer because the short does way more damage. And then this one very important has to be done. Actually, we don't need a tool type for the source because the source is the one that doesn't have a tool type. And then we have a copper pick axe. Right? Like I said, is, it's a little bit of copying and pasting. In this case, we're adding a and entire line of tools, and this is a pickaxe item. This one is also an integer for the attack. And then we're going to create a, How about a copper hold? And I mean the tool, please keep it PG here. And this is going to be a copper hole. And this is a oh, item. This one, as you can see, some of the things are not localized, but that doesn't matter because we actually know what this is based on the other things that we've already created. So the other constructors, and this is then the copper ax. And copper ax. Whoops. How about a copper axonal 6EI? We're not Elon Musk's child, sorry. Acts item. There we go. And then this is an axe as well. Very well done. Okay. Yeah, so that's basically the item registrations done. Now of course we need to also have the models. I am simply going to copy those over and going to quickly show them because that is way easier. Of course, those files are all provided where this is the copper X, it's all the same here. All files are provided as always in, actually in the first download, every lecture was provided there as well. So let's actually do the textures as well. And then we still need to add this. And I'm also going to copy this over because once again, just typing Me, like see me typing this out probably doesn't help anyone really. Ok, so now those are inside of here. We have done the models item. We have localized them in the EN us. We've registered all of them. Maybe just simply add this one as well. So maybe say something like the acts. A little bit more damage here, but a little less speed, maybe like minus three or something like that so that it's a little slower, which is usually how the micro cracks works, I believe. And then let's see what we can see when we actually go in and get these items. Now, of course, these items do not have recipes at this moment in time. I of course think that the recipes are, in our case, not that important because they shouldn't be that It's hard to implement on might. Just show you one of them right now. After we've demonstrated that the rest works. So let's see, let's just get rid of those things. Actually keep that. And then let's see what we have. We have a sword. That's pretty good. We have a, an axe, we have a pick ax, and we have a whole. So let's see if we can hold. We can that's really good. And also time set. They please. Thank you. And we'll see this one works. Well, of course this works because I'm afraid of mode. There we go. Okay, yeah, this one also works so we can actually tell the ground. Let's see. We can actually guess now it's not very fast, but maybe we actually don't want the copper to be very fast. We can also mine with this because it is not very fast. I would, I think it's a little faster than stone, but slower than iron, I believe. And then let's also take the sword and just quickly kill that pig over there. Right? And of course, what we can do is we can always specify the differences here. Well, we can also look at this. So let's quickly get like maybe, I mean, maybe not nether, right? Maybe like an ion sword. And then maybe also a pickaxe, just as an example. So the anthropic x actually has way more, way less tax speeds, right? So the tech speed here is definitely way too high and a little bit more damaged. And then a six, right in our textbook there is also way too high. But once again, maybe this is something that's like special to the copper items, right? That they are like the oven insane attack speed, right? But they don't have maybe that high of a, of a. You know, durability and also of the attack damage maybe, right, so that you can attack with them like really fast, but you can't really do that much damage with them. And then we're gonna just quickly look at maybe a recipe, right? So we're going to just copy one of those to stir quickly due just to control c and control v. And then we're gonna change this to, let's say the copper acts for the sake of argument. And then this is of course, the shape was one that was not the smartest thing ever to actually gonna take the block here. So let's take the blog and then let's say C, C, C. And then have this one. Yes. This, then x is gonna be Minecraft and this is going to be stick. If I do say so myself. I do believe it that it is Let me just quick double check because I want to end up yes, of course it's the I mean, what was I thinking? Of course it stick. What else would sticks be cold except maybe sticks, right? That's, that's that was my fault. So MC cores and Alice is going to be covering it. And of course this is how we would do this. Of course also do this. This would also work. Doing it that way, will also have the other side done in there already as well. So let's just quickly do this and let's see if that actually worked. And then, then I think we will actually be done with this lecture, yeah, with how to add the items. It's like I said, a little bit of, you know, I say grunt work. You have to type a lot of stuff and you have to copy a lot of files. Now, I provide everything and as resource, of course, so that's not going to be an issue. I hope. Let's actually go back here. And let's see. So give me some sticks as well. Sticks and stones may copper my bones. And let's see if this worked. And well, that's hilarious, isn't it? What have we forgotten? Of course, the only thing that we're that we've forgotten actually in the copper axis to have the result be the copper ax. So there you go. Yeah. But of course that's not that big of a deal. We've actually seen that the, this recipe worked. It just returns the wrong item. But that's okay. And the overall, that is basically how you add tools to the game. First thing that we did, of course, was the item tier that is very important. And this is also a way to look at basically how to, how the to, to basically tear your items, right? So it is possible you could copper, like I said, and then maybe get bronze, which is even better, and so on and so forth. So if you've already seen or played other popular modes, then you have definitely seen the way that that works and that those are also very interesting. Anyway, this was basically it. And if you wish, you can, of course, add the recipes yourself. I will now not add them because they should be trivial at this point to add them. And also they are that important in this case because like I said, they should be trivial to add. And we're going to test a lot of stuff in creative at this point anyway. So yeah, yeah, like I said, as well, the textures and the Jason's here are all provided as well. And yeah, that was basically how you add tools into Microsoft. So yeah. 49. (Minecraft) Events in Minecraft Modding: All right, welcome back to the Minecraft course. In this lecture, we're going to talk about events. Now, events range from a whole bunch of things that can happen in Minecraft that we can actually, let's say, get listeners to. So then we can respond to that and have things happen. So the first thing that we're gonna do is instead of our MC course package, we're gonna create a new package which we're gonna call events. And inside of that package, we're gonna create a new class. And we will call that motto events. So this mod events class is gonna be really interesting because in there we're going to specify two events. And these are example Events. And then we're going to talk about a few things. So the first thing that we're gonna do is it's just gonna be a public void. And we're going to call this uncovered sheep class. And now whatever we pass as a parameter is going to be the event that actually basically triggers this. So when we go down, suddenly we cannot see them like this, but you can see like this. So in this case, an attack entity event happens each time an entity is attacked. And then there are, as you can see, in this case, there aren't any living attack event. There are, there are numerous types of events. In this case, we're gonna use this, the attack entity event because we want to know when something is attacked. And now how do you deal with this? Let's say, well, first of all, we need to actually add the subscribe event on top of that. This is so that actually see if the tooltip has anything. Yeah, that's actually does. So basically the idea is that this class, then it can be for this class and then this method in this class can actually be cold via this event that is fired. That's very basic explanation here. And so what do we want? Well, uncovered cheap, basically, we have implemented the fact that when you eat uncovered apple, then you get glowing. How about what we implement is that when you like a taka sheep with this apple, then they also get the glowing effect. That is something that might be an interesting thing to do. And remember those events you can, I mean, you can basically almost do anything that your imagination, you know, gets to. However, you know, as the more complicated the event you want to put in, the more, the more complex the code is going to be in, a more complex is going to be to do. But we're just gonna go through this. So first of all, we want to get the event and there we can actually get the player. And then we get held item, main hand dot getItems. Write this simply will return the item as an item. And then we can just say, hey, if this is equal to mod item's dot com or Apple dot gets right. So this basically just asks, Hey, does, is the player right now holding the cupboard apple in his hand? And if yes, then we're gonna go in. Great. The next thing we want to talk about, or we want to ask is basically the target. So if the target is alive, right? This would be the cheap in this case. So we attack something and then the sheep, the sheep is still alive. That's great. We will then have to use the living entity here. So this would be Target. Target is equal to living entity event dot, event dot target. So what's happening here is basically I'm just costing the target, which is a, an entity into a living entity, right? And I'm saving this because in this case we need the living entity. So we actually ask if Target instance of sheep entity. And this is basically just asking, OK, if it's this target, a sheep, that is all that this asking because the sheep, as you can see, actually extends the animal entity and animal entities eligible entity and its creature entity and that's mop entity and that's living entity. There's a lot of, as you can see, a lot of inheritance going on here. But basically a living entity is also a sheep entity or rather the other way around. I'm not sure now, but that's not what's very important, but they are however related in, in inheritance. And if that is the case, then what we have hit right now, when we reach here is a sheep. Now, what we want is the player. Let's just quickly get the player. Because why not event dot your player? And then what we're gonna say is player dot, get item, main hand. And then we're going to shrink that by one. So what this does is it's going to, I mean, let's say delete one of the held items, right? So in this case, we're actually going to use one of the cupboard apples for that because, you know, just hitting it and then having this add, this effect would probably not be that, you know, whatever and I balanced idea. But in the, in that sense, you know, we're not talking about balance really. And then we're going to do target and we can actually do ADD potion effect and we can add a, another. For instance here, this is basically the same thing that we did with when eating the apple, where we had affects dot glowing. And then we have the duration that we had to actually specify. Let's do 600 just for the sake of argument right now. And yeah, and that was basically it. And then I'm also going to add, just because it's going to be interesting to see, we're going to do is remote. So this basically just checks whether or not we're on a server or not. And I have to just after we've done this, I actually have to say something else for that. So we're going to just have an output of a message inside of the, inside of the our chat in, in-game, right? So this is going to be text formatting dot. Let's just do another, you know what, let's actually do something like yellow, Yeah, like that. And then we're gonna do sheep is now glowing, glowing, legal acid like that. And then we're going to play R dot, send the message. And then we're gonna do a new string Text component. And instead of that, we can just put the message. And then we actually need to also supply it with the unique ID, the UE, the UID, the UUID of the player. And that is basically the An event that will now fire. So we're gonna fire this method each time an entity is attacked. And it's gonna ask, well, do we have a cupboard Apple in hand? If yes, then we ask, is the target alive? Then we ask, well, it's the target sheep. And if that's the case, then we're gonna go through here and actually at the potion effect of blowing through the cheap or the duration of 600. And we also need to add something here inside of our mod mod class. So the MC course mode, and that is going to be Minecraft or event bus, that register. And then we want to actually create a new mod events instance right here. And we can actually hover over this, I believe is the register rate. So we can either have the an object instance so created with new or we can just do a class instance. And then we would have to do this in static. So this would have to be a static method. In this case, we're just gonna do a new one. I think that's just totally fine. This is going to work fine. And this should already be all that we have to do for this particular event. Like I said, we're going to add another event, a second one after we checked if this works. And then I also have something to say about the server side and then also something to say about the next assignment, which is going to be a little bit more creative, but I'm getting ahead of myself. First of all, let's see. Oops, so lots. Yes, that's what we want. Let's see what we can see right here with the event. So A-LC e will first of all switch here and then we're going to go, or a sheep. It. And now it doesn't matter whether or not we're in a creative or, or not. So this is a cheap and now if I hit it with the covered Apple, we're going to get cheapest glowing. Now this, he, she passed the glowing effect and we've actually lost an apple. The apple was consumed. You can actually see this again, right? I know I have 605958. So each time I hit a sheep with it, an apple is actually consumed. Yeah, and we also get the message that sheep is now glowing. That's pretty good. So that works without an issue. And as you can see, this is like, it's a very simple event. Let's say, well, you can already maybe imagine that there are a bunch of things that we can do with this. You know, you could do all sorts of things. You can change the position of a, an entity. You could kill it outright. You can maybe even heal it. You could do all sorts of things with items and, and different events happening. Now the second thing that I wanna do is basically each time we, when we have a, when we have a sheep that is glowing, right? Then what I actually want to have happen is we want to have a drop, a copper ingot, right? That's just a, you know, like a cute little idea, I think once again, is probably when you would release a model like this, it probably wouldn't be that great. And let's call this on sheep drops. And this is going to be a living drops event somewhere. I believe I'm not a 100% sure. There is a list of the events that you can call here. And this, by the way, also details a few things of this event. That's really good. But there is a list somewhere. I'm going to look at whether or not I find it. If I find it, then I'm probably going to link it or not probably I'm definitely gonna link it has resource on this lecture because it's, you know, you cannot know what events are happening here, right? So there's also a undef event. So when the player dies or you can have a event when a, an entity diets. So there's so many things that can happen. And as living drops event when we actually hover over it, we can actually see that this is fired when an entity is death causes dropped items to appear. So this basically, before these items appear, then the event fires and then, so we can actually change a few things. So what we're gonna do is we're going to do a living entity. That's going to be our entity. And then we're gonna do event dot get living entity, entity living there. Yo. And then, first of all, we asked whether or not this is a sheep, simply because of the fact that right now we are only concerned with the sheep that are glowing and not anything else. And we're going to go for a World, World II entity, sorry, entity data, DT world. And we need to import the world loss here. And then we're going to actually save the, there's gonna be a little bit complicated and so those are the drops gets rubs. So basically we say, okay, what drops would have dropped from the sheep, right? For example, wool and what is it, the meat from sheep actually, right now, don't know what it's called. I'm gonna check right now is as soon a warmer in-game. I actually don't know, whatever. So those would drop. And then we're going to actually save those and drops and then buy adding to the drops, we can actually have something else added as well. So this is going to do that. Now. I'm going to actually do something just so that we can simply, now that's now what I want. Manager dot get logger. And then we're going to debug. And this is going to be Entity dot, get active ocean effects just so you know what, what's what's the issue here? Why does that not work with the log Manager? Non-static method cannot be referenced from a static context. Oh, well, I mean I would I didn't know we were just doesn't make any sense. Very certain that we do exactly the same thing up here. So well, that makes absolutely no sense. But there you go. Sometimes those things that just didn't make any sense that it does anything change here. Well, whatever it might be. Now we can actually have a log c. This is sometimes, sometimes these crazy things. That's why I'm not cutting this out right now. Because this sometimes something crazy contaminant. I'm like, okay. No one really knows what happened there. Well, someone on this planet probably knows, but in this case, that was just a weird bug. Well, and then we want to actually ask is if a certain effect, so in this case affects dark, glowing is active, right? So I have this logger here so that we can actually see in the in the when is, when the microphone is running that we can actually see in the log what happens. So each time we actually hit a sheep, we're gonna get this printed out and then we can actually see what active portion affects the sheep has. It's just an interesting way to do this. And as long as it's debug, that's great. It's also a very important thing to actually do. Sometimes get the logger in there and then just, you know, lock something out and then we're going to do drops dot add. This is going to be new item entity and item, entity. Actually item entity. This is going to be in the world. We're going to do a, it's going to be at position. This is a little bit t is once again because then we actually have to specify each of the three coordinates. So we actually have to do as y and also Entity dot z, where z. And then we're going to do a new item stack of mod item's dot covering it. No, not class copper. Copper in good dot get. Of course once again, because we are creating a new item stack, now should already be it. Yet that is all we actually need to add. To add this very interesting, but actually quite specific. Excuse me. That's actually all we need to add. This interesting and actually quite specific behavior at this point, right? It's not like this. You would see that everywhere, in every mode. And this is basically, you know, how you can think about these events. So you have the idea of Ahmad and you're like, oh, I want this ad and maybe I wasn't like this crazy. Maybe end, end pickaxe That's like really good at in the beginning, but maybe it teleports you around each time you break a block and you can do that. You can genuinely do that. So that's why I'm saying that, you know, your imagination is really the limit here. And now what we're going to see is if we spawn a new ship, right? Nothing happens right now. If we kill it, we're just going to get this now actually want to know what this is called. It's called mutton. Oh, I was not sure about that one. Actually over here to the sand and then we're gonna fit it here. Now the she was loading and then we're gonna kill it. And look at that. We actually get incorporating it out of this. Now, of course, the thing that we could do is probably something like have the, have the, have a probability for a copper ingot of dropping, you know, maybe like 1% or something like that. And then of course, balance would be restored, so to speak. Now if we actually go back and can actually, oh, well, so much for that one. Well actually we can see it here. There, we actually have the debug here from our MOD events as you can see. And there it is, effect dot minecraft glowing. And then we have the duration as well. And here, when we hit the cheap beforehand and we kill the sheep beforehand, we actually had nothing in here, right? So this was completely empty. And then after we hit it here, we actually had a or we killed it. We actually had the get active effects and one of the most effect minecraft dot blowing. So that's also very important. Know, sometimes you want to debug something and then you just use the log Manager. Now this is not necessarily the best way to, to reference a lot manager budgets getting the allotment of sciatica logger, but it's going to be fine for our purposes in this case. One more thing that some events have to be done on the server side and some events have to be done on the client side. At this point, this is going to work on both the server and the client. But there are some, let's say, very specific things. But once again, there are so many events that can be that can actually be referenced that it's hard to do like a short summary or or, you know, to, to summarize them. And any additional resources that I find interesting for this or that are going to help you with this. I'm going to put in to the resources here. And also the, you know, it can be sometimes a little bit tricky. But once again, the important thing when you don't, like when something doesn't happen, use the debug manager or the debug manager, the AlarmManager, and debug some things out. And also, I believe that that would be it's in its entirety. So I have the a small additional assignment after this one. And I want to quickly touch on that before this lecture's over. And this is where you actually have to create your own event. And this is complete freedom. You can create what you want. You can do crazy stuff, you can do everything, anything you want. But it should be one method, right? So one, basically one event here. And it can be anything. It can be you jump up and then all of a sudden a 1000 GoldieBlox dropped from the sky. And it doesn't matter anything that you wanna do. But it has to be, you know, the more creative, the better. It's not necessarily graded, let's say, but I will look at them. And I'm actually really excited about like by what you come up with, right? Like I'm, I'm actually like a mildly excited because I actually hope for like some crazy events would be pretty cool if the events are, you know, sort of like this length, you know, or even longer, but not like not like two lines. I would like I would be a little bit not sad, but it would be not the best thing if we're only two lines, but of course you can do whatever you want. The assignment is very open-ended. That's why there's really no, no solution to it. Like as long as the event works, you've you've done the assignment. So I'm very interested in what you can come up with. And this was basically it for the event lecture. I hope you got something out of this. And also, if there are any questions, once again, feel free to ask at any time. And also, if you have, if you feel like you've actually achieved something and have gone further in developing a model. I would really appreciate it if you could leave me a review. And yeah, that is basically all our to say. Thank you for listening. And yeah. Or, or just a short little addendum here on this mod events one. And I have actually an easier way to figure out what events there are. You can actually hover over, for example, this attack entity event. And then you just go through the extends tree basically until you find events, right? And then you simply gonna at its source right here. And then the event of Java file we'll actually open. This is somewhere in the, somewhere in the other files, like in the external libraries. Don't worry about it. Well, what we can then do, and this is like actually grade, we can actually just do control age. And then the entire hierarchy will open. Now, you might be like, oh my god, this is a lot of events. Yeah, it's even more because there are block events that we can reference, right? And then without piston events, entity place events, you can have cropped grow events. We can have world events where Shang, You know, and then those that we actually used where an entity events and we use the living entity events, as you can see quite a few here. And then there are also Player events. And as you can see as well, a lot of events you can reference. So and in theory, when you have the events that you go for, you really are not limited by anything here. As you can see, there are so, so many things that we can do, and especially you can do for the assignment. So yeah, that's just quickly that I wanted to mention. And yeah. 50. (Minecraft) Add Tooltips to Items: All right, welcome back to the Minecraft course. And in this lecture, we're going to create a tooltip for an item. Now, this is actually not that complicated. And what we're gonna do is we're gonna create a tooltip for our corporate Apple, because we already have a corporate apple file. So a class that is dedicated to this item. And we actually need a class or for this method that we're going to add. So we can't just do it in R mod items. We actually have to have a specific class. And I usually also, this is something that can be thought about. Sometimes we actually want our items to have a separate class, and sometimes we don't. Now in the course of our app, in the case of our Apple, sorry, we actually have it because we wanted to have a food item. And sometimes if we want more specialized behavior on items, then of course it makes sense to have a proper class for them. But yet, so we're just going to use the copper Apple as a guinea pig once again for this. And what we're gonna do is we're going to have a public void. And this could be add information. It's going to take an item stack. Back, is going to have a world, world, a list of ICT text component, which is going to be the tooltip and also an AI tool tip flag, old flag, right? So first of all, we need to import a few classes, import class, and then the world-class and of course the ICT text component class. There we go. And that was already it. Now we actually also need to have a sort of, oh sorry, the list as well. Sorry, a ago. Java.util. Yes, there we go. Now it works. And this is going to be an overwrite as well. Over right? Now, we actually want to have a sort of helper class and we're going to create that in our Util. And this is going to be the keyboards, keyboard helper. I'm just gonna call it keyboard helper. You can call it the keyboard util. You can also call it keyboard. Keyboard Utility Board helper. Input helper maybe. But this is going to be fine. Yeah, and this one will actually have two things as well. And this is going to have a public static boolean. And that's going to be is holding shift. The idea is that you've probably seen if you've played some Manpacks before, that, sometimes it says, hey, you can hold shift to for more information or you can hold, you can hold Control for more information. And this is basically what we're going to implement here. So actually going to, well, it's not going to be that different. So we're gonna do return and then we're going to have a whole bunch of stuff. So this is going to be input mappings. Dot is key down. So this basically just detects whether or not a key is down. And now what we want is we want to have minecraft dot getInstance, dot get main window that get handled. So this is going to return the Sort of the, the address, let say. And then this one is going to be the left shift key. Yes. Right? Sadly, this is not, this is not mapped in this case. But yeah, and very important that this is insanely important. This is going to be only in this dot client dist dot lined. And this has to be imported. This is really important because this is something that only happens for the client because a server can really hold Shift down, right? This is like very important and this is going to be hold down control. And this is going to be, we simply have to change this to control. That is all we have to do here. Yeah, and that's basically our keyboard helper. Now this is just going to help us so that we don't have to. Each time we want to say, hey, if, you know, holding shift, this one, it's a little easier to do. The citizens will also whites in the util class. You know, it's just a little thing that helps us with utilities. Basically, it's a utility. Yeah. Yeah. And then in here we're actually going to ask for the keyboard helper. So the keyboard helper than here. There we go, is going to be is holding shift. That's the question. And if we are, then we're gonna do one thing. And if you are not, then we're going to actually display another thing That's basically interesting is a very interesting way to format this once again. So let's first of all add the one when we are actually holding shift. So this is the thing that we're going to see when we hold Shift, right? So this is going to be a new string Text component. And inside we can just add a string, this basically whatever we will add. So let's say that when we hold shift over the pump, the resit, the apple, then we actually wanna say, turns sheep into copper ingots. How about that? Like that, right? And then the else one, I genuinely don't know why he so we're in the formatting at this point, hurd. Okay. And then when he doesn't have that, we can actually have something generic. Which when you think about it, like this is something that you could also have as a baby in the mod items. You can have in the mod items a static string that always has this, right? Because this is for every item that is going to be the same. But this is going to be a little weird. So this is using seven e. And then we want to hold shift. Sorry. Well, within like as we go, I'm going to explain soon enough. I'm just going to have to replay. Copy this over. And this is 77. And then it's going to be or more formation. Sure. In four major. Okay. That's it. Yeah. Okay. And this is simply a color that is added for the text component, right? So these are, these are colors. I will supply a as a resource here, I will actually supply a, the color. Like I think it's an image where you can actually see what colors you can do. It's almost the same as the, I think it's actually the same as the colors you can have in the in the chat. Yeah, exactly. Right. And then we also want to do super dot-dot-dot information and they just want to add all of this. So world tooltip and also the flag, they would go, right. That is it for the adding the total. This should be it. So it's only the keyboard helper and the copper Apple. And let's see if you actually see this. Like I said, somebody like this, the whole shift one, that is probably something that should be also as a static string of public static string and the mod items for example. Or you could imagine maybe having a, another class or util class where you actually have those strings all saved up. So that can reference them whenever you need. Because adding that string each time there makes no sense. Okay, then we are, now, lets see. So first of all, you know, this is all normal and then here, oh, hold shift for more information. And when we hold Shift turns sheep into a coverings. And that's pretty cool, isn't? It? Adds, I like that. That's pretty nice. We can actually hold Shift and then we get new information. Now, let's actually also you that now it's not going to be so close to the, to the other sentence. Yeah, basically only the keyboard helper and the corporate Apple. But overall, I think that that's still pretty straightforward. And yeah, that was basically it for adding the tooltip. And yeah. 51. (Minecraft) Create a new Set of Armor: All right, welcome back to the microwave course. And in this lecture we're going to add our own armor, right? So what can we do with our armor? And we've already seen that with the the items, the tuples, it was, you know, fairly straightforward. You know, there were a few things but nothing too crazy. The only thing that was a little bit tedious was the more item tier. However, this something that we actually have to do again. So we actually have to create our own mod armor material. So this is going to be a public enum mod armor material. But t is real. And this is going to implement a armor material. And we're going to quickly get the methods here once again. And this is basically the, almost the same thing that we had with the the ones that we had in the Mott items here. Now with the armor. Okay, there are, once again, a few things that we actually have to specify here. So first of all, we're gonna do copper again. Then we're going to create a few private variables. Again. This is going to be a private final integer durability. And then we're going to have a final integer array, which is going to be the damage reduction reduction amount array. That's a mouthful to say that three times fast after another OWL. And charm to ability as the third one, that we're going to have a private final sound event, which is going to be a sound event. And then we have a private final ingredient, which is the repair material. And we will have a private phi o private final string name. This one is very important. And then a private, private final float, toughness, that should be known, but that is then a private final float knocked back resistance. Okay. As you can see, a lot of stuff once again, but not to worry, we will be able to figure this out. So first of all, of course, we are going to hover over it again and we're going to actually create a new constructor with all of those, with all of those variables immediately. And that way we actually save ourselves quite a bit of time writing this constructor. And then we can also do something like that. Yeah, that's good, right. So the durability, I'm just going to put some things in your, so this is going to be a new integer array. And I'm immediately going to put something in there. So this is, we're actually going to have the reduction of the damage is different for each piece of clothing, so to speak, wrestle for the helmet, the breastplate, the leggings, and the boots. It's going to be a different number. So let's just say somebody like to arrow, let's say 75. And there may be a three or something like that. You know, you can, of course choose whatever you want. And tractability is going to be a ten. The sound event is going to be sound events that this is going to be item armor equip. Let's do armor. This is item armor equip iron. Right there we go. Repair repair material which is immediately going to get from stack again and just do new item stack from once again, the mod item's dot, covering it up get. So that's pretty much what we've done always. And then the last one is going to be named. Now this one's important here, because here we actually have to do mc course dot naught ID. And then we have to do a colon and then call this small copper. And this is because otherwise he will look for, this is basically to specify the place for the place and name for the model. So the 3d model for the armor has a very specific pattern of texture, which I will show soon enough. And that actually has to have a specific name. And if we don't specify it like this, then we will actually look in a different directory. And this also needs to be the case of copper in all in lowercase toughness, we're just going to do a 0 and knock BEC resistance. We're actually going to put a little bit of resistance on there, and that's going to be fine. And we also have to return those things. So we're going to go durability. In the damage reduction. We're actually going to have some of the different, this is going to be the demonstration array. And then we will just take whatever slot we get the index of the slot, right? So the slot is simply just, you know, it's 0 for the helmet and three for the boots. And that's just basically how we access the damage reduction area in this case, right? Enchant ability. We will get the sound events, the repair material, the name like a set of incredibly important the toughness. And in this case, this Funk which is not mapped here, is simply the, this asks for the knock BEC resistance. And then we can just do Nochlin courses. But it has to suddenly be stayed this, otherwise it will not work. So you can't change the name of this function or this method rather, sorry, yeah. So this is our MOD, armor material created. And now we can actually create our first piece of armor. But in this case, we're actually going to create all of them at the same time instead of with the tools. This is once again going to be a, an item where n, that's gonna be the copper helmet. This is registration dot items that register the O E copper helmets. And I mean, you've seen this a bunch of times now. This is now an new armor item where we supply the mod armor material dot copper. Then it asks for an equipment slot. This is of course, equipments lot head. And then we also need to provide some new properties. In this case, we're just going to do MCMC dot Course tab. That's it, right. And this is already it for the head and then we can just copy this. And now of course, once again, we actually need to have a few things where we change some things here. This is the dot, dot chest. And that's fine. Like I said, sometimes it can become a little bit tedious because you have to do a lot of the same things. However, there really is no getting around it. So we're gonna do this is legs. And then the last one is going to be the boots. And this is going to be copper underscore boots. And those are for the there we go. Beautiful. Okay, so there are actually already registered here. Now, we do need to add the localization. So let's go to the IIT and us. And we're going to add the IO, my lambda, that's not MC, poorest dot copper helmet. Let's start at the top. And then this is going to be the copper helmet. And I'm going to quickly copy this as well. And just change that up. The chest plate. Endless. The chest plate. This is gonna be the leggings. Oh, excuse me. Able the leggings. This is going to be the leggings. And the last one is going to be boots small and here boots big. Beautiful. Okay, that is going to be all of those. Now of course, we also need to add another thing, and that is going to be the item models, right? So we're gonna go to models and we're going to create a new file. This is going to be the copper helmet. There we go. Oh, ab.js. And of course, very important. And then I'm going to quickly copy this over once again, this is like the standard thing that we've already seen in the models as well. And we're going to copy this again similarly with Control C and then control V to paste it into the same directory. And I'm going to change this to chest plate. And then change this to chest plate, plate a widow. And then we can do the same thing again. Where are the links? Leggings, leggings they would go and then one last time or boots. Boots and here the same thing. Very good. Okay, so the models are set and we of course need the textures. So now the, now I'm going to provide the item textures Right here, right? And that's going to be you refactor. This is the chest plate, the boots, the leggings, and the helmet. Beautiful. Now, the next thing I'm going to need is we're going to now put the textures for the how it looks when we wear it. So that's gonna be the next thing and we actually really new folder in textures for that. This is going to be models. And instead of that one, we're going to create a new directory called armor. And inside of there, two other files go that's gonna be those two are actually going to yes, there you go. These this is for the leggings and this is basically for the torso and the the helmet. And I believe the boots as well. Yeah. Something like that. I'm not a 100% sure, but this does seem like it makes sense and this has to be also named this way. So remember the name that we specified. This hasn't been copper and then it has to be underscore layer, underscore one PNG. And yeah, those files as well always will be provided are first of all, provided in the beginning, in the sources and also as a resource, your rate. So if I'm not mistaken, I believe that this is already everything that we are supposed to do. So let's just run this and see if you've actually successfully created some copper armor, which would be pretty cool. All things considered. All right, so let's see what we can see. There we go. It is. And of course, once again, there are no recipes for these. As I've said, I will omit the recipes for this simply because they should be trivial enough to add. Alright, let's see. So first of all, let's go to our core step. Well, they are all there. That's pretty good. Let's get all of them. Okay? And now the big question is, when we switch tack, survival, if we can just put it on, we can. Well, there we go. I'm pretty nice. Denies. Now this actually has a lot of defense. I'm sorry. There we go. It says a lot of difference actually. Like it's, the entire suit of armor actually has quite a bit of defense. But this is something that you can of course play around with, right? Yeah. Like there's a lot of things that we can you can add once again. And there are a bunch of parameters you can play around with and say, well, actually maybe a little less here and a little more here. And yeah, but at the same time this does work. That's actually just well, that's well, let's just quickly switch again and then actually just jumped down from a little bit of height. I actually didn't damage it well, so much for that one. So monosomy. How about that one? A few zombies. Immediately gonna burn? Yeah, well, does matter. But I do want to turn this down a little bit because my god, are they going to be loud? Right? And then the armour actually gets hurt as well as you can see. So that's pretty good, right? So all in all, that is basically how you add the armor to Minecraft. It or no, I don't think it was that hard. However, there are few things to consider and that is mainly the models, the name here. So this is one of the biggest arrows I could foresee. You really have to do this, the name here correctly, otherwise, it will not work. That has to be the same, written the same way as the first word here. And then has to be underscore layer underscore one PNG, right? Yeah, that was it. If you have any questions, if you have any arrows or, you know, any suggestions, maybe of topics you also still want to see. Feel free to contact me, asked me a question and yeah, we'll get back to you as soon as I can. And yeah. 52. (Minecraft) Creating Stairs, Buttons, Pressure Plates and Fences: All right, welcome back to the Minecraft course. And in this lecture we're going to create stairs, fences, fence gates, buttons, a pressure plate, and also a slab. Now, these are sort of non-block blocks, I would say. And I will also show you how to basically create the other ones. But it has to be a little ingenuity has come from yourself. But first of all, we're gonna do the ones I said. We are first of all going to create the registry objects of all of them. Then we're going to complete the stairs. And then I will basically copy over a few other things because in the end, a lot of copying is going to happen here. But first of all, let's do the registry objects here. So first of all, this is going to be once again a registry object. Note a registry object of the type block. And first of all, we're gonna do the copper stairs. So let's just say for our copper block, we actually want copper series to go with it. But then we're gonna just call register and then this is going to be copper underscore stairs as, as always. And, and we're gonna do supply with new stare blocks. Their block. And a stair block actually wants a supplier of a certain block. So that basically means that we want a sort of blocked reference. In this case, we're just going to take the copper block dot, dot get default state because the supplier here actually once a default state. And then we also want the block properties. We're just gonna do 3h. And then with material iron, once again, a semicolon. And in theory the copper series are done. Now is we've learned before, it's not that easy as always, but we're gonna see. So next thing we're gonna do is we're gonna make a sudden public static final registry object. Once again of type block are always going to be of type luck. Of course we're in the mud blocks and there's going to be copper fins. And we're actually going to do this once and then we're going to copy this specific function or specific, let's say the initialization here we're actually going to copy because that's going to make our life a little easier. Fence block, abstract block, dot, nope, dot properties, create an AM wants to get and I will say material that iron, it seems to me to be the most sensible here. And I'm actually going to copy this one because except for the, the pressure plate, the other ones are fairly simple as wasteful as well. So the gate is simply this, that instead of a fence, we're actually going to have a fence gate block. That's it. Oh, that's a weird one. A you go, okay. And be sure also to change the name here. That's very important that you don't forget that. And then here we're going to have the copper underscore pressure underscore pleats. And the same of course in here, just in. A lowercase instead of uppercase. And then we're going to have a new pressure plate block. And that's going to be that's going to actually have something different here. And we're actually going to start with a pressure plate. We're going to have pressure plate, loc, dot, sensitivity dot. And then we're going to say everything. So everything simply means that everything we throw on the touches, the copper plate is actually going to activate it. And then here we're going to have copper slab. And that's gonna be a copper slab and also a slab block. They go. And that is all of the registration needed for the, for the blocks. Now, of course it's never this easy. Because now we're actually going to have to create a whole bunch of different models and, and things for the stairs, first of all, and this, we're simply going to go into our black states here. And we're going to copy this JSON file. We're going to name this copper stairs because I, like I said, we're gonna do the stairs first. And I'll, you know, we're we're we know this, right? It's like a variant model. Yeah. Well, tough love. This is, this is how it looks for the stairs. So the, the, the gist of this is basically, this defines how the stairs look, right? The model of the stairs basically is defined by this. Yeah, it's, it's it's a little much rate. So that's why I said it's going to be a lot of copying in the end at the end of the day, it's going to be it's a little more than than you might think. But of course we're not done yet because this is only the Bloch states. We actually have to copy a few things into blocks as well. So the first thing we're going to have is the copper stairs. And make sure it's written correctly. Dodge Jason. Yes. And that's going to be this. And actually that's not too bad rate. It's basically only looking at what textures are shown on the bottom, on the top, on, on the sides. That's not too bad. And then we actually need two more in this blocks. So in the models one, we need stairs, enter. And that's going to be basically the only change is going to be that this is going to, this is going to have inner underscore stairs instead of stairs. And then we're going to have, once again also the outer spheres. And this is needed, of course, when you have something connecting to something else as well. Now, the last thing we're gonna need is the item definition here. And that's Luckily like lets actually copy from this one. That's actually going to be the easiest of them all. I'm gonna do copper Sears is the only 11 up, which I'm not going to copy over because that's so easy. And then I'm gonna do block and then hopper steers. So it's basically just references, once again, back to the model of this one, which basically than references the textures. And for the stairs, this is it. Now this is, it is of course a relative terms, right? Because this is, this is quite a bit. And then we actually have 12345 different, five different files that we need just for the stairs. And for a lot of the other ones, there's also going to be at least four, maybe even five different JSON files we actually need to create. But first of all, we're going to look at the stairs. And then what I'm gonna do is I'm going to show you the fence because that's one of the other ones that is a little bit more difficult. And then the other ones, the the files are all, of course once again, as resources available. And then you should try and do them yourself. Because like I said, a lot of them is simply copying over. So there's not that much, that much to the magic. Okay, let's, we're going to create more and get away from the zombies. And let's see, there we go. So the other ones are in by the way, right. So we have the cooper slab, the pressure plate, the fence Gate and the fence. And but only the stairs have the like both a an an item model, like we see and it looks good. You can actually place them and it works without an issue. They also connect. And we can place them like this. No, you go like this. And like this, we go. Right. So they actually function like completely normal stairs, like you would like any other Sears. Now once again, of course, in the end, if we have them, they won't drop anything because no Lu tables that will happen at us. So that's very, very important to add as well, of course. And also there's no crafting recipe for them yet. So this would also need to be added. If this is something that is important. When you really launched the mode, then you conscious like, as I would our recipe, right? So the stairs, as you can see, not the craziest thing. The so we're going to close all of this and then we're gonna do the copper offense and defense gate. And I'm actually gonna do a little bit easier for myself. I'm just going to copy those completely oversaw. This is going to be the block state. Sorry. We're going to pull us over. I'm going to show them. So there's going to be copying. Yes, please. So the fence looks like this. Once again, all of the files are available as a resource. And then we also have the fence gate, which is a little bit more like, a little bit more complicated. Let's say that this is actually a multipart in this case. Of course, may also make sure that this is your MIT ID, right? So if you haven't used the MC course malady, of course, change this and make sure that the, these names are actually correct. Now, the then we also need for the fence. Now you're going to I mean, this is insane, right? So in the blocks for the fence, we need. The fence Gate Defense get open. The fence get wall and the fence wall open. So those are the ones that we're going to need here. Those are just simply for this one, this one, this one and this one. Right. So gate it Open, Gate Wall and wall open. And then for the fence, we're actually going to need three more. We're going to need the fence inventory, fence posts and Fen side, like I said, in and of themselves only the Bloch states are really the crazy ones with the content of them is crazy. The other ones are, are very easy to, you know, to understand and that sense only the parent really changes. So this is Fence inventory, so that is how the fence would look like in the inventory. This is how the fence post looks like. This is how the side of the fence looks like. And now for the fence, we actually need well, first of all, we need the item ones as well. That's once again, not that. I mean, one very important for the Ka'apor fence, you use the inventory one and for the OR gate in the inventory you use normal copper underscore, underscore eight to reference as a parent. Now, there's one more thing we actually need to add in this case, so that our fences actually joined together. And that is, we're going to need a new folder in side of our data folder right here. And that's actually going to be a directory called Minecraft. Maybe you've heard of it. I'm not sure about that, but we know that's a little game you play by like 120 million people are severe liver. Inside of that folder, we're going to create another folder called tags. And inside of that last folder, we're gonna call blocks. And in this, this time it actually needs to be plural. So it needs to have the S at the end blocks. And inside of there, I'm gonna create a new file called fancies dot JSON. And here we simply need to add the, this line where the value inside of the values are copper fence is actually added into. And then if all of the files have been added, and if I haven't missed anything, then we should be able to see the fences in action inside of Minecraft. Now, like I've said, these are a lot of files that have to be created and added. This is why I'm going to have all of them as resources. And it's better for you to simply take them, copy them in, probably look them over. And after we're gonna see our fence inside of the game, I'm actually going to show you where you can also get them if for example, they are ever lost or, you know, if you can't find them or whatever happens, I will show you where to actually find them. Let's see. So that's pretty good. Already. We're actually gonna see this and this. Now of course, the names can be changed very easily with inside of our Lang folder, they EN us adjacent file where we've added the names. Every time. I've just skip this step right now. So let's add this then led at the gate and let another one. So that works perfectly fine. And of course the gate is openable, impossible, like you would expect. And now let's place another fence and they connect. Isn't that great? So they connect to both the 12 blocks, as is usual with offenses. And they connected to fences themselves. Now they wouldn't connect to other wooden fences? I believe. So. Let's just get a fence right here. We've got an offense. They should not connected. Yes, they don't. Right? So they would not connect. That's a very important thing to note, right? So where do you get the other things that you need, right? Flow first of all, for the other ones here. So for the pressure plate in the slab, you actually going to get the end button? Yes, the button, I've actually added a button here. Unbelievable. That is C, that is this. I mean, but the button is actually fairly easy as well, is going to at this quietly here and want to see NAT button. Now we're gonna do copper button right here. I mean, at this point, still button block and that's it. I mean, shouldn't be, shouldn't be too crazy to add any two adder, you know, any of those things. Anyway. So those are some of the ones that are these non-block blocks. And where do you find, for example, these Bloch states? Well, you can actually go down here to external libraries. And then when you open the 1.8em folder right inside of there, we're actually going to go down to actually, that's not right. That's not even the 18 folder. We're actually going to go down even further, but we have to go past the 18 folder. And we're going to look for a net Minecraft client extra one and then of course the Minecraft version. And inside of there there's client extra jar, that's the root, and then there's assets and then this Minecraft, and then there's Bloch states. And then you have all the block sets of all different things, right? So those are all of the adjacent files that are actually for Minecraft, vanilla. Alright. So you can just go to the acacia ones. For example, you can say see the acacia door. And then you can simply copy of this. Now as you can see, the door, crazy complicated as well, because there's also hinges and they need to know where to rotate it and, and all sorts of things. So, you know, copy all this. We should change Minecraft to your MOD ID. And also, of course then the name the acacia, probably two, for example, copper. If you want to have a copper door or whatever you want to add to the game. So all of those things can just simply be added. Be sure of course for so for example, if you want to add a trapdoor rate, then also go into the the data. Nope, that's not right. No, no, it is right. Into the model. Sorry, of course, i genuine agency, the multiple models block. And then also look for the Acacia. And then we're going to see acacia trapped o bottom, open-end top, right. So those are some things that you need to look out for. Every of those, any of those files has actually added to your own directory, right? So this is just something very good to note that you can actually look at the original files, simply copy and paste. There really is no other way in this case to do it. Cuz I took properly, like grasp everything that's in here. That's gonna take like another like 20 hour course probably, right? Because this is of course just how something handles in this case. We're not going to concern ourselves with that. What we're gonna do is we know how to add these things. Now, like I said, we have added the stairs, offense and defense gate. Now, the block button press played and slab. I would guess that you can probably do it on your own. Once again, if there are any issues that you run into, you're free to feel free to contact me or ask me a question. Very important for the slabs. What I simply want to mention, you also need to add them into the blocks folder for the tags. But that is luckily also something that inside of the net Minecraft one, you can actually see what they have added themselves into their blocks tags. So you can actually see that there are a lot of things that they've added and some things need to be added, some don't. And yeah, so overall, Those are the, let say non-block blocks. And as always, feel free to ask if there are any questions. And yeah. 53. (Minecraft) Mod Configs: All right, welcome back to the Minecraft course. And in this lecture, we're going to create our own config files. Possibly you will add something into your mod, which you actually want to maybe have the user have control over, right? So for example, the speed at which maybe a crop grows or an item smells or something in that nature. And what we can actually do is we can actually create your config file that then the end-user can change r modify. You've probably seen this. And for that we're gonna create a new Java class inside of our util package, which we're gonna call config. And now There's conflict clause is going to look a little bit wonky, but not to worry, we can actually, we can actually go through the, so first of all, we're gonna do a public static and then we're going to have a forge conflict spec on fixed spec, right? And that's gonna be the server conflict because we will need a separate conflicts for the server and the client. In this case, it's actually not touched any of the server things yet. However, don't worry about that. It's better to have it be done in this, in this case, for everything so that it is easier to be added onto later, right? And then we're going to have spec dot value. This is a, this is the example I'm gonna give. So what we're gonna do is we're going to have a, the word glow duration. So if you remember back, we added the event that when you actually hit a, hit a sheep with and with the corporate Apple, then they're gonna get a glow effect. And this effect, we had a duration set. And also when you eat the apple, you also have a 50% chance of getting this effect. And in this case, what we're gonna do is we're going to actually have this copper glow duration as a conflict that can be changed, right? So then we're gonna create a static block here. And inside of that we're going to make, we're gonna create a, a fourth conflict spec builder, which is going to be the server builder. That's gonna be new builder. And then we'll copy this. And this is going to be the client built IN builder. And we're going to have a new, New Method below, which can be private, static, void, glowing, duration. This is what I'm going to call it. You can in theory Call it wherever you want. And that's going to have merge conflicts spec builders. So that's going to take a server builder. And also a builder. Not not conflict builder, but a client, a builder, a ego Bilder? Yes, sir. Hey, we go. And inside of there, we're actually going to now specify this. So this is going to be the conquered load duration equals. And now we're going to use the client builder.com. And now this is very important. What we're actually going to do here is we're not going to read in, well, we are going to read in a config file, however, we're also going to write a conflict file, right? So this is very important because of the conflict file doesn't exist. We're actually right, it, if it exists, we're gonna read out of it. So this is basically the comment above the Above the value or the variable that we're going to define. So this is, for example, how long the glowing lasts for four copper apples, right? And I'm going to say intakes because this is the amount of time that it takes. And then we're also going to do define in range. So this is very important, or it is not important, but it's a good idea to do this. So below, duration is gonna be the name of the, what the user. Basically it's gonna see, we're gonna see that soon enough. And we have a default value of a leaf. Our default value was 600, if I'm not mistaken. Well, here it is 300. Inside of our events, it is probably 600, just yes, here is 600. So we're just gonna stick with 600. We're going to say that the minimum has to be a 100. And then the maximum is simply going to be integer that max value. So it's basically, you know, we actually see what it is. Yeah, yeah, 2 billion and some more. So, yeah, in, in theory that this would be the max value. You could also say, well, I mean, if it doesn't make sense to have something like this, but, you know, for our purposes we're going to do max value depending on way you, what variable you want to set. Two's the sensible. And the next method we implement is a public static void. And we're going to call this the load config file. Here we're going to pass a conflict spec, which is going to be conflict and a spring which SNP with a path to the file. Now, this is going to be a commented file config, which is going to be the file. We're going to all the builder year with a new file. With the given path. We're gonna do a sync, auto save and then a writing mode, writing mode, dot Replace. And then we're going to build this. Actually I also have to implement the class from java.io, so java.io file. And then once this is written, we actually have to write by load. And then conflict dot set config file. They, we go, right. We're actually going to call this from our MC CourseSmart class, but we are not a 100% done yet. So in like very short summary, what this basically does is like, hey, if the file exists, replace, if the file exists, read it, if it doesn't write it. That's like the most basic of forms that we take here or that I can explain it in. We're going to call the globe duration with the server builder and then the client builder that weave. I'm implemented here. And then in the end, we're also going to say the server config server conflict, not the server. The server configure is going to be equal to the server builder build. And then same thing is going to happen with the client conflict up here. So this is going to be the client builder dot. Right. Now the config file actually completely done. If you want to add a new variable, of course you have to first add it here as a public static, forge, conflict spec, and then int value or a double value or whatever kind of value you want. And then also you have to do it here so that it actually gets added into the. Whatever you want. Now, either what you can do is you can create one method here and not call that glowing duration. Actually call it, for example, no int, maybe intValue initialization or something like that. Or however you can make a new method for each of your, each of your config, configurable variables, that is up to you. That is, you know, there's no, there's no set way in that sense. Whatever you prefer and however you can read this best would be best for you now to the MC, worse MOD plus. First of all, in the very beginning, we will load to this. We're going to do model loading context dot get. And then we're gonna do register conflict, mud conflict, that type. We actually need to specify the type of either client or server. Now there is another type which is, which we're gonna see here. So if I change this, we actually also have common. This is something that would be configured on both the server and the client. However, however, the those are, I would argue a little more advanced things as well. Then we have to do something in-between these two. And this is going to be the config dot load conflict file. I'm going to say conflict odd, client conflict, FLM paths. So this is basically the path config dear simply specifies the directory in which the conflicts are dot get, and then we'll resolve. And inside of here we can actually simply write a, the name of our client config file. So for example, MC course dash client dot Tamil. But this should be a diatom, a file. And then we're gonna do two string. Yeah, there we go. And then we're going to copy this and do the same for the server once again with your, and then we're gonna just call this the EMC servers humbled. And now if we actually have done anything, everything right? And I do believe we have, we're going to run the game. And then I'm going to show you where the Hmmm FEC is generated and how also, how we can also implemented into, for example, the cupboard on the corporate Apple MD events. Let's just let this load for just sort. So we have the main menu here. And then we're going to quit immediately. And now inside of the run folder up here, instead of the config folder here we actually see we have AMC force client and MC4 server. And inside of here, exactly what we've done. How long the glowing loss for the cup level and ticks ranges more than a 100. And then we can actually change this as well. Now, we also want to change it here, right? So this duration, and that's as easy as typing conflict dot covered the load duration. Now this is an int value and we wanted in, this is why we have to do. And there we go. That's it. That's all we need to do. More events. We can do the exactly the same. So we have conflict dot Hubbard low in duration, dot get. And then we go. And that is, that is all we need to do. And now the, now the effect actually has a variable duration that we can set here, right? So we can say, well it's 600 or we can say it's 50 thousand or 500 thousand doesn't matter. We can, we can do whatever we want. And in that case, the user can also do whatever they want. Which is pretty cool actually for a lot of things. And it's as easy as simply doing conflict. And then the name of the variable that you specified. And that's it. The good thing for this as well is because these are like totally different pieces of code. In this case, we can make sure that they always have the same value. You could maybe think that maybe we had this cupboard glow. Duration is maybe reference in 18 different places. Well, if you have the actual number written there every time, right. As a number of 300 or 600. Well then changing that would be well, quite a bit of work simply because of the fact that maybe you don't even know where, in what places you've actually, you know, committed that number. So it's very useful for that as well, and also for having conflict, right? Yeah, so this is basically everything for the config file I wanted to cover here. And once again, feel free to ask if there are any questions. And yeah. 54. (Minecraft) Exporting your Mod: All right, welcome back to the Minecraft course. And in this lecture, I'm actually going to show you how to export your MOD add into a jar file, which you can then use in basically a MOD pack or in, or a normal version of Minecraft. And this is actually going to be fairly easy. You just gonna go down here to terminal and you're gonna type in Gradle w, build. That's it. Enter. And then we're just going to wait a little bit. So he's gonna do all sorts of things in the background he's going to compile. And that is, it is basically all that needed to happen. And now we actually have to navigate to the directory here. And if we do that, we can actually see this. So we're gonna just quickly, I'm going to quickly go from the other day we go there we are, right, so this is the directory. And inside of here, we can go to the Build folder. Instead of the bill for rho, we go to the lives and instead of here we have MC worse and then inversion one jar. Now how we can actually use this, well, what I'm gonna do is I'm gonna go to the twitch launch up. I'm going to actually create a custom profile. I'm gonna show you this. So this is the twitch launch up where, for example, we have a few more packs I've already played. And then inside of here we're actually going to create a new profile with version three there. And we actually use the, we have actually used 3410 because that was the version that we downloaded at the beginning of the course. And profile it's just gonna be Mc. Worse, test, create that load of few things. And then here we can actually open folder and then get a new folder here. And instead of mods, you can simply do the following. You can simply take this jar, copy it, paste it into models, and that's it. And then play. Now let's see if that actually works. So down here we can see that this is the profile that we want to do. I'm actually already logged in. You might have to log in first, and then let's do play. And let's see what actually happens here. So something is going to load and somebody's gonna open. But is it what we wanted? We are gonna see that. We're going to see that very soon. So first of all, of course, we're going to get once again music which turn off for the purposes of this demonstration here. And while we have three Maslow did and look at that MC mode, that is crazy. Let's actually just simply create a new world. Creative as fine. Yep, let's just create a new world and let's see if that actually works. So you could imagine this could also be, of course, a MEDPAC rate with a 120 months, all the modes or whatever. And then we can find ourselves somewhere while we respond in an island that is, that is Hilary's. Ok. Well, let's see. Of course, the core step is in there. And all the things that we have actually done or haven't done, like the buttons on the slabs. I hope you've done those. They are actually in game with no issue whatsoever. We can place them. You have the biotic hopper blocks and we have a0, the helmet for example. The helmet, wait, here we go. It's actually put that on. There we go. Well, isn't that great? And that's pretty nice actually. I mean, this is how you export the model. Like I said, it's not a difficult thing or fairly complicated. It's one, basically one command that you have to put in. And, and if you want to add this to a certain mods, mad pack, or a profile, or you want to give that to someone else. You can give, simply give them the jar. And then they can use this simply as they would in any other model, basically. Write. This also sums up most of the course. I have one more lecture after this. We're just going to talk a little bit about a tip I have for a lot of you. And then there's also going to be basically the lecture where I'm going to say how you, how this course is going to conclude and all of that. So yeah, I hope that everything here was of value to you. I hope you liked it. I would, of course, appreciate a review. And yeah. 55. (Minecraft) Use Github for Source Code examples: All right, welcome back to the Minecraft course. And in this lecture, I'm actually not inside of the IDE. I'm actually on GitHub. And the reason why I'm on GitHub is actually because I want to show you a few tips that might help you in future development of your mode. When you actually wear make a serious mode with real things and you actually want to create it so that it can be released to the public and say right. So what you should do is you should go to GitHub, you could get, you should get an account, it's free. And then you can actually search for basically your favourite maths, right? I've chosen three of my favorite math. So there's immersive engineering, mechanism and mythical agriculture. And those three are actually all updated for the newest version in our case where 1.16, three right now. And in this case we can actually look at the source code that they've written, right? That the people of those matchmakers there have written. So we can just go into source right here. So in immersive engineering, and you can go to main and then Java. And this is basically all of the same things that we've done on our own, right? This was, this was Java and this one for us was calm Copan Joe and an immersive engineering was MC course for us. And then we didn't have the API, client and common difference here or the folders, but we did have our own Java file, right? And we can just look into this. Then we can look how they did something, right? So this is what we did as well. We had a public spring Mar ID. We didn't have the MOD name, we didn't have the mock version. This is, for example, something you could do. And then there were a lot of things in here that we haven't even touched on because other things are crazy complicated that need to so much more knowledge on the fundamentals and here. But the best way to learn is try new something. You can also try and fork this. So you can simply basically download the deforest, the source code of one of these modes and then launch it on your own, right? So you have a, you basically have the source code of the smarts then downloaded and you can simply play around with it, right? So you have a local copy of this. You can play around with it. You can actually change the code, see what happens. So this is a real thing about, you know, in within eight hours, you're not going to create, let's say the next immersive engineering or the next mechanism or the next mystical agriculture. It's simply not going to work like that. You are going to have to work a little bit more on all of you that you've learned and you have to build on this rate. And this is, I think one of the best ways you can do it. Go through these files, think about your favorite mass that you have. Look at them, look how they done it. You can also go back into the past basically, right? So you can also go into a previous, previous versions here rate, for example. Or you can go back into the past with this history button basically. So you can look what changed, in what version and all of that is you can just go through and see, okay, how does this were Harris's work and it's going to be difficult at times, right? Is gonna be maybe or I don't understand this, I don't understand this. You know, it, everything comes with time. This is also, of course, why I've said that Java is simply a requirement. Otherwise, you will be lost in this one. Definitely. Right, so let's just go for mechanism, just for the sake of argument as well. So mechanism and this one is I believe in client I'm not sure. No, it actually is in common. Well, they will. Carmen and the mechanism dot Java. And then we can also see some things that he has. So packet handlers, the logger, we, we, we've seen the logarithm before. And he also has radiation manager because he actually added ready irradiation and mechanism and sort of those things right there we go. So we have these listeners, we have three, you have seen something very similar to this. There are events that are registered. So you oh, you will always see some sort of similarities of things that you've already seen. But also of course you will might see All that I've seen, that I've not seen that, that is interesting. And in this case you can also, this is really cool because what you can do is you can actually hover over these and then click on them. And then for example, if you want to know, well how does the tank multi block data work? You know, you could just go in there and now you're on the tank multi block data, java, the java file. And then you could just look at it, right? You can look at all sorts of things. Now, once again, this is not going to be a thing where you look at it. And in an instance, you are going to understand everything right. You will actually have to work through this and, and look at it a little bit and also try something, right? Because you cannot learn something if you don't try it, and if you don't adapt something and if you work at it, right, that's basically some like an impetus I want to give to you as well. Just to, to just try, just try out things to be creative with this and to not be discouraged even if sometimes it doesn't work. And if you really want to create a model, I highly, highly, highly recommend looking at this, looking at modes that you like. Maybe even that, maybe you want to have this mod and you want to change a little bit or just your creativity really the odd any limits to this other than your creativity, what you can think of. So go out there, you know, create a killer model. I would love it. And of course, the most important thing if you actually created one genuinely, genuinely January, please send me a link or a preview or even a GitHub repo to this because I would love to see it. I would love to see it. So, and yeah, I think that is it for now. I hope that the course was of interest to you and actually got you. Maybe a fire started. And that you actually want to create something and that you learn something here. And yeah. 56. (Minecraft) Use GitHub as a Version Control System: All right, welcome back to the microwave course. And in this lecture we're gonna take a quick look at how you can import or upload your Git repository. So your Minecraft mod to a GitHub repository. Now there are two things that are very important. Like I'm not going to give you a, let's say a theoretical understanding of GitHub. That's not the good in general. That's not the point of this lecture. The point of this lecture is just to show you how you can add it to GitHub. And I will give you however, three links as a resource. One of course is github.com. I would say that this makes the most sense. You will need a, an account there, but it's completely free, so no worries there. I will also give you this link to the JetBrains.com. So this is intelligent idea, basically how to set up a Git repository. There. It's explained basically exactly what I'm explaining here is explained there in far greater detail actually. And then I will also give you the download link. Forget, now I'm not a 100% sure that you need this because I think that until j comes with Git itself, but I'm not a 100% sure. So if anything doesn't work, you might need to download this, but go through it. We're probably with this, with the, this tutorial or with my lecture here first. And then if, for example says, hey, you don't have Git installed, then you can install Git. Otherwise, I wouldn't I wouldn't bother with it. Right. So that's basically the preamble here. And then let's, let's, let's do that. So first of all, we want to create a new repository. So on GitHub, we see this new button here. We're going to click this. And we're gonna say repository MC course. Of course. That makes sense. We're going to leave the description empty and we're gonna make the, make this private. So you can choose to make a public or private just to be sure a public, anyone can see it. And in private you can choose who can see it, right? Anything else we don't need. So let's just create repository. And there we go. So quick setup, this simply means that there is nothing here right now. So we don't have a branch, we don't have anything in there, and that's basically exactly what we want. So what we're gonna do then is we're going to copy this one here, right? So we can just click this copy button and then it's going to copy this HTML. There's the URL rather. And then let's go into our MC course MOD project. Inside of here we want to, first of all go to File Settings. And then under version control in GitHub, you want to add your GitHub.com account. You just click the plus button. And then when you go, I guess you could do either one of those token order via GitHub and then it's going to prompt you to log into GitHub. So it all works are medically, you don't have to enter your password anywhere except for GitHub itself. And that should then work and then you should have your account in there, right? And once this is in there, you can go up here to VCS such that for version control system. And then when you go into import version control, you say create a Git repository. And what you can do is you're going to select your, your directory where you have your mod I_n. So should be actually selected by default. Click OK. And then what's going to happen is a lot of stuff here is going to turn red. Don't worry about it. That's all normal. And then up here where you're actually going to see in some new buttons pop up. Those are some good buttons. And at the bottom right corner you're going to see this master's. So this is your branch that you're going to have. A lot of things are gonna pop up. Don't worry about it. This is, this is all fine. Now the red doesn't mean that there are arrows. This simply means that you don't have them committed. And we're just gonna do that right now. So what we're gonna do is we're going to go up to this one, to the, to the check mark and say commit. And we're just going to click this. And then it's going to say we have a 182 inversion files. We're just going to select those. And then we're going to say this is our initial commit. At down here you can see masters of this is going to be in the inside of the master branch. That is totally fine. We can leave this. And then we're going to click Commit. Now is he's going to add the files to the version control system. Now he's looking at the analysis is going to like say, oh, here's the code, Fine. Are there any arrows in there? Are the warnings in there. It's going to tell us that there are a few warnings right now. Don't worry about that. We're just going to commit. Warnings are mostly the things we've, we've ignored. Because sometimes there are warnings that we have to ignore. And sometimes I'm just not suppressing the warnings with a, with an annotation. We should probably do that, but it's not necessary, right? And now as you can see, nothing is read anymore. But if we go back to the, if we go back to the GitHub, if we reload this, there's nothing here. So, so and we've had an haven't even put the, put the URL in anywhere, right, so, so why? What's going on? Well, we need to add the URL, so we have now a local version control, but we don't have the remote version control. And remote basically just means somewhere else, right? So this is the one that's on GitHub and we need to add this as well. Now how do we add this? Well, we can just add this by saying push. And then he's going to say, well, first of all, you needed to find a remote. I don't know where to push it to. And we're just going to click this and then paste in the URL that we have copied from GitHub and say, OK, it's going to check whether or not everything is fine and of course everything is fine. And then we're going to say push. Now he is uploading all of the files to get up. So you can see down here it's pushing and then he says push master to new branch origin slash muscle. And if you go to the MC course now on this, on GitHub or on our GitHub repository and reload. As you can see now everything is in here and everything is fine right? Now. The great thing here is that once you change something in your code, so let's say, for example, just as an example, we're going to add a really important comment, right? And we're going to save this, as you can see, now, this file is blue. This is because there was a modification to this file. And then let's say we're going to add a rage. Lee, greatly important comment as well, just, just for the sake of argument. So we're going to have two files. See they are going to be blue when you have modified them. And the way you can now upload this is simply by once again committing, right? And then you can say added important comments, right? And then you can either say commit or you can click this little arrow and say commit and push, and then it's going to immediately push it in. We're going to say, I don't care about the warnings. Like I said, we're just going to not care about this. You can overlay. You can also just review what has changed and inconstant. Alright, push it and, and pushing it, it's gonna say you, everything is going to be fine. Now, right now if we reload here, we can see that go at it. Important Commons. Now the important thing is that currently we're only working on one branch. But like I said, I don't want this to, let's say devolve into a complete GitHub tutorial. I just wanted to show you how you can basically save it. And it is a good idea to maybe look at both the GitHub repository in here. This is actually a good resource to have as well. And then I will see if I can find a good resource. I think on GitHub there should be some examples on how to do you know how to branch out some things and so yeah. Right. Yeah. And that was basically all that I wanted to show you how you can upload your MOD to GitHub and we'll make sure that it saves properly that you have a proper version control system. And yeah, so if there are any questions of course 3-3 ask, I want to remind you that this was just a short little introduction or overview. I I doubt that I'm going to go much more into anything related to, to get, cause it really shouldn't be the main focus here on this course. But yeah, no, but like I said, I hope that, that was working for you. If there's any problems, of course, feel free to ask and I'll be sure to respond. And yeah. 57. (Minecraft) Current Forge and Minecraft Version (1.16.4): All right, welcome to this special lecture in the Minecraft course. And here we're actually going to update to the newest Minecraft version. So 1.16.4. And I've already located the Minecraft forge website. There's just on the normal microforms website and then making sure that you are at 1164. As we can see, the latest version is 1164 and then 30, 5.0.2. And we don't actually need to download anything. We can change this in our Gradle build file. Now, note very important that this is just the latest version and it has this little bug here, meaning that this is sort of a beta version and a debug version. And however, we're going to use it for the going forward and it shouldn't break anything and everything else we're gonna do should work for both versions. There might be some mappings that are changed in the future, but that is all done in a different, in a different lecture as well. So we're going to switch over here. And as we can see, this was the old version. And then we're going to just change this to 4350 and then a2. And then we're going to save this. And we're just going to load Gradle changes. Now this is gonna take a little bit because he has to download everything. And we're going to actually open this in the build. And then he's going to download a bunch of stuff, download the snapshot and all of that jazz. And once that's done, we've updated. All right, so everything seems to be done and it took about two minutes, like you can see here. So depending on how fast your computer is, it can take a little bit longer or maybe it's going to be faster. And we can just run this and see whether or not everything worked. If there are any things, then they should pop up as arrows and the client shouldn't even run. But I believe that everything is going to work out fairly well. So we're just gonna see that it's already opened here. So I do believe that everything is going to work and we're going to see first things first that up here, warning forge, beta. So like I've said, It is the beta version of words. However, usually there isn't that many errors and craziness. And if there is, then you can always update. So especially while you're in the Veda, it is good to pure periodically check the website for updates and maybe even for a stable version. So I would definitely advise to do that. And once a stable version is our, then you should use that stable version. Anyway. So let's just go into, right. So this is because we've played this world and 1163 and now we've updated. We're just gonna say, I know what I'm doing. If The world breaks, I highly doubt that is breaks because we don't have anything crazy in it that could break. I don't think so. Yeah. So this all works. And everything still in here? Everything still seems to be working totally fine. Yeah. So that all seems to be working fairly well. And that's basically how you update, like I've said, from 1 16th, three-to-one, sixteen for nothing has really changed all that much for us at this point in time. And everything else going forward is going to be done in 116 For so yeah. 58. (Minecraft) Current Mappings: All right, welcome back to the Minecraft course, to this special lecture for updating the mappings. And this is going to be a very short lecture. And in here I'm just going to update the mapping. So I'm going to show this once with this video. And then as a resource here, I'm going to actually have the updated mappings that you can use, which are going to be the most up-to-date. Basically, those should be updated. I'm not sure how how often they're updated actually, in terms of forge. However, I'm probably going to update this about once a week. So worst-case scenario, you're off by about a week. But I'm sure that that's going to be fine. Either way or you can, you could look them up yourself. It's not the most important thing to update the mappings that often. However, it can be useful. So we're just going to rerun this quickly. So I've pasted this in. Like I said, this is available as a resource. And or you can just type it up the type from the screen. I mean, that's not going to be, I'm going to be the craziest suffering if we're absolutely honest, let's see. So it's going to download the mapped. The mappings once again. And what they basically are is just so that we don't have these Fung underscore 2869 underscore BY methods, but they actually have names. And I do believe that we have one example which we actually have to change if I'm not mistaken, and that is going to be in the more items, I'm fairly certain that they are. We have the knock BEC resistance and that was a, that was a funk method with no proper name. And we can just fix that. But we'll see that once the, once the mappings have downward. And as a note, it doesn't matter that this is 1163. This is also going to work in 1164. And now if we actually go to the mod items, I do believe yeah, we have a an arrow here because this fund was actually updated and this is now getting get knocked back resistance. And they go, Yeah, and that's basically all you need to know. A another resource I've also provided is the official forge mapping. The official forge mapping ex excel sheet, where you can, for example, if you didn't know that this was not big resistance, you can take this, copy it and find it in there. And then it's going to actually say what that is. So yeah, then everything is everything else is going to work totally fine. I do believe that as nothing else. Let's just I'm just going to start it just for the just so that we can see that everything's going to work. But I do believe it is. Otherwise, we yeah. Okay. Everything's gonna work. Okay. Everything works. I just stopped it. So no no other mappings actually have to be updated. And yeah, that's basically just a short video. Just quickly swapping out this string here. And yeah. 59. (Minecraft) Advanced Loot Tables: All right, welcome back to the microwave course. And in this lecture we're going to look at some advanced loot table types. So the first thing we're going to look at is how can we, for example, have a drop from a block that is similar to Redstone, right? So when you break a Redstone or block, you can have maybe two or up to five or six pieces of Redstone actually drop. And then this also gets modified by the luck stat. However, we're going to look at just how we can set a count. So how many, how many items are gonna drop from a block? And I'm just going to copy this over and go through it. So as you can see, it's not that similar. Very similar actually, it's not that complicated and different from the normal drop. What we changed here is we added this Functions list. And in here we can define multiple functions. In our case we only have one function defined. And this is the setCount function. I'm going to, at the end of the lecture here, I'm going to show you whatever functions there are. And I'm going to give you a resource that is very, very good for you to deepen the knowledge on how Lou tables work. Yeah, and this simply means that minimum counter is two. So, so each time I break the copper block, two to five cup box drop. Of course in this case that doesn't really make sense. This is, however, just a demonstration basically, right? I'm not going to show this right now, so I'm not gonna go in game. But however this works And also important, this is uniform distribution. If that says something to you, then you know what that means. If you have no idea what that means, it doesn't really matter. You can look that up. I'm just I just wanted to tell you. Okay. This is one of the things. So multiple items or how do you know the hot defining how many items drop? But how about multiple drops then also works. So we could imagine that maybe we want a copper block to drop 20% of the time and 80% of the time we actually want copper wire to drop. And that's all that we've done here. So inside of the entries, we've actually just added a new entry. And we've given both of them weights, right? So they are now dependent on each other in the sense that 20% of the time a copper block drops and 80% of the time copper wire drops. Now in this case, with the function near, we can just keep that in there. So this is very modular. Let's say with a function in here, we can actually have this be exactly the same. So 80% of the time copper wire drops and 20% of the time between 25 copper blocks drop. So this is the great thing here. Now, it might be that maybe we actually don't want either or to drop what we want both of them to drop and have an independent chance, let's say. So we are going to also look at that as well. So this is a little bit more as you can see. So it gets a little bit more complex the further we go down here. And what happens here is that we actually have multiple pools this time. So before we had multiple entries, right? Now we only have one entry. Now we have multiple pools, right? So each of those pools, we can actually specify inside of an entry here. Hey, this is a random chance of, for example, a condition random chance 0.5. So down here, the cover, why will always drop? That's always going to happen. And in here, the copper block, so between 35 will drop 50% of the time with this random chance condition. And the great thing I have as a resource is actually here in the game PDR Lu tables, ie. I admit this is like the top-notch resources for how to look at how loop tapes worked basically. And here you have the entire tax and it is gonna take maybe a little while, so a few moments to actually gather how this is laid out. But once you've, you know, once you've learned how to read this, it is really, really not only interesting, but also very useful. So he, for example, there are functions that can be used apply bonus is for enchantments. For example, we have, what do we have enchant randomly. So this is when we, as you can see, when we have items that are dropped that we would want to enchant that. So when items dropped, right, we can limit counts so that we can say, hey, this is maybe the specify how many, how many drops actually drop. There's so many things in here, as you can see. We also have conditions in the predicate over here where we have different things that we can use. We can look at the properties. We can look at whether or not something was killed by the player. We have the random chance that I've already shown you from the conditions. So there's a lot of things in here. And I highly recommend if you want very specific Lu tables that are not of the type that I've shown. Then this, you have to go through this and use this. Of course once again, you can also go through the GitHub of mods that might have similar functionality that you are wanting to use. But this is a very good resource for general things if you don't find anything there. Yeah, that was something for advanced Lu tables. And yeah. 60. (Minecraft) Custom Crops: All right, welcome back to the Microsoft course and in this lecture we're going to create our own crops. So I have prepared a new crop. So this is going to be a zucchini crop. Now, the first thing I'm going to say is that the textures were self-made, but I am not an artist. So they're not going to look great. But this is going to be something for later in the lecture. First of all, we're gonna go to our blog package and we're going to create our zucchini crop class. This is going to extend from crops block. And and we're going to simply get the matching, the matching constructor. And we're going to override the two methods. One is going to be the item provider, which is going to be the get seats item. This basically just going to return the seed. Now of course we don't have that in our MOD items yet. So we're going to do that in a little while. And then we'll also want a voxel shape. And that's going to be good shape. With a block state. No, yes, this actually was right block saved state. A I block reader, which is going to be the world. A block position, position and an eye selection context. This one, which is going to be context, robot position actually has to be imported. We'll just do that with old and enter. And this is going to return something and we actually need the shapes and import them. You can just do Control and then left-click on the crops block. And right here, we actually have this shape by H. And this is going to be something we're going to use this pull, this shapes, shapes. And this basically defines how the, how the block looks. It's basically the same as wheat. And this is going to be shapes. And then this is going to be inside of it. We're going to do state yet this dot get H property. And what that basically does is it gets the shape that is corresponding to each of the ages of the, of the, in this case the zucchini crop. So it's going to grow bigger and bigger as you've probably seen with the wheat block as well. Right? And then we're gonna go into the model items and we're going to create our zucchini. And we're gonna do this below the armor. This is going to be a public static final registry object of type item. We're just going to be the zucchini seed. And then you were gonna do registration. Registration that items. Now that was correct. Items. Register is going to be the zucchini block. No, it's puny seat, of course. Sorry. And this is going to be a new lock item actually. And then we actually have to supply the MOD blocks, zucchini crop as well. So this is going to be a little jumping back and forth, but let's not worry. So in the map blocks, we actually also have to specify this as well. We're actually going to know we're gonna do this below the old stairs and such. So it'll be a public static final registry object of type block, which is emitted zucchini crop. And that's going to be read just ration. So in this case, we're actually not going to do that. This is going to be, so we're not going to use this register method here because we don't actually want a block that corresponds to the crop or an item that corresponds to the crop. We actually want to have a different item and that is going to be the seeds. Basically. This is going to be a normal register of zucchini crop. And this is going to make a new zucchini crop with the abstract node, with abstract block dot properties from. It's going to be a little bit different and it's not just going to save loc dot wheat. So we're just going to take exactly the same properties as we'd. That just makes the most sense in this case. And then in the items, we can actually supply this block item with a block now, which is going to be Mott blogs, dot zucchini, Rob dot, get. And then here we actually want item properties, as we've seen plenty of times. And we're just going to define the group EMC. We're smart. First tab, read, right? So the zucchini seed is now implemented already. In the map blocks we have the crop implemented. And inside here, we can actually simply return the mod items or items start zucchini seal. That gets read. Right? Now this you would think would already be it. Of course we still need to do the Bloch states and the JSON files. Now those are, well, how can I say this delicately? Quite a piece of work, let's say like that. So the Bloch states is not actually that bad. But the and the textures and the model, models for the block are going to be something of a liberal works organised. Do zucchini crop, the dot JSON in the Bloch states, yes. So it's a kidney block, is opinion crop dot JSON. And we're just going to copy this over and surely explain. So this simply goes to the, to exactly this age. So inside of this weight, this H property, right? So this of course extends from the crops block. And the crops block has an integer property which is called age. And. At this, the Bloch states can of course, look at this age and then modify the model that is being used. And in this case, we're actually just going to have eight ages, so 0 to seven. And therefore we also need all of those eight block models in it, in the models. And I'm going to copy those over. Those. Those are of course supplied once again. And also I'm going to go over one example. So we're just going to copy those over just a second. Sorry. Yeah. So you go. All right. And now all of them are in like I said, all of them have to be done. As you can see, they are very much not that complicated as well. They're just a little bit tedious to do all of them on your own. This is why it's better to just copy it over because there's no real magic here. The parent is going to be blocked slash crop. And then inside of here we're actually going to have textures crop. And then we say, well, we want the zucchini underscore crop, underscore stage. And then depending on what JSON we are, we're going to add a 012 or up to seven. And that's going to be the same on all of them. We also then want to add the item. So the zucchini seed JSON for the item, most going to quickly copy this over and look at it. Once again, this is just a normal item. There's nothing particularly crazy about it. The fact that we can plant it is all already done within the zucchini crop. Basically. That's all already defined. And then the textures which I've been dreading to look at, if I'm absolutely honest. And that's gonna be that's gonna be in block first. That's going to be the stages. I'm gonna quickly copy those over and see this stage 0 to seven. And I'm going to look at them, we're going to look at them when we are in game. And then we also of course need a zucchini, a zucchini seed texture. So I'm gonna put that in as well. And once we've done that, there is one more thing that we need to do, of course, which is, well, there's actually two more things for me to do. First of all, we're going to quickly define this. So we're going to have item dot AMC, coerce dot zucchini, rap. We're just going to be zucchini seeds. And then a comma here. Oh, well, like that of course. And then the last thing that we're also going to need, or that might be, might be interesting right here would be another loot table for the zucchini crop actually. And I'm going to also copy this over and I'm going to go through it for just a second. So this is going to be zucchini cropped out and Jason, and as you can see, this is. A big one. And what, what's happening here is basically, so instead of a zucchini dropping, in this case, we're actually just going to drop a gold block for the sake of demonstration right now. And the other stuff is basically saying, okay, we're gonna get a gold blog and we're gonna get a seed. And then there's a chance, a probability associated with getting a few extra seats. This is, and this is just copied from the JSON of wheat. So we can actually go here. External libraries, I believe I have shown this before, the net Minecraft client extra and in the assets Minecraft and then in No, it's not in there. It's actually in data Minecraft of course, once again, it Lew tables and then we have blocks. And somewhere here we have wheat. And as you can see, this is almost basic. Basically exactly the same just beat is exchange with MCQ, zucchini crop. And yeah, so this, you can always use those much easier than the Googling your way even we're asking question because this is very much accessible here and you can always see an example here of something that you might want to implement, right? I do believe that this should be it. Let's just, let's just see what happens, right? I mean, worst-case scenario, we're gonna get a 100 arrows. But I do believe that that's not the case. I don't think we're gonna get a 100 arrows. Maybe we were going to get one arrow but not a 100. Okay, so it looks good. Let's hope that everything starts and everything does start, right? We're gonna go into the world again and hope for the best. But I do believe that everything should be running smoothly. So let's just get a bucket of water and then let's also go and look OK. So the seed is definitely in. It didn't take the oh, it's because it's a block and add an item. Well, that doesn't make sense actually, but fair enough. Okay, so let's see if we can actually plant this. Well, we can do no what what the issue here is? That's not going to be an issue for a very long. You can fix that actually, very, very fast. But we can't actually landed. However, there is one more thing that we need to do before this looks proper, lets say. And that's going to be inside of our normal. Instead of our MC CourseSmart. We actually have to go into the Client stuff once, one time here. And we're going to add the following statement. We're going to add render type, HLOOKUP dot set render layer. And then for the Matlock stat zucchini crop and get, we're going to set the render type to get cut out, right? And this simply insures that, well, it doesn't look like what we see. And then we can also go in back here. And this is not going to be item but lock actually for the seeds. That's a little weird, but it's, it's the way this works because this is a, we actually have to specify the zucchini crop instead of the seeds as the lock item. It's a little bit weird, but I think it's going to work. I mean, it's not, it's not that crazy. So as actually see, I believe that the rendering should be robber. Now, let's, Here's hoping. But I do believe that that should be working now. Let's see. And yeah, it works. They go now whenever everything where it's all right, whether that's actually very good. So as you can see, that is totally fine. And what we're gonna do is we're just going to quickly, what is it, random tick speed, I'm just going to put the tick speed-up like 22 thousand just so we can see grow. And there we can see grow. Look at that beauty. Isn't that beautiful? And then gave rule random tics speed 20. So now it's all fully grown. And then let's just also switched to survival quickly and then icebreaker and as you can see, a few seeds drop and a, and a block of gold here. And yeah, so that all works. Now of course, once again, you wouldn't, you probably wouldn't want a lot of gold to drop from your props. Bought an item maybe or something that you specify. Well, yeah, that's that's basically how you add your own crops into Minecraft. So yeah. 61. (Minecraft) Custom Fluids: All right, welcome back to the Minecraft course. And in this lecture we're going to create our own custom fluid. And to do that, we first need a new class inside of our block package, which is going to be called the fluids. So in there, all of our fluids are gonna go. And this is very similar to the MOD blocks and the mode Items class. And we also need to register a new default registry. And that's going to be a public static. Final differ, not a deferred register, which is going to be cold or type of fluid, of course. And it's gonna be cold fluids. As one could have guessed. B, register dot create, word, registries, fluids. And then once again MC dot id. And then we're just going to quickly import this. And also very important added down here. Otherwise it's not going to work, not register an event bus. Right? That is the registration dealt with. And then comes the map fluids, which is going to be a little bit all over the place. But we're just going to start and then we're going to figure this out. So first of all, we need three resource locations. We need to specify the resource locations. One for the still. So for first of all, we're going to create a fluid that's going to be oil. I'm just going to create oil. And I think it goes well with the, with a copper sort of style, let's say. And the first thing we're gonna need is a resource location for the still oil, right? So this is going to be basically the name of your fluid underscore. Still underscore Errol, Of course, you can rename that however you want. This would just be oil still and then resource location. And that's going to be a new resource location. And we're going to put in our MOD ID, Match ID. And then we're gonna put in a path and that's going to be blocked. Slash oil underscore, underscore still. And this is basically, we can just simply copy this two times and have this one be oil flowing. So we have to create two blocks. Sort of, it's not quite that simple. It's, it's sort of two blocks, one still block. That's basically the water block that, you know, it's not flowing and then there's a flowing block. And they are also two. We also need to texture so that, and that's basically what we're defining here in the resource locations. And then we also need an overlay. And that's gonna be oil overlay underscore RL, right? And those are the three resource locations we need to specify. And then we can actually start and look at some registry objects. And those are gonna be registry objects of type flowing fluid. Because of course this is a fluid that we want to flow. And the first thing we're going to have is the oil fluid. And this is the this is the oil block itself. Sort of like I said, it's a little it's a little all over the place, the fluids, but I'm sure we can manage. So this is registration fluids register. This is the oil fluid. So here we're actually defining the source of the oil fluid. This is going to be a new forge fluid datasource. And in here we need to specify the properties which we have not yet specified. Because like I said, we need to go through this. It's a little, it's a little, I would say it's round, sort of its sum. Because when we specify the properties after this one, then we actually have to put in the flowing fluids as well. It is definitely a little weird, but like I said, it's not an issue. This is gonna be a another registry object of flowing fluid. And this time it's not oil fluid but oil flowing. So this is basically the the flowing part of the fluid. This is register, registration, dot fluids register. And this is oil flowing. And this is going to have a supplier of a new forge fluid, not sources assembled, flowing. And instead of fear, also the properties are gonna go and those are going to be treated next. And those are the fortune which flowing dot properties. And those are the oil ramp or tease, new properties. And those are going to be crazy as well. So the first thing is, as you can see, once a still of this fluid. So we're actually going to supply him the oil underscore fluid, right? So this is going to be supplied. And up here now you can actually put in the mod fluids dot or the properties. And same with your MOD fluids, oil properties. Now it's important that you actually make this a static pole with the class in front. If you do this, it ain't gonna work. Illegal forward reference. So very important that you actually do put in mud fluids, oil properties, just as a quick thing. And this needs to be a get. And then we need to supply or for the oil flowing. Also dot get. And we need fluid attributes and this is going to be the very interesting thing. So fluid attributes are builder. First we're going to put in the still texture that is going to be oil still RL. And then we're going to have oil flowing RL. And then we can define the properties. And as you can see, there's a few things that we can actually do. I definitely suggest too, with these four a little bit, I'm going to just put in some values. I've looked at luminosity to, and I'm gonna have a rarity of rarity dot rare, let's say. And we're going to have a sound event. Sound events, dot, item, honey, bottle, drink. I like that. That actually sounds really interesting. And it does sound a little bit like oil. And then we're going to have viscosity that's an arbitrary number. And then, and that's interesting. Then we're going to actually close the Properties parenthesis. And then we have a few other things that we can specify. And the two which are very interesting is slope find distance, which we're gonna do three. And then a level decrease per block three. And what those are is basically it's the level decrease per block just means that when you place the fluid, it's going to travel this many blocks. And the slope distance find basically is the distance where it travels. Two words, a slope down. Like I've said, it's best to play around with these numbers and to get a, get a feel for them. And hopefully when you play around with them a little bit, then you get the desired outcome of whatever fluid you're trying to implement. We also need to specify a block. This is a block that we have actually not yet implemented. So we're just going to not put in anything. And then this is going to be dot bucket as well. And this is something we've also not implemented. Like I said, it's it's white. The, quite the challenge here to do this in a, because it's not really a linear thing, right? Because we couldn't first do the properties because then we didn't have the register objects here. So yeah, it's a little, it's a little rough. But like always the everything, the entire code here is available as a as a resource. And either the registry object is now a flowing fluid and this is going to be an oil block. And we actually want to do a registration dot blocks this time DOT register. And once again, we are not going with the map blocks Register method. But another one because we don't want a, let's say one-to-one translation between an oil block and it's, it's, it's item because the item is of course going to be a bucket instead of a well, I'll just a just a block block item. Right. Fluids dot will fluid. This is the normal fluid. And then we're going to add some abstract block properties. So this is just normal properties we're going to create from material. Water, you real water. And then we're gonna do, we're gonna do a does not block movement and hardness and resistance. This is going to be like a 100100 g, but a 100 and no drops because the block has no drops. Then we can actually already specify this in the first one here. This is once again with the class name in front while fluids. Oil fluid. No, that's not right. Oil block of course, dot get. And then we also need a public static void Register method, which we've already seen in the mode blocks and the mode fluids. This one we're just going to add after this, after the blocks registers somewhat fluids DOT register. And then we still need to add the item. And that is, I believe, almost all that we have to do. We also need to add the textures and that would be it. So we're just going to add this after those opinions, seed the item. It is a normal item, registry objects of type item. And that's going to be an oil bucket. With registration dot items. Register. This shouldn't be well, anything crazy? It's going to be a new bucket item. And a bucket item is actually defined with a fluid as well. So mod fluids dot weight of fluid. And then we're going to use the lambda expression here. New item dot properties, and we're out. So we're just gonna put this once again inside of our tab. And we're going to add another one. Another property which is going to be maxed access one because that's usually how they how you would define a bucket. Buckets don't usually stack with fluids in them, right? And then we can here actually very simply put in the mode items, dots, well bucket, that good. And yeah, that is, I believe all. Now of course, we also need to add the textures. And I also, yes, and we also need to add a tag as well. So let's first of all do the textures. That's going to be in the block textures. And once again, I'm going to copy those over. That's going to be in block textures. That's going to be five files copy over. Yes. That's going to be oil flowing. We're going to have oil flowing. Mc Mehta and another MC Mehta. This is just for animation. And the oil overlay. Like I said, all textures are as always supplied in as a resource or it's going to get bucket. And there are still two JSON files that we need to do in the models. So the first one is going to be the oil bucket. That's not an issue. We'll bucket JSON. That's nothing. This is just a normal JSON file for the for an item, right? That's not anything we've not seen before. And then for the block, we actually need to specify this model's block. And that's just gonna be old oil dot JSON. And this is also simply going to be a very easy JSON file to see. And we also need a Bloch states because we have added a block. This is going to be oiled up JSON once again, oh, Jason, ego and surprise, surprise. It is all very similar to all the other things. So most of the definitions of the fluids are actually within the forge fluids. And I do believe that this should be everything. The textures have been added, the model has been added, registration. So let's, let's see in-game whether or not our fluid has been added properly. But everything should work fine. Well, I mean, I've already seen a typo here. So there you. However, I believe that should be it. Yes. Now, the name here, oil, this, of course, needs to be the same as the Bloch states here and the same as this block model. And then the oil bucket, of course, is the item that corresponds to the oil block. That's why we've added a model item, the oil bucket JSON file instead of an we'll file for example, there's no oil item in that sense. So let's see if everything has been added properly and well, first of all, we're going to set the time today so that we can actually see something. I'm going to switch to reactive mode. And so the oil bucket has been added. Of course it's not localized. That is something that should be very easily done after all, after all the things that we have localized. And let's see if I can actually place the fluid. I can. Beautiful. Okay, so we're going to see that I've just placed it on here. You actually see that. So it travels out three blocks. The source block is always also something that's counted. Now, I can just walk through it. This is because it has not been added to the to the water tank yet. So this is what I said. So we need to add a tag in Minecraft tags and then instead of blocks, we actually want to have another directory called fluids. And inside of there we have a JSON file or water dot JSON. And I'm going to quickly copy this over. Nothing crazy exciting. It's just that this adds a tag. Yeah. And then it's going to actually have some resistance and it's going to, well behave a little bit like water, at least when you enter into it. So it would also carry entities and items. But we're going to see that just shortly. And we go there we go. Ok. And yes. And now it actually has some resistance to it. And if we go in, it's being it's very similar to being underwater, right? That's great. Yeah. And this is already all that we need to do to add a new fluid to Minecraft. So yeah, I hope that that was of interest to you. And if there are any questions like always, feel free to ask. And also if the course has been a value to you, I would really appreciate a review or rating. And yeah. 62. (Minecraft) Clean up and Refactoring: All right, let's continue with the Minecraft course. And in this lecture we're actually going to refactor the code a little bit because there are a few things than we actually need to add and maybe change so that going forward, the more complex topics are going to be well doable and a little bit easier to follow and to understand. So the first thing that we're gonna do is we're gonna go into the registration java class. I'm actually going to re-factor this method and rename it to just init. Simply because I feel that the red calling this register is white, like it does register the the deferred registers in the with the event bus. However, I believe that init has a better is a better name for it. I do believe that that is the case. Next thing we're gonna do, we're gonna go into our MC course model and we're gonna delete the, these two. So the Enqueue IMC and process IMC. This, these methods are would be for intermediate communications. So that's what I am. C stands for. And also you can see intermodal enqueue event. So those are interlocked communication. At this point in time, we're not, we don't want to communicate with other models. So then we can also delete this, this decline stuff we're going to figure out soon and the setup we actually want to keep. So in the setup, we can actually clear the setup. And instead of the setup, we wanna put a few things, mainly the configuration, so we want to copy those over into the setup. And then we also want to put in but we first of course, this way around, yes, first we want to load the configurations. Other way around. We first want to register them and then load them. And now that's the first thing that we can do is also, well, I mean, this is fine. But if you read this you like, I'm not a 100% sure. That's why we actually going to pull this out of this method and we're going to create two new methods. So this is gonna be register conflicts. So this is something that is very much where I think that it's very hard to explain and, or even know you could probably write many books of knowledge about it. But it's very hard to get. Get what, why this is a good thing or how this is a good thing. So in this way, if you now read the setup method, you can actually see OK, so first we're going to register a conflicts and then you might do something else here. And then we're going to load the conflicts. And if we just have this, the mental effort to understand what's happening here is just a tiny bit more. And you might say, well, I mean, it doesn't matter, that's the tiny bit effort here doesn't matter. Well, when you have, let's say 200 classes. And in each of those classes there's a little bit of tiny effort to actually read it. And then it's going to matter, right? So this is basically what that is. Something that should be, should be noted. We're also going to add another private method, and I'm going to call this the register mode additions. This is basically, once again, this, these names are all, would say. They're all custom rates. So you can, if you think I want to name this differently or something like that, this is all, you have the freedom to do this. The most important thing is that you can read the source code. And hopefully then other people can also read the source of that is, that is the thing that we want to have happen. And we're actually going to take all of this. So the registration in it and all of our registered methods, and even the mod event bus. And we're going to put this in here. And I'm actually going to separate this a tiny bit. And we're going to add some comments. And it's the registration of our additions. Additions, they go. And this is then registers, items, blocks, ETC. Added by our mode. And this one is going to register MOD events, right? This also and then of course needs to be added to the instructor here. Then next thing, we're going to delete the Duke Client stuff. I'm going to lead this comment. And actually we're going to register this after setup. And there's one more thing to do this is we can also delete that comment. We don't need that. And we're going to actually create some new classes as well. So inside of our MC course package, we're going to first create a new package called setup. Once again, you could, you could possibly also put this into util. This is very much a question of how you want to organize your packages so that you feel comfortable. We're gonna create a new Java class, which is going to be an interface, and that's gonna be called IP proxy. And then we're gonna create a second class which is going to be the client proxy. And then a third plus pulled the server. Roxy. Alright, so i, a proxy actually is not that crazy of an interface. So there we go. This is going to have one method which is going to be called void in it. And then another method get pliant world ie to import this one. And then both of those of course, implement the eye proxy, implement methods. And right now we don't have anything in the sorry. In the year we can just return minecraft dot instance dot world. And then here in the init Actually we can add something. And that is going to be the render type for the zucchini crop. And we can also delete this method here. So we can add this right. Here we go. And then the server proxy, this also implements I proxy. And the, well, first of all, implement methods course. And here we're actually going to throw a new exception. And on the run server, because we shouldn't get the client World on the server side. And the init is just gonna be kept empty right now because there's nothing in that we are doing on the server at this moment in time. We're also going to add the event bus subscriber. So that's gonna be MOD event bus subscriber, mod id, dot mod ID plus. This is math.pi event bus subscriber dot dot. And this is the most important thing, just dot, dot reliant. And we go, I'm going to copy this over or the server proxy. And the only difference here is that this is going to be dedicated server, right? Right. So that is all that we need to do here. And then inside of the MC course class, again, we're going to create a, I believe dismiss must be public. Yes, this is a public static IP proxy will proxy. And we're going to initialize this right here. And this is going to look a little bit crazy. But don't worry about it. Dist executor, dot safe, run for list. And then we're going to create these client Roxy new and server proxy, new server proxy, New Evil. Yes, like this. And also import these two. And I believe that that should be all of it. We want to knit this right here. So proxy dot in it in the setup method between the register conflicts and the load conflicts. Yeah, I think that should already be everything. Now we've actually tidied up a little bit here. So the, the, this class looks quite a bit different. And to make sure that everything works when I run this, just so that we are sure that everything is working fine and we haven't broken anything. It's always a great idea, especially when you're refactoring your code to make sure that everything still works. If you've have tests written, which of course would. I don't think that that makes sense to write tests, especially for something of this size. But if you write tests, then making sure that the tests still work and the program still works, that's when important. So for example, one of the things that we might want to look at is whether or not the render type has been probably activated and has so that's pretty good. Or items seemed to be all in place of the thing sleeps, be working totally fine. So yeah, that's great. That's pretty good. And this was basically all that we needed to do for the cleanup. So just just cleaning up a little bit and having this be a little bit more readable, right? So yeah. 63. (Minecraft) Custom Block Models (Including Blockbench): All right, welcome back to the Minecraft course. And in this lecture we're going to look at customer Brock shapes and how we can make a block that is not in the form or shape of a block. So what we're going to need for that is the, another program which is called block bench. Some of you might have already heard of it. The link to the program is available as a resource. And if you open it, something like this should show up. And what we want is a new Java block slash item. So we're going to click on that. And then we can give it a new file. I'm just going to call this test. I've already prepared everything. And then we're just gonna say, okay, and then we find ourselves in here. So we can zoom in with the mouse, we'll right-click, we can. So holding right, the right mouse button is going to transform our vision here. And then if we hold left-click and we can rotate around. And this is actually one of the easiest 3D programs to use. And it translates really well to Minecraft. So we can just add a cube here and then we have one cube. Now this would be the, so the entire t of this grid here is one block and one cube is 1 16th of a block basically. So for example, we could say here the size x, and then we can say 16. And now this would actually be the length of a block. And then we could say, well, I actually also want to have it in this direction as well. And now the bottom layer, so the bottom pixel of the block texture, so to speak, is now filled up with this 3D model. And yeah, and then we can, for example, say, Well, then let's pump it up here as well. And now we would have a full block, 16 by 16 by 16. And yeah, so with this, we can basically build stuff. So we can say, well, we went one here, one here, one here, and then we can build it with either these individual blocks or we can have bigger blocks and, and just, you know, build something. So the creativity really has no limits here. You could also rotate it, right? Depends on whether the pivot is. So this pivot is basically the point where rotates around. So if we then centered the pivot, then it's going to center inside of here. And then we can actually rotate it like this. So we can actually make the shapes that are nano tubes that are non-block related. And actually do that in this case. But now we can do this, for example, right? So we can make a pretty crazy things here. However, I have already prepared a model to show you. And it looks something like this. It is nothing spectacular. However, it is a non, it's an irregular block shape, let's say. I have also put in three textures, those are just colors in this case. Of course, if you wanted to have a real blocked and you would need to import the texture seer. However, this is very easy. As you can see if I, for example, go in here and I select, let's say this cube here. You can see that there are different sides, right? So the north side would be this side. And I can move this around now if this were to be a texture file that I've created, and you could basically say, okay, this part of the PNG should now be displayed there. It is. I think, very straightforward to use this program and you should be, like, I would say in about an hour, you should be able to create fairly well, nice models here. And yes, so this is actually very nice and very well done. However, there are a few more things that we would need to do for this to work. So let's say you have created your model yet you want. We actually need to look at a few other things. And that's gonna be done in display up to the top right. And that is how it's going to look in the players hands and in third person and so on. So there are a few things that we actually have to put in here. So for example, these scale, by default, it is, well, very big. So you will probably need to adjust the scale in a lot of ways. And you need to go through all of the slots here. So the third person, and you can see in first-person left first-person ride, you can look at it, how it looks on the head, how it looks on the ground. So the reference here is one block. So you can say, well actually I'm maybe, I want to have this really big or not so big. And we can look at it in a frame. You can change it in a, an island frame and also in the GUI. So how it looks in the inventory, you can all change that. And this is all gonna work fairly easily. And yeah, so too, to export this, you then need to go to File Export and an export block item model. This will then generate a JSON file and adjacent file can then be used as a as a block model. However, there are few more things that we also need to look at. And that's inside of the class that we're going to create. And however, we're going to finish this up, what you need is you need a plug-in which is going to be called Mott utils. So you can just go to available mod utils and then install it. I've already in solid of course. That then allows you to export this as a voxel shape and you're going to need that. So voxel shape, this is, this is also a JSON file. It creates the shape for the block so that the, that you basically have the boundaries of the block in exactly this pattern, right? So you could imagine, for example, a block that maybe we have. For example, you can, you know, a slab. And a slab of course, doesn't have its boundary in the entire block, but it's only half a block. And that's exactly the same thing that we want to have happened with that. So for that, we actually need to create one group here called voxel shapes. And then we put all of the cubes or parts that we have made below that. And then we can export it. And we actually need to export this four times. We, because we want to explore this one's facing to the north. That's why I've created this sort of with this bigger part here, facing to the north. So we actually know what the facing where C. And then we always want to know, we want to work with everything and we want to rotate this around and then export this as a voxel shape. Export this as a voxel shape, export this as a voxel shape. And then we're back to here. So we can actually, for, once again, for this particular example, everything is supplied as a resource. For this lecture. However, if you want your own, then you will need to export those things. And I will show you the files, how they look and what to do with them. And just a second. So we're going to switch back to our intelligent here. And then we're going to quickly take a look at, for example, the voxel shape that you're gonna get. This is going to be a.java file and it's going to look something like this. So this is just going to be a stream of voxel shape. And we're going to implement this well very soon. And I'll show you how to do this. But first we need to actually create a new block. So for that we're going to create a block. I'm going to call this the electric fire electrifying. Yes. And this is also the basis of some other things that we're gonna do, which might be tile entities in future lectures. But right now, this is just gonna be a broke with a new and custom shape. It's going to extend block. But it's also going to extend the right block. That's very important. Because sometimes he does take the wrong block. That's little annoying. But there you go. Alright. So that's pretty, pretty good already. We have this done in there. And then we're going to immediately yeah, we're gonna immediately put all things in here. So the first thing we need to add is a private static final direction property will facing. And this is going to be equal to horizontal block dot horizontal facing. As the first thing we're gonna do, oh, there you go. And then we can add some overwrites. So the first thing we're going to override is public voxel shape. Publics. Public voxel shape gets shape. This one. I don't worry about this. The arrow here. We can also do a suppress warnings. This is deprecation, right? Yes. Deprecation like that, right? Yeah. Okay. Yeah. It's not the big issue here is that it just shouldn't be called, but you can override it. So that's not the worst thing. And then we also want to override the blocked state, public block state, get state for placement. And this has as a parameter item, use contexts. Context already returned something and that's going to return this dot get default state with facing. And then the context dot-dot-dot placement, horizontal facing, and then the opposite. And we're going to go Override here. Nope, that's not that's not quite what I wanted to do. This is what I wanted to do, the ego. And then there's two more, actually three more methods that we need to implement. One of them is a blocks stage. We're just going to be rotate. It's going to take in a block state, state and a rotation. But this is also going to be an override other one. And you do quickly get rotation in here. Once again, this says a depreciation. We're just going to suppress that warning because it's not going to be the worst thing. Right now. We're going to return state with the facing and then the rotation in the direction of facing. So this, all of these methods that we implement right now at this moment are basically for knowing what direction we are placing the the block. It is very similar to when you place a furnace, for example, The side of whether furnace burns always is facing you. This is basically very similar to what we're doing right now. This is going to be as the same thing here, the mirror. And then we're going to return state DOT rotate and then mirror in DO2 rotation. And this is going to be state.gov facing once again. And that's it. And then the last one, last method we actually need to implement is a protected, protected void fill container. That's going to be a state container. And a container, nope. A O dot builder of lock and block state. And this is going to be a little bit more complicated here. But it's actually not that. Well, it looks complicated, but actually we're just going to say builder dot add, basing. That's all we need to do. And I want to import this class. Say this is an overwrite as well so that we know. And that is it. Now, we will need to change this one as well. Because now we're going to take the facings that we've gotten. So this would be for files and that we get when we export the voxel shapes from rock bent, like I said, basic north, east, south and west. And I'm just going to take over one of them. So this is something how it would look like. Of course, this for us right now makes little sense. But not to worry, we're going to figure this out. This is just something that you need a copy over. I've already prepared this for all of the sides and I'm going to quickly explain once I've copied it over. Okay? So voxel shapes needs to be imported. Boolean, function and stream as well. And then that works very well. Ok. So what's happening here? Well, we define a private static final voxel shape. And then we want to define the voxel shaped for north, east, south and west facing. And then we just copy over the stream. Very important. The stream is without the dot get here at the end. So you need to add this in order for it to work. And then we also need to add this to the ghetto shape right here. And we're gonna do this with by making a switch statement. So we're gonna do switch and then we're gonna say it gets facing. So we're basically depending on the facing, We're gonna give it a different voxel shape. So the first one we're going to have is case north, which is going to return shape underscore n. And then what? I'm going to quickly copy this a few times. And the movement say east is then going to turn shape, ie. South is gonna return shape S and West is going to return. Can you guess it? Shaped W? And then we're also going to add a default, which is going to return shape. And he's going to say, hey, we can then leave this out. We're just going to leave it like this. This is going to be fine. And that defines the shape of the block. Now we also need to add the Bloch states and the model. But that is going to be actually not too terrible. First of all, let's let register this in here. This is going to be public static, final registry object of type block. And that's gonna be the electric fire. Yeah. Which is going to be which is going to be register electric fire. In this case, we can use the normal register method again. And this is going to be a new electrified with abstract blocked properties. Properties. And then we're gonna say, sure material, material that iron. Let's take that one. And then let's do Partners in resistance or format this a little nicer. And what else? How about harvests tool? Yeah. I think that that makes sense. It's going to be I would say, pick X makes sense. And then anything else that we need? Yes, we need the group where I want the group. I don't know the group is going to be defined automatically because we've, we've done that down here. So yeah, I think that that's fine for the Registration. And then we want to add the block state. So now the Bloch states is, it's not difficult or anything. However, I'm just gonna copy this over and explain that once again. So this will be the electric fire dot JSON. And in here we actually have different variants right now because we want to change the rotation of this model depending on where it's facing. So this facing here is referring to this facing over here, right? So when this is north, then we're just going to display the normal model. And when itself, we're going to rotate it by a 180 degrees and so on and so forth. But this is basically a short explanation of this. This is nothing too crazy. And then we need the block model. And this is going to be the one that's the craziest. This is the one I'm just going to switch over to the other one, this one. And this is going to be the one that you're going to export here. So the exploit broke item model. And that's going to be the JSON file that you're going to see there. And that's going to be quite crazy because this one is going to look something like this. I'm going to copy this over and you're going to all fall out of your chairs. I'm going to copy. And this is how it's gonna look like. That's a little much right. That's, that's quite a bit of things. This basically simply defines the, each element, right? So each element you are, is simply a block, basically that we've defined in block bench. And then it says what texture each face has. And yeah, so this is just something that you copy over. Very important that the inside of the textures Here everything is OK. This might also have an issue. So the texture names are the same names that are here. So right now the, here, they would be called Texture one and texture to it x three. I've renamed this year to electrify our underscore 123 because it's textural 123 are really not that good of a name simply because then, well, what is it that and also what you need to add is you will need to add MC course or your mod ID in front here. That's very important. And I do believe that from the default that block bench creates is Brooks and not block for the texture is very important. We have named our texture in our text or words. In other words, our texture, textures, folders, block and item, singular, not plural. Very important. And so let's then also get the electrified JSON for the item that is a normal item that refers back to the block, that is it. Then we also, once again, every file, even though I also have the block bench file, the JSON, and all of the four voxel shapes, as well as the textures, are all available as a resource once again. And we also want to add the textures in block right here. Copy over. Yes. We also have the electric cars. They're just red, green, and blue squares. So it's not it's not a real texture in that sense, but yeah, yeah, and I believe that, that is everything. Now, it is a little bit more of course. However, for special blocks, let's say it's not that complicated. All things considered, let's just start and see if everything works. That will be the best case. Of course, we haven't added a localization yet. But once again, the localization should be fairly easy to add if you want to add that later, that is mean trivial at this point, I do believe so. Alright, let's look in here and let's see how it looks in game. With. The more complex the topics get, the more error prone they might be, right? That's why it's always good to check if everything has worked and let's see. So first of all, that's pretty good. So we can actually already see that the model has been implemented. We can also hold it in our hand. That's pretty nice. And now the big question is, can we place it? Yes, we can. And as you can see, the black borders when I go over this are actually exactly the shape of the block. Same with, for example, the envelope as you can see. And then here it would be the entire block. So this is the very, very like black line, the black lines basically. And that is exactly it. So if we step on it, I think we're gonna, we're gonna sink if we go in here a little bit. It's it's barely noticeable that there. Okay. So it is noticeable. And other big question is if the facing is always correct, so we always want this bigger part here, we facing us. And that also works. So let's just look at it like this. There we go. So it is facing the correct way. The voxel shape retains. Its, oh, there's a, there's a tiny URL, I believe. Look at that. So this is I think one pixel wrong. This has probably something to do with. This one is correct. So there's probably some error in the facings. However, it is barely noticeable. And I do believe that that is not the worst thing to happen. Anyway. So this is the custom block models are very much interested in what custom block models you come up with. So those could be, of course, crazy things or, you know, or normal machines possibly, or magical apparatuses, who knows? And yeah, this is basically how you create the custom block models with help of block bench. And yeah, if there's any questions, please feel free to ask. And if you enjoyed this course so far, then of course I would really appreciate a comment review. And yeah. 64. (Minecraft) Creating a new Tile Entity: All right, welcome back to the Minecraft course. And in this lecture we're going to add a tile entity to our MOD and specifically to the electric fire here. So the first thing that we need is a new package. Once again, we can either call this tile or tile entity. It really doesn't matter that much, but tile or tile entity is sort of where you should go with this. And then we need two new classes. One is going to be the MOD tile entities, entities that we go. And the other one is going to be the electrify or tile. So basically the electro fires the block. The electrify or tile is the tile entity associated with it. It could also, something that we might do is, for example, call this the electrify our block so that we are even sure of that. Okay, this is the block and the other one is the tile entity. That is something that could be done. We're gonna keep it like this, but this is something that you might want to think about. So first of all, we want inside of our registration a new default register. And that's going to be public, static, final deferred register of type, tile entity type. And then we're gonna put a question mark in side of there. And then this is going to be tiled entity types. That's equal to the different register dot create. Ford's registries that tile entities. Mc mod, mod OD. Beautiful. And then down here, we're just going to add this to our register for init method. And that is that the Mott entities we're going to look at right now is in there. We of course, simply need to add a final registry object. Again, this is very similar to all the other things that we've added, the items, the the blocks and the fluid. This is going to be of type. And then in sort of a question mark in here, we're going to actually specify the electric fire type. This is going to be elect electric fire into T. Let me zoom out a bit. That's equal to registration dot tile entities register. And it's gonna be like electric fire, Tyler entity. That's going to be a Tyler entity type dot builder dot create. And then we need supplier for a new electrify our tile. And then here mod blocks, dot or we don't actually have a blog yet. Don't know. We do have multiple, Of course, we have the electrify are already filled. And then inside of here we want to specify a null and that can then be deleted here. One more no. Somewhere. What's the issue? I of course, the electrify our title is not yet a tile. However, that should be fine. So then we also need our noted public void register like that. And we can register this instead of here, where we didn't just simply say mod tile entities that register. And that's great. And then inside of the electrify our tile. And of course we want this to extend tile entity. Tile entity. While entity a we go, yes, this one. And this is going to create a an instructor. That is fine. You also need a second instructor which is going to be electrified or tile with no parameter. And inside here we want to take the mortal entities, electrified style.css. So this, this constructor calls this constructor with the, with this tile entity. And then the arrow here is way and then the error here is also a way. And then we can continue to populate this. So right now, what we're going to create inside of our electro fire is simply an item stack handler. So I'm gonna create a private final item stack handler and this is four. While handling items. Crazily enough, I'm going to call this create handler. And this is a method that we are going to read right here. Items Stan, item, stack, handler. And that's going to be pulled create handle is and it. So tile entity is basically just a block or its, its data associated with the block that can store dynamic data, right? So it's not, it doesn't have to have a, doesn't have to have a GUI. That is something we're going to look at as well. However, it doesn't have to. So in this case, we're actually just going to make it so that we can pass items into the electric fire and get them out again. And we're gonna do that with hoppers, but we're gonna see that soon enough. So right here will actually create a new item stack handler with sighs One and insight. We need to override a few things. Protected void on content, on contents changed in slot. We're going to mark dirty. So this is just to make sure that the this is something to do with the, with the trunks and making sure that this is safe properly. Boolean is valid, is item valid, that's r1. I let. So this simply defines whether or not we can actually put in an item. Into a specific slot. At this point, we're simply going to return true. And then the last one is actually the method where we insert the item into a specific slot. Once again, a non-null item stack, stack and a Boolean simulate. And the Boolean simulate is just so that we, if this is true, then we actually only simulate putting the item in. We don't actually put the item. And so usually this would be false if it comes in, but it still has to be there. This is non null and an override. There we go. And then here we can finish this. And that seems very good already. We also need to make sure that we have specified the this as a lazy optional because we need to specify the capabilities. So tile entities work with capabilities. And in this case, we want an item handler. And here this handler, and this is a lazy optional of and then we supply him the item handler Evo. Yes. And then we want to return this. I'm with another override down here that's going to be public. Lazy, optional. And let's get capability. Capability. Yeah, I think that that's right. And be a non null capability, t capability and a nullable direction side. So you could imagine that different sites might have different capabilities. This is once again an override. And that simply is going to be cave, ability is equal to a probability item handler. So we're checking whether or not what is holding for is the item handle a capability. And if that's the case, we're gonna return handler dot. And if nothing else the case, we're just gonna return super dot git capability, capability and side it will go. That is all that we need to do here. So the capabilities and you can also, I believe look at them year i storage. And let me just quickly see capability, item handler. Well, those are specific ones actually. Yeah, so there are different capabilities, like I said. And in this case the item handler one is the one that is, I think the most interesting one right now. And one we're going to look at, there are however, two more things that we need to add. That's going to be a write and read function. So it's going to take the block state, state. And a compound nb t. Maybe you've heard of that before. This is the nvt data that a lot of people talk about when looking at items and so on. And we're going to have this item handler dot de-serialize MVT. That already works perfectly fine. Yet compound with a string inventory. We're going to quickly write this, something in there. So read and that's the state tag. So this is basically a read. So it's gonna read the inventory or the, the, what we say. It's going to read something with the name enough. So inventory in our case. And then we also need a public Humboldt MPT. We're just going to be right, that's going to be compiled and B t tag. And that's the other way around. So in here we're actually going to put the in there. That's going to be item handler dot de-serialize. Sorry, serialized, actually serialize. And then we're going to return super.onCreate with a tag name. We're also going to overwrite that one just so that we know. And I do believe that this is the tile entity created with the capability of handling items so that we actually have that we can actually put items in there. And it has one slot, four items now we can't see that slot. And we can, we can only interact with it sort of from the outside. There's one more thing or two more things that we need to add right here to the electric fire. And that is two methods to override methods. One of them is, let's see if I can find it here. It's a lot of methods by the way, that you can implement. So there's a lot of things that we can do. This is going to be a public tile entity, read, read tile entity, block, state, state, and an iBook reader which is going to be the world. And that's gonna return, return, mod tile entity, tile entities, electrified talents dot github, V8. This is an overweight as well at that. So we are sure that and then the best override at all of all of them is has tiled entity. Well knows if it has a title entity, we do know and that is of course, that it has one. And there we go. All right. Done. So I do believe that that should be all of that. We have added this. I do believe that that was all of it. Let us try and see whether or not this works already. We've registered it. We have added the identities here. Well, once again, the worst thing that can happen is we get an arrow, but I don't think that we're gonna get one. I think that this should be fine. And yeah, so there's, the, the capabilities are an interesting one. But let's see if the item capability has been added to this. So from the outside, the block will not have changed. And while it has, we'll have changed from the inside. So as you can see, the block is still here. Let's just destroy those because sometimes when you change the block, then it, it, then sometimes it has some weird things that might happen. So let's put this down and then let's actually try and take the hopper or two hoppers actually. First of all, we're going to put this year. That's pretty good, right? So we can actually see that it wants to put something in there. And we'll also put one below. And then let's just put in the hoppers and we can actually see that there are inserted into your lab. Right-clicking doesn't work. And there are also being I pulled out down there. So right-clicking on it doesn't work because it doesn't have a GUI and it doesn't have the capability right now to be right-clicked. And we can add that of course, but, and we are going to add that in the next lecture. But right now, as we can see, the blocks are, or the items are passing through this block down here. And that's basically what we wanted to demonstrate that, yes, indeed the, this has an item block handler capability now. And it is a tile entity and saves the items in there. And look at that. The bunny is going to show up as well. Isn't that nice? That's great. Right? So that is basically how you create a tile entity. Of course, this is not quite done yet. However, those would be sort of similar to things like pipes that we might see or an item can widths or something like that in different modes. Where those might also be tile entities, but without a specific Gy, because they only, they only need to save some sort of data. And they don't necessarily need to have a GUI, right? So this is how to create a tile entity. Once again, if there are any questions, feel free to ask. And yeah. 65. (Minecraft) Create a Custom GUI: All right, welcome back to the Minecraft course. And in this lecture we're going to create our own custom GUI for our electric fire that we've created for our tile entity. And there are few things that we need. We need two more packages here. The first package we're gonna create is going to be cold container. And the second package is going to be cooled screens. Now, this screens one can be argued whether or not we wanted to have that somewhere else and the container as well. Once again, this is something that is customizable, let's say two, however you want to break this down, same with the mud fluids. A few lectures back. Maybe you want your own custom, custom package for the fluids and so on and so forth. It's, it's really a style rather than something that has to be this case. I'm gonna do it this way. But you are of course, free to do it almost whatever way you want to. So this is going to create, this is going to have a new Java class called MAD containers. Containers a ego. Very well. And this is once again one of those classes like the mud blocks and the moat events. Not something that we've not seen before. First, of course, we need to go into our register and registration and get a public static final deferred register once again of type container. And that is going to be actually it's not of container, but it's of container type with a question mark here, containers. And that's going to be different. Register dot create four registries. We've seen this plenty of times before now. And that's going to be containers, scores mod, mod ID, right? This shouldn't be a mystery anymore. And then of course added here, very important. As always. Those are, those are the sort of mistakes that you, that one makes for getting it to add here. And then it takes like an hour to actually figure out why it doesn't work in a new CEO. I just forgot to register it. And that's always, that's always something that might happen. And those are the worst mistakes. Okay, so first of all, we are going to actually immediately put this in your public static final. And that's gonna be a registry object. Registry object actually not registering, registering object of type, container type. And then we need the leg electric fire container. Now this obviously doesn't exist yet, but we're going to create that elect fire container and making sure that I'm writing this correctly because. I don't know why I've chose electrify or as a name, but I mean, I mean, I know why I chose, but sometimes there might be a typo in there, but yeah, this is going to be of type II forge container type dot create. And that we can actually already create a few things in here. And block, block poss, pos equals to data.frame, Blog. World, World equals inventory dot player, dot get Entity world, and then return a new elect fire container with window IID world. Pause in dot-dot-dot player. Once again, this doesn't exist yet. Well, we also need is a public static void Register method. Once again, as always. Also, we need to import a few things. This of course can be imported that doesn't exist yet. Then we're going to add this down here. This is going to be the mod containers. Containers register, write o, right? Then inside of our container, we're now going to create this, electrify our container. So it'll be the electric fire container. Let's hope that I've written it correctly. Otherwise, we're going to end up in serious trouble. Now of course, we can always refactor it if this name wrong. Very important that this is the correct container that we're gonna take. The net Minecraft inventory container and not the one from the Java can interact with. Yes. We're going to do that and then we need a constructor. Okay. I mean, I don't excuse me. No. I don't want anything to do this way. Why doesn't it work like that? That's weird. Okay. Well, let's then we don't even need that actually. That's the, that's a crazy thing. We don't actually need that constructor anyway. We're going to create our own constructor that's going to be electrified or container with the things that we have done before. So we're going to need a window ID. We're going to have a world, world. There's gonna be a blocked pause, pause. It, player inventory, player, player inventory, and a player, player entity, player. And then this needs to be imported. This needs to be imported. And what else needs to be done? A few things I believe. We need to insert super Yes, with mopped container dot electrified dot get and the window ID. And then everything is going to be hunky-dory as the kids say. Oh, container type has to be has to be imported and then I believe that this has no more yes, this has no more arrows rate and, and this has no more errors. And then everyone is fine. That's great. So in the container, we're just gonna go through the container first. We're going to get the title entity or well, that's something that we actually need to specify here. So there are three things that we are going to have. The private tile entity, title entity. We're going to have a private player entity, layer entity. And we're going to have a private, private eye item handler, which is going to be the player inventory. And those are the three things that we're going to immediately put in here. So this dot tile entity is equal to WorldCat tile entity at the position that we specify in the, in this constructor. And this dot player entity is equal to a player. That's actually pretty easy. And unless player inventory is going to be equal to a new inventory wrapper of player inventory. Okay, that's great. Next thing, and this is something that we were just going to do and then I'm going to explain it as we go along like always. So if the title entity is not null, so this just ensures that we actually have a title entity. Then what we're gonna do is we're going to say, hey, so tile entity dot gets capability. That's what we have defined before. And if the capability item handler dot item and the capability if that is present, then one we're gonna do is we're going to create some stuff. And this actually has some consumers. And what we're gonna do is we're going to add slots. This is the slots that we see in. So for example, the inventory where you put in the items, each of those is a slot. And we're going to create those slots now inside of the GUI itself. And I'm going to just put in some of mice, stuff that I've already prepared here. I'm going to quickly explain afterwards. And the greatest thing for that would also be to already start Photoshop up, just so that I have it hoping that it starts in on the right screen. Right, because that is something that we need to look at. So we need to look at the GUI. And how would you know what those positions are? And don't worry, you don't necessarily need to have Photoshop for that. You can also use, for example, GIMP or something like painted.net. I wouldn't I wouldn't suggest paint because paint is not the best for that reason, more helper functions and methods rather. So first of all, we need an ad slot arranged. Once again, all of this code is available as a resource as well. If you don't want to type it up. However, I do think that it makes sense to go through this with me in your and typing it, because sometimes typing it actually solidifies. So here we actually add a slot range. This is a helper function to add a multiple slots at once. So this is needed so that we have the, we can add the inventory a little bit faster. And then we have ad slot, the new slot item and lawyer. Handler index the x, y. And this is going to be then x is plus equals to dx. Dx is of course only the change, the index is going to be increasing. And we're just going to return the index. That's ad slot range. Now we wouldn't be private in ad slot box. Once again with an item handler, will handler, I think. And actually this one. And the only thing that needs to change is that this is actually why, and this is the vertical amount. We need another one, another integer, old. Well, that's actually Afterwards, my Lord, my land. I'm going to copy this over from the other one. Sorry. There we go. So we need into the index x, y, then the horizontal mount in the change of x, then the vertical mode, and then the change of y, so dx into d y. And instead of here, we're actually going to have an int i, j 0, j is smaller than the vertical amount. So we're gonna go through how, how many, well basically how many rows there are. And index is going to be to add slot range. So now we're going to call this one. And the idea here is that once I have typed this out, that y is n equals two d, d y of course. So the change there, and then we're going to return index. So the idea here is that this basically adds the, the row. So this is okay. This is called for each row, right? So ad slot ranges basically called for each row and add slot boxes called In how many rows there are. And this is needed for the private void layout. Layout, player inventory slots. So this simply makes it way easier to just immediately at the, at the player inventory, right? So we're gonna sit their inventory and then nine and then left col, and then we're gonna say top row and then we're gonna say nine. And then, and then we're gonna say 18. And then we're going to say 318. And this is more because this is not a slot but S LAB box. There we go. Nice. And then we also want to add the hot bar. So then we're gonna do top row plus equals 58. And then we're going to add another slot range with player inventory is 0 left call top row, 9180, not 1980. Thank you very much, Diego. Right? So this basically is just for the fact that we want to lay out the player inventory and it makes it way easier. And I wouldn't say that it's not necessary to understand how it like he couldn't. You can of course go through and understand that bit by bit. However, it's very important to know that this is, this is just some helper functions have health. Again, helper methods. They will go. Yeah. And one more thing, right inside of our head, interact with are actually going to return is within usable distance. And we're going to say I will pass callable of tile entity, entity, dot, get world. Then we're going to specify the position. And then we're going to specify the player entity. And then we're gonna say that this is in the mod blocks dot electrified air. There we go. There we go. This just is within this usable distance that we're just going to say, hey, we can interact with this if this is within the distance that is specified inside of this method that is within the container class itself. And that, that makes sense, that that's good to use. Okay, so in this, we've actually specified here, so the layout of the player inventory, we've also added the slots of the container itself. And there's one more thing that we need to do, and I'm going to actually copy this over because this is a very large method. And this is going to be added between those two. Like I said, a very long one. And in this case, the gist of this is simply that this method is called when we transfer a deck into a slot of index in O of index, index basically. And this makes sure that, well, if there is already a stack in there, so if there's already an item in there, of course we can't just put another item in there. That doesn't work. We cannot ever merge the stack if the if it's the same. And Yeah, and that is right now. In here. We also have the item specified on index one so that this, that only items can be diamonds, story items. The diamonds can be put into index one. However, we're going to see that this is also something that we have to specify in side of the instead of the I believe it's the tile entity. If I'm not mistaken. Idea inside of here, is an item valid, is something that we can also use for that. So next thing, this is the container, and the container is done. Next thing that we need to do is we need to actually register the container. However, we can't do that yet because we need the screen. So the screen is the, it's, I want to create a new Java class cooled the trip fire screen. And this is going to extend, extend from. Containers screen of type. Electrify our container. As you can see, it does get a little bit more complicated than before. The one method we actually need to implement here is the drug we container background layer. And then of course we also need a constructor. We're gonna just do on our own. This is going to be d electrifies screen. And that's takes in an electrified container, old container, a player inventory, old enough. And I text component would name. Right? And then we're just going to call the super on that. And that is going to be it. We also need a resource location here for our GUI file. We're going to have a private final resource, resource location. Let me hold GUI. New resource, resource location. We MC, mod mar ID and textures. Gui, electric fire, GUI, PNG. I'm going to show this soon enough, the GUI. However, right now, we're going to finish this screen that I'm going to go into the GUI and then also explain where I got those numbers from and how this works. So the first thing inside of here is actually nothing because we also need two more methods that we need to be overridden. And that is going to be actually, let's do it like this. Let's do, let's call it or render. And that's going to be the first render here. And then let's also say draw GUI, container foreground layer. Yes, I believe that that is the case. Ok, in here, we want to do this dot render background matrix snack. And here we wanted to have render hover, tooltip matrix sack, mouse x, mouse y. This basically just renders the, the the screen itself. And then in the background layer it draws a background layer. First of all, we want the render system colour, colour 4F. So this color is it, it matters. It it also says It doesn't really need to be there. I would do advise to put it there. Let's just do this one then we have this minecraft dot and get texture manager. With this, we are actually setting the texture. So this is the, we supplied the resource location of our, of our texture. And I'm going to say int i, this. We left. We have this int j, this GUI top. And then we'll just say this doublet. And this doublet basically cuts out a part of the image and displays it with the, these offsets and with the size. Now, this might be a little bit complicated right now, but don't worry, we're gonna go through this, okay? So this is everything except for we also want and energy label. I'm just going to quickly copy this over. That's going to be in the foreground and we actually don't need to call super. Of course we don't have that yet. So we're just going to say, let's say energy 0, well, the time being. And then we're going to add this when appropriate. And right now, this should already work. So we're gonna quickly, I'm going to quickly copy over the GUI texture. So this needs to be inside of the textures. And then we actually need a new one, a new directory called GY. And sort of there we're going to put this one, we're going to copy it over. And I'm going to quickly pull this to Photoshop and show you this info shop how this looks. This is how the, how the GUI looks at this moment in time. And I am going to explain the yellow and the gray here after we've gone through the slots. So basically the slot, as we can see inside of our container, once again, we've actually specified the first slot with index 0 at 3057, right? So 0-0 is up here, right? So at the top left. And then when we go with this, the first part of the slot is 13. We can see. And then up here, we can actually see that this is 57 height, right? So this then defines the slope is at this position. And the other two are exactly the same, right? Once again, this is also supplied ie. The yellow and the gray bar are for the energy levels. This is what we're gonna do that soon as well. But first of all, we're going to check if everything works with slots. Because we still need to do a few things in order for this to work. However, that is how you get those positions. Like I said, you can also use paint on net. It basically works exactly the same thing. And of course you can also make your own type of interface, right? It doesn't have to look like this. It can look crazy different. It can have a different color or symbols in between. Or you can, you could, you know, draw on it. It all works. It's just a PNG file. Now, what we now need to add is inside of our, So first of all, inside our client proxy, that's the first thing we need to add. Inside of the init file. Init method. We want to add the screen manager, screen manager dot register, factory mod containers, electrify container dot get. And then we want to say electric first screen. And then you were just going to use the lambda construction there, right? Was one of the thing we need to add. And then inside of our tile, Well, first of all, inside of the block, we actually need to add the capability of right-clicking. That's very important. So inside of the electrifies itself, we want to add, I believe, only one method, but it's going to be a doozy again. So this is going to be a block activated. Once again, it doesn't matter that this says, Oh, it's deprecated. We can just add this application again because for our purposes, this isn't that important. And we're gonna say, if world is remote. So if the world is not remote, that we're gonna do this. And this is going to be tile entity, title, entity, world dot-dot-dot tile entity at position that has been specified. And then we're going to say, hey, if this tile entity is an instance of the electric fire and tile entity, then we're gonna do something. And what we're gonna do is we're gonna say I named container provider. Tenor provider is equal to a new IE named pre-print provider. And then it's gonna go crazy and read something here, which is actually great because this is exactly what we need. Here. We want to create a new translation texts component. And then this is the screen dot MC, worst dot electric fire. So this is basically the, this is the thing that we use inside of our EN us localization file. And once again, you don't need to do that, the nullable necessarily. And we're going to actually read, rename those because it doesn't need to be. There we go. Okay, let's then also not return null, but a new electrified, electrified air container with a whole bunch of things. I world, oh, this is I, by the way. I world POS, player inventory and player entity that we go. And then world is not in here because this is what we're in. Well, that's not the worst thing ever. There we go. And it then needs to also do something very interesting. And that's going to be a network books dot open GUI. And we're going to say server player entity, player, container provider, and tile entity dots. Yet OS. If this is not a instance of electric fire, we're actually going to throw an exception. However, they do sometimes. Question my sanity with this. Let's, let's just return the actual result type of success. And I will leave then it is going to know it's still not gonna do them. Well, sometimes I don't know why he doesn't do it the way I wanted to do it, but OK. Throw new illegal state exception. And this is basically our container is missing. Well, it is the container provider, but yeah. Rho vita. Okay, in theory, this should be all of it. At this just makes sure that this is opened on the client side as well. So that there's this, once again, the server client difference. Anyway. So the unblock activated is cold when you right-click block. And I am just going to check if everything is done. And I do believe everything is done to at least make it so that we can open the the GUI. I do believe that this should work at this moment in time. We're just gonna try it. Actually. We would get an error. Because one thing we need to do is we need to put this to three. Because of course we have three slots that we specified inside of our container here. And this needs to correspond to these three slots. Let's just run this and see whether or not it works. And as you can see, the more complicated it gets, the more we need to look. And there we go, we actually do have an error. All right, I've successfully fixed the arrow and it had something to do as an owner of this lecture or the lecture before, where the weird annotation was, he wanted to sort of add something. And he added this in the Gradle build file. And that, I mean, I wouldn't say corrupted it, but then it just didn't work anymore. So I fixed it by just deleting that from the build Gradle build file. And yeah, it was a an arrow that had nothing to do with anything that we've did or that we've done. So, yeah. Let's just check whether or not the screen works now. And if we can actually see EEG UI in here, let's see. So first of all, it's best to, if you still have listening, if you still have the block somewhere deleted and place it again. Because otherwise, there might be some weirdness. So let's see if right-click whether or not it's gonna crash or if it works. It works, that's pretty good. We like to see that. That's very good actually. And now we can place things in all. So we can play all sorts of blocks in each of those things. We're going to change that very soon. First of all, we're going to, I actually had something in mind where what I wanna do this It also makes this energy label here. It creates that automatically. So that is done with the, with the with this draw GUI container foreground right here. And the first thing we're gonna do is we're actually going to add to the electric fire tile entity. And we're going to add a two things. So number one, we're going to add. Is we're gonna actually implement, oh, we're going to implement the clickable tile entity, which is going to make. And then we need to implement the method tick. And this is, let's, let's put that up a little higher. Actually. Let's put that up here. And this is called every tick basically. And we're also going to take two things. I'm going to just going to copy over s2, two integers, one tick and one energy level. So energy level in this case, I wouldn't call it, I wouldn't say that this is the energy level, like in machines necessarily. This is just something as an example here. And we're actually going to also go down here and we're gonna say, okay, is item valid? And now we actually want to say, well, it depends on what slot we're in. So we're actually going to create a switch of slot. And that's gonna have a case 0. Once again, we started with start counting at 0. And they are, we actually have a get item. Stack dot getItems equals Adams dot diamonds. So I only want to return, so I want to return this. So this returns true if the item is diamond. So only diamonds can be put into that slot. And then we're gonna say 12. And here we're gonna say default. And in this case we're going to return false. And in this case we're gonna say mod item's dot copper wire, No, not cover x cup wire.begin. And here the Adam is going to be an emerald. So the idea here is that we want to create is a machine that can, that can diamonds a copper wire and turn them into emeralds. Of course, there's maybe not the most logical thing, but it's still, this is of course, just an example of how this could look. And here in insert item, we're actually going to say if and then is item valid and then we, and then we actually want to have that not happen. So if the item is not valid, We're just gonna return the stack. So nothing changes. And so we're going to return the super insert an item if the item is actually valid for that slot. So that's something that we need to do. And then we also, I believe one, a paste possibility of reading out the energy levels. So we're gonna do that public int, get energy level. And that's going to return the energy level. And then we need to add this in side of Arctic method as well. So each time this is cooled, we're actually going to increase the tick by one. And then we say, for example, if tick is ten, so this would be every 2.5th. We want to have something happen. And then we ask ourselves, what do we want to happen? And this is of course, something that we need to think about ourselves. So, for example, I could say, well, if The stack in slot 0. So this is where we put the items if this actually is an item in there, right? So dot diamond. And for example, the energy level of this machine is smaller than 64. Let's say we want to say, well, 64 is the highest energy level we want to have. Then what we can do is we can say, well extract the item of the slot 0 by the amount of one and we don't want to simulate, we actually want to delete it. So this is what, this basically deletes the item, right? And then we want to have energy level. So the energy level goes up by each diamond that is being destroyed. And then we can save as well for each tick. If we have a slot in, if we have an item in slot one, which might be, for example, the copper wires, right? So MOD items, copper wire, dot get. And, and this is very important and the energy level, energy level is bigger than 0. And also if the other, this is also very important. If item handled drug gets stuck in slot to get count and not get item, but if count is not equal to 64, well, actually we can say is smaller than 64. Yes. Yeah. And this basically says, well, you know, we want the energy level, the energy to actually have some level in order to create new emeralds in this case. However, this is something that this needs to be thought about. And the, this basically is the logic of this, of this machine, let's say. And we're gonna say that it is, extracts one item here. And then it's going to insert a new item into this one. And that's going to be a new item stack. New items stack with item's dot emerald. That's going to become one. We don't only want to simulate it, we actually do want to have that happen. And then the energy level should decrease as well, know, minus-minus, and then the tick is reset to 0. Now this one here should be configurable, right? So you should refer back to the conflicts lecture where we actually put in config. This should be something that should be configurable. Same with the energy level, I do believe so. This should be something like Max energy level. And you could also think about, you know, having the amount be configurable than you would need to change a little few things here, but it would still be similar. So to basically say, in this moment in energy level is basically exactly equivalent to a diamond. In this case. A maybe you want to change that. We also need to then go to the container and add a another function Milan method as well at the bottom. And that's going to be a public int get energy level. And this is simply going to return a surefire title, this.title and t because it doesn't know what Thailand's This Is that good energy level. Without that one yet, and this is only in desktop client. By the way, this should only be done in the client because we only need to update this or the client. What is the issue? And the container? Well, it was one-to-many. Okay, they go. And inside of the screen, now we can actually added this. So we can actually say container dot get energy level. And then the energy level is going to go there as an update there as well. And, and then we're going to also add this another, another billet. I'm going to quickly put this in here. So the idea here is that if we go back to the GUI, the GUI, as you can see, it's always full. So if the yellow bar is up to the top, then it's basically full. And what we're gonna do is this thing is going to be laid on top of it. So I'm just going to quickly do something like this. So this is going to be laid on top of it, and it's going to be deleted for each. So each one pixel is going to be deleted for each energy level we have. So this is exactly 64 pixels high by the way. And this is one way you could do it, for example. And yeah, we're just gonna look how this, and this actually looks in-game and whether or not this works. So this is basically the idea at the offset. Once again, here is, those are some simple math. I would say the x and y is the top left corner of the, of the where this should be placed, this, this cutout. And the cutout is defined by the you offset and V offset. And then as a certain width and height associated with it. And the height of course, is dynamic with the energy level, because we want the, the gray bar to be higher or lower depending on the energy level. But that's sort of the idea. We are going to destroy this one more time and actually get a new one just so that we're clear with, you know, sort of weirdness. So let's get diamonds, let's get some copper wires, and let's see if this works. So first of all, this did work before it was a yellow. And now we actually see that the that the overlay did work. We're just going to put we're first for a woman tried to put something else in there. Okay. That doesn't work. That doesn't work. That doesn't work. That's pretty good. And I'm going to just put the diamonds in here and see what happens. Well, the energy does increase and the diamonds die off. And it does look like the, this is increasing. Isn't that nice? And then what we're gonna do is we will actually put in the copper wires here. And they then turned into diamonds and of course, two emeralds. And then the energy is not increasing anymore because this is a one-to-one relationship basically. So if we take the diamonds away and the energy is actually decreasing at this point in time. And the cup wires are being turned into emeralds here. And once this is done on, the energy is depleted and no more animals are created because of course, we have specified that energy has to be bigger than 0 for this to work. Right? There we go. Yeah, this is a simple machine. So it's not a crazy complicated machine. No, crazy complicated machines might be. The examples, of course, once again, are in GitHub and in popular modes they are. I would always encourage to look at that. But this is how you create a Gy, how you create some sort of a tile entity with a bit of functionality. Like I said, the functionality is within the tick function basically. And there are also other things. Capabilities you can add, of course still. And you can make those capabilities sided. But this is just a general introduction to this. And yeah, once again, sand, this is a bit of a more complicated and more complex topic and also more complicated lecturer. So if there are any questions, feel free to ask. Once again, all of the gy and also the source code is all available as a resource. And if this was helpful to you and you liked it, I would very much appreciate a review of the course so far. And yeah, that was how you create a custom GUIs. And yeah. 66. (Minecraft) Ore Generation in the World: All right, welcome back to the Minecraft course. And in this lecture, we're going to talk about or generation. So we're going to generate the copper ore that we've created many, many lectures ago. And we're going to actually generate that into the world. So for that, we are going to, first of all create a new node, not a package intellectually. We want to create a new package. And that's going to be a world. And inside of that package we're gonna create another package which is going to be hold Jen. Once again, this is, let's say a style or customizable. It just makes sense to have it in a world. So at least the world packet should be done. The generous, sort of optional. And we're going to create an enum actually, which is going to be Cold War type. Now this is something that's going to be very similar to the thing that we've done with the armor and the, and the weapons and the material. But we're going to go through this, so we're going to have a block in here. We're also going to have a, an integer which is going to be called max Sylvain size, a final into job min height. This is the minimum height that the and that is spawns at. And the Mac side, basically the max block height where this would spawn the correct block, yes. And we're going to have an ore type block, block ind, max, vein size. We wanted int min-height and an integer i, max H. And then this block, so this is just a normal, once again, a normal declaration and a normal constructor. Maxwell incise this dot. Min-height equals min-height. And this dot max height equals max has beautiful. Okay? And then we of course, also need some getters for those. I do believe that I can create these ones here again, create a getter for block, read, ghetto for max vein, and a getter here. And I know that's not right. I wanted to have a getter. There you go. Okay. So then getters full of us and then we're going to have a public static or type, which is, we're going to get with the block. And we're going to go through this. So for each word type or in values, if the block is equal to word.lower, OK. Then we're going to return that or and if that's not the case, we're just going to return null. We could also throw an arrow but were an exception, but that's fine. Right? And then here, up here, we're gonna create the copper one, and this is going to be multiple ox dot. Copper block gets, and then we're just gonna, I'm just gonna put in some numbers right now. So the max vein size is going to be eight. It spawns at Y level 25 up to Y level 50. And the great thing about this is that we only need to add in new enum here if we want to add another one. So for example, we can simply do something like this and then say, for example, copper block. And then also this is copper or by the way, not copper block, right? And then we can say, Well we actually, So the adding of a new or is literally just adding this. That's it. This is why I find this to be an interesting idea to do it. And then we're gonna create a new class actually, because this is now done, which we're gonna call mud or generation. And your generation is actually going to be have a MOD Dot event bus subscriber, import MOD immediately. That it's going to be a little bit easier. Mod ID, let me MC course id. And then the bus is going to be dot if it was subscriber MOD. And then we're going to have one big method in here which is gonna be regenerated worse with an FMLA, FML load event complete, unearned away for other parenthesis of runner that it's not necessary. And this is going to be a subscribe event. And inside of here, I believe that what we're going to have is a method called add feature to biome. So I'm just going to copy this over because this is a, this is a method that simply breaks down the, the features of the biome and then adds something to it. And we can actually use that to our advantage. And this is going to be, we're going to go through each or type in word type dot values, right? So in this case we're just gonna go through all ores and we're going to go through some things. So the first thing is we're gonna create a or feature config, which will have a new Orfeo conflict. This is going to be worth feature Conflict dot filler block type. So in here, which say, what is the filler block? So if you have it, it's possible. We'll, we want to create eight. We have set the max veins has to eat in this case. But maybe we have, you could imagine that then is a two-by-two cube. But maybe it's the max vein size, so it's possible that only six or seven generate. And then the question is, well, what do we want to fill the rest with? And that is basically done with this filler block. We want the get the resource actually ordered. Resource does not own its actually get blocked. Yeah, you're right. Get default state. And then we're DOT GetMax vein size. This is the where feature. Then we want a configured configured placement and figure placement, which is gonna be placements. No, it's actually just going to be placement. Placement, dot depth, average, dot configure. And in here we're gonna create a new deaf average config. And that's simply gonna take min-height and or Mac side like that. And the last thing, the two, well, not quite lost, but almost lost. We're going to do registry that Register a world. Jen, registries that configured feature or dot get block, dot-dot-dot registry name, it registry name. And then we're going to have feature dot or with configuration. And to implement the CS, the ego, or dot width configuration or feature conflict, we've already configured that. That's the great thing with placement that we've also configure that one. And then we have a dot. It will go dot square, dots. I believe that this is not like mapped yet. This is going to be this. And that's once again or dot max bin size one more time. And that's it. There we go. And the great thing is now what we can do is we can just go through each biome and coal in a forge registries that biomes. And inside of there, each biome is basically written in. We just read that out. And we, for example, don't want biomes too. We don't want this to be spawned in, for example, category.net, right? Because that makes no sense. And we also don't want this to be cooled and get category equals and then biome dot category. And that would be the end, right? So we're only going to generate this. So we're only going to add feature to biome of biome and generation stage. This is decoration underground ors right here. And then the last one is going to be world Jen registries, dot configured feature, get default or none, or dot get block, get registered name. So that's what we've basically registered here. And that's going to be added as a feature to the biome. You can, of course, also instead of, let's say this negative here where we don't do it if it's the nether or the end. You can also specify specific biomes. So maybe you want specific oars only to generate in specific biomes. You can of course, all do that with some if statements over this is actually already everything needed for the generation here. The, this is being called automatically. So let's just run this and see in a, in a new world what that brings. And if we can find, well, in our case, both the copper ore and the copper block. I've of course, for as an example, also generated some copper blocks. Just to show how we actually easy it is to add new ors in this case. So of course the blood needs to be added, but if you have added all the blocks, then you can just make this end. This is super easy. So let's create a new block. Newton knew block, new, new world, of course, in creative mode for the time being. So it's generating, which is a good sign, of course. And the fact that nothing has crashed yet is also a very good sign. Also something that's always something that's, you know, might happen. And we're going to just go into spectator mode and flight down. And maybe we can find that I put the, there we go. We've actually already found both of those. That's great. Let's right. So here we have some copper blocks, 123, that was a small vein. And here we have another one of copper or 1-2-3, 4-5-6, right? That's great. And so you can you can, of course, play around with the numbers a little bit, right? That's always something to be done. Well, so I could just write that. That probably would help. Let's see if I can find some L's. Are there is another 11234. That's four. Vane. And yeah, so as you can see, there are, of course, a few things. It is also dependent, of course on the, on the height. And there we go. There's a few other ones. So at this point we are it height 2020 to this barely just made it in 12. I, here's some more three. So this is a really great ate. The generation is fairly easy to understand and that's actually a big vein. That's nice. And of course you can play around with the numbers. That's like the best thing you can do. Let's circle back. And that's the best thing you can do, right? So play around with the numbers a little bit and just see what you can do rate. So this is the tip here for the origin ration, but that's basically already it isn't that, it's not that complicated, especially compared to the GUI or the the other the tile entity stuff. So yeah, that's basically it. If there are any questions, feel free to ask. And yeah. 67. (Minecraft) Creating a Custom Tree: All right, welcome back to the Minecraft course. And in this lecture we're going to create our own custom tree. Now what we need for a custom tree is of course, plancks, logs, leaves and a sapling. And this is the first thing that we're gonna do. We're gonna go into our mod blocks, the class and create exactly those objects. Registry object of type block. They are all of type block. And I've decided to create a redwood tree. And it's going to be record plank is equal to register the red wood planks. And then here we're going to do new block with some abstract block properties, which are going to be from Locke's dot, OK. Planks. Very easy. We're just gonna take whatever the plank properties from o planks cause does nothing special in this case about them. And also have the redwood log log here. And I log here. And this is going to be a rotated pillar block. And the properties are going to be, of course from OK. Ok, would you go? And here we're going to have Redwood leafs. And don't forget to change the name inside of the register method as well. But here, because otherwise you're gonna run into errors, leaves as well. And that's going to be a leafs block. And then one last one, which is going to be a little bit different because it makes sense to copy this. Yes, it still doesn't make it make sense to copy this and this is going to be the redwood sapling. And that's the one that's going to be the most interesting, let's say, or the one with the most work associated with it. Let's say, let's actually get rid of that. And this is going to be a new red wood sapling, which of course doesn't exist yet. But we can already fill this in because I already know how it's gonna look. And this is gonna be a new red wood tree, which also doesn't exist yet. So there's a few things that we actually need to create some properties from. And here we're going to take locks dot oak sapling. Suddenly you go, and that is it. And of course those need to be created. First, we're going to create the redwood sampling. This is inside of the block package again, the red wood sampling. And the redwood sapling is going to extend the Bush block and it's going to implement an eye roll. Okay, let's first of all, have the methods implemented. Can grow, can use bone, meal and grow. And then the next. And then also of course, a constructor with the super inside here. We're actually also want a supplier of tree, which is going to be tree in. And this is also something we need to have as a final field here, a supplier of three, supplier of tree, which we're just going to call tree. And Or we have to take three, reimport that. Very important that it is tree, net Minecraft block trees and not the other one. And this is going to be the normal supplier. And this is then this tree is equal to three. And we also pre answering the EU. And then we also need a integer property. Integer property called stage. This simply is the lock state properties dot state, dot stage 01. So this basically means that it has a integer property whether or not it is grown or not grown. And inside of the can grow, we're just going to return true because this block can rope, can use bone meal. We're going to create a random number basically. So we're going to do a double and it's going to be world in dot random dot. Next load is this. I mean, we could also use a float, but it matters very little. So this basically has a 50% chance of bone meal working, right? So this one basically says that. And then we have a grow method which needs to be, a few things need to be done. So right here we actually need a state, state dot get stage is equal to 0. And here we're gonna say world in set block state. And I don't know my adds these parentheses that are not needed. State, and then we need to use function 235. This one, yes, this one I believe is the correct one. It is unmapped. And in this would actually be state DOT cycle, just so you know. And I'm gonna do else. Once again, the, the fighting with a form formatting. And then here we're actually gonna say, forgiven factory dot sapling, grow tree, world in random position. Oh, no, that's not position. Thank you. And if that's the case, then we're just gonna return turn. And that's not the case. And we're gonna see this dot three, dot get attempt rho tree world in, world in yet chunk provider get trunk generator, pass, state and random. They go. Looks crazy, but it's not actually that crazy. We also want to override the fill container, which we're just gonna save builder dot add stage. And we go. And we also need to override the tick method. And we're going to add these suppress, once again suppress warnings because the relocation, because that's not that important. So we're gonna say if the world in this area loaded position one. So if the position round the tree is actually loaded, is not loaded. Rather, we win, negate the SIR and then we're actually not gonna do anything. However, if this is loaded and if then the light at that position, so if the light above this position is above a light level nine. And then we also put in a random number. We're going to take an integer actually, next int with bound seven. If that's 0, then we're gonna do this star grow with world random position and the state, right? This is wrong because the test looked like this. If the position above the thing is above nine and if the random integer is equal to 0, So basically as about a, what is that one over 7% chance of growing each time the, the, the tick comes in, right? Something like that. Good. Now this isn't, by the way, this doesn't just happen in like seven ticks or something like that, then that would mean that it basically grows every second or it attempts to grow every second. That's not what happens, but yeah, this is fine. Let's then look at the tree. So this one works, but we have not implemented a redwood tree yet. Now, where to put the redwood tree is sort of a thing, which I'm not sure where it makes the most sense because it is actually something to do with the world, but it's also sort of a block. And if you have, if you know, you're making a mod with a lot of trees, for example, acting it makes sense to maybe even have a extra package for that. However, if you have like one or two extra trees, then it also makes sense to just put them in the blocks package. This would be the redwood tree. And this class is going to extend tree. This is almost a shock, I know. And first of all, I'm going to copy over some static, the same static variables here because they are going to be really helpful for or do. We want the ghetto tree feature as an overwrite? And that's gonna return something with a configuration. And that's going to be the public static final base three feature configuration, which is also be called redwood tree config. And this is going to be a real piece of work. But don't worry, we're going to be able to do this is to be base Tree configuration, config. Dot builder. And then we start, and now it gets crazy. So this is a new simple block, state provider. Blocks dot read would log. So first of all, we need to give him the redwood lock and we need to get them the default state. Then we have another simple block state provider, which is going to be the Mott blocks. Redwood leaves. That gets, that gets default state. Then we're going to have a new blob of foliage, pleaser. So with this, we're actually going to place the leaves. This is going to be a feature spread funk 2.4.2 TO HIV2 AES is correct. And this is going to be the leaf radius that we're going to take. Now actually put these in so that it's way easier to have a well coherent the configuration of w1. And instead of just putting in random numbers, let's say this is going to be the leaf offset. Then comma leafs height. Then we have a new straight trunk laser. So this is basically the place the placement of the logs in a straight line up. We're going to see a base height. Then we are going to have a first random height and a second random height. So that if the trees are randomly high or low, where two feature to later feature, which is just going to be 101. And then add them back here we're gonna say Build. And all of a sudden everything works. We've used all over things here and everyone is happy. This is also something we're going to return. So we're going to return feature dot, dot width configuration, iteration. And of course, feature has implemented or rather important. And then red wood tree config, bam, that's it. That is the entire tree. Already done. And I believe that that is correct. Yeah, everything should be fine here. Right? That is it for the classes. Now of course, we also want a generation. I'm gonna go get to generation soon, but first we're going to actually implement the or import, let's say the models and bloc states. So once again, I'm going to copy those over all files, once again, available as a resource. So we're going to copy over the Bloch states. And the Bloch states are, for the most part, they're very much easily understood and find the log is a little bit more complicated, of course, because we have a horizontal and a vertical log that we can place it in different ways. And the sapling, as for the bloc states, easy. But of course, when it comes to the model, then we are going to have a different thing. So we're going to go into, I'm going to copy over the block models. So there you're actually going to need the redwood leafs lock, lock underscore horizontal and then planks and sapling. As you can see, if I go to the log and the log horizontal, it's very much not too crazy. I also want to once again say that you can always go down here to net Minecraft client extra in sort of the external libraries. And look at all of the Bloch states and models of things that have already been done. So the acacia log, for example, acacia leaves, planks, vacation sampling. So this is all available to you as well. So this is basically where you can get how to do it properly, let's say. And the redwood sampling, once again only says, Hey, go to the sapling extra cross of course, because we are, when I have this in across patterns, so to speak. And the item models, we're also going to get those over. And those are here. Redwood leaves, just normal, normal stuff. Nothing too out of the ordinary. Right? And then we also need to add the new tags. And I'm going to copy those over as well. I'm going to put those in here. So this is basically going to be leaves, logs, logs that burn planks and the redwood logs. And they look something like this. So inside of the logs and the logs that burn, we actually have. This refers to Minecraft is because of course the data Minecraft tags are in here and then the redwood logs themselves referred back to the item itself. It's a little crazy, but once again, everything is provided. And then we also put in the textures inside of the block. I want to mention one more time I'm not an artist, so those aren't the greatest thing, but I think they are decently enough that it works. And now I do believe that everything has been added except for the generation, but we're going to look at the generation in just a second. First of all, we're going to look if the banana has been added. Now once again, as I've done in past lectures, I have not added the, the localization for the language. This, however, it shouldn't even be an issue. It's literally one line added. I just usually omit that out of here because it doesn't really change that much for the purposes of the lecture at least. So let's see if everything has been added and if we can actually see everything. So that's pretty good. So all things have been added. So that's a good first sign. Let's actually also get some bone meal as well. So this is the Planck's. We have the logs which we can also place horizontally. We have the leafs. That's pretty nice, and then we have the sapling. And that's of course the big question whether or not the sapling actually grows. So let's place it down. Yet does another thing that we need to add, but that's going to be very easy once again. And let's see if we can actually have it grow with bone meal. And it does grow. That's smaller than I expect that actually I think that they should be a little bit bigger. Well, that's a very small tree. Wow. This one grow are that sort of the that's sort of the size that I expected. You go. That's pretty good. Ok. I mean, that's like two very low roles. That's probably like about the normal height that I wanted to have. Half. Right. Great. Yeah, so that actually works. Once again, the this is the same, let's say arrow or issue we had with those ones. We just have to add this in decline of proxy. So we're gonna do that first and then we're going to look at the generation as well. This is inside of the client proxy. There we just need to add the render type HLOOKUP set render layer. This is going to be the model blocks, dots, Redwood, sapling, dot get. And this is rendered type get cut out. Once again, just the same as the zucchini crops. Right? And now we can actually add the generation as well. And this is going to be very, very similar to the Mordor generation. We're gonna create a new class cooled mod three generation. This once again goes from mod Dot event bus subscriber. Then just put in the mod ID and that's it. I'm scores mod, mod IID. And here we're going to have a, an event is public static void on biome load. And this one takes a biome loading impotent. Cool event. This is of course, a subscribe event. Does the word event already sound weird to you? Ok, let's see. So we are going to have a registry key of type of biome. So this is almost the same thing that we're, that we're doing in this method. A little bit differently. Let's say like that. It's almost the same. But we're gonna do it manually. Let say registry qi dot get or create key of registry dot biome key. So we're looking for a biome and we're going to look for the biome that has this name. They would go set, we're going to also have a set of biome, biomed dictionary type. Let's first of all get biome imported. Let's also get set imported. Now let's, let's keep this in one line actually and just zoom out a little bit. I think that would be fine. Yeah, there's going to be the type. So this is going to be all biomes, basically. Biome, it's going to be biome dictionary dot gets types with the key. And then we're gonna go through types dot contains biome, biome dictionary. And just for the sake of argument right now, we're gonna take planes. So I only want my trees to spawn in planes for the sake of argument right now. Of course, usually planes don't have that many trees. Otherwise they wouldn't be planes of course raise. However, this is sort of, sort of the idea or enough. This is going to be a list of supplier of configured feature. And this can be question mark, question mark actually a ego. There's going to be the base. And that's event dot gets generation. Now. Oh Lord, no, good generation. Dot get features of type generation. Declaration, duration, stage declaration, vegetal decoration. So this is the stage of generation where you add the supplier not supplied. This is the point of generation where the vegetation is added basically. And then we're going to need to get list as one. And then to that list we're actually going to add something. And we're going to add to that the feature dot three dot width configuration. And that's going to be the redwood tree dot redwood tree configuration with a specific placement. And right now we're just gonna take placement at other dark oak tree configuration, no placement configuration instance. So basically we are just copying over whatever placement configuration the dark oak tree oak tree has. It is I would advise you to simply take this one and play around with it a little bit, right? So inside of this placement. So you can either take placement right? There are a lot of things here that you can configure. And there's also placements. Placements, which you can also take the already done placements basically, and just play around with this a little bit. It's until you basically get the desired outcome. Once again, this should be done already. I do believe that that is it. We've also added this in decline proxy, so everything should work. Yeah, everything should work fine. So let's, let's actually see whether or not that works or not. And see what we can see when we generate a new world. This should definitely generate some of the trees inside of planes biomes, Like I said. Now let's see if that works. So we actually have to create a new one once again made of. And let's see. If that actually works. Would be kinda nice. Because generating note no errors. So far. So that's pretty good. And there we go. We are in planes, and this is now full of those trees. Now, once again, it's important to mention that of course, the planes we really wouldn't have, first of all, that many trees and second of all, not really any trees at all, if we're absolutely honest. So this is, of course, this is all planes. This is of course a crazy way, too many trees or planes. Like I said, the thing about it is that it's best to just play around a little bit with the placement and see what you can see over this is how you can generate some trees of your type. And yeah, this, this is the custom tree, the custom sapling and also how to then turn and then actually also spawn those and generate those inside of the world. Yes, so that's pretty good. If there are any questions like always, feel free to ask. And yeah. 68. (Minecraft) Creating a custom Mob: All right, welcome back to the Minecraft course. And in this lecture, we're going to create our own mob, or also known as an entity inside of the game. And the first thing that we're going to need for that is we're going to create a nother package. This is gonna be called entity. And inside of the package we're going to prepare already for two other packages that we need and that is going to be the model. And then inside of the entity package, again, render the NICU, not rammed up, but render a ego. Alright? And the first thing we're gonna do, however, is we are going to go to registration and declare another deferred register. And that's going to be is public static final differ register of type, this entity type. And then a question mark again. And we're gonna just gonna call this entities. You could also call this mobs if that's something you prefer, but it matters very little how it's called forge registries and then entities. Because in sort of the games code, they are called entities and not mobs, but usually people who play Minecraft, but don't really look at the code. They know them as mobs. Those would be passive and active mops. Then of course, also add the entities DOT register with the event bus down here in the init method. And then the registration is complete. Okay, then we need to create our entity. And this is going to be inside of our entity package or a new Java class, and we're going to create a buffalo entity. So the naming scheme is the name of the entity and then just ended with entity. And this extends the animal entity class. We're going to implement the methods. We only need to implement one method. Apparently. That's not the case right now. I of course, and also the the constructor. And that's gonna be that's gonna stay like it is. And this is a the eligible entity. We're gonna look at that soon enough. But the main thing with an entity is the register goals method. And that is the one that is basically the brain of the entity, right? So in, inside of here, we're defining goals for the entity to actually do something, right? So this has plenty of goals. We're just going to create a few right now. So the inside of it is you're going to write this dot goal, selector, dot add goal, and then a priority and integer. So this is just a priority. When you compare two goals, what would be, what would be done first and lower would be at a higher priority. So let's say, for example, a swim goal and then this, and this is first goal right now. It would simply swim. Now you can actually go inside of your right when you hold Control and then left-click. So you can actually look what's, what's happening and what I really advise. So I'm going to build a, just an example, buffalo here. The entity with a few goals. However, if you want to really go in there, you can go into the goal class itself and then press Control H and look at all of the different goals that they are. As you can see, just with the events, there are a lot of goals in here that you can use. And this is once again, sort of a thing where you just have to play around with a few of those goals. And if you maybe say, well, I kinda want something like this and it should look like this. Then you can just go through this and look at what we have. Avoid entity goals. So for example, this is something that happens in the right, the oscillate, for example, it runs away when you get to it. And there are so many things that are in here that are already defined goals that it's, it's actually staggering, like it's a lot of goals. And that's definitely, if you want to build a more complicated and more complex type of entity, the goals are incredible and of course, you could also add your own goals later on. If that's something you wanted to do, right, let's do a breed goal of this. And then the speed is one, d one, this is the speed modifier. In this case. We're also going to create a template goal. This is the goal. This is something that you add. For example, when you have a Pig, I believe that you can tempt them with carrots, I believe. Yeah, I believe so. And chickens with seeds, that's is the attempt to goal. So they, once again, you specify the creature. Then you specify the speed at which it moves. Let's take more speed. And then inside of here we're going to have an ingredient and it's going to be ingredient from items, more item mode items, more items, please. There you go. Mod items. I got three assets covering it. Let's just take the covering and what L dot get. And then here we have false. So the force is scared by player movements. This would, once it began to be something where the, where if you don't have the TMD item, then they're scared of your movement. In this case, we don't want the buffalo to be, to be scared. Let's also give the buffalo a add goal with priority free knew follow parent goal, follow parent goal. This. And then we're gonna have a little bit more speed. So this is basically speed modifier to the original speed of the animal. So it's going to move 10% faster. And then we're going to add a another one which is going to be delivered water avoidant walking goal? Yes. Random walking also, when it is rocking randomly around, then it tries to not go into water. And those are, let's say some of the things that we can add. We can also add. Let's go with the look at goal. Look at goal or loot at well, I mean, that would be an interesting goal, definitely. And inside of here we can then for example, say, hey, look at the player entity dot class. So we can specify what it's looking at. And this is actually the max distance is a float. Let's say for example eight f. So it's going to look at us even if it's eight blocks away. And then inside of here we can also add a look randomly goal. And that just takes itself. There we go, right? But why is this eight? Who knows? It's going to be six. Ok, so these are some of the things that the entity does now. These are some of the goals, like I said, best thing if you want to look at the goals is go through here and actually look at some of them. Try some of them out if, whether or not they're what you want. And also, what I can also say is you can also go into the animal entity and press Control H here and actually see the other entities. So the B, the B pig, the Fox, and whatever you might want. So let's say, for example, the chicken, you can actually see what the chicken has as a goal, right? It has almost the same thing that we have right now. We just have an added the panic goal. Because I would argue right now that maybe the, maybe the buffalo was don't panic when you attack them. And this is how you can really very well build up a new entity. So I can very much only advice to do that. Let's also add the sounds that this entity has. So the first one is get ambient sound. And we're just going to return the sound for the cow because this, in this case the sound events dot entity, ambient. Because this entity is actually very similar to a cow. I'm going to represent, I am going to show you my entity soon in block bench and you're gonna be amazed at the unbelievable creativity I came up with. But I think that it's actually, it's actually not that bad. It's actually not that bad. But yeah, so we're going to have an ambient sound. We're going to put the death sound in, get hurt sound is also something we're going to put in. This is going to be the sound events that cow hurt. And then I believe one more yes, the step sound and that's going to be close. That is placed step sound. We're actually going to say this dot, this dot play sound. I want the normal play sound. Yes, this one, I'm gonna say sound events, cow step. And then we're gonna say that the volume is a little bit higher maybe. So you could imagine that, you know, a buffalo is quite a sizable, quite a sizable animals. So maybe the steps will be a little bit louder, something like that. And then one other important thing is going to be a public static attribute modifier, map, dot-dot-dot mutable attribute. This is gonna be cause set a custom attribute. I would actually say it's set custom attributes, I would say makes more sense. I do believe that's the case, but yeah. Write it inside here, we can actually put in some return, some attributes that this entity has a mop entity dot funk. Yes. And then we're going to say create a mutable attribute. And then inside of ad tributes dot, and then we can see actually what type of things we have. So max health, we can set, for example, something like 20 d. And then, oops, like that one and then another one, for example, the movement speed would be kind of a good idea. Attributes, attributes, attributes, dot movement speed. There we go. And that's going to be, let's say zero-point 3D 35, right? Something like that. We can actually have that. Is that a no, I don't think so. I think that that's fine. Okay. And then yeah, and here, like I said in the when we go into weight, this one, beautiful attributes. No, that's not right in the attribute, sorry, this one, of course, and that we can actually see the different attributes that are present in the game itself. So flying speed, attack, damage, and all sorts of things that you can set for this entity. And yeah, I do believe that that is basically it. Now we actually need to specify this in a MOD entities class. So we're going to have a much entity types. So this is once again very similar to our, to the classes we have done before. The mod, mod blocks and all those, we're gonna say a public static, final registry object of type, entity type. And then in the end that no type, an entity type is going to be a buffalo entity that is going to be the buffalo. S is equal to registration. Dod entities register with name Buffalo. And then a supplier of entity type builder. Actually, we're gonna create a new buffalo. Let's use the is a lambda expression here, entity, classification creature. And then we can actually define some other things as well. So then we can define size. So this is going to be the size of the letterbox. Let's just make it a little bit bigger. And this is going to be a churned and build a few more things than we can do. So some of them are sadly a not mapped here. But there are other things that we can do. For example, there's a immune to fire. We can set this to be immune to fire. So this is, for example, something that a blaze rod would be, right? It's immune to fire. Resource of a new resource. No, that's not right. A resource location actually. And that's going to be Mc courts mod, mod ID plus the Buffalo. So this just once again it says a, where's the, where's the resource for that? And that's going to be two string actually. Reading that's already it. We also need to add, of course, our public static void, a register. Method and that needs to be called inside of our method here, Mott entities, entity types, three if three dots and those dots too many. And that registered, right? So this once again simply registers the buffalo and then we can actually also put this one in. So this is the age blended t. This is what gets created when 22 buffaloes mate or a breed. And this, we can simply get back one of those. So this dot world, so this simply then returns a new buffalo and creates new buffalo. Which would make sense. And yes, that would be that. And then we also now need to concern ourselves with how does the entity look and well, yeah, how does it look and what is its texture? Now? First of all, when you go to block bench, so I've I have prepared something, but when you go to block, when she can actually go in here and have this modeled entity, one, you can create a new entity. Our advice to first test this, retry this out, and then look at the texture later, because this is exactly the same thing. But most importantly, you should definitely set the groups as something that makes sense. So the groups should be head, and then there's body, leg, front, right leg, left leg back, right and leg bag left. Because this is what the entity model is based on. I'm going to show you what I came up with for Buffalo. Now you're going to probably laugh, but at the same time, I'm actually pretty happy with it. Actually. I actually kinda like it. So it's not that, it's not crazy. But I added these little horns and I made the body too. When little bigger, QPR and then one other end, your ultimate detector. I took the cow phase and modified it a little bit and then give it a texture. It's not that bad on amino would say that before I will release this for a game, I would probably change it up a little bit, but I don't actually think that it's that bad. One thing that's very important actually is the pivot points of the containers here, the groups. So they should be where you want this to rotate around. So the pivot point is always located at what point the, the group rotates around. So if I rotate this head right now, rotate from basically where they had reads the body. And that's of course exactly what you want to have happen. This is why you have to actually specify this at, say, the correct point. Same with the front leg. Once again, the group is the most important thing. And this one, if I were to rotate, it would also brought it here. So it's going to look kind of kind of like it actually worse that way. Then the thing about how to export it, you actually exported by just going export and export Java entity. Then what's the export somewhere? And then let's just see how that actually looks. If we export this. This would be inside of here and then the buffalo export. So this is a buffalo Export dot Java. And what you basically want is everything inside of here. We want to copy this. And we're going to create a new class for this though. So we're going to create the buffalo middle-class. And we'll create this instead of the entity and then model. That's gonna be new class buffalo model. Then we go and this is going to be with a T that extends buffalo entity or entity. And then this extends the entity model with a t. There we go. And we're going to just take everything inside of here, copy this, and paste it in here. And we need to import a few things. Microwave entity, you import the mall render, the renderer, the matrix stack, the vertex a builder. And this method can actually be deleted. And we're going to get a new one. We're gonna get that from. Actually, we need to delete this. I mean, we definitely do need to delete this. Actually, I think it's just going to be a t, right? It's not enough. Yes, it has enough. Okay. We we have to change this from a model, what was a model entity, entity to t. And then inside of here, we can actually do a very nice trick. We can go into Entity model and then we can actually look at, for example, the eligible model. A, this is a quote, quadrupeds model. And inside of here we actually have the set rotation angles and we can just copy this one. We just take the book and then we can say, there you go, that's not the right one. This right one can say that you go. And this would then be head and sort of had model. This would be had. And then we go. And inside of here, what is the problem here? We want constructors for that. And that is indeed not the case others, because the constructor has not been named properly. And I'll name this to Buffalo model than it actually works, right? So now this is important into the game. But first we also of course, need to write a renderer for this. Now the renderer is actually not that complicated. The renderer basically defines where the textures. So we're going to say this is a new class, buffalo renderer, and that is inside of the entity dot render package. This extends the mop renderer of type buffalo entity and then buffalo, buffalo model. And then I've typed buffalo entity because we haven't, we haven't specified that it's a buffalo enough yet. Yeah, and inside of here we simply have the resource location for the for the entity texture. And we also need to add a constructor with the super. And here we're just going to return a new resource location with EMC Corps model Ahmad ID, oop, not my ID. And then the path is going to be inside of textures slash, entity slash, buffalo, P and G. Let make sure to close that. There you go, right? So this is simply specified, okay, whereas this where's the texture? And I do believe I have the texture here, yes, four, so we're going to quickly move that over so that this is done. This is going to be in a directory called entity. And then we're going to copy over the texture. Yes, please. And there are a few more things that we need to do, but we are almost done. And then we're going to see whether or not the same thing happened, happens when I use this as happened. For me, this is a important thing. So there was one small, let's say, it wasn't an arrow, but it was a sort of a mistake that happened. And I'm not a 100% sure why, but we're going to fix that. We actually need to add inside of our client proxy a rendering registry, dot register entity rendering helper. And then we want to add the mod entity type, buffalo dot get, and then the buffalo retro. So this just makes sure that we actually, the game actually knows about the buffalo renderer mode entity types, buffalo dot get. Turner knew, have I missed something here? There is another thing that we need to add, but I would actually be amazed that that is it. So we actually want to add a deferred work queue run later here. And this is going to be something that is going to be a global entity type attributes output. And instead of here, we actually specify the attributes that we want this buffalo to have dot get. And that's going to be buffalo entity, dot set custom attributes, dot create. And then here we go. There we go. Alright, I actually figured out what the issue is. There wasn't that big of a deal actually. It was simply the constructor here was a little bit wrong. This actually, we can actually get rid of this. And we can just say, well, we know what the model is. This is going to be a new buffalo model. And the size of the shadow we can simply define by just typing the float in here and then no more error is going to be in here. Was just a little something. But once again, I'll leave the at least the short thing in because once again, at the end of the day, these things happen and sometimes the mistakes, I mean, I can tell you a little anecdotal say, when I first did this, it was actually insane. The ice forgot to. So this was, as you might have seen, this was returned null rate, returning a null. And I forgot to actually put in the resource location here. But the issue was I got an unspecified arrow. Well, that's just that was just terrible because then. You actually have to go through everything until I found that well, that was, there was some. So that's why I sometimes think that some arrows actually should be kept in. Because once again, known as infallible and number two, it might actually help with some of the things that you're gonna do and the arrows you run into. But once again, if there are any errors or questions or mistakes along the way, you can always feel free to ask and I will respond as soon as I can. Let's actually see whether or not we can see the buffalo in-game. Because like I've already mentioned, the model did have one weird thing with it after exported it from, after exported it from the block bench. So we're going to see whether or not that is also the case or that it actually works immediately. So let's first of all do time set date. And then we're going to see if we can actually sum on it. So someone M scores Buffalo, so does Swan. And as you can see, for whatever reason, that is definitely not what we had in mind, right? And so this is definitely, let's say, a little weird to say the least. So it's in-game, we can hit it. So that's pretty good, right. But well, the body is definitely not supposed to be. What have you done? Tell me what have you done. Ok. So actually going to look at this. So this is of course an issue with the bottle, with the body model type. So the, the textures Here, the boxes that are hired are definitely not in the right place. Now, I have actually fixed it in here, so we can simply quickly get this over. So I'm going to copy this over and we're going to look at this. So number one, these ones are insanely wrong, right? So the, so the, as you can see this, these are the positions versus the y position and the Z position of the body of the box. They are definitely not where they're supposed to be their way off. And as well, I have also rotated around because it was rotated 90 degrees and this is a then rotate around 90 degrees. So we're actually going to look at this one right now. So the fixed one and also the height and the depth has been changed up. I'm not sure by the block model did this. However, the good thing about it is that the parameters here are actually not that difficult to understand. This is just the x, the y, and the z coordinate of the specific box. And then you have the width, the height, and the depth of the box added. So in theory, even if there's a little arrow or a little weirdness going on with this, you can always fix it and you can also always go into the block bench and see, for example, when you take the Bollinger now and then for example, let's rotate it like this, like it was in Endgame. And you rotate it like this and then you export it. You can actually see what this rotation would do. So I would once again, if there's something that's weird, that could be one of the things that happen there. And let's run this actually and see whether or not this has actually fixed it. Because like I said, it is kind of weird. So from block bench to this, there's some weirdness I feel like when exporting. But like I said, you can actually fix it. It should actually be fairly easy to fix. And then let's actually see whether or not the model has been fixed or whether or not it still looks weird. They go, okay, the model has been fixed. Like I said, it's sometimes a little weird. So there is a also a little texture glitch down there. So as you can see in the behooves, let's say It's not really taking the texture. I can show you the texture just quickly. The texture is here. And t buffalo. And what I did was I surrounded this width. The width just like a bright pink or magenta, somewhere between pink, red image gentle. And a put is there just to signify. Okay, where's the, where's the textures are? Because inside of block bench, i'm gonna go back once again. You can of course, specified this year. And each block that you click on, you can actually specify OK, where's this texture? And then this d sectors simply have to be made, especially for this. But it isn't that difficult or complicated, I would say. Because if the, if the head, for example, this is 666. So basically you have six sides and each of them has six pixels on each side. So you can actually calculate, okay, what's the, what's the texture size that I need? But the best thing here is when you really want to text or something is too little, do trial and error rate because you can, as you can see, you can just move this round and then the texture changes. It's a little weird to do this, but it actually does work. So my advice, once again, it's just to try out a few things. Just tried out until what you want to do works. And then you can also cut down the texture in size, right? So this, of course, could be made a little bit more space efficient. But I do believe that that is going to be fine. Right? So all in all. And that is it. Like I said, the the adding of mobs or entities is definitely a little bit more complicated and complex than some of the other things. Because we actually do, we have actually written a custom renderer. Now of course, this is really not, there's really not a customer and real, let's be honest. It just facilitates to put in where the textures. But yeah, that is the mode entities. Once again, if there are any questions or if you've got any arrows, feel free to ask. And I'll be sure to respond. And yeah. 69. (Minecraft) Making our custom Mob spawn inside the World: All right, welcome back to the Minecraft course. And in this lecture we're going to actually have our entities spawn. So the buffalo is going to spawn both inside of the world. And we're also going to create a item so the, so the spawn egg for the Buffalo. So the first thing that we're gonna do is we're going to create the egg. And that egg is simply going to go into the items here. So instead of our item package, we're gonna create the mod spawn egg item. Now this is actually a great thing because this is going to be all of them at once. So if we have multiple ones, this can actually serve as multiple, different eggs for multiple, we say multiple entities. So we actually have to only create this ones. And then we can reuse this class for different entities. And the way we're going to use this is by making a protected, protected actually did static and final list of this model spawning item. We're gonna call those MOD eggs. That's going to be a new ArrayList. Exactly like this. And then we also need to import list class, and that is it. Now inside of this one here is actually going to be a little bit different. So we're going to actually make this differently. What we're gonna do is we're actually going to have a final registry object. And we're going to put in here with a class that extends entity type. Question mark. This is gonna be the entities supplier. And then the primary color is going to stay in the secondary coil and the properties are going to stay in. We're going to call this with a null and unwilling to fix this, this.tab entity, entity types of player i, we actually need to put that in. Of course, there's going to be a private, private final lazy of a type question mark and then extends entity type. Let's remark that's going to be called entity type supplier. And we also need to get Entity a lazy rather. And then this dot entity type supplier is going to be equal to the entity supplier. And we go, oh, of course it's going to be lazy off the entity supplier. There we go. And then yet, I do believe that that's the best thing to do. And then the mod eggs dot add this. This simply then adds the, the class that was just created with the constructor into our static list that we have in here. And then we need a static method. We're just gonna use the list of eggs to initialize the x basically. And what's gonna happen here is we are going to actually take a map, final map, entity type and spawning item. So it's a little, it's an, it's just the map. This is going to be done with the obfuscation reflection helper, get private value. So this basically allows us to get a private value from a class. There's going to have null instance that the field name is going to be x. Let's import map quickly and then I'm going to quickly talk about this. So inside of the spawn egg item, we, As we can see, there is a private static final map, exactly what we've specified, which is called x. Now this is of course private. This is why we couldn't exit. But with the association obfuscation, reflection, helper can actually get that private variable and in this case the value of this. And then we can use it to add things back in there. And then it's just going to add this for us automatically. So the first thing that we're gonna do down here, actually we are going to type the public entity type, question mark, it gets type, so that it's done out of the way. This takes a compound NVT and BT, and it's going to simply return this dot entities paradox. Yet this is by the way, an override as well. So then that is done. Then we only need to add something to the inlet spawned eggs, right? And now we're going to specify the behavior that's going to happen for the dispenser. So we're gonna create a default at the spins item behavior. Soon call that dispense item behavior. So be a new expense item, dispense item behavior, default, right? And instead of here we have to override one new method and that is going to be the dispense stack. Yes, exactly this one. And what we wanna do is we want to return stack. However, there are few things that need to happen first, the first thing we do is we want to get the direction. Well that's not the right direction and the read direction is the direction. And that's going to be sourced dot-dot-dot getter, block, state dot, get. No, not get that direction, but get dispenser block dot facing. So here it is just we want to know in what direction the dispenser is facing. Then we want to specify the entity type. So we just get the entity type that is within the spawn egg item. So this stack dot get item, o, item, they would go dot get type, stack dot, get, hag. There we go. And this, this, this then simply gets me the entity type that we want to spawn and then we wanna spawn this so entity that type spawn insight of the world that we need to specify the spec, well the spawning, no player. The position at which this is the spawn reason which is dispenser of course. And then we'll wanna say direction is unequal to direct shut up and not down, but up. And the last one is false. So this simply makes sure that this doesn't spawn upwards when the, when the Spitzer is pointed upwards. Stack dot shrink by one, right? So then the egg is actually consumed, let's say. And we want to, once that is done, you actually want to add this in here. So this is going to be spawn item, spawn egg in all, all of the entity types. But we wanted to mod spawn item, the mod eggs. And for each of those we want to add the, so x-dot. Put. This is going to be the spawn egg daguerreotype with no and BT and the spawning. And we also want the dispenser blocked at register the behavior. And there we said that spawn EG and the dispense behavior that we have specified up here. And then in the end, when we've done all of this and initialize everything, then we just want to clear the mod x. So basically, this needs to be called, let's get rid of a few things here. This needs to be cooled in the plaque client proxy. We can actually already put that in here. So this is simply mod spawning item in it, spore next. So this is now called in the client proxy. And we however, need to read a new item first. So this is going to be the actual spawn eg. And like I said, when we have a, another example, if you want to create another entity instead of a buffalo, I don't know a hyena for example, or something like that. Then you can simply add almost the exact same thing that we're going to add here now. And it's going to immediately work. So this is going to be the registry object of type model spawn egg. I took some sort of an item. It's gonna be a monotonic item. This is the Buffalo boning egg. Oh, no, it's not an edit. The egg. And that's going to be in registration items. So it's going to be a normal island, let's say the buffalo spawn eg. And that's going to be a new modes, one act of type, mode, entity types, Buffalo. And then we've specified the colors and we have to actually specify those colors in hex code. So we're gonna do a 0 x and then the hex code, I'm just going to take a few colors that might not be the best thing over you can. If you can actually play around with it a little bit and try a few different colors. And these are just the hex code for the color behind the Xerox. And then the item properties are simply going to be once again, the group, which of course is mc cores metadata course tab. And that would conclude the the egg. However, before we go in game, we're going to quickly do the spawning inside of the world. Inside of our gen folder or a package, we're gonna create a mock entity spawn plus. This, once again is going to be a MOD DOD event bus subscriber with MOD ID MC course that already. There we go. And that's all we're going to need. And then we're going to have a take void on biome load by OMA nob on biome load they oh, this is a biome loading event. Event. And this is a subscribe event. And I'm quickly going to copy this over because this is basically going to be exactly the same. Since I'm important they go, there's going to be almost exactly the same happened with the tree, I do believe, Yes. But this is almost the same as happened with the tree is going to happen here. Just instead of a list of configured features, we're gonna have a list of mob info dot spawners. So we're gonna get the spawners with the entity classifier creature. This is the classifier that we put the buffalo tube. And then we're gonna create a new spawner here. We can actually go in here and look what things that there are in there. So we're just going to specify the type, the weight, the min, and the max count. The weight here simply means how often this is gonna be spawned. And I believe that what it was was an sheep and things like that are ten. I just put it to 30 so that we're sure, okay, actually, somewhere they spawn. This is once again something that you need to play around with a little bit with the numbers. And also very important year, I've actually specified that they don't spawn in the ocean biome, otherwise they would probably drowned very quickly. And then the min count simply ok, what is the size of the herd, let's say in this case, and yeah, let's see whether or not this actually works. And the spawn item, most one egg item also works, but both of those should just work. The good thing here is that you can also specify, of course, let's say maybe one, the buffalo only to spawn on planes. We can already do that by specifying here that the types contains only the a type of the orbital planes. Yeah, exactly. So that is something that is very easily done actually. Let's see. So let's create a new world and let's see if we can both see the already spawned ones. And then also the item that we have prepared, the egg. Wouldn't that be nice? Well, it would be very nice. Yes. Let's see. Oh, we spawned in a jungle. That's fascinating. O a, we have the egg with no texture. Well, that's definitely not what you want to see. However, we can't spawn the buffalo that, that's kinda nice. Then let's actually fly around the outside of the jungle. I'm not sure. We can actually even see them if they're in the jungle. Let's go over there and see if we can see some of them. I do believe they are, they are let go. Some of them are actually spawned inside of the world. But don't worry, they, they've not walk from here to over there faster than I can fly. Like that would be, it would be crazy. They're actually spawning a murderer or somewhere that you go on even turtle, let's go and drills. Alright. But they spawn in the world. Now the egg actually doesn't have a, doesn't have a proper texture because of course we have not added the model for it yet. Then how can it have a texture? If it doesn't have a model? That is a very good idea for a question actually. So let's add the model for this. I'm just going to copy this over and look at it again. Well, it's not that complicated. But once again, sometimes the one line is enough to not have it work properly. I do believe that once the item here is added, then it's gonna work. We don't actually need to supply a texture because we have of course supplied the texture, so to speak, with this one. So this is the template spawn egg simply has to NO2 two numbers that it associates with colors and then it's going to radiate that on its own. And there we go. Now it actually has those two colors in it. Of course, you would probably choose some other colors. But once again, the colors you can play around with them if you want to or need to. And then you can add your own custom helix. So we're but I like I like it actually. When they run around. Yeah, that's pretty cool. Yeah. And that's how you add some new entities. That's how you make them to spawn in your world, and how you can add the spawn items. Once again, the localization is the easiest thing ever, simply inside of the localization file as always. However, what you also should do with the entity itself is you should definitely add the entity. So you should definitely add this one. So this should be an entity on MC, worse, Buffalo and then a buffalo, right? And of course, the small neck. It's going to be fairly trivial to add this, right? That is how you spawn the the mobs and how you can create a sperm and egg. I do believe that that is it. If there are any questions, always feel free to ask. And if you found anything helpful here and actually have created something, then I would very much appreciate a review from you. Otherwise. This was it for now. And yeah. 70. (Minecraft) Creating a custom Biome: All right, welcome back to the Minecraft course. And in this lecture we're gonna talk about creating our own custom biome. So we actually had a student who ask, okay, how can I create my own biome? And this is a way advanced topics. So this is way more complicated than some of the other stuff that we've done. But don't worry about it. We're gonna go through it one by 11 piece at a time. And then I think we can manage it. So first of all, inside of our world package, we're gonna create a new package, which we're gonna call biome. And then directly after that, a second package also in or a world package. And that's going to be or feature. Now we start with the biome package. And in there we're gonna create a new Java class called the logging surface builder. And making sure that the o is small day go logging surface builder. That looks good. So this is basically a well sort of helper class so that when our biome spawns, we can actually see, okay, this is where it spawned. So that's basically all that this is. So let's, first of all, this is going to be a whole bunch of generics in there as well. So this is going to be C, extends the eye surface builder conflict. And also as which extends a surface builder, surface build stories surface builder See, there you go. And then also going back. And this class itself extends the surface pillars as well, right? So then, first of all, we're going to get a few arrows here. Just implement the methods as we see here. We have actually extended the surface builder plus. So we of course need the, we need one method and that is going to be the built surface method. This is basically called when the actual surface spill, we can just middle mouse click or Control and then click on the surface. And we can actually see that instead of the surface. But when we go down, we actually have this built surface. This is an abstract an abstract method. And this is, like I said, hold when the actual thing is generated, let's say. Now what we want inside of here is actually we were just making this class as a sort of, it's not wider wrapper class at sort of a class that just functions so that we actually can lock something out in a efficient and easy way. So let's get a logger here. This is the log for j logger, will logger, and that's going to be the log log manager. It's not the right log Manager. Log Manager, this one dot get longer, they go. Then we'll also have a private final and then a lazy of type S. So this is the Type that's given here, which has to extend the surface below. And that's just gonna be the delegated surface builder. And then also a private boolean called logged, so that we actually only logged as ones and not every time we continue to build stuff. And yeah, so then let's make a nice, a nice constructor here. So we're gonna get a supplier of type S that's going to be the surface blur delegated surface builder. And then also a final Kodak with C codec. And we're just going to call the super constructor. So for the surface builder clause itself, and we're gonna give it the codec here. And then this dot delegated surface pillar is equal to delegative surface blur. We also need to import the codec plus this is e come Mo Geng serialization, very important. And this is, of course, this is because this is a lazy, lazy dot. Whatever we pass in your, their ego. Or so, this is the constructor or ridden. And, and we only need to finish this. And this basically just goes up along the way of Hayward. Take the delegated surface builder. We're just going to get that. And then we're going to call the the build surface. And then we're gonna put in every parameter there. We can actually already just autocomplete that. That's really nice. And this then basically simply calls the normal surface builder that will be cooled anyway. But like I said, there are a lot of moving parts here. So don't worry if there's something that's a little bit unclear. We're gonna go through it. First of all, class by class, and then we're going to see how they all fit together. So we're just going to say, hey, if logged is not true as when the surface is built, first of all, we're going to set it to true. And then we're going to simply the chunk pause of trunk path. And this is just gonna be the chunk in dot get past. So this is just the chunk which is currently going, which is currently being built. And then we're gonna say logger dot info. And then just going to be like currently generating at. And then I can do this one, yeah, exactly. Entering this Act. And then two ordinates here. And we'll just say biome dot, get registry name. And then chunk pause. I'll get x start. Is that doesn't exist because we don't have the chunk paths in there and passed dot get X stored. And then chunk paths not get y star, y, I get z, sorry, z stored because y is of course the top, while the axis that goes from bottom to top of the world. And that's the logging service builder. Like I said, it's sort of a helper class in that it's just easier that we can actually check the terminal and the console to be like, OK, this is where actually a biome of ours has generated. And then next part, what we actually want, we now want the surface builder to, well, have, we actually want a proper surface bidder 42 that we're going to create a new class. Once again, we're just going to be the Mott surface builders. Important. This is plural, right? So multiple ones. And inside of here, this is something we've seen many times before. We're actually going to create a new registry object. And this is going to be the final registry. Read history. Check. The ego of type surface builder with a surface Builder conflict. And this is going to be the logging default. So this is because like I said, we're just going to create this as a sort of a default surface pillar that we are going to use so that it always spits out the ordinates. And I will of course also need to do, we also need to go into our registration and actually add the new default register here. We actually have to add two new registers. We can immediately do this. So the first one we're going to add is actually, we're going to add the Register of type a biome. So this is the type where we have, well, our biomes, of course, right? So biomes, and this is going to be do the def keyword Register dot, create, and then forge registries. We've seen this many, many times already. So this, of course, shouldn't be an enigma anymore. Let's go with this one biome. And then also, oops, and then also a public static final deferred register of type surface builder. And then a question mark because we want to actually specify the config ourselves. Right now we're only going to use a specific one, but like I said, we're gonna get to that in no time deferred Register dot. And this is going to be four registries that surface builders. And then once again with the model Ahmad, evil, right? So those are already in here. Always make sure to put them into the unit. This is like some of the one of the things that can happen that you forget that and then, well then everyone's kind of baffled. Well, why doesn't this work? You know, make sure to put the wolf, the biomass surface builder Register method into the index, into the inner registration. And now we can actually already go in here and say registration, dots, surface builder, surface builders DOT register. And we want a name. Once again, this is going to be logging default, like I said, it's just going to be our default one. And then you need a supplier of a new surface builder. And then we're going to do the logging service pillar that we've just created. With no typing here. Instead of here, we actually need a supplier as well. That's going to be. Spiller dot default and then a surface below or conflict. And we're going to choose this field right here. Let me see. This is going to be yield 37 to o. That doesn't actually exist. I guess that means that we actually do have a default here. I know why because this is not the surface photoresist, surface conflicts, sorry Diego. And there's the field, of course. Right? And then also make sure inside of our, of the MOD surface builders plus to add our trust the old static void Register method that we can then call in inside of here. Let's do this after the fluids have been have been done. This is an maud surface builders DOT register. And then that's also done nice. Right? And after this one has been created, we can now look into the something else. And that's going to be another class instead of biome here. And that's going to be the MOD bigger surface builders. Now i, you might be like, what the hell is going on here. And don't worry about it. We're gonna get through this. So this is a registry key actually, right? So this is a registry key of type configured surface builder with a question mark. And this is, we're going to call this the oil surface. Now this is going to be made clear very soon. And this is going to be equal to Registry e dot e or create key with registry dot configured surface builder key. And then a new resource location with our MC smart MOD ID and then we'll surface. So and like I said, there are multiple steps and paths to go through this. We're gonna go through this and then check out each of the each of the components individually. Yeah. So there are now I believe, two more things that we need to do. One thing is inside of our feature. Features. So this is the ensures that we might want to add and we actually don't need that yet. We can actually, first of all, the microbiome. So let's go in our biomes and create the modern biomes class. And this is going to be are like master class where all of our biomes are well at. So we actually start with the static final registry object. So this is now the register appropriate biomes. So this is your, we are actually defining our biomes now. And this is going to be the oil biome. So of course we created oil and I said, Well, why not make a biome that sort of like a dead lands vibe that has like oil Petrus. I thought that that was an interesting idea is just to show how this works. And then I'm gonna show you how to customize these things as we go along. So of course we are going to once again, all the registration biomes or registration and then the biomes deferred register. And this is going to be. The oil biome. And then we're going to have a method call, we're gonna cool, make oil biome. Now, this is a method that we've not yet created, but I'm going to quickly finish the, the, what we want for this and then we're going to see, so this is going to be world gentle registries, dot configured, surface builder. There we go. And then get worth rho. So this basically now goes to the configured surface builder. Let's try and format. That's a little nicer so that it's actually readable. Those are like really long statements. It's actually not that easy to get everything on here. This is going to be the mod configured surface filters. So that's what we've just now done with the oil surface. And we can close this. And then actually only one. Yes. And then we have the depth and then the scale. Like I said, we're going to create the, the method just after this, import, the registry object. And then of course, we're gonna get an error because the the big oil biome does not exist yet. So we're gonna make a new private, private static. Biofilm will make oil biome with a final supplier of type configured surface builder with a question mark once against this surface builder. And then a float. And a float, not height, but they go. And then we need to get supplier in as a class Java util function. And then somewhere there's probably a, yeah, there we go. Okay, now that actually already works. Now of course we're not returning a biome yet. And this is also a method that is definitely what you should look at someone else for this. So I'm just going to put this in. So bio maker. And if we once again Control click or middle mouse button, we actually get to the biomarker class from Minecraft. And inside of here we actually have these static methods that have, that are available to us or are, they are used to make certain biomes, right? So here make giant, giant, giant tiger biome, right? And as you can see, there's a lot of stuff in here. And we're actually just going to copy what is in one of those and then change it up a bit. So we're gonna take the swamp and we're going to take that as a, well as a basic, let's say. And we're going to copy everything that's inside of it. And then we're just going to paste it in. And we're going to get a few errors. Probably. The first thing we want to do here, the hill variant. In our case, I decided to not have Hill variant on our biome. But of course you can, you could also change that. But like I said, this is just a, a short introduction into the biomes to make them like really specific and make them really customer. You have to play around with all of the tools that are given to you. But first of all, let's create the bio mainland. Let's see what happens here. So. The top, we're actually going to do a final biome generation setting settings there, yo dot builder. And this is going to be our biome generation setting setting builder. And we're going to create a new one. So new and we actually get that suggested here, that width surface builder, and that's the surface builder. We're gonna give him up here, right? That we've supplied in there. So this is the surface right now. And this is then gonna be used instead of this bio generation settings right here. So this is basically this one. You can also just change this. Actually that's probably a little bit easier. So just change this one. And then that also works with ego. So this is the biome generation settings. Yes. Ok, but like, and as you can see, there's a few things that already happened here, right? So default biome features with passive mobs. That's very interesting in all. Well, let's first of all go down here. So this is a very long, as you can see, a very long, a return statement here. So let's try and set this up a little bit so that you can actually see it a little bit better. So there's one thing, as you can see, that actually has a, an arrow here. And that is going to be the get sky color with temperature modifier. Now, there are multiple things that you can do. I gotta be honest. The easiest thing personally is simply to take this private method that actually calculates the sky color on based on the temperature and just stick it in your mouth biomes. This to me, just the easiest way to do this. Of course, there are more clever ways and you can use reflection to the obfuscate this and all of that. It really doesn't matter. I think that this is totally fine and this is, well, well, well, alright. Okay. Let's look at this make oil biome now and see what is actually going on. Before we do that, actually please add another method that is going to be this public static void Register method here with nothing in it. So that we can actually register the, the biomes as well. And they should be registered before this biomes DOT register. Just in case. And now the biomarker, let's get rid of that one and let's see. So the map biomes. Right now, this would simply add a new biome called the oil biome with this oil surface right here. But there's one more thing that is, it's not missing, but it's, well, it doesn't really do anything at this moment in time, right? So, so there's nothing really exciting going on is basically just going to create a new, a new swamp biome. Because that's basically what we've, what we've copied here, right? And so the real question is, well, where can we get a the next thing that we can change up? And that's going to be inside of the features. So let's first of all add a new feature, a new class. So this is going to be the march on triggered features. This is how the class is going to be cooled and inside of your work actually going to have some configure features. We're gonna start with one, then add another one, and then we're going to look at this. So this is a public static. Final configure feature was trademarked western mark. And then we're going to call this the Euler lake. Now what I've done and how I've actually, well, really this let say is I've basically just taken the and these default biome features, right? So they are also all configured features. And once again, middle mouse-click, you can actually go in here. And you can see this is a class where there's a lot of static methods. Instead of here we have Builder dot with eater. And this is always what, what is being cooled. And if we look, for example, into the wood, that's not quite right in the Builder. And we see that there's a few things that happen here. So for example, we can say we actually want lakes, right? So with lava and water lakes, right, lover modal x, you've, you've probably seen those. Say OK. This simply means that we have to call with feature lakes and teachers lake water. And that's a feature we actually have a new feature of arm. So that's interesting to know and that's how we do this. So let's do registry, dot register. This is going to be a world gender registries that configure feature, right? We're gonna call this late oil. And this is going to be a feature. We've seen this feature with the generation already. And that's going to be lake, right? That's as easy as it gets with with configuration. Now feature actually has to be imported a Eagle Lake dot width configuration. And instead of here we need a new block. State, a provider, a block site feature conflict actually. And that's going to end. Then inside of here, we're actually going to specify OK, what type of what type of block or do we want. So we can actually go into the lake here. And we'll see that this register method is exactly the same, exactly the same thing, but it's a very similar thing. Can see your new Lake features. You can then go into Lake features. And now this is, this is a whole bunch of stuff that we're not actually interested in necessarily. However, you can actually see, Isn't there a lake feature is similar to the water. Here We are. So it's in features, not in feature that, that was the issue. And here you actually have the absolute. So the register method that we've just called, you have exactly the same method right here. So we can basically just say, You know what? Let's just copy this, right? So let's just take this from the lake. Just copy the sludge method and say, all right, we're just going to copy this. So let's see, we actually have to get this registry dot register that you go, right, and then the rest is already done. So we auction actually also want to change the name lake oil, right? And then here we have interests dot states, water block. This is of course, the block that we want to put in there. So this will be mod fluids dot oil block in this case, dot get yet default state because we need a default state in her. And then what seems to be the issue issues that we don't resolve this, don't worry about it. Register. And this is because we have our, we actually also need the ruled, sorry, the world registries dot this is configured features or are they evil? Figured heater. And then the oil leak, oil, they go. As you can see, we can actually sort of just copy the and that's one-to-many, that's good. And we can actually just copy from the features. And if there are similar things that you wanna do, well, you can just take them from the features here and modify them as you please. Now this is a trans feature. Let's just put this to like ten, just for the sake of argument right now. And that is something that we can now use and put into our model. Now how can we do this? Will we go in here, into our microbiome and then anywhere really. But let's just put it here so that you know where this is, say, the biome duration settings builder. So this is a thing that we always pass into these static methods here. What we want is we want this width feature. And then we can just say, well, first of all, at what stage, so we say generation and then Lakes, declaration, lakes, right? This is the stage at one. This is added. And this is going to be inside of our mod configured features, because this is a feature that we want to add and this is going to be the oily. Right now. What's important here is that of course, it would probably make sense to also make another class called mode biome features and then have the static methods be cool there and have this in there as well. However, right now, I want to show you how to really make the, the biome work and any, let's say refactoring, maybe even some more efficient things are, it's not always the best to be preoccupied with making everything if inefficient in the beginning. Now, down here in the biome builder, we also have a lot of things we can do. So for example, we have here the biome category that we can choose, right? So we can say, oh, what categories it. And so let's say for example, well actually you know what, let's keep the category at Swan. That's fine. And then we have the precipitation type. So if it rains, if its nose or if there's nothing there, so that you can change here, then you can change the downfall. Now, most of those are not actually commented, so you have to play around a little bit with this, but these are a lot of stuff that you can change up here, which is pretty cool. And yeah, now we've actually done a lot of suffering. And that is one more class that we need to do. And then we can actually see this biome in action inside of our game. And that's of course the generation because right now it wouldn't even generate. Now we create the MOD biome. Generation, I told you that it was a little bit more than, let's say we're used to. And in this class actually will get the mobile subscriber again. And we're going to have to events as to subscribe events. The first one is going to be a public static void, register, register, no ego with a final registry event, read, history, event, register, a surface Pilgrim. So this is going to register a surface builder called event. That's fine. And then we're going to say, I'm going to say I'm on accompany this over again. So this is just so that we make this a priority low so that the order in which we do these steps is well conducive to actually what we want. And then we have another subscribe event, which is going to be a city. We'd set up biome final FML, common setup event, event. And here we're actually going to enqueue work. So this is simply made so that it fires once again in a way that works. What would you say? So that it fires in the correct order, let's say subscribe event, right? And now we need to more private methods that are sort of helper methods. And it's going to be the register biomes. So this is going to register the biome with a resource location, biome RL with a block state. So those are three blocks that we actually specify. So those are the blocks that are gonna be used inside of this myo. So we have a top law. We are going to have a filler block and we're going to have a underwater blocks. This is block state under water. The ego and the way this works, luck status already important, that's great. That you go. And the way this works is we're going to go into the registry dot register. Once again the word registries. And this is going to be configured surface a builder. Then we're gonna pass him the resource location that we're gonna pass him, the mod surface builders dot lobbing, default, dot get. And then we're going to call this method here Funk twenty four, twenty nine, twenty nine. And inside of here, we do a new surface builder conflict. So the Xenu silver brutal conflict, right now, That's going to be top block, the lower block, and underwater block. And then we can also, oops, that's not what I wanted to do. And then we can also get this actually appear ended laws. This is the register biome method needed to register the biome. And then there's another private method and that is the method called add biome. And this basically adds the biome to the dictionary and the managers. So we have the biome, we have the biome manager, dot pioneers, MY implemented first bio manager. Okay. My OEM. Manager. This one by M type. Not that that's not the right one, I guess. Biome type. Let's type. Okay, then it's not the right bio manager. We actually want this bio manager then. Yeah, that's the right one. We want the bio manager from. Where's it gone? There it is from Minecraft, which common spam manager type. We have an integral weight. We have the biome dictionary dot type, and then we do dot-dot-dot types so that we can, so every thing that's added afterwards is simply. And so every parameter that's added after the weight is then simply taken as a type with the registry key, biome. So key, so this is very similar to what we've done in the word generation, that tree generation already. Just that. Now instead of just getting the keys, are actually creating a new one, which registries keys dot biomes. So this is simply so that we can create a biome and then objects. We are actually going to do this properly require not null. So this just makes sure that there is no exception thrown, something like that, which registries at biomes dot get heat by L. So this is the biome that pass him. And then that's great. And then down here we actually only need to add dictionary at type with the key and types. So that now the types are associated with the biome that we've chosen. And then the bio manager. Hopefully the right one has add biome that we add the type of biome and then a new biome entry with the key and the wage. Right? And those are the methods that we needed. Now inside the Enqueue work, this is where we add the biome and that is going to be in mod biomes, dot oil, biome dot get. So right here we actually have to specify the biome that we want. Then we need the biome type so we can have warm will desert. There's legacy IC. We're gonna make a warm biome. Let's choose weight of a 100 and then add the type. So type, Hot, Dead, dead and dry. Now, what we can also do, instead of always having to type this out, we can actually import this as a static ones we can actually say import static, that Minecraft or no microphone, common biome directory. And then, and then just do type and then a star, they go store. And then what we can do here is we can just write hot and dead and dry like that. That's a little bit easier. Instead of our Register method, we want to call the register biome. And there we have to once again say a surface builder oil surface dot-dot-dot getLocation because there's a resource location, right? And what we're gonna do is we're gonna do belong stopped soul sand. Just for the sake of argument right now, we're just going to create something blocked. Stop the sand, let's say. And also blocks dot. That's the underwater one also sand. Let's, let's find sandals. Get equals say very important, that is the default state because we want the Brock states and not the actual blocks there, right? And now, if I'm not mistaken, everything should be done. Now there are of course a lot of moving parts. So what we're gonna do is we're just going to run this, try it out, and let's see what happens. I'm actually fairly confident that this is going to work. But still, there might also always be, you know, some small thing. Because as I've said before, it actually is a way more advanced topic than, I think almost all that we've covered before. I think the trees were sort of along the line, but yeah. So we actually get something here. That's a good start. Now let's see if the game actually starts as well. It looks like it. Well, that's a good first start, and let's then create a new world. So let's call this 1-2-3 creative and just, yeah, well, let's see if it also creates a new world. And of course would be as fascinating and also great. Everything working on the first try is always a good sign. All right? Okay, so we actually started and there we go. They can actually already see the thing that we have created. So this is the, when we go over here, right, this is microwave planes, as you can see right here, rate microwave river. Then we go over here and this is m scores oil biome. There we go. And if we go through this, hopefully air it is, we actually already have those will these oil lakes that generate inside of the bio, for example. Right? So this is basic idea of how to make a bio. Now, let's go out and actually create a second feature just for demonstration purposes because of the features. So this would be in side of, let's just close everything right now are endless here. This would be inside of the feature MOD configure features. Because the features are going to be the one thing that is going to be really powerful. Like I've said, you can go into features, right? So micro features right here and actually see a lot of features that are present. And you can add those to the more biome then, right? So instead of year, for example, there are some things that we might not actually want, right? So maybe we don't want, don't want any passive modes. Maybe we say, you know, actually I don't want overworked or's here, or I don't want the mushroom generation, I don't want swamp. You can get all of this out of here and only use your own features. That of course works. But yep, this is definitely something you have to play around with a little bit. And there are so many, let's say, layers that you can uncover with this and so many things that you can do with this that it's, I mean, it's almost, it's almost inexhaustible. Now, let's create a new, a new. The thing here that I just thought of that it's going to be like a copper box spread. So that's just gonna be a few, couple blocks, like the throne somewhere on the, on the biome. And this is going to be a block cluster feature conflict. Now, the way I figured this out, I'm going to show you in just a moment. But this is gonna be a copper spread conflict. Conflict. There you go. This is going to be a new block cluster conflict. Each conflict of Builder, new simple block stateProvider. And there we were going to say mon block Sadat, copper block, dot, dot, get default state. And then here we have a new simple block placer. And that's going to be something you're not. This one. Rise, yes, tries 25 and then build. Beautiful. And then in here we actually have the configured feature because we need a conflict or that this is going to be a configure Fisher. Once again, question mark, question mark. This is gonna be the copper block spread. And this is once again the registry dot register with a world registries configured. This one's cool, copper spread. And then we're going to have a feature dot, random patch. So there are many features in here as well. So in feature, there are different types of configured feature. The options that we have, we have the same thing that we've seen with the placement of the trees, which also you have to play around with a little bit. And then inside of here, you actually want the block cluster feature. That is why the conflict, that's why I made the conflict already. And then width placement, we're just gonna save placement. Placement dot chance with a new chance config of let's say 200. And we're going to also get this down here just for a little bit better readability. And don't forget the semicolon right now this is of course not in yet. We need to go in here. We can just copy this, let's say and then say declaration dot. Let us say this is surface structures. It might be serviced, rushed, it might be something else. And then say the copper block spread and thus is already all you need to add. Let's say another configure feature. The way I've figured this out is basically so inside of the feature and of course have the different types of things, how they spawn. So for example, you know, you know how the glow stone blocks spawn inside there, inside of a end rather than nether. And then you see what else? There are some, for example, the bamboo Wow, that spawns the bones chest surface worse. So there are a lot of feature features that how they how they spawn. And in the placement, you have something similar to this as well. So there you can play around with how the, how you were configured features spawn. It really is a lot of trial and error here. And trying out. Once again, advise looking at examples in at, in GitHub, right, for how other people have done similar things. Because this is going to be, it's just a really smart idea to look at how other people have done it. And to try and play around with it a little bit, say, okay, how does that work? I'm not sure how this works. Yeah. And that should then that is a really smart idea to play around with that a little bit. And then let's see if actually when we load a new world. So we're going to create a new world. Will that one? For now? Radiative? Yes. And see when the new, when the biomes spawns again, whether or not that actually the copper spread there exists. There will be kind of nice. Ok, let's see. Oh, there it is. Okay, there's a biome and by the way, we can also go down here and look at the run. You actually see this one there are you locked in with, sorry, that's not the entity ion. And I actually wanted the generating. I just saw the sort of coordinates and I was like, oh, there it is. Now, it's really way before that. There is currently generating MCT oil biome at minus 28 and minus 272. So that way you can actually see and say, well, that's pretty much exactly where we are. And let's throw, go through this and see if there are any copper spreads. Are there, they are there is the first one. So there are actually quite rare all things considered. And you can make an even rarer or not, or more common. And this is simply basically the thing that I came up with sort of as an, as another example of the configured feature that you can add. Like I said, they are, there are so many things you can do with it. And there are so many, well, let's say knobs that you can turn in all sorts of directions that are that you just have to go through a bit. Try out the default features. Try out your own features. Play around with all of the numbers that you can play around with and just, just keep experimenting. But usually this at least gets you a, a rough estimate of how to create a biome. Now, let's also, just to sum up, let's go through each of the steps that we've done. So the idea of the logging surface builder Was just so that we can actually get out put and where the, where our biome is actually generated at. This is the idea of this class simply so that we have a way of knowing. Okay, there's the biome, let's just fly over there. It's way easier for both debugging purposes and, you know, probably, you know, going forward, if I were to actually publish this mod, I would probably put this to debug or maybe even. I actually want to publish this, maybe even disable the login right here, simply because of the fact that maybe I don't want people to look into the console and then say, Oh, there's the biome. But of course, it doesn't make that much of a difference. Not, not really. Now, We then had a configured surface builder. Now this is the this is basically a key for this for the oil surface. So we have a configured surface builder and then we have our surface builder here. So the difference there simply is that there is a, one of them is with basically configuration ones without configuration. That's sort of the what the name implies rate. And they're then used in different ways. So when we go into, for example, when we can see right, we can right-click this and say, hey, find usages. Then we can see hey, where is this used? For example, it is used in here inside of the make the make oil biome. And we can then say, okay, what does that, what does that mean? And we say, well, this is a configured surface builder and this one's a figure surface builder. And this is exactly where this oil surface then comes in and says, Okay, but it's kind of I can get that. That makes sense. Then we ask, well, where did this logging default come in? And it's looking default. And then we can also do that. We can do and usage, uses. And this came in also. This can be an entire generation that should probably actually be renamed because what we're doing here, of course, is we're not registering the biome, registering the configured service builder. So there's logging default is actually what we're registering here. So would actually say that at the end here, I would refactor this to be pulled register configure, surface builder. And then this is also not the biome resource location. This is actually the, this would be the, let's just call it C. Now, let's do configured surface builder RL, resource allocation. Because of course this registers the configure surface builder as we've given it. The first the oil surface. And that is, if we go back to the oil surface once again, this is the registry key and that's why we need the key here. So there's also something to be said about taking the configured surface builders and putting it into the mod biome generation and just keeping them in this class. There really is no What would you say? That there's no set way of doing it. And you can of course, play around with it a little bit. Maybe. Usually what? It's better to have too many classes and have it separated, then? Well, having only one or two classes and have everything just be in there. And yeah, if you then want the surface to do something different, right? In this case, we use the use this function to generate a top block, a Philip Brock and underwater block. What I suggest is once again here, play around with it a little bit. The simply makes the most sense. And this probably also the way you're going to learn even more things. And yeah, I can. Once again mentioned the GitHub repository. I've put in to GitHub repository zeros resource that are, that were very helpful for me to figuring out how to set up the biome because I actually didn't know how to do that beforehand. And they are linked here, like I said, as resource, you can definitely check those out. And they were very helpful. And one of them actually is a modeling testing, one like it's not an actual mode. It's where someone is testing a bunch of stuff and yeah, I can actually, you know, really, really suggest going through that, for example, looking at a few things. And yeah, that's basically my suggestion here. Yeah, that was it. Like I said, a little bit more complicated and complex than things we've done before, but I'm sure we've gotten through it quite well. Another thing, if there are any questions, of course, you're free to ask, understand that this is a way more advanced topic. But I hope you got something out of this lecture. I hope that you understand the biomes at least a little bit now. And yeah, if if everything was to your liking, I would definitely appreciate a review and a rating. And that was it for now. And yeah. 71. (Minecraft) Sound Events and Custom Sounds: All right, welcome back to the Minecraft course. And in this lecture, we're going to talk about sound events and how to make our own custom sounds, right? So the first thing we need to go into the registration file where we have all our deferred registers and create a new deferred register. This time for the type of sound events or some event rather. And we're gonna call this sound events. And this will be equal to a deferred Register dot create registries dot sound events, MC, smart MOD ID, right? Once again, do not forget to actually registered down here with the event was. Otherwise it won't work. And next thing, we're gonna need a new package. And this is going to be inside of MC scores, a new package, old sounds. Now we're going to call it Sound singular. And we're going to create a new class in there called Ahmad sound events, sound events, that ego. And this, of course we have seen plenty of times. We're going to, first of all create a public static void Register method. And this is going to be called inside of our register motto editions here doesn't really matter where it is. Yeah, I think down here as fine mode sound events DOT register. And then we can create our registry object. So this is going to be a little bit different, but not quite, not, not as different as maybe some of the other things. So first of all, of course, public static, final, registry object of type, sound event. We're going to call this the test sounds. Or actually, let's call it, let's call it small explosion, because that's what I've prepared. And this is of course, equal to registration dot sound events, DOT register. And now what we're going to put in, first of all, of course, the, let's call it small explosion again. And other supplier ear is a little bit different than what we are used to. This is going to be a new sound event and this has to be net Minecraft util, very important. And to make this, we actually need a new resource location. So this is a little bit different than what we're used to. And this resource location, of course, starts with the MOD ID and ends with the name, which is just going to be small explosion again. So the name here and the name here should be the same. You can make a private string in theory and do that as well. You know, there's a, there's a point to be said. Maybe, you can also maybe make a method for this. But we're just gonna do it like this. It's plenty fine like that. And yet that is already how this how the sound is actually in. So we've registered it, it's now in the game, however, we don't have a file that place. So that's the next thing we need to do. And for that we need to go to the resources, assets. Or worse, or your ID and create a new directory called Sounds, this time plural. Very important. And in there we have to put the file. Now I've supplied the small explosion dot OGG as a file. We're going to just simply get that in there. It has to be an OGG file, so otherwise it will not work. And we also need, and this is basically at the level of MC course here, we need a new JSON file and that's going to be sounds dot JSON. And I'm going to quickly copy something over. Actually, we don't need a copy something over. It's actually not that complicated. We just start the JSON file and then we have the name of our key. So this would be small underscore explosion, then a colon, and then curly brackets. Instead of that, we have a category. For our purposes, we're using blocks. I'm going to show you after we're done with that JSON file, I'm gonna show you what categories are. And we're going to have a subtitle. This is mc pores dot test sound. So this would be something you would put into the into the language thing. The subtitle is what is displayed if you have subtitles on and then displayed in a chat. And then sounds, this is a list. Overwhelmingly put it in one thing and that is going to be Mc coerce or that's actually our test somebody way. It would actually be small explosion. And inside of here we also have small explosion. So it's important that the name here and the name here of course is the same. Personally. I mean, this doesn't have to be the same. Personally. I think that it makes the most sense to have the key and the sound name. And all of it have the same name. Just so you have a little bit of a consistency here. Yeah, and if you want to, for example, add new ones, we just add another one. And then, for example, you know, a big explosion and then satellite then, and then so on and so forth. You can simply copy this one over. And yeah, that that's already all there needs to be done. Now of course, we need to somehow have this explosion or the sound be heard. And what we're going to simply do, we're gonna create a copper block. So the idea is that let's say for example, we are going to create a new block, a class here inside of our block package. We're going to call this the, let's do copper wore shorts. And this is going to extend block. So this is something that's, that's not the right block. Again, it's going to be net Minecraft block. They go. And then let's just hover over it and create the constructor here. And then in our model blocks, instead of making a new block here, we're gonna make a new paper or so this is basically the same thing we have seen with the mod item where we've done the corporate apple. A, Well, we have an extra class here. And we're going to make it so that when the block is destroyed, then a sound place. So this is a method we can override, which is on player destroy. And inside of it, we're going to play this sound. So first of all, what we want to check is whether or not this world that gets in there is remote. This basically just checks, hey, is it server? Where is it not server? And we want to play this, in this case, if it's not server side, because we want only the player who has broken the block to actually hear the sound. Otherwise, every, it could be that every player inside of the server heard, hears the sound in a certain distance or radius. Of course, that is something that might work. But this is not what we do and I'm just going to show you this quickly. So world in this world, in this case, and there we have a play sound method. And we, as you can see, the player here is nullable if null the player and is simply going to play at that position. And then it's gonna play if the world is a server world, it's going to play for everyone and a certain radius. If the player is actually in there, and then it's going to play for everyone except the Player. I have a great resource on that. The official documentation for the sound is actually really good. So I'm going to, of course, have that as a resource available. But this play some, we're not gonna use the world here. We're actually going to use a minecraft dot and getInstance. And then we're going to get the player. And we're going to play the sound like that. So that's going to be placed sound and this is gonna be the sound in. So we need the sowed event that is simply going to be mod sound events. Small explosion, dot, get. And then we need a volume which is going to be one and the pitch is also going to be one. And he's going to say, ooh, let's check whether or not this is null. We can do this, we don't necessarily need to. So you can, of course, for surface, it is not necessarily all that important. Yeah, let's just keep it like that for now. And in theory, if everything has worked properly and I have not forgotten anything and I don't believe I have. We should hear a small explosion when we destroy the copper or lock. Yes. So I'm very much interested in whether or not this has already worked, but I think it should. I do believe that everything is in there. So it's not actually that complicated. So overall, I think that adding new ones is, I mean, I would argue almost easier than adding new items or blocks. As just go into this world here. And let's see what's going to happen. I hope that it's not too loud. Otherwise, if it's too loud for me, I'm just going to turn it a little bit down for you. Let's get a hopper or block, right? So those get away from those. Most buffalo. And let's see. So let's just break it and let's see what happens. Well, I did certainly heard it and it is definitely not too loud. It's actually it's a good volume. Right? And that's so that's basically all there is to it. I didn't even respond. I'm OK. And there you go. So yeah, that's all there is to it. So this is how easy it can be to add new sounds to Minecraft and also to play them basically when something, particular habits. So yeah, that was basically it. I hope that was informative for you. If there are any questions, of course, feel free to ask. I would of course, always appreciate a review or a rating. And, uh, yeah. 72. (Minecraft) Creating custom Enchantments: All right, welcome back to the Minecraft. Worse. And in this lecture we're going to look at creating our own enchantment. So this was actually a, something a student asked and I found it to be an interesting topic. And well, this is why we're making this lecture now. So this is going to be a very specific enchantment in this case. So we're actually also going to create a new, let's say, item group for it. But the general way we make this measurement is actually how you would make any IN sharpened. So it can, You should be able to just abstract it or let's say generalize to normal environments if you want. So the first thing that we're going to create here is a new package like so often. And we're gonna call this Incheon mint, making sure that we read it correctly. That's not the easiest word, right? And then we want to have two new classes. One of them is the enchantment itself. This is going to equal the blunt enchantment. And the idea of this is simply that, Well, we have a, we will have a club soon, right? So like a like a blunt weapon. And instead of having sharpness on it, we want bluntness on it. That's, that's basically the old everything that you need to know as the realization of this. And then we want another class which is going to be Mott enchantments. And this is of course also in the enchantment package, right? So first things first, the blunt enchantment needs to be extended. And we need to extend this with enchantment. There's of course, makes sense as this is an enchantment. And what we're gonna do is we're going to read the, read the constructor. And then what we're gonna do is we're gonna middle mouse-click on enchantment. Then we're gonna get to enchantment, and this is the basic Charlton class. And I've showed you this trick before, but once again, if you hold Control H, we can see all of the Champions that are present in the game, including our own, but these are all the ones that are added by minecraft. And we're looking for the it is the damaged enchantment. Because what we're gonna do is we're going to be really sneaky. We're just going to copy everything in this damage enchantment. And we're gonna paste it here because we need to make sure that we don't and we don't have two constructors here. And we're gonna take the members and put them up. And this type will need to be added to the constructor. And there's one more thing that we need to do. We actually need to shuffle around the perimeters in the constructor a little bit. So the damaged type should be after the enchantment type. And then the slots should actually be instead of a pure, a pure. We say array. We actually do three dots so that everything that is given after the damage type would count as a slot. Then the great thing is that we can also only give one slot in that sort of the idea. And now the rest of this. Of course can be changed. For example, mX level, you know, this is basically like sharpness. You have chartreuse 12345. We could make ten or 11. And these instabilities, as you can see, there are these well, rather small functions. Mathematical, mathematical. What would you say calculations, that's the word, right? So calculations, you can also say calculate damage by creature. So there is a few things that you can do. And we also have this can apply, and this can apply to an axe item or something else. Now we're going to look at that soon enough. And we also have kinda play together. This simply returns. So it's given an enchantment and then says, well can disenchantment. And so the blend and Troutman and then shortly given here be applied together. That's basically the idea of this method. And then down here, we can just clean this up a little bit and go on. Entity damaged simply has a, as you can see, cold whenever I'm opus damage with an item that has this in common on it. And then we could, in theory also do something else here. So there are actually a lot of things that we can do in with this instrument. We don't need this damage names because that's not actually used. And yeah, so this is the way we can I by the way, I would encourage also to just sometimes when you don't know where to go, just copy a class from Minecraft and then change it around a little bit because as long as it works, that's fine. Yeah. So this is fine and the London Chatman is almost completely done. What we now need is, we now need to add this into our modern Shamans. But first, we need to create the new item. And the new item we're gonna go into item and then we're gonna create a new package in there. We're going to call this weapon. Now, this is really a stylistic choice. You don't really have to do this, but I personally think that it makes sense and we're gonna call this the blunt item. Now, the blend item is going to be very similar to the sword item. And we can just look at this by pressing shift, shift control f. Then we can actually search everywhere. And then if we go to scope and then for example, search for sort item, then we're gonna get to, well, first of all, our stuff, but at some point we're also going to find the sword item. Well, For example here, so we can just middle mouse click and then we're at sort item. So as long as we get to the sort item class, then everything's fine. And as you can see, this extends the tiered item and implements the IV punishable. Now I vanish trouble of course is just that. When you swing it all of a sudden it's gone. That's i vanish bubble and the tiered item, we can look into our mod items and think back, this is quite a long time ago, but we have actually created a mock item tier. Well, that was copper. We have an armor material and we also had this mode item tier. We are, we had different ones. So we created copper, right, with harvest levels and Max uses and all of that. And we can just create a new type of item, right? So instead of a sort, we're gonna make it blunt item. And we're going to extend both tiered item and also implement the i vanish troubles. So we're going to extend I Tier I, your tiered item. Oh, it's not ice. Just tiered item. Well, there you go. Of course. I'm extending it. They go implements. I've punishable a go. Then we hover over it and we're gonna create a constructor matching super. And this should, well, we're going to change this up anyway, because once again, we're just going to copy the entire sort item plus. And then we're going to actually replace everything. We're just going to change this to be lumped item. And we're gonna save this and then we actually shouldn't get any arrows. There are however, a few things that we need to look at. And so for example here, you know, get destroy speed. So if we don't want the cobwebs to be fast for this type of item that we could change this. And what else is there? There are some builder, attack damage and tech textbook modifiers that are reality or we could just leave it like this because at the end of the day that's totally fine. And I believe that, yeah, actually, this is all that we need to do. We now only need to create a new item in our mod Items class. And so we're just going to get this in. Let's go up, let's say between the sword and the pickaxe, we're just going to copy the sword for now. We're going to call this the copper Club. I have, by the way, created a new, what we say, a new texture for it. And I gotta be honest, all the textures that I've created so far, I actually found this to be really good. I found this to be really nice. Okay? Of course, copper Club has not been created yet as a, as a class. But this is going to be almost like the other item classes will just increase the cost. Copper lub. You could of course also make it a new plumbed item that would also work. But I think that in this case, it makes sense to make it, let's say explicit. We're just going to match this. And this is all we need to do. Save this. And there we go. And all of a sudden it works. And so this is between there and there. And now we simply need to go back to the where is it blend in, shunned. And down here, we had the first of all can apply together. So this is of course, a, once again, a choice that you have to make. Okay? What can happen? So in theory, if you have a sharpness enchantment, you can't put another shortness and Chapman on that. That is basically what this says because previously this was a damaged enchantment. And we can say, well, I mean, we don't really want to have that in there as well. So what we then can do is, well, you know, we don't want this to be applied with a damaged enchantment and we don't want this. So if another enchantment is put on there, we don't want this to be enchanted with lumped. Non-planned item, it's blunt and chapman. Right. So if it's a damage in chocolate or a blunt enchantment, then we can't apply this together with another blonde and Shannon. That's basically the idea here. And here on the hand apply, we're going to put in the blunder item now, our own created to tiered item. Right. And I do believe that that is all in the year that we needed to change. Of course, once again, if you want to have more levels or less levels, now you wanna go and say making ten or something like that. And of course feel free to do that. But we're just gonna stick with five right now. And now we're finally getting to the mode enchantments class. And before we can do this, of course, we need to go to our registration and create our good old friend a new deferred register. As Without a different register, it wouldn't be a good video. I feel like, you know, it's a good video when we created the four register, this time of tight loops of type enchantment, of course, in chant Mint, there you go. We're gonna pull this enchantment with an S at the end. And then we're gonna do a different register dot V8. Or it registries that enchantments. Mc, coerce mod, mod ID. Good old favorites. And we're just going to add this at the bottom in Chopin's DOT register with even plus the rate. And now we can create our registry object. So we're going to have a public static, final registry objects of type enchantment and minutes. And this is going to be called lumped nece. It's going to be equal to registration dots in Chopin's that register. And we're gonna give it the name bluntness. Of course. You're pretty blended today. In new bluntness enchantment. Isn't that great? And then we need to specify a few things. So one of the things is rarity. Let's just make it common. So this is just how often it would show up. In side of the table. We're going to have modern sharpens dot, sorry, this is o, this doesn't exist yet. Okay, we're just going to ignore it right now. Then we have the damaged type, and then we have E equipment slot. And this is going to be main hat. Now as you can see, we've actually left one of this open here. And this would be the enchantment type because we're also gonna create an Sharman to type here. And there's going to be a private static final enchantment type, lunch, NAS type. Now the idea of the type, and we're going to quickly it also entered to import the enchantment type. The interim type isn't enough. And it basically says So let's look, for example, at the Whereas it isn't there a damage weapon, right? Return true if this can be passed, disenchantment can be no unbelievable. If the given an item, can this enchantment be in Charlotte on this item? And the idea is that, well, a weapon, one can be charged to a sword item and a digger can be the tool item and so on and so forth. Now. And this is basically what we're doing with its bluntness type. We're just saying enchantment type, dot-dot-dot create. So we're creating a new one. Now the name here, I'm not a 100% sure whether or not we need to supply the the MC corps. Were the, let's say the malady here before. Or if we just can cool it, bluntness. I'm not a 100% sure about that. It worked both ways, but I personally think that this makes more sense because otherwise in Sharma type has no idea about where this is coming from. And then we need to supply a, this is a predicate, Yes, an item. Let's do item and then item, instance of blunt item. So the idea here is that the create method takes in a name and then a predicate is delegate, is basically exactly this cannon shot item right here. And this is what we've read it here. And then what we can do is we can do more in Sean months. Lameness type. Now it's very important that you write the name of the class in here because if you only do bluntness type and you get the get the arrow illegal forward reference. And this is not what we want. We want to make sure that you have the name of a class in front of it as a static call. Then we of course, also add our favorite public static, void, register, register, register a ego. And this is then all inside of our MC. Worse mod, mod enchantments not register. Right? And that is, I know it sounds crazy, but that is all. I find it to be fairly straightforward. All things considered, or the fact that we just created a new enchantment with a new type of item. Let's say. Of course what we also need are the different files. So we're gonna just yet, we're just gonna get the lang Actually, I'm going to quickly copy this over because this is something that's, so for the name of the enchantment, we have enchantment dot mod ID, so MC cores and then the name that we've given, the enchantment here. So this one. And then this is just going to be lameness. And for the club, which I've created is just item in SQL, there's copper club. And we of course, also need the item model for this. We're just going to copy this over. Yes, please write, shouldn't be anything crazy. The item once are interesting and now you're gonna see my absolutely amazing creation of the copper club. And I gotta be honest with you, I really actually really like this. Oh, we see allow or should we look at it in game? We're going to look at it in game. I really like this, but this is firstly, I think that is one of my best creations, or let's say my better creations. And I believe that this is all that we need to do for everything to be in game. Let me just quickly go through no, it should be everything. So let's just start it and let's see what happens. And of course, once again, what I wanted to mention is that the thing with the blunt item isn't necessarily needed. Because of course, the this is just a, let's say a prime example or a not a prime example. Rather a specific example that a student had. You wanted to they wanted a specific, a blunt item. I want I have a balloon. I don't want, I want it to be accountable with London, with shortness but rather bluntness. And I was like, okay, that actually sounds an interesting idea. And this is why we have done this. So let's do just create a new world with creative mode. And then see what we can see. All right, let's just quickly set this up. So first of all, the club look at this. Isn't this beautiful? Isn't this club just the most beautiful thing you've ever seen? While maybe not, but it's still, I like it. I do like it though. Let's get an enjambment, a MOOC. Let's get bottles of enchanting. And now you can see the enchanted books here. And if we go down, we can actually see bluntness 12345 because they are automatically added. And if we now would have increased the level, this will also increase the number of books that we have. Let's just take bluntness S1 and S2. And let's also take the OSU. Nolan. I wanted sharpness, right? That's just take NO2 shortlist, three books. And also let's get a sword. It's going to normal sort. And do we need anything else? Maybe a bookshelf, Omar mime. You also need an animal. A lot of things that we're gonna need. There you go. Let's just set this up quickly. Just show you that it actually does work. And then we can switch to survival mode was a few levels. So first things first, if we put this in. So you can get an braking, as you can see. Because this is, this does work on breaking and breaking. Force would be kinda nice if we also have some lattice a. Now let's see. If you are in creative mode, then there is some funkiness. That might be, might not be good because E and breaking unwritten and written. And let's see. So if we however go in here, so we can enchant this with bluntness, as you can see under the sword, we cannot n-channel bluntness. We can do this with sharpness. That works. And sharpness on this one does not work. So That's a good test for, first of all, that this, that this works. And if we give ourselves a few books, maybe we can, well, we can do this. And then let's see, flatness, that was bluntness ones. That's kinda nice. Now the big question is, can we get this other? It is now we finally have some bluntness here. There we go. Lameness one, right? And that is already all we need to do to get this in chocolate in there and actually have it be specific to something, something like that because it's like our own item. And if we look at this, right, a normal one has attacked image three, this now has attacked damage or because it has blindness. Right? Isn't that great? Yeah. And that was it for adding a, an enchantment. And also, let's say simultaneously are ONE item class, our own unique brand of item, let's say. And yeah, that was basically it. If there are any questions, of course, always feel free to ask. And yeah. 73. (Minecraft) Data Generators for Items and Blocks: All right, welcome back to the Minecraft course. And in this lecture, we're going to take a look at it, data generators. Now, data generators are basically an easy way to generate the entirety of all our adjacent files that we have been manually making all this time. And this is basically a an automatic way to generate those. And it makes life about, I would say approximately a 120% easier. Especially if you have a lot of blocks, a lot of items. It makes it incredibly easy to generate everything. And so the first thing that we're going to do here is we're actually going to rename the Course Tab two cores, taboo, small t. We're gonna save this. And then just to make sure instead of our language folder, we're also going to change this. So instead of assets, MC cores, Lang, and then inside of EN underscore us works. We're gonna change this to course, tap with a small t. Because otherwise we're going to get an error inside of the coming lectures. And that's of course not what we want. What we want however, is to, well basically figure everything out. We actually wouldn't even need to change this. Because what we're gonna do now is we're just going to lead, we're just going to delete everything. So Bloch states, Lang, models. All three of those. Delete, Yes, away from me. Mc course loot tables, recipes, all of it entirely. Out of here. I don't want you an hour or I want to see you anymore. So now we don't have any textures, we don't, we don't have anything when it comes to our blocks. And we need to figure out how we can basically restore that. Now, by the way, there are a few things where this, of course, first of all, don't just delete it. That's most folding. Don't just delete it. Actually makes sure to back that up because you've made those Jason's ones. So that's kind of important. Also when you have, especially inside of our custom block data. So the our title entity that we've made the electrify or make sure that you don't throw that Jason way because that is well basically generated so from workbench. So that's not going to be easily reproduced, let's say as some other ones might be, right? But now we're going to start with the data generator stuff. This is, of course, the deleting here is of course just for, let's say, somewhere between comedic purposes and shock value. And we're gonna create a new package in our MC course, MB package called Data. And inside of that, everything we're going to make goes now. So the first thing is going to be the data degenerate Jenna rate towards the ego class. I'm going to add this of course. And then we're going to simply have this be a, add a mod dot, even a subscriber. This is of course, once again something that we've seen already. This is mc course MOD id, and then the bus is going to be mod, mod Dot event bus subscriber, bus dot. We then also need a private data generators with nothing in it, the constructor. And then we want to hijack basically. Now this is, this is correct. I'm, I'm fairly certain. Well, how about this one? If it's the right name, then it's going to work. And then we're going to have a public static void gathered data. So this is the event that we're going to hijack. This is the gathered data event or event in this case. And this here is of course a subscribe it. Now this is all something we've seen with the mod events. We are actually going to need this. So thank you that in there, inside of here, what we want is a data generator. This is going to be the generator equal to event dot get generator. So this simply gets us the data generator. Instead of this gathered data event together data event. Let's see if it, it doesn't have any explanation to where it is. The idea is just that, well, it gathers data. I mean, it's hardly hard to figure out, but the ego, and this is the existing file helper. You can also get that this is just something that we're going to need because we want to basically check whether or not some files already exists. That's sort of the gist of it. But let's just make sure that this is basically what we have, right? So we're going to start with, if you think the first thing that we're going to make is the a block state provider. And this basically is, makes it so that we have Brock states. So let's make a new class called the mod block state provider. Of course, the names here r can be chosen on your own. However, having a clear that's a nomenclature to them does make a lot of fun. This will extend the block state provider. Make sure that it is the right one and the right one is in client. So my net microforms, we want this one, client model generators is very important that you choose the right one. Otherwise, we're going to run into a lot of issues. And as you can see, it wants us to implement one specific method, which is the register sets and modals method. We're gonna do this and then we still have an error. And this is of course because we don't have a constructor. Now what we can do here in the constructor is we can just get rid of this mod ID as we know what our motto is. And we can access it by going to MC course Dartmouth. Easy enough. Now instead of here, we can now register our blocks. Now. The thing is that these blocks, a provider of course, has a few nice things. So if I put in block, for example, as you can see, look at how many things there are that we can actually just very easily register here. We have access block, directional blocks, we have door blocks, fences. We have four way blogs, horizontal, horizontal, phase lock, pain, slabs. There's trapdoors, walls. All of those very easy to register with simply using those method calls. We're of course going to use the symbol block here. And what we're gonna do is we're gonna say more blocks dot. Let's do the copper block dot get. And then we're just going to copy this. And then we're gonna take the copper wire as well. So let's just take this. They go, well and that's already it. Or basically how to do the block models. I mean, we only need to add it here and then, and then we're basically done. And this is really easy to add. So we simply need to say it generator dot at Provider. Now we've just created a provider, so we're just going to say new mod, block state provider. And then the provider. The provider needs a generator and an existing file edible helper. That's it. That's all we need to do. And then it's going to generate for us the mod Bloch states. Yeah, that's basically the whole, entire deal. And we're gonna continue, first of all, with the and what item model, because that's something that's very interesting as well. Because of course, with the item models, what we need is we need the, we need this for both normal items and then also for block items, right? And this is as simple as that. We're just going to say, Hey, what item model provider. And we're going to say, take this item model provider once again from net microforms client modal generators, very important. I really want to stress this because otherwise if you take the wrong one and yep, that's just not good. Of course that never happened to me. Of course not. Maybe, possibly, possibly in the beginning. Let's tends to happen sometimes that's why I want to emphasize this here once again, same, same deal. Just take MC course dot-dot-dot ID for the MOD ID. And then every, everyone is actually happy about this. Now the register models. We want a few things in here. So first of all, we want to call the width existing parent. And we want to use this because this is basically creates our block model. Sorry, not Well, yes. Use the block model. It makes the item for the block. So this is the block item. Basically. This is gonna be the copper block. And then we're going to use the mode lock here, which is just gonna be block slash copper block. And then we're going to copy this over. Then or as well because this is what we've created inside of our block, statesman blocks it's provider. And then what you want is basically a few different ways that we can do it. And I'm just going make a new method here. This is not necessarily needed, but it's fine. So we're going to return an item ModelBuilder builder. And then this needs a mono file item generated, and then a string with the name name. And we're going to return get builder with the path name. And then the parent is going to be item generated. And then the texture is going to be layer 0. And then the texture is located in item slash. And then the name. Ego. Let's zoom out a bit. And this is just a little bit easier to basically fill this out. There's multiple different ways of doing it. So for example, right now here we are going to make the model file, the item generated. One. This is just when you have at the top of the JSON file where we say item sludge generated. That's basically almost all of our items were that. And yeah, this is simply what we're doing here. And then what we're going to say is a builder and an item generated. And then the name here would be, for example, copper ingots. So we're gonna create our copper ingots. It mod item models, right? And that's then of course, also needs to be added into our data generators class here. And this simply gets down here. So let's just copy this over and say mod items. What item model provider. And of course also takes a generator, takes existing file helper. And overall, those are the first two things that I wanted to show anyway. So how about what we're gonna do is we're just going to run this and see what happens. Now we're in-game and look at this. What is this? What nothing has anything, not even our core step. Nothing has a texture. Well, that's not what we wanted exactly. Because what we need to do is we actually can't just run the client here. Well, we actually want is we want to run something else. And that is the run data. So we just need to go to Gradle on the right side here, microwave tasks, if she runs and then run that data and then double-click that one. And then right now we have this appear. And once this has run through, we're going to see something very interesting. We are going to see a new directory being formed inside of our source directory. As you can see, usually, this era is normal. Now this error actually is not normal. So we can actually see what is being going on here. So there's something there. So the texture MC course blocks, copper block does not exist in any known research packet. Now we can actually check, check that, and go to resources, assets, story, that's textures. No, that's definitely in there. It's also in their Hopper block, dot PNG. So that's definitely in there. So there must be something else that's a little bit wrong here. Let me just check what is going on. Is Of course, I actually know what the issue is here and it's actually very good. This is something that I actually when testing this also forgot, but it's very important that this is actually done. And this is why it's very good that it's sort of like in the middle here, maybe. So the error here is that inside of our build-up Gradle, we actually need to add a few things. And this is number one insight. When we go down here to our arcs, we need to add this so we can basically replace this arcs with this. It basically just make sure that there are also. So basically that When we run the data. So this run data that we have an output at source generated resources, but that there is also a source main resources and the source generated resources both count basically as a resource set. We also need to add between the end of this. So between the end of this Minecraft opened here, down here, and then before dependencies, we're going to add to this, these things of course, available as resources as well to download and all of that jazz. And yeah, exactly. And then we can basically just let the build run again. So just click the little elephant with a reload button and this should basically work very fast to build it. Yep, there you go. And if we now run this data again, we can just hit the Run button, the Play button here, then everything should work out totally fine. Now we're still going to get a quote unquote error. Now this is not actually a real error, so this actually isn't real arrogant. I mean, clearly it was generated. Wouldn't run this again. Because that is very weird that it makes no sense at all. Why that would be the case. Of course now it works because that's that's how we do it. Right. Okay, that's great. So if you get that, that's sort of an arrow here. So basically, if you, if this is an error and then it's just like remote host was closed, that that's probably something that's better for you. Then if you look at this, as long as the task execution finished run data is set here and you have all providers took whatever, how many milliseconds, then everything is fine. And that's very weird. It probably was because the, the JSON file wasn't yet generated. So some weirdness they are, if you get that as well, don't worry about it. That's probably not going to be an issue. But anyway, so now we have a generated, as you can see, generated Maine. And if we go down here, resources, assets, MC course Bloch, states and modals, and item models and block models. And they are basically just generated for us. Now. We actually have to switch here to run client, and then we have to run the client. So now the game is going to start. It's very important that you keep in mind where you are on this. And that once you change something inside of your data structure, that you just let the run data once and then start. So this is like I cannot stress this enough. Run data first, then look at the changes. Otherwise the changes will not be seen. And if we look at this for example, you can see that the copper in good, the copper block and the copper or block all have textures. Now they only, they have texture spoken. Well that's not what they want. They go, they both architectures as a block and also as an item. So that works perfectly fine without having us to do the JSON files manually because they're all here generated as you can see. So this is just a copper block, right? Generated automatically. The, let's look at the corporate England for example. Generated automatically. So this is the great thing about data generates the basically just generate everything automatically. We are also going to add just quickly the block tags and the modal items, tags, generators for providers. So we're gonna create a new class inside of our data package, which is going to be blocked. Modal tags, rho vita. Now we have actually not used the tax an awful lot. That is going to extend block tags provider. This is one, this is one time. This is the actually nets Minecraft the data one. In this case, the constructor. We're going to get the second constructor, not the one that is crossed out. Once again, the mode ID, we can just take EMC, we're smart ID. And then we also want to, or we want to override the method or register tax. So if we put in register and hit tab, then we can just do this. And then we're just going to do an easy one to get or create builder. And I'm going to give it a tag. So we can go to tags blocks, and we're going to take ors. X needs to be imported your ego. And we're going to add the blocks dot copper ore to it yet. And that's it, right? So we're just going to add the corporate work to the or tags because it is an or. And then we're going to also create a more item tags. We're not gonna put anything in there, but we're just going to create it for the Halloween. So mod item tags provider at this as well, and this is going to extend its closest away. Extended the item tags provider once again, that net of Minecraft data. This time, we're going to create a deconstruct. Or once again, with the more I d here, just out of that. Mc, worse, AID, oops. Mc, smart id, the ego. And it is also registered texts override. And we're just not going to fill this one in this case because we actually don't, I don't think we've used the more item tags or the tags for the items yet. We have used some tags for the blocks, I believe. But nothing too crazy, However, it is there if you needed. So that's pretty good. And this is going to be done down here after everything else. So this generator dot generated dot-dot-dot provider. This is the new. Let's do the mod item tags. A provider. This needs a generator and now, as you can see, this actually needs a block tag provider as well, which is very important. So we actually need to do a little clunky, but that's okay. We need to make a new variable. So mode Block tax provider, you're just going to call this something like block tags equals new block tags, provider generator and the existing file helper here. And then this can be done twice. So we can do ad provider with the block tanks here because we of course need the block tags and then we also need to provide the block tags instead of our item tags. And then also the existing file harbor, and that's it. Those are the things that I wanted to basically add here. So what we can do is we can just run the data again. Right here. It's going to want to stresses very importantly, if you change anything inside of your data generators, you add more tags. Or if you add an item model, they are always run data. I mean, I know that the question is going to come up, hey, I, I added something and it doesn't show up. Run data. This is, I will only answer with run data on questions like that. And as you can see, there you go. So instead of generating main resource, we now have a data folder as well. And inside of that we have the Minecraft tags. Now it actually will add every Jason for every tag, just basically with the main values that are already in there. And then if we go to the oars for example, then we're going to see, well, it's not gonna be in here actually that is inside of the inside of foreseeably VSA you, so this is the override basically, so the orbits and then as you can see, MC coerce, copper or that's in there. So then he goes, that's sort of a, an interesting and well, very easy and efficient way to generate new JSON files for your items. For your, if you want to add tags or if you want to add the Bloch states or blocks, it is very easily done. It is, I think, incredibly useful and it saved it. Especially if you have, are like a 100 items. I mean, at some point you're gonna get mad with the copying and pasting that we'll have to do just because of the JSON faults. And there, this is an easy way to generate them automatically. So I hope that that was useful to you. If there are any questions, of course, always feel pre-task and I'll be sure to respond. And yeah. 74. (Minecraft) Data Generator for Loot Tables and Language: All right, welcome back to the microwave course. And in this lecture we're going to take a look at another data generator, actually two of those, and we're going to make the lute tables and then also the language file generate automatically. So let's actually just create a new class instead of R package that we've already created last lecture. And this is going to be the MOD loot table provider. Once again, the name is, doesn't, you have to be exactly the same? But it makes sense to keep everything at least in the same neighborhood. So this is going to extend it the loot table provider from net Minecraft data. Then we're gonna create a constructor that has this. And now there's going to be something that's a little bit weird in here because we're actually going to have something. So if we go into the loot table, middle mouse, button click. And as you can see, it has this final list, which is a list of pairs of suppliers, of consumers, of bike, consumers of resource location, loot table builder, which is, I mean, that is a construct that is absolutely ridiculous in my mind. I gotta be honest with you, but OK. And if we then go here, as you can see that there are fishing loot tables. There are for example, loot table, Lu, Lu table, entity Lu table and so on and so forth. And this is also something we're going to need. Because what we have is we're going to have a, So first of all, we're going to have another thing in here, which is going to be e mod block loot tables. So a new class instead of our data package. Cool MCH Block loot tables. And this extends the Baroque lute tables. All right, now there's nothing in here. I'm going to put something in there shortly. First of all, we're going to, I'm going to copy this over because this is absolutely madness. So this is the list of a pair of a supplier, of a consumer of a bike, consumer of resource location loops, table builder. And then here it has loot table perimeters. It's called loot underscore tables and is a mutable list of exactly the pair of the mob broke loose tables that we've just created here, this class and a lute parameter set. Now, what this whole thing is, I gotta be honest with you. I really would not worry about it. It's just a crazy way of making sure that it's a crazy example of okay, maybe there could have been Southern better done here. But it works. Just really, I mean, you know, I I could probably explain it in the end, but in this moment in time, I would actually say, just, just take it, just say okay, as just some weirdness that we don't have to get into. Now what we want is we want to take this. So if we putting get, we see this protected and then this whole Get the tables. This is what we want to override. And what we want to return is just basically this dot lou tables. Nope, that's not, that's not at all what we wanna do. We wanna do this totally took they go. And then the other thing that we want to override is validate. This is the validate method and we don't want to call super, we actually don't want to call anything in here. Sort of like everything that gets as, hey, is this a valid thing? Yes, it is a valid thing. I, I'm not a 100% sure what we need to overwrite it with nothing. I believe that it has something to do with some sort of microwave weirdness to where if it's not inside of a microwave directory, then it doesn't validate or something close to that. Just make sure that this is also in there. And that is basically the mode loot table Provider. Now this we can already add here. This will be added. Let me see, this will be added here. So this is generator dot-dot-dot provider, new loot table provider with a generator? Nope, a generator and an existing file up until this time, we don't actually don't need the existing file helper, but we need another, we need an ending parentheses o. And now we have where we actually added the LU tables is inside of our motto block LU tables, very important thing once again, also, if we look back at the LU table provider, right now we only have this mod block LU tables. If we of course want to add a loop tables to, for example, mobs or chest or whatever. I advise you to go into the loot table provider class here that we have extended and look at this field, right? So this, this crazy pair, supplier craziness. And as you can see, you can go into the chest loop tables. We have the entity Lu tables and you can look at those. So if you middle mouse button click on it, then it's going to open the, the actual class. And as you can see, there are, for example, in here, I would advise you to look at that. And this is basically one way of making Lu tables for other things. As, you know, other things, not only blocks. So if you go into there, you will be able to see that. And then it's basically just extending that class and then adding some stuff in here. And we're going to add the add tables method. We're going to overwrite that. And we're also going to overwrite it the get known blocks method. Now this is going to return the registration dot box, dot get entries, stream dot map. I'm just gonna quickly and what this does. And then we're gonna do to Colin's iterator. So this one's an iterable of type of block. Now we have all of our blocks inside of the registration Brooks deferred register. And this basically has the list, so to speak, of blocks. Now when we get the entries, we're just gonna get a, as you can see, a collection of this is basically a list. Then we convert this into a stream and then screen we can map. And the map basically, as you can see, returns a stream consisting of the result of applying a given function to the element of the stream. So basically for each of the elements in here, so these are of course right now. And blocks. Instead of our deferred register, right here, there are collection of registry objects. So we have the registry objects in a stream. And then what we're gonna say, okay, for each of those we're actually gonna do dot get. And as we know, we've seen multiple times, if we do our MOD blocks, dot gets, so unworkable, Brock dot get and we get the actual block. And then we're going to turn all of this into an iterator. And then it works. This is the gist of this. Once again, this is something where it's not necessarily like important that you understand everything that happens here. Just know that the get known blocks is basically all of the blocks we have registered. That's basically all we need. Now, I'm going to show you this with two or so blocks and them, I'm going to copy this over because this very important actually, every block that you have in here, you need a block like a loot table for. Otherwise, the game is not going to start. This is a little annoying. I'm not gonna lie, but that's how it is. So first things first, you can just do this register drop loot table. So then the block drops itself. Blocks dot copper block for example. And then of course not good, right? So this simply means that the copper block upon braking, we'll drop itself. That's the whole entire thing here. Then we have, for example, if we do this register loot table, we can take this one. Then we can, for example, say if we have, let's say E, Let's do mod blocks, slab, cooper, slab dot get. And then we can have a function here which is a block. And then we're going to open this. This is then going to return a dropping slab. Not dropping seeds, propping slab with exactly this. So Ma'at blocks, not copper slap dot get. And we need to do this, of course, because this is a slab and not a, well, it's not a, not a normal block, right? So it needs to function like a slab. This is when we need to do this, it's very important that we basically put this in this register loot table one. And this is almost basically the entire idea yet. I'm just going to copy the rest over right now. I hope that everything is in here, but I'm fairly certain that it is. Okay. So if there's a few things that we actually don't have in your array. And then the cooper slab, didn't we just like literally do this. Oh, well, oh, that's three piece. There you go. That's well, that's kind of embarrassing. Well, whatever. So this is, this should be every block. We're going to see whether or not it is once it works or not. But yeah, this is the idea. You have to add table for every block. At least that was one thing that didn't happen. Like it didn't work for me if I didn't add any, every block that was basically in the non blocks. So let's just run the data and see what happens that we've already added the Mott loot table provider here. And this is of course, the block LU tables are of course, basically in this list in here. So let's just see what happens here. And we are actually going to get an error. Most likely there is a block that I have missed. That is the most likely thing. So it's definitely the LU tables as well as you can see when you have an arrow in this run data, you can always see okay, item tags finished and then starting provider Lu tables. And then you know, okay, it's something to do with Lou tables. And usually this is not actually going to yield a lot of ideas about what happened. You actually will have to go up a little bit. There actually, this was some of the missing and that is the pressure plate. I don't know from my testing my testing repository, basically, my pretesting project. There's probably a there probably was a typo in there as well. Let's see. So there's probably something missing again. And that is going to be let's see. We can also MC, No, we have to go into this one and then I'm scores. And then let's see, this would be mc. Ok. There you go. So missing loops table for the red wood planks. Also just a name that was wrong. Plank. Okay, that's interesting. So I call the plank here. That's fine. That's not an issue. At least there. So that's a little bit of an oversight probably. But if we now run this, I think now it should work. If there's no more block missing. And we also shouldn't get any errors. Looks good. And then, oh, providers took whatever milliseconds. And then of course, as we know, when we get the quote-unquote era, the remote host connection has been closed. That's fine. And then if you look down here into our data MC cores, loop tables, we can actually see that everything, every loop table here has been added properly. Well, that's pretty good. And then let's also go to the Language provider. That's something that's very interesting. So we're just going to add a new class to our data package, cooled the mod mod language provider. This class extends the language provider this time by net Minecraft communist data, very important. This is going to implement the EPS translations, the method here. And then we also of course, needed a constructor. We don't need the AID once again. So that's very similar to a lot of the other things that we've used. Mc course, dot-dot-dot. And inside of here, what we're actually going to do is we're gonna make a string called locale, this.name replace with Lang, Lang Guan sagas languages. And then replaced with nothing. And then we're gonna do a switch locale. And then in here we actually have a case. So we're going to do the yen US, so like this. And then they break here. And then a default case with basically nothing because I excuse me, I have no idea why it switched over, but they go, that's what happens. And then inside of here we just use the add. We're just gonna use the add method to add stuff, right? So as you, I have seen, you can either you can also put in blocks or someone else, or you can put into keys. So for example, our keys would be something like. So our keys are something like, for example, item MOOC course, copper ingot. And this would be translated to operating it. That I mean, that I feel like makes sense. Now we also need to do two things in our data generator. So we're just going to add this and see if it works. But I'm fairly certain that it will. We need to add something here. This is a private static final string array called local codes. Now these are the codes of localizations that we are basically, well, let we want to support. In our case, we're just gonna do EN us. You can of course, also add your own once. So for example, I believe that Germany would be something like d, d, I believe, I'm not sure actually. Makes sure that you look that up, that's easily found. Or if you have, I'm not sure if it's EN GB for Great Britain. I'm not sure. But yeah, this this is basically where you would add all of the local codes. This is just basically the same name that we had in our site over assets Lang folder, right? And then we are also going to add a private static void at language providers with a data generator, the generator as a parameter. And inside of here we're going to use a for-loop string locale set over local codes. So this basically makes sure that we go through each of the local codes that we have. And then we're going to generate our dot-dot-dot provider, new mod language provider, the generator and the lookout. Right now of course, we only have the EN us, but that's fine. Like I said, you can add your own languages or even more languages like very easily actually in this case. And then let's just run this and see if it generates the, well, it's not going to generate this. Actually. Stop it because we actually need to add this in here as well. Of course, add language providers with the generator. And then it's going to, then we're going to run and see if it works. Now, that's kind of an important part of this. And then we're actually also going to look in, in-game whether or not everything that we have added here is going to work. So all providers took whatever milliseconds. That's great. So that means that everything at least seemed to work important. We actually have to let this run until this way, until this message comes. Otherwise, nothing here is generated. So let's see. This was generated inside of assets, MC course lang, But it is not right now. But let's just see whether or not this, the locale still took place. So let's go to run client and then let's run it. Alright, let's see, let's just start the game. And first of all, we're going to see whether or not this, so the copper ingot has not taken its name, but that's fine. Because I actually think I know why it also didn't generate the left thing, that, that was one of the things. And let's add a pickaxe and let's see if I can mine This, of course go to survival. And then if we mined this is of course still are sound that we've added. And as you can see, we are actually getting the things that we want. And if we go back to the slabs for example, which of course, right now have no slab. There you go. That's actually like stack of, That's right. So as of course, great. It looks amazing. But as you can see it drop two of those. And we can, of course, do this and then drops one. So it does work. Now of course without any, without the models, it doesn't really make that much sense. Now those of course, need to be added in side of our models, or rather the block, block states. And then of course, yeah, the block statesman. And then of course inside of our item models as well. So that's where this would be added as well. And now back to the language. So really dumb mistake. Actually, this needs to be a big L. So, uh, so a capital L. And I believe that that already fixes everything. It's like really dumb about this is the issue. Sometimes when you are using hard coded strings, they are not always. There, can often lead to bad things. And as you can see, language E, N, U, S finished in at ten milliseconds. And then once this has run out, they go. Then a language folder here is created. Inside of it we have the EN underscore US item MC course covering it to copper ingot. And then just so that we're clear and we're going to see this work inside of our game. We're going to see this right here, and that is the real easy like this also is really easy to add on, right? We can just go and add everything here. You know, having multiple languages supported very easy, just make a new case at all of the items. And yeah, and then it just it just works. So it's really easy and real nice. And then let's see. So if we go to the item here, they go hovering it and that's it. That's all there is to it. It's very easy. Very easy too. Add the languages in this case. And yeah, yeah, that was it for the Mod language provider and also the Blue tables. And in the next lecture, we're going to basically finished the data generator 4k, so to speak. We're gonna take a look at the recipes and also the advancements is they are sort of linked together. They are a little bit of an overlap. And yeah, so that was it for this lecture. I hope you found it useful. If there are any questions, of course, always feel free to ask and I'll be sure to respond. And yeah. 75. (Minecraft) Data Generator for Recipes and Advancements: All right, welcome back the Minecraft course. And in this lecture we're going to take a look at the mode recipes and also the advancements to generate them inside of our data generators. So first things first we're going to create a new class. Once again, this is going to be the most recipe provider. And this is going to extend the actually a little bit more complex this time. So this is going to be extends the recipe provider from net Minecraft data. And also it will implement the condition builder. And we're gonna see what it has to do with that soon enough. First of all, of course, just import the recipe provider. And then we're going to overwrite the register recipes method here. And we're going to create the, let's say, a shaped recipe for our copper block. So this is going to be really easy. And you're going to say, this is amazing, Exactly. So shaped recipe builder, not shaped recipe. And then what we want is the result. So this is mod blocks, that copper block, dot get. And then we just make a new line without closing this. And then we're gonna do dot. And then we'll say key. Or the key is what we are, what we give insight over recipes as well as the keys. So this is, for example, let's say we're gonna make a big C. And this is going to be what item's dot copper ingots. Somebody like another leggings the ingot actually they go dot get. And then we're going to say that the patter, light and pattern line is a string and this is the pattern that we have to make. So in this case, this would be a full and a crafting table, right? If we were to do this than the middle would be empty. So this should be actually very easily understood with the same idea with the recipes that we've done with adjacent files. Then what we need is an app criterion. And a criterion is basically a way of specifying when you have that recipe unlocked inside of your book, right? So you have this book and there you have these criterion. We can give those names. So for example, we could say cooperating gets as a theory name, right? And then we need to have a criterion instance. This is why the condition builder is kind of nice as well. Has item is a, something that we can do. And has item literally is just exactly this. It checks, hey, do we have this item? And if we have this item, then this recipe gets added to our inventory or yeah, basically like that. And then in the end. Duck-billed with the consumer that we have up here. And that's it. That is basically how we add a shaped recipe for the copper block in this case. And this is going to show up inside of the book. So in sort of a recipe book, as soon as we have a copper ingot inside of our inventory. That's it. Now let's check when we go into the data generators and we are going to add this. So we will add this between the item tags and the loop tables right here. Generator dot app provider, a new mode recipe provider with the generator that you go. And then let's run data and see if it generates ourselves a recipe here or whether or not, once again there was something missed. It's not it's not unlikely, but I think this time, you might have luck. And we did have luck. Maybe it was luck or maybe maybe it was experience. Who knows? Whatever it was it worked. So let's see. Once this is gone, they go MC course recipes and also advancements. Because the advancement is always part of the recipe basically. So if you go in here, as you can see, this is exactly the same that we've seen already. This is a shaped recipe with everything being the copper ingot and the result being the copper block. And this advancement is part of the recipes. And this is also why we needed to change the course tab name. If you have not changed the course have aimed at this moment you will have an error. You simply need to change this to a horse and a small tab. You can also make it put in a, an underscore between those two words. But whatever it is, it needs to be basically compliant with the naming convention of the of the well, like IDs. Yeah. That's that's the word I was looking for. They go, right. So this is one thing that we can add. And then of course there are plenty of other things, right? So we can, of course, also, if we just put in builder, if can we get them, the easier, there's a lot of builders, as you can very clearly see. Okay, how about like recipe, probably easier to get that shape recipe. Okay, let's go sheep recipe builder again. We can also go that, that's actually where I wanted to go, shapeless recipe builder. And then we can also make a shapeless recipe, for example, of course, but very easily done. But one thing that's interesting is let's copy this and let's say, well, you know, we can use all copper ingots for this. But if I may, you know, theft like copper wires in here, that that also works for a for a couple of book. I don't know why, but maybe that is the case. We can, for example, just copy this key. We can have, I think as many keys as 31, but more than nine makes no sense in this case because that's the number of possible the crafting blocks that we can actually have. So let's add a copper wire here. And then, for example, we could add another criterion to have, hey, you have to get copper wire. This is all very, this is why it's a builder, right? It's a builder. And the great thing about the builder is that it's very easy to just adds up, right? We can just add stuff and say hey you, that's another criteria on and so on and so forth. Now, in this case, what will happen is that this is not gonna work because now we have a copper block adjacent and then another couple, Dr. Jason, because of the name, is always the the name of the the result. Therefore, what we need, we need to actually add a new resource location here. So new resource location. This is going to be Mc course AID, AID. And then we're going to call this, for example, copper block, old one, alternative one or something like that. And another parentheses. There they go. You know, something like that. That is not the same name because otherwise, like I said, it's not going to work. Let's just run this again and then it's going to create a new recipe once again. And also in new advancement, even though they are both, they both happen at the same moment when you have a copper ingot inside of your inventory, it's still, I believe, going to add a new announcement if statement. So let's see whether or not It's actually works. But I am fairly certain that it does. It does. And as you can see, copper underscore Block, old. One. Very important thing. If you want your recipes to have the same, So to occupy the same space, for example, if you add something like colored, something colored, right? So then you want each of the recipes to be in the same group, then you can just do set group and have the same name in here, right? So set group, I don't know fff. I would advise you to take your ID, put that in before some colon and then and then you can do whatever group you want. In this case, we're just going to let it sit like this. And let's just, let's just start it and see whether or not the recipes you're worked. But I'm fairly certain that they did. They generated completely fine and I believe that then the recipes are going to work just fine. And this is the reason, of course, why the advancements are gonna come after this in this lecture as well is because as you have seen, the advancements are very closely related to this. And let's see if that is thing. So right now I don't have the hovering at I guess. I believe no, I don't. So let's just take the covering us and throw them on the floor. And then I switch back to survival. And as soon as I get them, we're going to see new, new recipes are available. As you can see, let's just go back here and get away from this guy. So new recipes are available. And as we open this and go into our right, yeah, it's not actually in anywhere because of course we can craft this. We want to go to the functioning today crafting table, they go. And then if we look at this, they go harbor block, either with the copper wires here or the English or just the ingots. And we can actually do this. So we can do this, BAM. And then there you go. Yeah, that's, that's how this, how you add the really easy to use recipes here. A best thing, once again, is to play around with it a little bit, get a feel for it. And yeah, then let's take a look at how the advancements, one skin, they are a little bit more complicated. Maybe even when they should be, but that's fine. So first thing we're going to need is we're going to need a class called the mod it Vance months advancement provider. Now, this is going to implement in interface. I did a provider. This is this the correct provider should take because I'm not a 100% sure. It actually is the Minecraft to data.frame provider implement methods. This is when we have the act method and the getName method that we need to implement here. And there's a couple of other things that we want as well. So for example, we want a public mode advancement provider constructor with the data generator. And the generator. And we're just going to say this.name generator, which actually doesn't exist yet. So we need to add the swamp private final data generator, generator, generate tore, sorry, the ego. And this generator is equal to generator. Then we need yet let's just add this as well. So let's just add the lower as well. So sure, static final logger, This is going to be the org Apache logging. Look for J logger, lock manager dot get logger. Usually we've what we've done is we've just got lock manager, dot, get logger and then put something out. Of course also do this. Both work. This is probably a little bit cleaner. Not only probably it is a little bit cleaner, but that's fine. And then what is a private static, final gay son. So this is a G SON from Google. And then there's a G, some not adjacent, but a JSON. So little confusing equals a new json builder. Dot set, pretty printing dot create. We're gonna need this for something. We're going to see that in just a second. So first things first, inside of the name. We're going to return at var advancements. Made sure that that is correct, advance the ego advancements and do it. And then we also want a private skeptic half. Now this path is going to be the path for Java new file. That is correct. This is get path, path with Puffin. We have, and then you also have with us not yet done, but that's fine. So we have the finished. Advancement, which is just an advancement return path in that resolve. Nope, don't resolve. Resolve the ego, which is data, and then the advancement, get ID. Now, this is all not done yet, but we're just going to namespace. And then a plus slash at, on cement. Advancements, very important. Plural Plus advancement, dot getID. What get PAF, dot plus dot JSON. Looks crazy. Of course, available for you as a resource. Once again, also, this would be Advancement. They go, well, this is a class we're also gonna make. I can't believe it's always the E after the C, that's a missing there. And so it's not too good, but that's fine. And then I believe we need the finished one cement as well. Yes. So we're gonna create this right now. So this is a finished unbelievable. The E sort of gets swallow always. And this actually is just going to be, we're just going to copy this over just for the Halloween right now because it's very much easier. And I'm just going to shortly explain what's, what's going on here. So this basically allows us to have a resource location and as you can see, an advancement builder. So we can build an advancement with this. And as you can also see, we have a JSON object. And this basically serializes. This returns the builder, which then in turn makes it so that we can use it inside of our advancement provider class. We actually have a list of, it's not too crazy lists. So if we look at our data provider, there's some, some things in here, but if we use this, I believe that we can actually see the advancements as well, right? So Advancement provider, so this is the runtime provider from Minecraft. We could of course, also just take this and make it so that we are extending from this. Instead of implementing the Data Provider. Both works like it's not. One thing is not right and one thing is wrong works both ways. But the big reason why we do this basically on our own, because the advancement provider has a few things that are not open to us. If we extend it. Lets the basic gist of it, we're just gonna leave it like this. However, what we want is this list here, so let's just copy this over. So let's just copy this list over. And then let's see what it is. So it is an immutable list of some types of advancements here. We're just going to make a new story advancements. Basically tab or not a new tab we're going to add in there. So we're gonna do is we're going to now also create a new class. Again, this is going to be the Mod story at Van cements. And those are going to be, this is going to implement something crazy as well. This is going to implement the consumer with consumer with the finished advancement. No, that's not at all. What I want. This one is what I want to finish advancement a go and implement methods. We're going to implement the accept method. And that's all we need. And I'm going to ask, I'm going to copy this over as well. Actually, you know what, no, let's go, let's do that. So this is going to be, let's just call this the consumer, a little bit easier. So what we want is basically we want to go to finish advancements dot builder. So this is the builder that we've just created inside of here. And this builder, we can say dot builder. And then we can go advancement and then advancements, builder, dot builder. And then we create a basic. So with parent ID, nope, that's not right with parent ID. This is the resource location. Basically. This is under what? Under what? Advancement is false. So basically, every advancement has an advancement that comes before. Otherwise, it's the first advancement in the group. And this specifies what Advancement lies before. So in this case, let's say, for example, Story, iron tools. We're just going to take this as an example here. Then we have with display. Now the display info can be all sorts of things. First of all, of course, it is going to be a specific item. So we're just gonna take the mod blocks, mod blocks, dot, copper block, dot gets. So we're gonna take the copper block and then we can have a, a name and a description. So we're just going to make a new translation text component. And instead of that, we actually need to specify a translation key. I'm just gonna do at advancement, advancement, story, copper, block dot title, something like that. And then we can copy this again. So another calmer than just copy this. Oh man, it's not like that. And this is going to be this. And this we can now add inside of our language provider right here. Let's just copy this twice. Make sure that this is correct. There's something to be said about putting the, putting the, he's here in, into like string variables. But let's call this covering. And then this is going to be something like choir hopper blocks. Sure. Why not? And then we're going to also do, there's also some more things that are coming in here. This is gonna be null frame type. So in this case we can specify a frame time. We're just going to make this nun another Goldman task. And then true, this is a toast. So this is the thing that comes up on the top right-hand corner. When you have this, you want to announce this to the chat. And then also folds for whether or not this is going to be also this is like one further down. The EO edit is false and then we have width criterion. This is once again the criterion that we want. We're going to call this the copper block. And then we want to have the inventory change trigger. I know this is an insane amount of stuff. I would just advise to once again play around with it for quite some time because this is just an example. So we want to have this happen if we have a couple block inside of our inventory. And then once everything is done here, then we can build with the consumer and then a new resource location. Mc course. Mc were smart MOD ID. And then also inside of story sludge hopper block. Now they write no one more. Not quite. New resource location build really just one parentheses somewhere, too many or too few. Found. Two. You are sure about that one? Not build. I'm fairly certain that this is correct. I'm probably the build for the wrong for the wrong builder. One more parenthesis? Yes, one more parentheses and one less here. Like I said, this is why I wanted to copy it over because yeah, that's that's a whole bunch of What the hell. But yes, this basically now creates a new advancement inside of the story. Advancements. And let's just see what we can see. We also need to add this to the data generators. This is going to be added at the very bottom here. So we're just gonna say generator stuff and provider, and then new mod advancement, provider and generator. And let's save this. And I believe that this is all that we need to do. No, that's not quite what you need to do. We also need to go into R. We can actually go into the data providers and look for the advancement provider. And basically just copy out the entire act method here. And then just paste it in here. I believe that this should work totally fine advancement. So that's probably just the let me just check. I, this is not advancement but finished, advanced, but in our case, the ego. And then this is instead of just, instead of copy, we're just going to serialize. And then in the end here, we also have a consumer of not finished advancement, but of same with this one. I'm advancement but finished advancement. And then here we'd want image, sorry, advancements. So name finish advancements. Maybe, maybe mode advancements actually makes more sense in this case. But let's find, let's see. Can see. Yep. And then once this has been done as well, once again, all of the losses or for download, sometimes a little bit easier. And then just going through it, let's run the data. So run data and see whether or not this works. I'm hesitant to say that it will just work immediately because we've we've run into problems the last two times. But I am very much a there you go. So all providers took a 136 milliseconds. That's kinda nice. And then we're also going to see that new advancements, it's going to be generated inside of here, I believe. There you go. So this is a recipe advancement and then store advancement, copper block trades, and this is how the advancement looks in this case. Yeah, so let's just run the client and I believe that we should get this advancement immediately. Well, let's just start a new, we're going to start a new world where we don't have this advancement and then we're actually going to be able to see this. And then the data generator, let's say Odyssey is actually done. Finally, what's important that I, especially like the advancements might be a little bit complicated for the moment. What I can really say is that once again, it just, it's just a matter of trying things out and saying, okay, I want to do this. Trying it doesn't work. Okay, let, let me try it a different way. All of a sudden it works and then then it's understood. So let us just get like, I don't know, let's just get some iron. And I believe as soon as I get iron, I have some advancement required, of course. And then we look at advancements, they go so isn't this the iron tools? And as you can see, what does this covering acquire cup blocks. And as soon as I get my copper block, they go advancement made, covering and uncovering down here, bring, acquire a couple blocks. We look at the advancements. Now it is filled. So that's actually as easy as doing this. Now, as I've said in the beginning, it can be a little bit daunting, but overall, once again, everything is available as a resource. And this does make it a little bit easier. If you want more. If you want to add those indifferent categories, let's say then of course you need to add this indifferent elements here, so Story and so on. So that's important to note. And apart from that, I believe that every year data generator has been covered in this case. Yeah. So that's that's basically it. And of course, in our case, this is why I said, don't just delete everything that you've done here, that all adjacent files. Because of course we've just added basically the copper block and the copper or block and the copying it and that was it. So the rest, either you need to add or you can just keep your resources in there. Because otherwise we're going to have a little black and purple in your game. Also very important that for your, for your own block. So for a custom blocks, for example, for us, it was the electric fire. Very important that you don't delete that inside of your asset folder as well because that's something special. And usually you want those things to be in there. They don't get overwritten, so there's no issue. If you have some some things in your assets and have them made manually and something's being generated automatically. That is not a like that's not an issue. The game just works out. What is the what what makes more sense to take somebody like that. And yeah, so that was it for the data generators. I hope that it was useful to you. Maybe for especially in end here it's a little bit more complicated, but I think that we've went through it fairly well. If there are any questions, of course, feel free to ask and I'll be sure to respond. And yeah. 76. (Minecraft) Tile Entity Fix and Capabilities: All right, welcome back to the Minecraft course. And in this lecture we're going to take a look at our tile entity. And we're actually going to fix it a little bit because there are a few things that were definitely not that didn't work properly and well, one of the things is first of all, the energy level. So I'm not a 100% sure I tried to be clever being like a and let's just add this integer and early level to it and that's going to be fine. It doesn't really work. The issue being that the energy level at the current moment is only linked in the client. So the server sorta doesn't know about it. It sort of knows about it, but also doesn't really strange, just not a good idea. So the first thing that we're gonna do is we're going to delete the energy level i. We are going to get a bunch of errors. That's going to happen a few times during this lecture, but that's fine. Because what we want is we actually want to use a, a, another capability. This is also sort of the capability lecture, looking a little bit more into capabilities. Personally, I gotta be honest, I find them a little bit confusing and a lot of ways because I don't know, I probably would have done a little bit differently. Maybe there's something I don't understand, but I don't know. I find them a little bit confusing. Whatever it is, let us create inside of our title entity folder, or a package or a new class called the custom energy storage. Now the custom energy storage is going to do two things. First of all, it is going to extend from the energy storage plus instead of net microphone energy. Now this is the basically how Redstone flux power system works. And then it is also going to implement I nb t serializable of compound nb t. So let's just make sure that we can, we can basically serialize and de-serialize it. So let's do implement methods s. This is the serialized. So instead of here we have a compound NVT cold tag, new component Vt. And inside of that tag we're going to put an integer in. And this is going to be called energy. Energy stored. It's not actually something that we can actually yep, that's fine. And then de-serialize is going to be set energy, which is actually something that we've not done yet. And BET dot getInt energy. Crazily enough. I'll set energy. We can actually just see what is here. All we also need to return the tag here. And then instead of here, we actually need to create a new public void. Set energy, set energy, integer energy. This stored energy, energy. And then on energy changed. This is just something that happens that's get cold when the energy changes the goal. So this is protected. Void on energy changed with nothing in it. By the way, right now. Because we're going to overwrite this. That when we go down, when we, when we continue with this. And then we're going to also create a constructor with this, I believe. Yes, capacity and then max transfer. We are going to call the super. And then we're also going to say this max receive is equal to 0. And now this is actually four. Also outputting something. So when we output something from a generator, so for example, generator of course you would never receive anything. You would always transferred. In this case, we actually have a contained system where we are going to use this. And if we look into the energy system, then you can actually see, for example, you know, receive power. If we can't receive, then we're just going to return a 0 here. If we can receive, then we're going to say, hey, we have the capacity and also a maximum receiving. This just, just basically a way of, okay, what are we doing here? This is just basically a bunch of math, making sure that everything works fine. Now we are actually going to override almost all of the methods that we have it. So let's see is, so from here to basically here, I'm going to copy this sum over. So we're going to have a few methods in here. So for example, can generate power and consume power. Generate power makes sense is just increases the power and then consume power just decreases the power. Now of course we can't go below 01 thing that's important. And we can't go above our max energy stored. And I believe that that is basically it. We also have some overwrites here. Our life tiny beads here, but only a little bit. And then inside of our tile entity, we're going to create a new private, final custom energy storage. Energy storage. This is going to call the create energy storage method that we have yet to create. We also want a private. Final lazy optional is the of high-energy storage. This is the energy, let's call it energy handler. Sure. This is a lazy optional of the energy storage. Now this is of course the capability that we have, that we have to give it in down here. So inside of the Get capability, we now add an else if statement, which is going to be at capability equals to this, the capability energy, energy for easily enough. And if that is the case, then we will return the energy handler dot cast nets. Not quite what I want. They, that's what I want. Right? So if that is the case, then we're going to return the energy handle account that a cost. And then we also want the method where we create this. So we want the the cost of energy storage one. So this is going to be a private customer. Energy storage, create energy storage. We have nothing in here. We're going to return a new custom energy storage with, let's say, a capacity of a 100 and, and the mex of one, the transfer doesn't really matter. But also going to do is we're going to override on energy changed. And we're gonna say Mark dirty. The idea here being that we're going to mark the mark dirty basically marks the actually steer they go interests that are Chung continually tell MC you save to disc later so that we make sure that this is actually saved. This is the rough idea of what of what Mark dirty does on remove. Do we have the remove method here actually? Well, I've never added this apparently. So let's just overwrite the remove method as well and just making sure that we invalidate both of the laser and optionals here. Instead of a tick, this is the first one world dot is remote. Return. Why is this the case we don't want to take on the client. So is remote means that we are on the client and we don't want to take to happen on the client. Therefore, we're going to return if we're on the client, on the server, the rest is going to function. So we need an energy level. We're gonna say energy storage, energy stored. So energy storage, energy stored. And then this, in this case, should also be handled. So the idea of, well, we can only store 64 is actually already handled by the capacity. We're just going to keep it in here for the moment, for the time being. But this shouldn't in fact actually be needed. We're going to keep it in here. Nonetheless. Energy storage, dot-dot-dot generate power one. So for each a diamond where generate one power in this case. Here, once again, this is going to be energy storage, energy stored. And I, of course, the changed the file here is available as a resource once again, so that you don't have to type everything out. And I'll also, you know, do a mistake somewhere. That's not what we want. So extract energy one. And then importantly that we actually say false here this is the simulate. So this would simulate the same with the extract item. There's also a boolean for simulation there. So yeah, the energy level we actually don't need anymore. And I believe that the only thing that we then need to do is the read and write and the energy storage. The one other thing that was a thing was that someone noticed that when they went out, so they saved and went out of their game and went back in that the energy storage didn't save. That is of course true. This is why right now we're going to make sure that it does save. So this is going to be energy. We are also going to put the tick in here as well. So Tic Tac Toe, getInt counter I believe is the name or I've pulled it take rate. Yeah. Shirt and let's call it let's let's keep it as counter. I think that that's fine. Just so that we have the As well. Usually doesn't make matter, but it would be really dumb if we have the tick set to like ten thousand, twenty thousand or something like that. So we need to wait like a bunch of time. And then just because we start the game again, we actually reset the tic. That would be kind of dumb. And this is why we probably want to put the current tick in there as well. This is genuinely just four things when you have it a little bit, a later or or longer lead. That's that's what I meant. A little bit longer. So let's also do tagged output energy. And the energy storage serialize nb t, and then that's it. And I believe that the other thing that we want is we want to mark it dirty here just in case this shouldn't technically be necessary because we market 30 each time we extract energy or regenerate power, just in case, let's mark it 30 here as well. There's no real reason why not to call this actually. Now, this is all fine. But this should now have caused the screen and the container to be a little bit confused about a few things. So the screens not confused at all. The container, however, should be confused. Yes. Yes, the container is confused because it doesn't have the energy level here anymore. And there's also a few other things that we actually need to do in the container that are gonna be very interesting actually. Now, the first thing is we are actually going to add a new method inside of here. I'm gonna copy it over and then I'm going to explain it best I can. Because it is actually a little bit crazy if I do say so myself. So let's put this here. Let's copy it over. Get energy is another method that we also yes, get energy. Of course, there's also a new method that we need and this is basically the replacement for this is the replacement for the energy level down here. We're just going to delete this. We're going to keep this and then everything works. So, and then attract power is going to be called right here, track power, cold inside of our constructor for it. Now, the idea of track Power is the following. This is something new to me as well. But as you can see, we have this reference Holder Method, which is, you know, has some weird like get integer and then with these codes here, and then we have a big shift of 16 bits. What the hell is going on? Well, the idea being that, and this is generally something I didn't know as well. Apparently, on-site dedicated servers, integers are actually converted into shorts. What does that mean? Well, an integer is a 32-bit. Number, a short is a 16-bit number. And this is why we apparently need to separate those into two 16-bit integers. This is why we bit shifted here so that we can basically take the first 16 digits and then put the first 16 bits of the number, put them in the first one. And then the second one, we bit shifted 16 bits to the right, I guess, and then take the other 16. That's sort of the idea here. I gotta be honest with you. I wouldn't think too long and hard about this. It's just something that we need to do. And if it really comes up, I would advise you to just look into a few things of how this works. The track power is needed, the method so that the client knows about what is going on on the server. So in this case, we're doing everything on the server. And the server's like eight. There you go, client. That's what's going on. It feels a little bit weird to me that we have to do this, but this is apparently what we need to do. So ok. When we look in the get energy, we just get the capability of the tile into T. So the energy one. And we're just going to be, and we return this, the energy storage. So they get energy stored. And if that doesn't exist, then we're just going to return a 0. But of course it does exist, so that's going to be fine. Now inside of our screen, now we have the energy level that doesn't work. But the good thing is that this is not an issue because now we have the get energy. So we actually do get energy. Get energy. And I believe, if I'm not mistaken that this is everything that we need to do, and then it works. Now, let's hope that that's the case. But I am actually, no, I think that that that's everything that we need. And most importantly, I believe is this track power method, which is a little weird. I'm not going to lie, but we're just gonna try it. Let's just start it. Let's see whether or not it works. But I'm actually, I think that that's going to work fine. And you, I'm not a 100% sure why I had the idea of the energy-level just being an integer in here. That's not going to work anyway. But you know, sometimes, sometimes, sometimes you get an idea and then afterwards you're like, That's kind of weird that that's definitely should not have been done like that. But that's okay. This is why we're here, this what we're going to fix it on this while we're going to take a little look at this. So I basically also added back all of the JSON files for each of the things except for the language. And let's set down the electrified and lets look into it so that all works. Let's take a diamond where let's take two stacks of diamonds. Let's also take like a stack of copper wires and let's just see if we place it in whether or not we're going to get energy. We are getting energy, so that's pretty good. The diamonds are decreasing. So before. That was the issue that sometimes you were able to sort of double your diamonds by taking them out. And if the tick was at the right moment, then the server and the client, God's DD synchronized. And then basically you were able to basically double your stack. That doesn't work anymore. If we put in the cupboard water, as you can see, the emeralds are getting treated, but the energy does not decrease. So that's interesting. Now, I believe that the only thing that doesn't decrease is the energy because it doesn't like it doesn't show. So I believe that if we're if we're at 32, then it's actually going to stop. It does not stop. Very interesting. So let's see why that is the case. Outside of this sum are sort of the game. All right, I actually was able to fix it. So as you can see, it increases the energy here. And then when I put it in the copper wires, they actually decreases. And then it stops at 0 and it doesn't generate any more emeralds. Now, the reason why it didn't work, I can actually show you was that I didn't use consume power here. So I use the extract power. I believe it's called extract energy. That was that was what it was. I'm not a 100% sure why it didn't work. Because I use the extract energy method in my tester scenario because I've always test out that everything. And there it worked. But in this case, it didn't. I don't I don't know why. I just know that consume power is somewhere like It's cold somewhere inside of my tester scenario. But it wasn't cold inside of the, instead of this project here. And I'm not a 100% sure why. Now, there might be somewhere where have like overseen or, or I didn't I didn't see that. So like somewhere where I, you know, didn't call it. Kinda weird. Kinda weird. If I do ever find it where that was, I will of course some, you know, maybe add a little extra somewhere. But yeah, now it works with consumed power. Once again, it's only something like very minor, but it should also be, should also work. In this case, is that it actually will store the energy from one time you open Minecraft to another. So what we can do is we can just check that as well. Because that was something that was an issue with one student who asked, well, you know, there is, I have energy in there, but if I close the world than my energy is all of a sudden gone, which of course, well that you don't want that. So let's see. So if we put in a little bit of energy are right. So let's say something like, I mean, let's just do it like this and then let's just go outside of your save the world. And then let's get back into it and see whether or not everything has been saved. But it has been saved. And also the diamonds had been saved and the energy as well. But it didn't destroy it accidentally there. But yeah, so and then you can go in, put the put the copper ingots or copper wire in here and emeralds. Yep, that is basically it. For the fixed to the to the electrify are here. And Yan is also like a short exploration of a little bit of the capabilities here. In this case, the energy. Overall. The capabilities are little bit more complex than first thought about, especially from myself personally. So yeah, that is the general overview here for this and also how to fix the tile entity. There were a few well, I mean, literally things that were not synchronized properly. So yeah, I hope that was useful to you. I hope that that fix the well, the issues concerning the power there. I would also advise you to take a look, take a good look at the energy storage class here and also the high-energy storage. This is basically what happens, what the implementation of this very useful to look at. And it's going to really like make it look like a few things are more clear, right? So it makes it a lot clearer. And you're gonna be probably able to surmise a lot of what's happening from that as well. So yeah, I hope that this was useful to you. If there are any questions concerning anything that was done here, of course, always feel free to ask and I'll be sure to respond. Also, always remember that the entirety of the source code is available as a download, as a resource. And yeah, that was it for this lecture. And yeah. 77. (Minecraft) Creating Custom Commands: All right, welcome back to the Minecraft course. And in this lecture, we're going to take a look at how to create your own custom commands. That was basically suggested, or it was a request in the Q and a section of this course. And someone said, Hey, I want to basically have a set home command and a return to home command. So that I can basically jump from one section of the world to another section of the world. And yeah, we will implement this. And this is basically also how to make your own custom commands. Let's just start with this. So let's read in our sight of our MC worse, a new package, which is going to be the command package. Now this is of course once again, just the structure here can be changed and changed around. But I think that a command package here makes sense. And instead of it, we will make two new classes. The one is the set home command, and the other one will be the return home command. So those are going to be two different commands that we will implement. Now, there is, I will show you basically how I figured out how this works. Because at first I thought that this would be really complicated because microbes changed up how commands work and how you can actually register them. But after digging some bit, I actually found a very, very easy way to do this. And I figured this out by, let's just do the following. So if we press Control Shift F, Then we will and basically have this find path, finding paths. And if we go to scope, then we can search for something in the entire scope. And they're the forge command is the thing that we would actually want to look at. And that is going to be hearing words command if we double-click on this. And as you can see, this is all of the commands that you can basically do with the slash board. And then you have different things for it. So for example, two slash TPS and then you get the TPS output. And if we then middle mouse button click on any of those commands. So for example, the TPS command, and you can see how this is built up. Now we're going to build it up in a little bit of a different way, but almost the same. And as you can see, the actual command itself is simply registered with the command dispatcher. So this command simply has in its constructor a command dispatcher. So this is exactly what we're also going to have. And then it calls the register method. Now we're gonna do it a little bit differently. So instead of actually calling these register methods which are inside of here, for example, this would be which is giving back sort of an argument builder. We're going to make the argument builder ourselves. For now. This looks a little bit, oh, what is happening here? What has happened here? Don't worry about it. We're gonna go through it. I think that in the end it's depending on what you of course want to do. It might get more or less complicated. But I can tell you that overall, making a new command, not that complicated, depending on what you wanna do with it. I mean, if you I don't know if all of a sudden you wouldn't like an entire village to appear. That might be a little bit more complicated. However, if you, like I said, wanted to just slash home slash home slash home return, that's going to be really easy and we're gonna take a look at that. And now my first issue and this is why I'm telling you this is I didn't know. Okay. Where would I actually register these commands? Because I didn't know, where is this cold now, if we think about it, this is a constructor. And of course this constructor has to be called somewhere. And we can actually figure this out by pressing Alt F7. And then we can see that inside of the fort internal handler in a little nice subscribed event called on commands register event. With the register commands event. This is basically initialized with the Event Dispatcher here. So this is the, this is the constructor that gets called. And then we basically say config command register and then bam, that's it. So this is the really cool thing. Now this is basically how I figured out how this actually works. I just wanted to mention this quickly at the start of the video so that you know where that came from because I actually didn't couldn't find anything anywhere else. And yeah, so let's first of all make a constructor here. So public set home command with, like we have said, the command dispatcher of type a command source. And this is going to be the dispatcher. And instead of here, so what we could for example, do is we could copy something. We're going to build it up on our own and well, we'll we'll see how this looks. So first of all, we have the dispatcher, this utter dot register. And inside of here we now basically build our, our command and then we have commands dot literal. So this is the spring, so this is the string name that we have to type it in, so slash, and then what do we have to type in? We're going to stay home, for example. And then at the end of the commands literal, we're going to do another dot and then we're gonna say them. And we will have another literal. So basically it's gonna be slash home and then set. And this is basically sets the position of the player currently. And then we'll, and then we'll have a different command which is going to be home return, and then we will return home. This is basically how we're going to do this. So the, oh, sorry, not then, but we actually do need to set a new command here, sorry. So this is also command dot literal, and this is then set. And then once again at the literal here, we're going to execute something and that is going to be just the executes. A method, let's say we're going to call the execute method. And inside of here we need, if we hover over this, we actually need a command. So as you can see, this is the argument builder that will be returned in the forage commands here. And we're just building it inside of our structure here itself. So this can take a Command believed that this Oman, they ego. And then we can make a new. Like I said, it's a little bit more complicated. Let's just quickly check this. So this is the command. And then we're going to get a one here. And then inside of here we're going to return something and that is going to be the private and new method, private interests at home. And that is going to be cold in here. And we also need the command source. Source. And that is going to be Command source. There you go. All right, so that's basically what we want for the dispatcher, the registration here, like I said, you can either look at the commands in the forge commands to see sort of how this works. So you can also require certain things like the permission level and, and execute where it executes. So there's a few things that you can actually do here. We're not gonna go too crazy into this. If you want to figure something else out, then you will have to do it on your own. I will. I'm just basically here to tell you, okay, this is how we're going to make a new command. And then any functionality beyond that, that will be your thing to figure out, right? So this is the set command. Now. And first of all, we can basically return a one here, and then that's going to be fine. So we'll basically just return a 1 and then we're going to build up, okay, how can we set the actual home position? Well, the great thing is that this command source, if we open this with the middle mouse button, this actually has a lot of things. For example, the world. We also have the, we should have the player somewhere. I believe, player, player, player, separate entity as player. So we can get a few things in here. So for example, we can get to the server player into t, which is going to be the player. And when we say source as player, there you go. So then it basically converts the doesnt converge, okay? Yes, I will, we will do this soon enough. So it basically converts the source into a player, because the source of the command can either be the player or it could of course also be a command block. Now in this case, We're just gonna say as player. Now, if we hover over this, you can see that we have an unhandled exception. If we add this to the method signature and it's going to save throws a command syntax assumption. And now I believe, and I've actually not a 100 percent tests of this, but I believe that this would be thrown if the command source, so if the command is actually being called by a comment block, and this conversion wouldn't work, right? So if source as player would not work, and of course, that's an exception. An exception will be thrown. But that's just something to be wary off. And then we actually need the position of the player, which we can simply do by block Pause. It would be player pause, play or pause equals player dot. Get to position, new position, actually, position. There you go. Now we actually need to also import blood pass. Simply put the carrot overlap and then press Alt and Enter. And then I want to build a string which we will also put out. So we're going to output that in the chat. And it's basically say something like a home position set or set home at. And that is going to be done with the not as strong but a string Pause, which is going to be this plus the block. Actually this is the player, POS, Player pos dot getx loss. So this is not strictly necessary. However, I think that it is a good idea to output this as well. They are passed out get why? Because this is also why I've done it while I was testing just to make sure. Okay. Is the block position actually like is he getting the actual player position, get z. And then we're going to close it up with a parentheses here. That's fine. And then how are we going to save the data? Well, let's first of all, output of the actual home, the like, the position. And then we're going to see, so this is going to be source. Send Feedback is basically what we want. And inside of here we have a new string text component set home at. And then we're going to say pause. And then we're going to say true or allow logging. So right now with what we have built, you should be able to, after we have registered this command, we should be able to do the following. We should be able to slash home, slash home, and then a space bar set, and then end the message should appear with basically the position of the player current. And now the question comes, well, how can we save this data? And the way that we'll save this data is basically if we go into the player, sorry, the server player entity here, we're actually using something that is called the persistent data. Now that is actually we actually have to go into the tree here. So we have to go to the player entity. And I can close this, and we can go to the living entity and we close this and then we go into the entity. Because the entity has something that is the persistent data, right? So it is right here. This is a private compound NVT. So this MPT data, we've only sort of have like put a cursory glance on the NVT data. But it was basically a way to store data. And in this data of the player entity, we're going to store our position. Now how can we do this? We'll be, we'll save player, get persistent data. As you can see, there we go there we get the compound MBT from that. And we can do the same things that we have done with the MBTs before. We can, for example, put an int array. And that is exactly what we want to do because we have three different positions or three parts of the vector XYZ that we want to save. So this would be the home paths, for example, could also call this home position or something else. And then we need a new int array with the following three things. And that will be the player pos dot get X, the bilayer pars dot y. And at the layer paths. Your past dot get z, actually not what zed. And in this way, the position is now saved inside of the ghetto, persistent data of the actual player. And we can read this out later in the return home command right here. Once we are writing that, now this is all that we need for this particular a thing that we want. So this is already it for the set home command. Like I said, it's not actually that difficult. It really depends on what you put into basically this method here, right? So if you want something that is more crazy and more complicated, it sort of goes back to the events that we had. Events itself. Really, really cool and really powerful. Same with the commands, of course. Basically a very similar thing to an event, just that the player can, while basically execute that an event on a whim by typing in the chat. It's just that depending on your use case and what you wanna do. Yeah, that's there might be a lot of Else, else to figure out here, but that is of course up to you now how can we actually Some sent home command registered? Well, we simply go into the events, mode events, and then let's actually do something like this. So let's make a new event. And that event is going to be the public public void or no, that's not. What I want is I want the on commands register and then this has the register commands event, what event. And instead of here, we're actually going to do exactly what the command does here, which is here on commands register right here. So we're just gonna say new set home command. Let me quickly close a few things. So MOD events. There you go. New. Set home command with the Event Dispatcher. And then in the end here we can say the config command, command that you go register. And then we say Events dot get dispatcher. So that is all that we need to do. And now we're going to do the return home command. And then we're basically already done. So that's, that's the cool thing. Now, for the return home command, the cool thing is that we can basically almost copy this over because the thing here is very, very similar. So this is simply going to be returned home command. And then instead of a set home, we're going to have a new private int. And this is going to be returned home with basically also a command source, command or the sorry source, of course the ego and that like this. And then we're going to call this instead of set home. And here instead of set, we're going to say return, because that's what we want to return home now. And then the thing that we're gonna do is we're going to first get the player once against. This is once again the server player entity layer is equal to source dot as player. Which once again prompts us to add the exception to the, to the command here or to the method. Let's save. And now what we're going to check, it's actually because. We could do is we can say, hey, get the persistent data int array and then let's just easily go. But the thing about it is that we're actually going to check whether or not this is empty or not. So we're going to say if player dot get persistent data, get persistent data, get int array. So we're going to say get into area and we know that the key here is the home PaaS. And if the length of that array is not 0, right? So this means that in this case, so not 0 means it contains something, right? So for right now, we don't actually want to know, we don't want to save this. We actually only want to know okay, doesn't contain anything. What we have found out, I believe and if I remember correctly, the idea is that if you get an error here, it's always going to return a new array even if something doesn't exist. So that's why we check for the length and not for whether or not it has null. And then we also have an else, just so we can basically say source dot, send feedback. And then we can say a new string text component and say No home position has been set. And then we also say true here. And then we will return, Let's, let me zoom out a bit. Return a negative one, negative one. There you go. This is because we have twice that one to, you know, understand feedback. Am I crazy? Yes, I am crazy. There you go. That's what it is. And then we have one-to-many. There you go. Okay. Send Feedback, spring texts component, no home position has been set. Because of course, if there's no data in the array, then we have not actually settled the home there. And now what we want is we want a new int array. This is the player position once again. And we can basically read this out by saying layer dot-dot-dot persistent data. Dot, get int array, get int array with the key home pause. And then we actually have this inside of this variable. And then we can use the player dot set and the set position and update. Very like, nice thing that we actually can use. And then we can simply say player Pos 0, layer one, and layer two. There you go. And now the position of the player will be set to, well, exactly what is written inside of the persistent data. And then we can say a source, Send Feedback can say new string, text component layer, returned home, returned home, they ego. And then also say true here. And then in the end, the only thing that we need to do is return a 1 and everyone is happy, right? And now, like I said, this is a way to do it. There's probably a multitude of ways to actually teleport a player to a different position. In this case, this is going to be fine using the set position and update method. And actually I think is going to be very, very good. And yeah, this is basically all that we really need to do. And we own also just need to set this year. So new return home command event. You go Event Dispatcher. And that's it. Well, very important at subscribe event, they go right now, it should be fun, right? This is actually all that we really need to do in order to add our set home and return home event. And I guess let's just start and see what we can see. That's probably the most interesting thing. If this actually does return, well, take us home and we can set our home that. So that's going to be really the test. Now, overall, I really think that commands are fairly easy to implement, really depends on what you wanna do with them. Like I said, this is very, very similar to the events we had before, where if you have an interesting idea for an event, that's pretty good. But they can get really complex depending on what really want to do with them. But yeah, this is basically all of the tools that you really need in order to make your own commands. So that's pretty good. And let's see what we can see. So first of all, we spawn here in some sort of a redwood forests. So let's just move about a little bit of the light and let's move to this hill here. And then first of all, what we're going to say is we're going to slash home. So as you can see, this is already here as a suggestion. So we can basically auto completed. And as you can see, we also have the two literals. So let's first of all say slash home return. But as you can see, no home position has been set because we have not set any home position. So our if statement, if we look back simply here, our if statement has worked exactly how we wanted it to. So that's really, really nice. And now what we want is we want to set our position right here. So we want to say home slash, slash home settled, they go and now it has, has set home at position negative 718200120. Now let's see if we press F3, you can see negative 2, 34, 91, and 120. So that's pretty much exactly where we're at. So that's pretty nice. Now let's fly away. I'll look at this. A nice, nice, peaceful village right here with a few buffalo as well. That's pretty nice. And then, yeah, let's just, let's actually just fly over here. Now we should get back there if we call the home return. Let's see if that works. So we can of course also press the Tab key to autocomplete this. And if we do this, as you can see, layer returned home. That's how easy it is. That's all there is to do in order for you to make your own commands. In this case, the set home and the return home command. And yeah, this is basically all that I wanted to show you. One more thing I want to leave you with is the other commands that there are. So if we just actually, if we can do that like this. So I believe that there is a time command that's like the easiest to get there. Yes, exactly. So if we, for example, put in time command here. So once again, Control Shift F and then open the time command. As you can see, it's a little more complicated right here. But this is one thing that you can take a look at with the commands, basically what they can do. And then you can also follow this register method. This is a static register method in this case. And if we look at that, then inside of the, inside of the commands class, there are all of the normal commands or the vanilla commands, let's say. And you can open each one of those once again with the middle mouse button. So for example, something like the Game Mode. And then you can look at everything that's happening here. And you can basically just, well either copy or expand on this, which is really good and really nice. Let's take a look at those. So yeah, that is what I wanted to leave you with. A really nice thing and commands. I gotta be honest. Way easier than I personally anticipated. But yeah, once again, that was it. But if there are any questions, of course, feel free to ask and I'll be sure to respond. And yeah. 78. (Minecraft) Making our own Dimension: All right, welcome back to the Minecraft course. And in this lecture we're going to take a look at the most requested topic I've gotten since probably day one. And that is how to make your own custom dimension. Yes, we're finally here, it's finally happening. And once again, just like last lecture with the commands, he was very much way easier than I had anticipated. There are a lot of changes between Minecraft versions with both of the world, the world generation, and the dimension generation as well. Now luckily, what has happened is that the dimension generation has moved to basically have only the, so you can basically almost do everything inside of JSON files. Now that's pretty cool. If you want to have data packs made For us, it's actually also very easy because we only have to have two JSON files that define what type of dimension it is. And then also how it looks like. The, I wouldn't say that there's a few drawbacks there, but well, let's just see how this works. The only thing I will mention this at the very beginning, because some people might be a little disappointed. We're not going to take a look at how to make your own portal. That is not going to be a lecture. In this case. The way we're going to teleport is by right-clicking. We're going to probably make it the copper over just because I find that kind of, uh, kinda funny. But we're going to right-click a block and then teleports to the other world, Basically the other dimension. Yeah, if you were a portal, then stat to say this, but then you will have to figure this out on your own. But I believe that this should be doable because the teleportation itself happens within the block when we right-click. And it's also not that complicated. Well, yeah, let's just see what we can see and stored by making a new package in sort of a world package called dimension diamond Xian. They go. And then inside of here, we're going to make a new class holds the mod di mentions class. Now this is actually going to be a little bit different than our other well MOD and then something clauses. This is going to be have a public static and then a registry key actually of type world. And we're just going to call this the How about like KJ? Dim? Sure, that's great. Aj. Like that. Yes, I love the count and draw dimensions. Why not? And then let's also import all of this by pressing Alt and Enter on this. Then we also need a public static void register method. A register method. And this one will actually do the following. We will say. A j Dim is equal to registry key dotted catwalk 38. And this is going to have the register read just re, not a world key. And I'm going to have a new resource location with of course our MC force.html Friday. And then this is the path in is basically the name, which would be KJ shirt. Now this is all that we need to in order to register our dimension here. And instead of MC course, we're of course going to add at the very bottom, the mod dimensions register. So the great thing here, or the other thing that we're, the way we're going to create this is without a different register in this case, but that's totally fine because this actually works just as well. And then what we're going to need inside of our dimension here is basically a. And this would be, I will call this the KJ teleporters. Teleport tear. There you go. Yes, that's one. And this will implement the AI tell a quarter interface. And this teleporters is basically while what will teleport us. This is the thing that we're going to call when we right-click our block later. And this is going to have a few things. Now, I have adapted this from a very, very nice GitHub repository, which was the day light dimension. If I'm not mistaken, this will definitely be this would definitely be linked or blog post. That's not quite right. There you go. And this will be linked as a resource because that was invaluable. Because usually I have tried to take a look at dimensions. And the issue is that, for example, with RF tools, great mod, absolutely great, amazing, even code base, right? It's really good. I only want the dimension. There's about a 180 different classes that are for the dimension because the actual MOD pack or the other mode is so vast the like big. It's so huge that it's yeah, it's a little much. And this is why the daylight dimension, because that's the only thing that the mode adds is a new dimension. And that's really nice. So public static, Boolean, this is going to be inside a dimension. I mentioned rule. We'll leave it. That is the thing that we want. Yes. And then we have a public K, J teleporters. So this is a and new in new plot here. Sorry. This is a new constructor with the Boolean here. So this is simply inside dimensions. And then we can basically set this dot, this position equals past, and then also this dot inside. Sorry, this is static. That does not work. Of course we can't do this, but don't be crazy. Inside dimension is equal to in settlements they got. And then we will have the only thing that we will override. And that is going to be a, we actually have to rename this inside the shirt. Might not. Something like that. That's why they go. And then the only thing that we need to have here, this is a public entity, will place entity. And this is going to have an entity. Entity. It has a server world, which is deep learning world. We're going to have a server world. Just the destination world. We're going to have the float y'all. We're going to have a function of Boolean and a return type of entity. And then this is the repositioned entity. And this is going to be it. Yes. Okay. First of all, entity, yes. The server roles old and and and then the Function Java util function that you go. So this is the override method or the method that we need to override here. And this basically is the thing that is responsible for our teleport. And now we have a lot of things to do. So first of all, that the entity that we're given here is going to be falling or reposition entity dot apply with a faults here. And then we're going to have a double. So this double is, if I'm not mistaken, the y, excuse me, why I wondered why they go. The y position where the top layer is. Well basically available for teleportation. That's sort of the idea here. So then we're going to say, if so, isn't inside of dimension that what we're gonna do is we're going to say y is equal to this dot, get y. And then we're going to stay the following. We're going to have the, we're going to have a position which is going to be the desk nation physician. Pause, that's better. Which is a new block pass, which is going to be the x and y of this position. So good. And this dot get z story. They go and then the y is just going to be the Y that we have calculated beforehand. And then there's a few things that we need to do, and that is number one and integer with tries. Now this is there, I believe, so that we can basically try to tell upward and sometimes it might not work. And if it doesn't work, then we will stop it basically. So we have a while loop and this is going to be a crazy wild loop, like the thing in there. So we're going to have a destination world, sorry, the destination where bagel. And we're gonna say, okay, get the following blocks, its block state at the following position, and that is going to be the destination position. So this is the position where we want to basically will appear it. And then we say git material. And if that is not equal to material.ai, then we will have to change some things. And that is going to be, we're basically going to move up. So it's not only going to be air is also we can, so we don't want to spawn in other way round. We want to spawn in air. But it also should not be water, so it is can't be destined. Let's actually do something like this. And then let's move it down here. Sorry, the destination world gets locked. State at destination position. Once again, I'm going to say, this is going to say is replaceable with the fluids dot of water. And this should not be the case. Then we're going to have another end, which is going to be the destination world and get black position, a block state story. And then we're going to have the destination position, which is going up. So this is one position up. So this is yets off offsets. This block was by one, and this is in the upward direction. And it's going to be, sorry, this is down here, which also going to get material. And I'm going to say this, if this is not equal to air. And then the last thing you could have guessed it probably is basically this one. Copy it again, just negate it. And this is going to be, is replaceable. And then no end right here. And then this one, and then the ego 0. And then also there is another end and this is going to be fries is less 25. What does it's doing is basically saying, Okay, Listen, we need to get the destination where we can spawn inside of this world. And we're going to basically move up. And that's what we do here. So we say distillation position is equal to destination position shot up by two. So we're gonna move up two blocks every time. And we're going to try this for 25 times. And two were like, screw it, this is fine. So the idea being that we are trying to find a position in which the both blocks where the player would spawn is air. That's basically what we're trying to do here. That's the easiest way to quickly explain it. Let's say that's all this does, is it basically checks if a particular position is valid or not. Yeah, that's pretty good. And then what we can do is we can say entity, set, position and update. And this is going to be the destination position, ydx, destination position get y and destination position get is the E or Z. And this is exactly we've seen this in the command custom command lecture as well. So that's really, really nice. And now we need to do one last thing. And that is going to be, we're going to say if inside the dimension, then we want to do a few things and that is going to be a Boolean to set block. Now the idea is that we're going to, of course, if we this basically the teleportation back. So we wanted to set a block where we spawn, because otherwise we're going to have a bad time. So this is going to be for a for loop. This is going to be a foreach loop basically. So we're blocked past check house. This is going to be blocked. Pause, get all in Mark's mutable crazy thing. Don't even worry about it. I'm going to explain this what this is. This is not down that west and this is 10. So we're going to do this in a ten by 1010 by ten by ten, I guess radius. This is afterwards, after this or in the ego. So after this, the West comma and then another destination path of up by 10 and then East by 10. And then once we have this, then we can go and have a for loop. So we're basically going to check each block position in a ten by ten by ten cube. And then we're going to say the following. If the destination position dot-dot-dot yet, sorry, destination world, who very important distinction there, get blocked state at the position, check position. So this is the position that we're basically going through the for loop that we're iterating through. If the Bloch theorem get blocked is an instance of copper or because what we're gonna do is we're going to have the corporate work. This is very important. And you'll say replace copper or with your Taleb order block right? Now this is very important. The copper or in this case we're only putting this in because we have an instance of this map block here as a class. And we can easily basically accesses this is going to be your teleported block. This is the block right-click that basically has the ability to teleport. So we're going to then also break. So basically, once we have a copper block found, recipe like Okay, Okay, we don't need to set a block. Now if we do not find this, then we're going to say if you set lock, sorry, There you go. We're gonna say destination world, that set lock, state of the destination position. And this is going to be mud blocks, dot or dot get. That gets default state. Oh, look at that. He's actually already done that for me. That's very nice. And then in the end, we're just going to return the entity. No entity. There you go already. So what have we done here? If we are teleported to our dimension? We wanted to set a copper block because this is the block that gets us to the dimension and we need something to get back. And this is exactly what we're doing here. If the, if we actually find this copper block them, we don't need to do anything. If we don't find the block, then exactly where we teleport, we're going to put this block. That's all we do with this. Now the KJ teleporters, like I said a little. It's actually okay. It's not too crazy. If we if he took first take a look at it, might be a little crazy, but overall, I hope that it was not too insane. This one we just check that we can actually spawn. And this one we'd simply set a particular block to our copper block so that we can teleport back. And now what we need to do is we need to go into this very copper block and modify that. Now, the cup, what do we need? We need a public action result type. This is on block or unblock activated. Yes. That's way too much. Way too much. Let's just go to override it and let's go there they go. Because typing that out is would be absolutely ridiculous. They ago, so, okay, on log activated, this means that we right-click the block. What do we need? We need the first thing we want world in is remote should not be the case. So if not, if it's not remote, Let's go. Next thing. If the player is crouching, round shape is crouching a ego. If that's not the case. So the player can only click the cover block. If it's not. If they're not crouching, then we have the server. You need the server Minecraft Server, which is the server, is equal to Berlin dot Git server. Interestingly enough. And now we need to look at this. And then we say, okay, if the server is not null, then we can proceed. And then we will look at this. We're gonna say, okay, let's see, what is this world now, we're getting interesting. So if this world dot-dot-dot dimensionally. So now we're basically checking in which dimension where if this is the multi-dimensions mod di mentions that KG dip, right? If we're inside of our custom dimension, then what we wanna do, well, we want to say this, we want to stay server world overwhelmed is equal to server dot get world. We're gonna go through this one by one after we're done your world.org. But we're just going to quickly, quickly, we'll semiquinone do this. So we're going to get the server world. That is going to be the overwhelm. And now the big thing is that if this overwork is not null, so that we can actually teleport to that. And we're gonna say, okay, player dot changed. I mentioned very nice command. Our method. I gotta be honest. We're gonna go to the overwork and we're gonna make a new KJ teleporters with the following. The position that this block is at. And with a false, a false because we're not, basically, it teleports inside of our dimensions. Okay? Okay, If, and now let's think about this. Yes, that's fine. Now, need is we want this one, sorry. That's a little too much. And then we have an else. And that else is very important. The formatting here always the same. So this is going to happen if we are inside of our dimensions. If we're not inside of our dimension and we right-click a copper block. Well then it should probably take us to that dimension. So we're gonna say server world. And this is going to be the key k-j dimension. Dim, sure, that's fine. It didn't. And then we're gonna say server, that world. And this is a great thing. Much dimensions dot KJ dim, isn't that nice? So instead of using world that overwhelmed weakness, say multi-dimensions that AJ dim. That's really nice. I gotta be honest. And then we also check whether or not that is null, just in case because you never know. So this is unequals null. And if that's the case, then we're going to say player dot-dot-dot change dimension. I'm going to say this is the KJ dim. New KJ telephone order. Position. And then we're going to say true because we are teleported inside of the dimension now. And once that is done, actually once all of this done, so this is right in here. We're going to return the action type result of success because we are successful. Now, after everything, actually. Yes, after everything, yes, we want to return the superbug activator. That's fine. And that's it. I know crazy what is happening. Okay, Let's go through this. First of all, we're checking whether or not we're basically not in remote. So we're basically on executing this on the server. Next thing we're not crouching should be both of those. Easy enough. Then we are getting the server and make sure that it is actually exist. If the server exists, we're checking, okay? Are we inside our predefined dimension? Where are we in another dimension? If we are inside of our dimension, then the, then the destination that we want is going to be the overwhelming. Therefore, we're getting the underworld, checking whether or not that is null and then basically teleported into the overboard. If however, we are not in our dimension, then we want to teleport to that dimension. And then we're going to basically do exactly the same thing here. Now something like this could probably be extracted into its own method. Probably with a few utils. In this case, totally fine. I will leave it up to you, especially if you have multiple dimensions. And now the last thing that we need is the actual dimension. Well, sort of how, how it generates. And we're going to have this inside of our data folder. So data m scores. And then we'll have a new directory called Diamond. And then we'll have another directory which is going to be cooled. Die mention underscore type. Very important. Now, the first thing here is going to be a new file, KJ db.json. Once again, very important that the adjacent follows. And I'm going to copy over a few things, which yeah, I'm gonna copy over and then we're going to quickly look at this. So first of all, we have a type. This is simply our MC, so our melody. And then the name that we have specified right here, Oh, Stella path right here has to be the same there. And then we have the generator. And the generator is really the thing that is very crazy. So in this case, what we're going to do here is simply a flat land basically with the at the, at height, one will have bedrock and then from height one to 60 will have sandstone. That's it. All going to be planes, uh, no structures, no features, nothing, right? If you want your own dimension and you want something fancy, I will have a resource in there which is going to be at the, once again at the Minecraft fandom.com, which has the custom dimension, sort of as a JSON files there and has the entire syntax highlighted. It's incredibly useful. And if you really want more control and we want to really specify what's happening there. Then you can take a look at that. For this lecture, we're going to leave it at this. We're going to make a new dimension. The way you construct it. That once again, you got to take a look at that on your own time, but I'm sure that you will be able to do this. I have all the, I have complete confidence you dimension type. We need one more thing and that is going to be a new file, once again, also named KJ db.json. And I'm going to quickly copy this over as well. And this is just some basic variables or parameters that the world here basically has. And like the time. If bets work, those sort of things. Once again, here with the name of very important that this is the MOD ID and you were specified name. And that is it. Of course, all everything that we've done, both the new JSON files as well as the classes are available as a resource as always. And now, let's take a look if this has actually worked, if our hard work has paid off. So let's start this client and let's see if we can get into our new dimension by right-clicking a hopper or it's kinda funny, but that's to be expected. All right. Let's see. Let's actually, let's they owe, all right. And now I'm very much interested in whether or not we have done everything right now it looks kinda find we actually of course need to create a new world for this. So let's just create a new world here in creative mode. And then let's create a new world. The first thing that's going to happen is you're going to get this sort of world using experiment settings are not supported. Now this is because we have a new dimension. And Minecraft is like, are you sure you want to do this? Now? We are sure. So we can proceed. While you're testing this, you're probably going to have to deal with this arrow when you create a new world. And I believe also when you load into a world, that's just how it's going to be. You can click Proceed and everything is going to work out fine. If you're modest, every Demotic, There is a map that says, that's like no experimental world generation error or warning. That's definitely something that you should include in a mock back if you want, if you were to use your modern amorphic. But yeah, that's, that's basically it. And let's see, let's get the copper or block. This is going to be very interesting. So we're going to set this down. And now The, Are you ready, cat? Are you ready? Right-click. All. And here we are. And there we are. A flat world with a bunch of sandstone, just like we've done in. And then if we take a look at this, so if we press F3, then you can actually see right here MC course KJ dim. So this is our dimension. This is planes like we have basically put in as a JSON file. And yeah, that's basically it. And now we would right-click this one. We're actually going to be held up, teleported back exactly where this blocket. So we can basically teleport from one other and will also always get the nice sound effect. Yeah, that's, that's basically like I, I think overall, the dimension is easier than I would've anticipated if I'm absolutely honest, because there was a lot of things surrounding it. But overall, right now I actually think that it's fairly straightforward. I hope that this was of use to you and you learn something new. But yeah, once again, everything is available as a resource as well as the link to both the GitHub of the light dimension, which is absolutely amazing, the daylight dimension. And as well as the linked the Minecraft fandom for the custom dimensions so that you can basically customize your JSON files however you would like. Yeah, I hope that this was useful to, like I said, if there are any questions, of course, always feel free to ask and I'll be sure to respond. And yeah. 79. (Minecraft) Creating a Big Chest Tile Entity: All right, welcome back the microwave course. And in this lecture we're going to add a new big chess. Now, I will warn you that this lecture, without a doubt is going to be 40 all over the place a bit more rapidly. And you might not understand everything that is happening. Now. That is because the adding a new chest is actually I wouldn't say necessarily hard, but it's very involved because there's a lot, a lot, a lot of different components that we basically need to get. We need to get them right in order for everything to work. And then one of things, sadly, that is going to be the lid opening and closing. That does not work. Now, I am actually not sure why I've rechecked and recheck everything. And I I just can't get it to work. If there is anyone out there who after watching this, knows why. I am very happy to add an addendum to either this lecture or as a next lecture to basically say, okay, this is how we can fix that. But for right now, we will only, only in quotation marks have a chest that we can open and that will display a GUI, and that is going to be the following week. I have actually prepared this already. It is this one. So it is a bigger chest. And yeah, let's, let's just see what we can see and how we can build this a bigger chest. So first of all, of course, what we're going to need is we're going to need a new Thailand T. And there's going to be the fertile entities. You're a new class called the big chest tight. I love it. Now this is going to inherit or it's going to extend the following extends chest tile entity. And it's going to implement the following two interfaces. Ihs, lid and the, IT, the identical pilot. And we can actually check the chest tile entities. So if we middle mouse button click on this, then we will actually get into this. And now the real fun thing starts. We can basically take everything in here and just copy it over. We're going to change up a few things, but most of it is going to stay exactly the same. So this is what you're gonna do. You're gonna go down to the chest tile entity to line 277, what your cursor there. And then you're going to go up and basically go all the way up here, press the Shift key and press the left mouse button, and then press Control C. Go in here, control V, and everything is in here. This is beautiful. Now, we will have a number of arrows here, which we're going to fix. Don't worry about it. This is all going to be fixed along the way. The first thing, of course, is the name of the actual, the name of the actual constructor is wrong. So we can simply copy this one and put it in both of these here. And then this is something that we need to change a little bit, waist down the line. Apart from that, the only thing that we want to change is the number of items that are stored. This is going to be 66. Now I know this because once again, if I reopen our chest UI, we can actually see that we have 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11. In a row and 123456 rows. Therefore, that gives us 66 items that this test can store this picture. And that is basically this. And then like I said, we're going to also, this size inventory is also going to be 66. So this is, I don't know why we need this in two places. It's apparently how the actual chest is built and overall, and this is almost fine. Now is the thing that is probably going to be a little bit weird is because usually when we have chests next to each other, the chests combined to a into a new chest. Now we actually don't want this year, but this is actually fine because this is going to be well, basically, you know, it's not going to happen anyway. So anywhere we have, for example, your chest container, we need to, after we've done our big chess container and our big chest screen, we actually need to change this up, but right now we can actually just keep it like it is. This is actually fine. Almost basically copying over everything from the trusted entity. Then next thing will be 1 inside of our screens and then know, and inside of our container, we want a container first of all, as going to be the new class container, the ego, the big stress container. This shouldn't be too crazy. This shouldn't be anything that is out of the ordinary is simply extends the container class. Container. This is not the right container. And the container we want is the net Minecraft inventory container. Very important. Can happen at anytime. Can sometimes also happen with happiness with a block which is really stupid, but a go. Okay, let's move the can, can interact with, we're just going to actually return the following. We're going to return, we actually need a, okay? First of all, we will need the following. We will need a private final int, which is going to be num pals. And we're going to be needed if private final int, number of roles. We also need a private, private tile entity, tile entity, courts tile entity, and a private eye item handler, which is the player inventory layer in. That's fine. We're gonna, yeah, let's actually just constructor parameters so we'll make sure that everything here is selected and we'll say, okay, and then we will actually have to change the constructor a little bit. We also need an int id, a world, world, and a block OS, OS. And then I want this the other way around. So I first want the tail entity and then the layer inventory and then the number of columns and rows. Yes. And then lock pass is just written wrong. There you go. And then we have it. Okay, So this is fine. This is actually o file. What we want is the other Actually can't do yet. Well, we can do however is we can set the tile entity already by getting world that gets island at the given position here. And that the player inventory. Interestingly enough, we actually don't want an item handler in here. What we actually want is the actual player inventory, because that's the way we get it. And to convert it, we actually want a new inventory wrapper with the layer inventory. Like I said, some of those things are kinda crazy. But yeah. And then what I'm going to do is, um, yes. So basically we're then going to check, okay, if is there even a tile entity there. So if talent is unequal to null, then we're going to talented t dot get capabilities. We've seen the capabilities and this is the velocity of the item handler. And if that is present, then what we're gonna do is we're going to do the following. We're going to say handler. And then we're going to actually make two new methods. Because if we take a look at a family, going back to the big title and we're going to middle mouse button click to the unadjust container. Then first of all, we're going to see is there are, there are a lot of static like cravings. And then also the trust container constructor has the following. This constructs the slots of the chest. Now this is like, I mean, it's a little hard critiquing other people's code, but that is like, I don't know what the hell is happening here. Same with this and same with this. Now what this does is simply this creates the chest inventory, and this creates the inventory of the player. And then this last thing creates the slots for the bar, the, the inventory bar. I don't know why. This isn't neatly packed into a few private methods because that's exactly what we're going to do, is we're going to have to private methods. We're just going to be the private void, generate chest inventory slots with the item handler, item handler, old handler. And then we're going to have it basically exactly the same thing. That's the funny thing. Like we can take this, right? And we can copy it control C and put it into our container here, right here. And we only need to change a very, very, very few things. I'm not a 100 percent sure that that's fine. And then this is going to be the number of calls. And then instead of making a new slot, we're gonna make a new slot item handler. And then here we simply put in the handle. And that's basically it. Now we need to do a few things here. And that is mainly the index is actually k plus j times this.com calls. And then the position, this position is actually correct and this position is not correct. This is going to be 14. Now, I will explain how I get to this position in a little while. We mean ligand 0, 1, Let's actually keep this currently like it is. And then we're going to explain how I get the actual position that we need. And then we can have a new private void, which is going to be the generate later, invent inventory slots. This is going to have an item handler called handler and a layer inventory. Layer inventory. And then. Do the same thing like we've done before. You can just simply take this and copy this over and put it right here. And then we need to do a few things. The first thing is we need to have the int I equals this dot num rows minus 4 times 18. We first want to subtract the 4 here and then do this. Now this is basically the idea is that we have the last four rows or the inventory. I've taken this from Exactly right here. Like I said, this is absolutely all over the place. I would say that it probably could use some refactoring. But it is going to find, so this is going to now have the player inventory instead of the handler inside of here. Because the player, the player inventory we're given here. Please. Because why actually, why not? I guess not. You go I guess I guess I was mistaken. No. We actually don't need that. We don't need either of those. So much for that one. And then we're going to keep the positions here as well. And the positions are going to be half to change as well. However, like I said, we're gonna take a look at that in a little while. So then let's just call this with the handler and then let's generate layer inventory slots. And that's fine. And yeah, then after we've done this, which is the slots that gets generated at, what is the issue here? Yes, we need to insert super that is totally fine. The rest, Interestingly enough, we can simply take so we don't know, We actually, we do not want the this. We don't want this. We want the transfer and slot, however, you want the container closed. And we also want the number of rows we don't really need. We do however, need the chest inventory. So let's take this so we can basically copy everything else and put it in. And we can then also get rid of this. And then we need the inventory, which is going to be the following. This is the, this is going to be the tile entity later down the line. So this is going to be basically the big chest tile, this tile entity. They go. So there's the inventory, I would actually say, or we can rename this to get chest inventory because get lower inventory. I don't know why that's the name, but yeah. Okay. I get chest sorry, this look good. Chest inventory. We can actually know. It's easier to just say, once again, to say tile entity. Yes, talented t, sorry, there you go. Tile entity dot cast and then it's going to cast this to entity, sorry, big chain and big chest tight. They go. And then we're gonna closer the inventory. That's all we need here. When it comes to the minimum, we can also get rid of this comment. And then the transferrin slot, that's fine. This handles the shift clicking. That's totally fine. That sum, we can basically just keep this year except for this one. It needs to be done with this dot num calls. And then this one is this.name calls. Yes. And then this is what? This.name because the number of columns in this case. More than nine. So it's not hard coded in there. Can interact with is the last thing that we need to basically do. And that is going to be the following. This is going to be a big chest title, this.title entity. And then we will surround both of this width with some parentheses. Sorry, I'm the ego. And then we say dot is usable by player. Player. I believe that that would be it for the container, the only thing that we need to add is the superhero. But we cannot yet at this because we have yet not yet defined at the hour mark container inside of our mouth containers. But we can do this right now. Can we do this right now? Yes, We actually can't. We should be able to do this. So we can say public static final. Actually, you know what, let's copy this over. Let's be honest. It's easier to copy this over. This is going to be the big chest container of type, big chest container with the name big chest container. And then we'll go on to create a new big schist container with a window IDA world, a position in inventory. And then instead of the interatrial, the player, we're going to say a six, 11. This is, sorry. Yes, We have one more thing. Interesting. What do we have? We have the tile entity. We don't need the tile entity. That's ridiculous. A legal number of okay. None of this. Six, right? Number of columns is 11 and number of rows. Yes, I hope so. We're going to see because there was some weirdness with the columns and rows. I'm not a 100 percent sure. We're going to keep it like this. Yeah. I think that's fine. Yeah. And then this already will work fine. So that's pretty nice. The container is done. And then we can also go back into the chest right here. And then we have the chest container. Now we can actually just basically select this, copy it and then press Control R. And then everywhere with that, it's just container. We can simply say big chest container and then replace all. Now first of all, we're going to get an arrow, but this is simply because the big chess container for Italy is not like it's not there. Excuse me. Please. Have I written this wrong? I have I have I missed types. Tom and I have not mistyped something. So I'm not a 100 percent sure why he has an issue with okay. For whatever reason that's true. I mean okay. I guess the replacing did not quite work, but they go. So you can simply everywhere if there's weather stress container, you simply replace that with big container. Yeah. Forever reason he didn't didn't quite work. Interesting. Well, okay. Sure. Yeah. Apart from that, we're going to worry about that in a little while. So the chest container has been well-fed. Down here. Yeah, down here. We actually also need to change something then that is, as you can see, the generic is being pulled here and that's not what we want. What we want is we want to return the MOD containers, docker, container, that gets done. And then with the ID and the player a, Oh, that's nice. Don't actually need this swap, the contents method. We also do not need the good players using that. We can also lead this. And now, lo and behold, we actually already have a well error-free tile entity class. Now this is not going to work yet, but that you are now inside, back inside of our big chest container, we call the super. And this is going to be the MOT MOT containers, docker, container, NOT gate with an id. The ego. That's it. That is everything for the container ended the Thailand T. Now we will need to change these positions here later down the line and after we have implemented the screen as well. Well, basically the sweet, yeah, that's it. Okay, Then let's do the screen. And that is going to be the big chest screen. Big chests screen instead of your big chest screen is going to extend. And this is going to be a container screen. To enter screen with type, big, big chest container. Love it. This is going to have methods implemented, this one and then was implemented the constructor, yes, of course. And there's a few things that we need to do. And the things that we need to do first and foremost is because we have a, so I'm going to open the electrified briefers. So this was the GUI. This is the normal size of a GUI that we're used to in Minecraft. And this is the size of the GUI in the big chess. Obviously this is bigger. Therefore, if we take a look at the container screen, if we middle mouse button, click on this. You can actually see that the size here is, is the predefined inside of the containers. So if we have something that is bigger, we actually just specify it here. So we have this dot x size is equal to 212. This dot y size is equal to 221 because those are the pixels that the, the GUI is big, right? So the big test is 212 pixels in the x-direction and 221 pixels in the y-direction. And then we can also add this already so we can go into text birds GUI and add to this right here. Make sure to copy it in there, not just move it. And then this is something that we can also put in as a resource, private, final resource location for GUI, new resource location. Mc course Math.min DID, as we are very well aware of. And then this is inside of textures slash chest and we dot PNG. What a beautiful, What a beautiful thing. Okay, that's fine. And the right, That's, that's okay for now. Then we need the render method. And this, of course, we can look back into our electrophile screen and we can basically take a few things out of this one. So for example, the random method is exactly the same. So we could, for example, just copy this over. Totally fine, because this is almost always the same thing, the random method. And in this case we only need the container Mac round background here. And what we want to do is basically also. Copy the insights of this electrophile screen as well. Sometimes it's easier, we don't need this actually, we only want one blip. And this split here is simply, well basically the GUI itself. And that's actually it. Like that's all we need. We will need to define something else here as well. But we're not gonna do that yet because I want to actually show you why we need to change up if you other things. And basically how to figure out how to change those up. Now, we might think, Well, I mean, that's great, we're done. And I must tell you that we are sadly not done yet because we will actually need a a renderer ourselves. So we need to, number one, make a new tile entity renderer. And we also need to make a new items tactile entity rendering. This is why I said that we're going to be sort of all over the place, but no worries, we will get through this. So tile entity, let's add a new class. This is going to be the big chest title entity and render our ego. This is going to be going to be a generic class which extends tile entity, end I, chest, lid. And then also this class extends the child's chest tile entity renderer. As you can see, really nice. Create a constructor. That's going to be actually what we can do is middle mouse button on this one. And then once again, get at the very top here and go at the very bottom, Control C. And go back here and basically just paste it in. And we will only have a few more things in there. And that is only because the name of the constructor is wrong again. And then we will actually not have any errors. Now we will need to change, I believe only one of the thing if I'm not mistaken. And that is just quickly check because this is, like I said, this is craziness here. I actually don't think that we need to change anything. And at the moment, right here. Yeah. I don't think we need to change anything at the moment. Let's just keep it like this. And if there's an error, then we're going to check this. Yeah, because we are exactly because we actually have the 0. We don't have a block yet. That's why we need to make a block which gets the extra stress block extended. So that's the next thing that we're going to do. So this is the renderer. And then we will need a block, which is going to be a big chest block. The chest, please, they will. And the big chest blog block, not blog, is going to extend abstract schist, schist block. And this is going to be of type chest, big chest, tile. Nice implement method, a new entity? Yes, easily enough. And this is going to be the Mode tile entities. We have actually not done the tile entities. So I'm if I'm not mistaken sorry, not the electrophile. The multiple entities. Yes. There we go. We have not yet done this, like I said, a little bit all over the place because there are so many things. I can only implore you to download the files and probably take a look at them. You know, instead of V, Well, we programmed priming this, but I mean, maybe, maybe it's, maybe it's fun exercise. Lets actually copy this over again because sometimes that is easier. This is going to be a big chest, big chest tile. And this is going to be the big underscore chest underscore title underscore entity. And this is going to be the underscore underscore underscore entity. And this is going to be a new big chest tile with a new block. We have not yet defined that in our map blocks. Unbelievable. So this is going to be the Mode tile entities. The chest tiny entity gets V8. Yes. Very good. And it's a little more blocks we can simply add for the copper or let's just do a public actually have to recheck this because I'm not a 100 percent Ciara. We do this. This was the big chess. Yes. Worse public static final registry. Registry, object of type luck, of course, big chest. The big just, I like it. And now next thing, register, let's just do it like this. Let's just copy the register here. Big underscore test. And then we're going to have a big chest block here, big chance block. And this of course, has one more thing. Yes, Awesome. We're going to have this fine. Let's get rid of this. And I'm also going to have the MOD tile entities, sorry, tiny entities. Pick chest talented p dot, get the expected 0 arguments but found to, well, this is probably because what we don't have a constructor here yet. Well, that's yeah, I will defend myself all day long. It's a very complicated thing. So let's make a believe that we should be able to create a constructor yes, the IPO. And then this constructor, it will also immediately fix this error. Very nice. And we will need to change this register method in a little while because otherwise we will not have the item rendered. But let's not worry about that right now. As you can see, we already have a, an insane amount of different places open. So next thing that we need to do is the block. Actually, we can go into the abstract blocked by middle mouse clicking and then press Control H. We can see the higher hierarchy. Now we can also see the, see the test book. If we double-click on the stress block, we will open it. And this is another one of those where basically just going to take everything inside of here. We're going to copy it and yeah, anything that we need, we're going to change up. So anything that we need to change, we're going to change and everything we don't, we will not. Well, let's copy this over. So Control C Once again, and then control V right here. We're also going to take our string methods that we have predefined, including the instructor constructor. And we're going to move this up after this one right here. Then we can delete the constructor of the chest block. And then we have ys methods, a doublet, but we've already defined one of those. We don't need this creative, talented t, Where are we? Get that one. Out of that. We also can basically get rid of a few of those things. You're yes, that's fine. That's fine. That's fine. So the fill its container, that's actually one of the most important things. The impound, comparator, impulse, input overwrite. We can just delete that for now because we don't necessarily need the same with this one, then the same container. So this is the GET container. We will actually also just delete the combine method. We have twice, I believe right now. This is why this happens. The chest inventory, we can also delete the OpenStack. We can delete this as well. The broad unblock activated, this is the right-click method. We're going to take a look at that in a little while. But there's a few things that we can basically get rid of on Replaced. We can get rid of on lays by I think this is actually something that we do need. I know we don't we don't need that direction to attach to we don't need that because we don't want this to attach in this case. And this is also by we get placement one. It's going to look a little bit different. We're actually just going to have and everything after this. We're going to delete, I believe. Yes, this one. So basically everything after the fluid state. Oops, what did I do now, I opened the block. Everything after the fluid state here we can delete so that the good state for placement only has the return of the default state with the different things here. So that the chest type always stays single. Direction too attached. Also get rid of this shape? No, Actually, sorry, that's not we'd actually don't want to get rid of this because we want to get shaped to be able to have a proper shape displayed. Update post placement leave is something that we also don't need, but I'm not a 100 percent sure. We don't need this. Well, they go get renderer type. I gotta be honest. I believe that this is the reason why they didn't old. But I'm not sure. I actually don't think that it is, but yeah, like I said, it's a little, it's a little crazy. A merger type. We actually also don't need this. And then the only last thing that one is the combined method, which is going to be the following thing. And I'm not actually a 100 percent sure where we get this from. Get this from here, I believe. So. Combine, the combine method is exactly this. So this actually needs to be copied again. We're going to copy this again. And then we had this null here. And we actually will take this because otherwise there's going to be an arrow. And like I've already said, this is a little, well wouldn't say quite cheating. I would just say that it is a lot. This will definitely need to be cleaned up a little bit. And creating it like this is it. It definitely is all over the place. Like I gotta be honest. I'm a little bit I wouldn't say quite embarrassed about it, but the way that the chest block is made is like absolute madness. I think that it could be probably made a little bit easier. But anyway, let's quickly see, so the container major, we don't need this as well as the inventory merger. We also don't need this. And now I believe we're finally here. We can where we can actually get rid of everything inside of her unblock octet activated. Because the way we're gonna do this is once again, the way we have done this. If we close this and this, like we've done this in the electrophile. No, not the molar flux, but the electrophile. So if we go down here inside of this one, and we can copy the entire inside of the list. And then we can also do this and this. And then we can save this would be, for example, screen MC, worse, maybe big chest. And then instead of the electrophile container we are, we'll say big chest container. And then instead of the layer entity, we're gonna say six and 11, know 116, right? Yes. I hope so. I'm I'm never a 100 percent sure here, but I think that that's right. Right. Okay. Now, let's think about this. I believe that we have almost done it, and I know that, but we're not quite done yet. So let's think about this. We have the testing here, this is fine. We need to specify the this in here. So mod Blog.config chest. Okay, that's good, That's good. This is now done. Yes, 100%, this is done. We don't need the tile entity render anymore. We have done this already. This is fine. And I actually think that we are fine with this. We can close it as well. That's pretty good. That's that's a major things that we have done. I'm not sure that we are done with this. No, we are not. This chest tile entities in here. And I don't think that we want those actually inside of this one. We do want them. How many do we have? We only have six. That's okay. That is allowed. Sticks is the right amount. And okay. Okay. Okay. Let let me just quickly look at this. So we have, let's reopen the screen for a moment. All right, now we need to add the models. Block an item. Yes. As well as the block states. Now it looks States is actually really easy. So the block states new file. This is going to be big. Chest, the chest dot-dot-dot JSON. If I'd done this in the blocks, sorry, someone has, someone has been no big chunk this underscore chest. Let's actually do it. She Sure. Why not? Let's keep it like that. That's fine. Refactor Rename big underscore chess. And this is going to be the following. And this is going to be really interesting. Model block and slash chess. That's not quite right. This is going to be big, just the ego. Now this I have taken from the JSON files from microphones again. So down here, instead of extra, then we can go to Assets, Minecraft, blocks, dates, and so on and so forth. And we can basically search for this. So if we just simply type in chest, then a little ways down we can see test, and it's exactly this. So this is also how Microsoft EMC worse. Well. Now it's a little weird. They ego. And a modals. Modals is, sorry, I'm halfway done this in the model. I am. This is a lot, this is a lot like I said, this of course doesn't go into the models block. This goes into the black States. Sorry. Yes, we can actually copy this over. Yes, please. Okay. Now a block instead of the models and block, we want the following. We want a little bit, like I said, is that's a little more, this is a little more than you're probably used to. This is a little more, this is simply going to be the easiest thing. This is simply going to be textures, particles, Minecraft, block o. Thanks. So when we to destroy the block, we want the particles to be 0 planks. Easy enough. And now the item model is going to completely knock your socks off. Because that's way Chris, did I do this with an underscore? You said it. This going to be file underscore chest dot-dot-dot Jason. And I'm going to copy this over once again, this is, this is built in entity. Now this is once again from the models down here. So you can recheck this. So this is exactly the same thing. And to use this, we actually need our own items stack renderer, like I said, that's that's always a very nice. And, and this is going to be, I'm going to create this instead of the items here. However, I believe that this, you know, like later down the line, this should probably be somewhere else, especially if you have multiple ones of those big chest item, stack, title, entity, renderer. I'm just going to say it, you asked for this. Now, but to be honest, this actually isn't that difficult to understand. So this is an extensive title, that item, stack, tile entity renderer, they go. And if we go into this, this only actually has one method here of this would actually be called the render method. However, whatever reason or it's not mapped yet. And we're just going to copy the actual method signature here. And then we're going to add a, another curly bracket. And then the only thing that we need to call inside of here is the title. And to your render dispatcher, that instance, that render item, Sorry, render node, it is render item actually render item. And then with the new big chest tile, then the matrix snack. We want the buffer, we wanted the combined light, and we want to combine overlay and, and that's it. That's all we need to do here. Let's just for the hell of it, add the override as well. Because mine and yeah, that's that's actually all we need to do. We hear, we of course need to hold this and the where we need to call this inside of our model blogs. And what blocks. I don't know why I'm calling it my blogs as if we're, we're, we're blogging away. We're not actually. So mod blogs, blocks. Yes. Aha, Yeah, exactly. This is because the register method is not going to work because we actually need to add a new item property. And we've done there is something similar here, but we actually want a new one right here. That's going to be register tile. And T. And then after the course tab, we're going to call the set Easter. This is the, this is exactly the items tactile entity renderer. And then we're going to say have a splitter of big chest item stacked other than her colon, colon new. And then this one going to be cold here instead of the register method. Yes. Now, we're almost done. We have to recheck everything, but I am actually thinking that we're almost done. Of course, we add something, something, something that somebody positioning. This is going to happen. But apart from that, I believe that we should start this and don't get it. We won't get any earth. Let's try this. I'm not sure because like I said, this is insanity. But I think that this might work. Let's see. Oh, I think that there was already an arrow in there. No mobile we're we're loading. So that's kinda nice. We're loading. We're even having a loading screen. Okay. So main menu, that's pretty nice. Let's go into our world. Yes, we will. I know what I'm doing. This is once again, the experimental work settings because of our custom dimension. Okay, we find ourselves in the world. Now let's see. If we have a chest. And it actually looks like a chest. If we place it down, it does not look like a chess, but that's okay because I actually know how to fix this. This is because we have not added this. If I right-click, nothing happens. Okay, that's, that's, that's the thing that we're okay. Let's see. What is the issue our container providers missing? Well, that's not okay. That's that's not good. Oh, have we not called super? We have called the super. Well, oh, this is the happening. And this happens if exactly, well, if our talent t is not an instance of electrophile, is it? Know it, of course it wouldn't be. It is of type. Big chest, tight. There you go. So this is the issue here. And then we will also immediately because I remember this, fix the oh, I actually gotten any something else anyway. And that is going to be the following inside of our client. Rocks. Right here, we need to add the following. Screen Manager, screen manager, register factory mod containers. Not just container don't get. This is the big chest container. New. Beautiful. This doesn't work because he doesn't like I'm actually not a 100 per cent sure. White is. Why weight that I do Container Instances screen. Well, well that would be the reason why screen, screen, screen, No, no, no, no, no, That's sweet. Now also, of course, important this class are you, Are you mad? And then we need to. Also have the entity you render, and this is going to lay in the registry dot bind tile entity renderer Mode, tile entities, not big chest tile entity dot gets and big chest tile entity renderer, colon, colon num. This and this also needs to be added to the client Proxy. This one will simply ensure that the screen is shown. So when, once we right-click and this one will ensure that the block is actually rendered inside of the world. That's pretty nice. And I think that this should now work. Like I said, once again, it's a little, this is a little looser of an episode, I would say, of a lecture. Because we're wouldn't say discovering it simultaneously because that would have been like a, I don't know, seven hours like a seven hour lecture. Probably even more. But they go, So let's get back into our world and let's see if the, if this works now. So the first thing that we're gonna do is we're going to actually destroy it the block before because sometimes this boy, this, because sometimes it gets a little weird. Okay, So it doesn't it still doesn't render. I'm sure that there's a reason for this, but if we right-click, so it does open and I mean, that's pretty cool already. That's pretty nice. But as an excuse me. Cat, would you please? Wait, where's my block? There is. There is. Okay, So it works, but as you can see, the alignment here is not quite correct. And this is exactly what I was saying with the offset that we need to do. So this is something that we need to do inside of our container. We need to offset this. And I believe this was for it. This is four pixels that we need to move this up. And this we actually need to move an entire row or an entire field to the right. And the way I figured out these numbers is the following way. So usually The the the containers are well, yes, inside of the container, the slots generate right here. And then if we were to move to this one, as you can see, the containers slots generate a little bit more to the right. And you can basically calculate this with a, with a Photoshop or GIMP or painted dotnet. For example, some programs in which you can open that. Let me just quickly go to the container, big chest container. And then the actual this is just a container that you go. And then what you need to do, this is exposition. This is story. This one is 26. And the position one or three is actually correct. Fascinating is, and then this one is 26, right? Okay, So those work. And then the y position of this is 14 Because we have we needed to move up four more. Last thing, I believe the container is done and now at least it should be. Why do we, why we're doing this? The next thing inside of our screen, we have seen that the text was displayed wrong. We can fix this in silver screen. So this is the 1s one last time screen. And I'm quickly going to copy this over. So if I middle mouse button on dictator can actually see that we have an int title and the title inventory x, y. And those were set to this. Usually. Now I have set those two. Actually is almost the same x and its two up, I believe. And this is almost the same. Yeah, it takes the size this size and then moves it down by word. I guess moves it up by 98 pixels, right? I believe that that's fine. This is the positioning. So this is the positioning of the text that's displayed inside of screen. And now I am not quite sure why the block itself is not loading properly or not displaying properly because I was of the opinion that I had everything in here, but I guess I did not. So let me just quickly think about the soul. We have implemented the big test render here. And I know why. I know we would also get a big, big, big arrow and that is inside of our big chest entity or tile. I'll entity type, very important MOD title entities dot big chest tile into T.gov. Okay, now we have done almost inside of our chest tight. Let's search for chest. Let's search for test. Now, we have just type this is okay, just block. We