Transcripts
1. Introduction to my Minecraft Modding Class: Hello, I'm Nico company
or a master's student for computer science and
an avid Minecraft player. You might know me
from my YouTube channel tutorials by Cotton joe, where I'm making Minecraft
modeling tutorials. But now we're going
to go even bigger. This is the microwave
modeling 118, one class with fabric. Here you will learn everything
you need to know to make an awesome and
amazing Minecraft MOD, even absolute
beginners can start by going through the provider
Java introduction, which is really going to help you learn some of
the fundamentals. Then we'll learn some of the simple concepts such
as how to add an item, block, recipes, and
even tools to my craft. After that, we will continue by looking at custom block models, custom crops, and so many other cool and
interesting features. In the end, we will even tackle
some advanced topics such as block entities and
world generation. So what are you waiting for? Sign up for this class now, and who knows, maybe your model is going to
be the next great hit. I will see you in
the first lesson.
2. (Java) Installation & Download: Welcome to the fabric 118 course and here to the
Java introduction. So we're basically starting off with a little bit of
a Java introduction. Either if you haven't
used Java at all, this is going to be very, very useful to you. Otherwise, if you
already have worked with another programming language
or with Java itself, then this is a very
smart idea to have this as a good refresher
here in the beginning. So I highly recommend going through the entire
Java introduction. There's gonna be some assignments
along the way as well, which you can do to
further basically solidify the concepts that
we are going to be discussing in this
introduction here. And there's going to be a few prerequisites that
we're going to need. The first one is
going to be a JDK. Jdk is a Java Development Kit, and they come in different
flavors, so to speak. But what we're going to use is the one from adopt him here, and we're going to
need to use 16. So JDK 16 in this case, this is called tamarin 16. And I have linked this in the resources basically
that you can download this. This makes sure that you select your operating system
and your architecture. So for me, this would be Windows
and 64 bit architecture. I highly recommend
downloading the MSI here because that's
basically just installer, which then installs the JDK onto your machine like basically
any other program, really. Well, just install that normally like you would
any other program, and then we can proceed. Once you've installed the JDK, we will also need an IDE. And IDE is an integrated
development environment, which in our case we're going
to be using IntelliJ idea. This is, I found absolutely a great tool
to be using for this, we can use the community
version which is free and built on open source, which is pretty much
includes everything that we would could
ever want or need. So definitely make sure that you choose the community
version here. Once again, also just download the EXE if you're on Windows, and like you've maybe seen here, you can also Trick check here
if you're on Mac or Linux, basically switch over and
install them as well. And also just install this like you would any other
program as well. And then once that is installed started and then we can proceed. When you open intelligence
for the first time, a window similar to this
will appear for you as well. Now it's gonna look a
little bit different, but it will have
these three buttons, The New Project button with the Open button and the
get from VCS button. Upon clicking the
New Project button, you can see a new
window will appear. What's important is
we want to select the new project right here. Here we can just name
it whatever we want. So for example,
Java introduction, you can choose a location
right here using the language Java Build
System intelligence and the JDK being 16 for our purposes here for
the Java introduction, the sample code has to
be checked by them. With this done, we can click the Create button and then
a new window will appear. Now firstly, what we
actually have to do in the newer versions
for intelligence, they changed some stuff. I'm unsure why that is the case, because they actually
do tend to change a lot of stuff which
is kind of annoying. But our main class right here, so you can see this main, if I double-click on
this, it will open. You might have opened
for you already. That's fine as well. Now, in going forward, it's actually going to
be in some packages. So we actually have to
do this manually for our case here in this case,
but that's gonna be fine. But we just right-click the
source folder so you can see source right-click
new package. And then we're gonna,
I'm gonna call this net. And then on this
net I'm going to right-click new packet and
I'm going to call this help. And Joe, now you just gonna call it whatever your name is. Basically you're going to have net and then your
name, for example, I'm going to drag the
main class into it, say Refactor, and then
we're gonna be fine. Then you have this
package up here as well. This is very important because there's an upcoming lectures. We're going to
have this as well. Now if this displays
differently to you, it might be the case that it actually looks
kind of like this. I'm going to show you
just for a second that it sort of compacts here, net dot count Joe,
all in one line. If that is the case, you can
go to this gear right here. To tree appearance, height,
MT, middle packages, you can de-select that and also flattened packages
also deselected. And then you're going to
have exactly the same thing as we have right there as well. Now we're going to
continue with Pascal and Joe for the rest
of the lectures. So in this case, what we're going to have is the, we're gonna have
something called main here and another main here. And then this is
a common where it says write your code here. Now we're not going
to write code in this first In lecture right here. We're going to start basically immediately in the next lecture. This is really just the setup. So overall, this is pretty
much all that we need to do. All of the code is
always going to be available in each lecture. So in each lecture
you're going to find a resource link
or you're going to find this basically linked somewhere where you can have either the
GitHub repository. So all of this is going to be saved in a GitHub repository. And each lecture is going
to be a individual, basically an individual
branch there. Or you also have individual jurists where
each of the different, each of the code,
everything of the code of this lecture is also
linked there as well. So no worries there. Everything can be accessed before you can even take a look at this
because of course, some people, they
would rather have the code in front of them and then change it a little bit. Some people just
want to code it, like while I'm coding it.
And that's totally fine. Both approaches are absolutely basically valid in this case. But for the time being, this is basically it. So all of the code
will be available and hopefully you've
made it to this point. And then see if once the
next lecture starts, you can see whether or not
everything has worked there. But that would beat for
this lecture right here. And I'll see you in
the next lecture. So, yeah.
3. (Java) Datatypes: Welcome back to the
Java introduction for a Minecraft modeling. And in this lecture, we're going to be
talking about datatypes. So we're starting
very, very slow. The idea is that in programming, we can save things in variables. Now, what those
things are, right? There's different types of data. And basically in this
lecture we're going to go through what types
of data they are, basically meaning the datatypes. So there are a few
different types of data types like
even going further. And the first one would
be the numerical types, basically how to save numbers. There's a bunch of
different datatypes here. So there's an integer, there's a float and the double. So those are the ones
that are mainly used. I'm going to talk
about those in a bit. So you can see first of all, when you create sort
of a new variable, which is, you can
think of that as a container that contains
a certain value. And the type of value is determined by, in
this case here, the first word, you
can see that it's actually even marked in orange. That is not always
going to be the case. This is only going
to be the case with primitive data types. But what those are
we're going to see in a little bit in a later
lecture basically. And you can see that
this is called a number. This is the name of the variable and then the value is 42. Now, an integer, like I said, is a particular
type of datatype, a numerical data type, which is a whole number. So this can only save
whole numbers or integers. And the actual range
that it can save, it goes from negative 2 billion to plus 2
billion as you can see. So this is basically the
numbers that you can save that can be
stored in one integer. That's the idea. And
then there's float, or when you need a comma. Now, what's very
interesting with floats and doubles that are
almost the same thing, not quite, but almost
the same thing. They're both floating
point numbers. And the idea is that this is actually not stored like this, is actually stored like
scientific notation. You might have seen
this before somewhere. And this is something like 1.412 times ten to the
four would then be 14,120. And basically in
this notation here, the floating point
numbers are stored. And what's important with
a float when using those, they have seven decimal
point precision, meaning that you can
have seven numbers. It doesn't matter whether or not they're left or right
of the decimal point, but seven numbers and then
they're going to be precise, and after that it's
going to get rounded. This is also why usually you
don't want to save very, very, very precise
things in floats. So for example, if you have like ten thousands or a 100 thousands of a Bitcoin,
something like that. That should definitely
not be saved in a float because that could be very
easily get rounding error. So those are floating-point
rounding errors. Those are very common. Now a double is a little
bit better in that it has 15 decimal point precision. However, still they might be, it might still lead to
some rounding issues. So that is something
to be aware of. Usually in most
cases, for example, in our case, this
really doesn't matter. So if you have a float, usually that can
represent, for example, you have certain block
positions in the world written this something
between those block positions because of course a block
is not like a single point in space as like a little
bit of a gradient there. And then there's a little bit of a rounding thing that's
going to be totally fine. And that's also probably one
of the reasons why if you go like millions of
millions of blocks in one direction at some point, the world gets really
messed up because floating point errors
and stuff like that. So that is probably also
one of the reasons. Now there are some
other numerical types which are not used as often, at least personally, I've
not seen it as often. A lot of people might say, Well, I mean that's
not quite right. Of course, you need
to be aware of these, but usually I have not seen
those used as often anymore. To a byte is eight bits
and it can store numbers from negative 128 to 127. So this, I'd call this a
tiny number because it can basically only store a
certain amount of values. Basically here in this case, a short is a small
number which can store between negative
32000 and plus 32000. And then on the other hand is a long which as you can see, can store it from
negative nine quadrillion to like positive quadrillion
nine quadrillion, which is Bree, that's
that's pretty staggering. That's a lot of like
that's a very big number, usually, very rarely used. Like I said, from
what I can tell, an integer is the most common
number for a whole number. And then floats or
doubles are used for, well, basically decimal numbers or something like that, right? The next data type of bracket are going
to be the Booleans. This is sort of the logic. So what you can think
about is, well, we have a boolean, a boolean and either
be true or false. So it can either be one or 0. This can be represented
in one bit because a bit, if you know or not know, can either be 0 or one, That's the only two possible
values that it can take. So this is pretty much the same. It can either be true or false. So are these great videos, will I do hope so. So that's true. And it's this HTML. Well, that is,
hopefully you didn't think that because
that's false actually. So that's sort of
the Boolean stuff. And the logic is actually incredibly powerful like
the entire logic field. Because of course, the entirety of all of our computers and operating systems and
all of that is all based on binary code. And in theory, booleans are nothing but binary code, right? Because a true is a one
and a force is a 0. So sort of the same laws
apply in that sense. You can think of it as
that, but overall Booleans, likewise with integers,
we're going to take a look at those in a little bit
more detail in the future. But I definitely wanted to
introduce you to those. In the third and last
sort of big bracket here, our characters and
strings to a character, as you can see, score a char. And this is a single character, so this is marked
with these single, single quotation marks here. And this can store
a single character and special characters
regulate commerce. So I can put a comma
in here, that's fine. I can put a dash in
here, like a hashtag, the plus symbol star,
that's all fine. Oh, well, I can even put
in a space and it works. However, what I
can't do is I can put two characters in here, then it's not going to work
because two characters or multiple characters next to each other is called a string. To a string, like I said, is basically just a
sequence of characters. And this is marked with a
normal quotation marks. So double quotation mark here and double quotation mark here. And as you have probably seen, the end of every line
always has the semi-colons. Those are also very
important here. And that's sort of the idea. So you have characters
which are singular, singular characters and an, a, a string of characters
is a string. So that's sort of the idea here. And then at the very end, I wanted to mention something
that we're going to definitely see in
the future as well, which is null, the null keyword. So you can see that
this string test is equal to the value of null. Now what's very important
is that null is not 0. It's literally empty,
like it has no value. Though. This is sometimes
in the beginning, especially a little
hard to really get across the distinction between
what I don't understand, no value. What does that mean? Well, it just has no value
is undefined, so to speak. It is non-existent. Write this test like while
it sort of is defined here, it's not, it doesn't
have a value, it's null. And we're definitely going
to look at that and see that in a later lecture as well. So no worries there if that is a little bit
confusing, no worries. The rest should be at least fairly understandable in
the sense that, okay, we have some buckets, we
can think about that, some containers in which
we can save some values. And depending on what
type of value they are, we have to write different
things in front. So that's sort of
the general idea I wanted to get across
here are the data types. Otherwise, I hope that this was useful to you and you learn something new and I'll see
you in the next lecture. So, yeah.
4. (Java) Java Syntax: All right, welcome back to the Java introduction for
Minecraft Martin. And in this lecture
we're going to take a look at how to read code. Or I'm also going to call
this maybe Java syntax. So the idea is first of all, and this might, some of you might have already
been like wait a second. It's been ignoring
all of this up here. What is this? First of all, we're
going to calm down as we're going to have
to start building up some more fundamentals before we talk about everything
that happens up here. For the time being, what I recommend is you
just ignore this. The only thing that
we really care about is that this early bracket here. And then if I actually
put my cursor there, you can see that this one
lights up everything. First of all, right, now has to happen between
these two curly brackets. That's all that we're
going to care about. We don't care what this means. We don't care what this is, what all of those public, static, void, main, string, all of that, no worries at all. We're going to figure
all of this out in the future lectures that are
to come for the time being. We're going to figure this
basically inside here. That's our main prerogative
at the moment, though, first of all, code is
read from top to bottom. And that's interesting. Well, yes. So this is also why we
have these lines here, which is very
useful, can be very, very useful in
determining arrows. We can say, Hey, you
have an issue there in line 18. You look at it online. 18, There it is. Okay. Fair enough. That's very useful. And usually there are, of course, exceptions
to the rule. But in general, you read
from top to bottom. Now if you have a
two slashes here, then you have a
single line comment. And if you have this slash, star and star slash, and you can have
multi-line comments. So that's also something
to be aware of. And The, There's a few different things that you can do when you
have a variable, right? So we're back to variables. And we've seen those
of course, right? Different datatypes. And variable was sort of like a bucket or a
container in which we could store a value of a certain type and we
have to specify this. So when you declare a variable, then declaring a variable
means that you declare the data type of that variable and the name of the variable. And note once again that all
lines end with a semicolon. This is normal. So every line, every instruction
ends with a semicolon. This is by the way, also very interesting because I
could in theory, right? Another one. So in x and
I could just do this. Well, this doesn't
quite work because we're all using this day 0. So y, for example, I could do this as well. This also works because this
is a single instruction, so it doesn't necessarily
have to be every single line. And basically doing this also would work even though
there is a two lines. And by the way, this is
like a horrendous thing. This is like formatting
that is of the devil. Don't ever do
something like that. But whatever the case may be. So it doesn't necessarily
be lines always, but it's in single instructions.
That's sort of idea. And you will usually saying that every line has to end with a semicolon is a good start. Basically that's a good start. It doesn't always be the case, but it is usually the case. Now, this is declaring a
variable and then we can also assign a variable
a certain value. And this is what
we're doing here. We've already declared this. So if I now exists somewhere
in the ether of the program, let's say, and now we
say I is equal to 30. So we have now assigned a
value to this variable, okay? Now we can do both
at the same time, declaring and assigning a value, which is then index equals 10. And this would be called
initialization or initializing this
variable in this case. And that's very interesting. Usually people don't throw these terms around necessarily. It's just something to be
aware of a little bit. Okay, I've declared
this variable, now I've initialized it here, I've assigned this variable, so it's just something sort
of the terms here should be, at least store it in
the back of your mind. That's the most
important bit here. And then there's a possibility of accessing
variables or methods. We have talked about
methods yet of certain variables or objects. We also don't quite know
what objects are yet, but we're going to figure that
out in the future as well. But for example, if
we have a string, we can actually get the
length of the string. So how many characters
are in that string by doing dot and then
something after it. So if I put this in, you can actually see
that enormous amount of stuff is thrown at
me as a suggestion, knowers at wall, we're
going to look at those things in a
future lecture as well. For the time being,
we just know that the dot operator also makes us able to access certain variables or methods
of a, another variable. That's sort of what we should
store for the time being. And then the actual
application of this we're gonna see in a later
lecture to a far, far, for greater extent and
in way more detail than this. But for the time being, this is sort of the general gist on how to read code here. Like I said, this is of
course not exhaustive. This is not everything, but those are sort
of the main things I wanted to get across
for the time being. So you have the idea of declaring a variable,
assigning a variable, and then doing both at
the same time and then accessing something
with the dot operator. And most importantly, that this year school should
be ignored and all this should be ignored and
everything just in between those curly brackets
should really be paid attention to
for the time being. But like I said, we're going
to venture out of this, these curly brackets avenged, but that will be it for
this lecture right here. I hope you found this useful
and you learn something new. And I'll see you in the
next lecture. So, yeah.
5. (Java) Output & Input: All right, welcome back to the Java introduction here
for microwave modeling. And in this lecture, we're going to be
taking a look at outputting things and
inputting things. So this is both
outputting something to the console as well as reading something
in from the user. So we're basically storing to supercharge our ability
to actually do something. And the first thing that we're going to do is
we're just going to output Hello world because
this is something that every programmer learns
at the very first time. And this is what we're gonna do. So we're going to
type in a system. And you can see that some things are actually being
suggested for us. We're just going to
write it this out system with a capital S, very important out, all lowercase and then
print line, print LN. And then we're going to make
a first open parenthesis. The closing parentheses should
generate automatically. And then we can just go here
and put in a semicolon. Now this is Oregon. We're going to be fine here. However, we now want
to put something into the parentheses and that
is going to be output. Now we have to make
this a string. Therefore, we're
going to type in the basically
quotation marks here. And then the second
quotation marks should generate
automatically as well. And then we can type
in hello world. So as simple as that. And now to actually
start this program, we go up here, ensure
that this is all fine. This should look pretty
much exactly the same. And we're just going to
click this Run button. And then after a few moments,
you have helloworld. If this was the first time
you have ever run a program where you have first
literary starting to program in this moment. And this is the first
time you've run this. And everything here says hello world and this says process
finished with exit code 0. Congratulations. I'm not even
being like I'm not being, I don't want to be
patronizing here because this is actually a step that every
programmer goes through. At some point, they're
going to write a Hello World program and they're going to
be like wait a second, I can make things
display that I1. So I could, for example,
say hello students. And you're going to be like, way that can't be the case. I can just do that. Yes,
I can just run this. If I actually run this
properly, There you go. Let's run this Hello students. And now it says Hello
students, no worries at all. So as you can see, this
is actually really, really freaking cool and this is going to be supercharged even more because now let's say we
have an integer variable x, which is equal to 10. Well, why don't we just output this once again system and
I can start writing this. And you can see that
this is sort of like has sort of a selected rate is sort of highlighted,
so to speak. And when I press the tab key,
it actually auto-completes. So I can write
this very quickly. So you can see out
as also already, basically is a
suggested here and then dot print line as well. And I can just put the
x in and look at this. Everything works and
sometimes goes very quickly. So you can look at
this like this, well that's so much
for that, right? So system out print line, you can see how fast
that sometimes works. No worries though, I'm
going to try to make this, especially in the
beginning here, a little bit slower so that everyone can be
basically keep up. And well, we can just
put in the x here, so the variable inside
of these parentheses and then the value is being output. That's really cool, isn't it? Where you have the ability to actually output something
that's in a variable. And now we're going
to go even crazier. So once again,
System.out, print line. Once we can just auto
completing it with the Tab key. And now I can say something like outputting some value.
And now look at this. I can go beyond
the string, right? Make a plus x. No errors whatsoever. Everything looks fine. What
is going to happen now? Well, look at this now. Outputting some value and then the value of the variable is
going to be output there. So that is pretty frequent, sick if I do say so myself. That's actually really cool. Another question comes in, well, how can we read something
in from the user? Now this is a little
bit more complicated. Usually, this is
something, you know, it's sort of a, I would say, semi
limitation of Java. It's kind of a bummer
that it is complicated, but no worries to what we're going to
write is the following. We're going to write
scanner and then just space everything when something turns red here, no
worries at all. We're going to keep calm.
Everything is fine. Then scanner in
small equals a new. And then once again
scanner in with a big S with a capitalist inside
of the parentheses. So we're going to make
parenthesis System.in. And I'm ending this
with a semicolon. Now both the scanner here and the scanner here
should be ready. That is totally fine. What do you have
to do is you have to click on this and press Alt and Enter to
import this up here. So like I said, usually we
want to ignore all of this, but we can make one
little peak up here. So you can see import
Java util scanner that this is basically imported. So that's no worries at all. You can, if this is important
while you're writing this, because when you
press the Tab key, when you write
scanner, this might be important automatically,
no worries at all. Just making sure that
this is the correct, well, phrase, so to speak here. And that this is
written like this. We're not going to worry
about what this means. What are we doing here? None of that, we're just
going to know, okay, we need this in order
to read something in. So then we're gonna say
system out, print line, type in your username,
something like this. And then what we're gonna
say, we're gonna make a new string variable
called input. And we're going to make
this equal to scanner. That. Next. There you go. Okay, So next, as you can see, has to be
written like this. So we have to put in next and then open and
closing parenthesis. And then that's fine. So this is now going to save
whatever we're going to type in to the console in
this variable here, and then we can do
something with it. For example, we're just going to immediately outputted again. So system out print line, your username is, and then
we're just going to say input. So just for the, we're
testing this basically. So let's store this. And what we should
see is a lot of students tend
outputting some value. And you can see
that first of all, the program doesn't end automatically because it's
waiting for our input. So let's just say this. Well, my username
is count Andrew. I'm going to press
Enter and then you can see your username is. So that is a pretty cool like
when you think about it. And this really
also starts where you can just play around
with this a little bit. You know, you have some
intractability with the PC. You can now actually
talk to the PC, so to speak, which is
really freaking cool. So this is one of
the first step. I very much a, basically would just advise you to try out a bunch
of stuff here, just typing some stuff in, typing some stuff out. It actually can be really fun, but we're of course
going to use this in future lectures and the
coming assignments as well, where we basically are
going to read stuff in evaluated and then do things depending on
what the input is. So that's all pretty cool. But this, for now, is it for this
lecture right here. I hope you found this useful
and you learn something new. And I will see you
in the next lecture. So, yeah.
6. (Java) Errors & How to Deal with them: All right, welcome back to the Java introduction here
for Minecraft modeling. And in this lecture, we're going to be looking
at some errors and how you can ask for help when
you get these errors. So first of all, we're
basically starting with some pre-done code
again right here. But no worries. This is of course, all
available to you in the GitHub repository or as
an individual just as well. And this is very interesting. So first of all,
we're basically can uncomment some lines
to find some errors. The first error we're
going to have is the java cannot
find symbol error. And that basically, how are
you going to see this is hey, something is red
inside of the code. For example, I'm just
going to uncomment this and you're gonna
see that a2 31, basically a variable
we're trying to access or reference is
not actually existing. So this is going to be red. Now, this might be something
that you haven't noticed. So red is also going to
be like underlined here and in the main class
appear and you're going to have a problem symbol
and a problem there. So there's gonna be
a lot of signs here, but you might actually
just not notice this, which is totally fine. So if you then still
run your program, what you're going to be
greeted with is this. So the first thing to say
is when you get an error, don't worry at all. Honestly, getting an error
in the beginning might seem very daunting and you
might be getting nervous. Let's say, Don't
be nervous at all. Getting errors is
actually something that is sort of expected when you're programming to have
something work the first time around
actually gets you very suspicious because it's very rare that when you're working on some code that it works at
the first time running it. So please, first of all, always remained calm
when you get an error. There's nothing like this. No shame in that whatsoever. You haven't done anything wrong and you will always
be able to fix it. So this arrow, in this case, it says, like I said, java cannot find symbol. It actually says to us what the variable here is and
where it is located. And if you take a look
at the very top here, you can actually see this 1128. And that actually means
this is at line 28, at character or other
line 11, character 2008. So this is actually
really freaking cool. So we can immediately find where this arrow is
and can say, Okay, I've made a typo there or I forgot to make a variable,
something like that. This would be this
arrow right here. The second thing that you might
run into at some point is exception in thread main, Java, Lang,
NullPointerException. So this means that
something is null, meaning that it
doesn't have a value. For example, we have a
string variable right here. And we set the value to null, which I already told you about is means that it
doesn't have value. It doesn't pretty much exist. Now if we were to now try
to call the length on this, this of course doesn't
make any sense because the length of nothing is also nothing like you can't call a length on something
that doesn't exist, meaning we're going to get
a NullPointerException. So this looks kinda like this. And this would be
called the stack trace. So a stack trace in like
layman's terms, just in general. So you know, what it is about is basically what code has been
called up until this point, until the error has occurred. And you can see
that this happened at cotton domain
main and then 16. So we can actually click on
this and it will give us the exact line and sometimes even the exact piece of code
where this has happened. So this is the
NullPointerException. This is something that happens routinely even with
advanced developers, that sometimes you forget
to initialize something. Sometimes you just call
something in the wrong order, you forget to call a method that is something that
happens all too often. Once again, nothing
to worry about, but that is the null exception. You can usually fix this by properly assigning
a variable. And then the last
thing that's not really like an exception, but we've seen
this here as well. So this is this process
finished with exit code one, or sometimes it might
also say finished with non-zero exit value one,
something like this. Or it could also be
something different than 1, 13042, whatever. So it could be some
number that is not 0. That's the most important thing. That means that
there is an error. You should never post only this. If you only post, hey, I got an arrow and you
post-process finished with exit codes 0 or finished
with non-zero exit value. Everyone knows that
you don't know Java. Now that's not an
issue of course, because you have to
start somewhere. But this just if someone
wants to help you, right? So for example,
if you were to go into the Q and a
and you're like, Hey, my you know, I have an arrow
and it says this. If you post this, first of all, I'm going to know
that you probably haven't watched this
Java introduction, which is of course finds
your own decision. However, what I also will
notice that this is not, this doesn't give me
any value at all. This just tells me there has
been an error. That's it. That's all that this says. If the exit value is not 0, then that's just means there
was an error somewhere. I don't know what the error
is. I don't know what the exception was. I
don't know anything. Meaning that I will
actually have to ask again. It can just be a
little bit frustrating because then you
have to ask again, Hey, can you show
me the error log is there are some output there. Just put the arrow
in there as well. Usually when you have an error, It's better to give too much information
rather than too little. So that's usually the case.
It's not always the case. Like don't just drop like
80 different files on someone that wants to help you or in the Q&A,
something like that. But usually you should have
something like this, right? An exception and error, some type of log something which says a particular thing
like this exception. You might have an exception somewhere, something like that. So that should be like the thing you
want to look out for. That's just something that
I wanted to give you, which can be very important. Rubber that is already it. So this is sort of the, just a general overview
of those errors. And of course, don't hesitate
to ask if there are arrows. If you get arrows along the way and ask for help,
that's totally fine. I just wanted to
mention, especially this year because it
can be frustrating, not only sometimes for
me because of course, then have to ask a
follow-up question. And then depending on
how long that's going to work and maybe you
just look for that. And another answer didn't
come in like 20 minutes, so you have to go do something else and then
it takes a long time. So that can be sometimes
a little bit frustrating. Well, whatever the case may be, this is it for this
lecture right here. I hope you found this useful
and you learn something new. And I'll see you in the
next lecture though. Yeah.
7. (Java) Integers, Arithmetic & Math Methods: Or I will come back to the Java introduction here for the Minecraft modern cores. And in this lecture, we're going to be
looking at integers. We're going to be
looking at math, and we're going to be looking
at arithmetic operators. Now those are all
very big words. However, I am sure
that we will manage. The first thing that we're
gonna do is we're going to initialize two integers. This is going to be int x
equals 100 and int y equals 20. So up until this point, everything should
be fairly clear. Overall, this is just, these are two
variables, x and y. They have the value
120 respectively. They are both integers. So we started with
the board int. So that should be
fairly straightforward. And we will also have an
integer called a result. Now we're going to
actually just declare this variable without actually
assigning any value to it, because we're gonna be using
that in the following ways. The first thing
that we're going to take a look at is addition. So those are basically
arithmetic operators, addition, subtraction,
multiplication, division, and then
there's a fifth type, which we are going
to be taking a look at in just a moment. So the result here of addition is of course
going to be x plus y. So that shouldn't be too crazy. We're just going
to in x in here. And this operator,
x in from the left. A, an integer could
also be a float. So that also would work. So both of those, both of these, if X and Y, when both the
floats would also totally work. Now this, of course
then the result would also have to be
afloat. Very important. Think about that.
We're gonna see one example in a future
lecture of that as well. Like if you start to mix those, but that should be
fairly sensible. We simply put in
the plus symbol and then basically we're
going to add x plus y. So let's do system out, print line and then print the result just so
that we're going to see, well, this should be a 120. Let's see. And of
course it is a 120. Everything working
perfectly fine. We can of course, also
use a subtraction, right? And what I'm going to do
is I'm actually going to let all of this right? So I'm just going
to drag my mouse over here and then press control C to copy all of
this for my mouse here, control V to paste it in. I usually do something like
this just so that, you know, it's a little bit easier
because this is of course very much
duplicate in this case. Now for subtraction, you
probably guessed it. We just have to put a
minus sign in here. And then all of a sudden
we're subtracting y from x, meaning that this should be 80. And of course it is
AD totally fine. And let's actually copy off
of these like completely. I'm once again going
to select this control C and then Control V right here. And then we're also
going to take a look at multiplication and of course, the vision as well. So multiplication is going
to be a star right here. And then division
is just a slash. So this should be
fairly sensible, nothing to be too crazy. Overall. Those are just the
normal ways that you basically would well
calculate stuff. So that's pretty much it. Let's just go through C 2005. That is actually all fine. And now the question
becomes, well, what is the fifth type? Or the fifth type is
actually the remainder. So this is also sometimes
called the modulo operator. That's in like actual
mathematical terms. But for us, it's the
remainder operator and that looks like
a percentage sign. So for example, we could
say 20 remainder two, which would of course be 0. So if we're just going
to copy this once again, Control C, control V, This is going to be 0 because
when we divide 20 by two, then there is no remainder left. So this is a very good way
actually of taking a look at whether or not a particular
number is even or odd. So that's actually pretty cool. And those are the five
arithmetic operators. A fairly straightforward
all things considered. How often are they use? Well, I mean,
you're going to use some math inside of the
entire programming thing. Whether or not be in modeling or in
programming in general, there is some math associated
with it, of course. So these things are definitely important
to have seen before. And then the last thing
we're going to look at here is going to
be the math methods. Now, first of all, we're not going to worry
about too much trouble. Well, it's a method.
Well, you can think of that as a particular function. So for example, Let's
make a call this math. So you can see if
I type in math, you can see Java Lang and
get that suggests it. And then if I put
in a dot, I have, I get suggested a whole bunch
of things that I can call. And there are
things, for example, like the max method right
here, where absolute, right. So I can call max here
and I can say x, y. And then it's going to return me the maximum value
of each of these, which of course in this case
it's going to be a 100. But we should see
at the very end here at a 100 pop-out they ago. So actually fairly
straightforward. And then let's just
actually duplicate this for the sake of arguments or
Control D to duplicate that. And let's get the absolute
value of, for example, let's say minus 500,
which would be 500. So In Math, like a mathematics, it is written like this. So maybe you've seen something
like that before with these like absolute
lines, so to speak. And that then turns into
500 because we don't really care about the sign
that is in front of it. So we're going to
see as 500 as well. And as I've said, there are
a bunch more stuff in here, like as you can see, this seal. So you can basically
round up, round down. You can get the cosine, you get some exponents. So you can put something to
the power of e logarithm 10. There's some crazy
stuff in here, rounding random Even,
even at random, there's even like
constants like e and pi. So there's a bunch
of stuff in here. Usually, It's very rarely
that you need to use. A lot of them are especially
something like the max and the Min method and
the absolute method sometimes are actually
quite useful. And it's good to have
seen this before, this so that you don't like
when you run into this, when you may be looking at
some GitHub repositories of other modes or just cold in
general from other people. And they use
something like this, then you're not completely
caught off-guard, right? But that would be it for
this lecture right here. I hope you found this useful
and you learn something new. And I'll see you in
the next lecture. So, yeah.
8. (Java) Assignment Operators: All right, welcome back to the Java introduction here
for Minecraft modeling. And in this lecture
we're going to be looking at assignment operators. Now we've seen the normal
assignment operator, which is the equal symbol. And there's actually a very
interesting thing for this, because this is actually sort
of a sided operator, right? So we're going to assign the right value that
the left variable. So we couldn't just
type in something like, for example, 30 equals y. That doesn't work, right? We actually have to have it in a particular order in that case. Now that well, is that
going to be the lecture? Is that it? No, of course not. There are some specific, very interesting
assignment operators that, well, you know, you require the arithmetic operators
to sort of understand. But what we can do is
of course we can say x, for example, equals
x plus y, right? So we're just adding
y to x in this case. And then writing that back into the variable x,
that totally works. That's not going to be an
arrow, that's totally fine. However, we could also write this in a little
bit of a nicer way, and that is going to
be x plus equals y. So that also works right here. And that's actually
really cool thing. So this is where
this is amazing. Oh, this is very much
like easier than this. And usually it's also a little
bit easier to understand. Now if this does actually confuse you more than
this, that's totally fine. You will, however, have to take a look at the
assignment operators, especially if, for example, if you take a look at
other people's code, they just might use
only these and not this long way of writing it so that you have to
be aware of that. So even though you
might not be using some tools that we're
talking about here, is all of this are basically
tools, rights to program. You still have to
know about them to read code that other
people might, right? So let's actually
just print out the, the variable x here, and then let's just go through
the rest as well, right? So we're going to select this, copy it and then let's just, you know, just paste
it in like five times. So what can, of course
do a minuss equals. We can also of course
do times equals. We can also of course do like
Ned, like divide equals. And then at the end we can
even do remainder equals. And that I've never seen
before like that is really something that is
probably a very, very specific like moment
where this is, has to be cold. But let's just see
if this works. Of course it does work
totally fine to start with a 140 because we've
added 20 here, right? So we're starting here with 120. An adequate again is a 140, and then subtracting it
is a 120 and then times 20 is 2400 and then divided
by 20 is 100120 again, and then dividing or
remaining it is of course 0 because we can divide a
120 by Wendy perfectly, which would of course
be takes exactly. That's very good,
Very well done. So if I however, now just wanted to
add one to it, right? So maybe I just want to
do something like this. X equals x plus 1, right? But just want to add it by one. This would be
called incrementing or an increment x by one. Well, I mean, of course we could just write this as well, right? We can just do this. Yeah, of course, that would
also work totally fine. But there's even an easier
way that we can do this. And that will be x plus plus. Look at this. This is pretty crazy. So we go from here to here, but that's actually
how crazy that can be. And let's just print this out. And then of course, you know, x minus minus, of
course also works. That would be decrementing it. So this is, let's just
keep it for a bit here. Platelets, so increment,
incrementing, and then also this
would be decrementing. So basically we're just adding one or we're subtracting one. Let's just take a look. We start at 0 right here. Adding one, adding two is two or adding another
one, right is 23. And then we're
printing it out and then decrementing it, and
then we're back at 2. So that's sort of the
general idea here. Those are the assignment
operators and then also incrementing and
decrementing Europe, which is kind of
important as well. But those two are going
to be seeing a lot, especially these X plus
plus and x minus minus. Those are things that
are definitely used very often in
certain capacities, let's say inside of the code. But that would already be
for this lecture right here. I hope you found this useful
and he learned to the New. And I will see you
in the next lecture. So, yeah.
9. (Java) Booleans & Comparison Operators: All right, welcome back to the Java introduction here
for Minecraft modeling. And in this lecture, we're going to be looking at a Booleans and
comparison operators. Last time we looked at integers, and now we're going to move
on and look at Booleans. So the Booleans in general, we can remember this
from the second lecture, are basically a
datatype that can either save a true or a false. So for example, we're going
to make a new boolean here. For example, likes the lectures, lectures major that
is written correctly, and this is of course
true, Let's hope so. And let's also make a boolean, which is, for example,
asked question. And let's just make this
false for the time being, maybe that turns true later, but for the time
being, that is false. So we remember
Booleans, like I said, a true or false, 1 or 0, that is the idea. And we can even print
this out, right? For example, we
can say you have, or you like these lectures. Let's say you like
these lectures. Who likes these lectures? And then I can press Control
D to duplicate this. And for example, you can say, you have asked a
question in the Q&A. So I could, for
example, say this. And then instead of
like the lectures, I can say ask questions. If I were to do this, then
what we're going to see is just true and false, basically just like a string outputting,
they're totally fine. Okay, so that's the sort of
idea of Booleans, right? True or false, Fair enough. But now what are
comparison operators? Well, let's think about this
comparison operators, right? Well, there's a few of them. And the idea of comparison
operators that of course, well we're going to compare two different values
to each other. And that is going to return
a Boolean because of course, if we compare something, for example, we could
say bigger than right? So we have something that's
bigger than something else, then of course, it's either going to be
true or false, right? If I'm going to say, hey, I have an apple that's like
the size of a baseball. Like okay, fair enough. And then I have an apple as
a sizable like a football. Well, obviously the size
of a football is bigger, so there's going to be
like a true under this. There's also a bigger or equal. There's also equals,
there's not equals. They're smaller than and
smaller or equal to. So those are the
comparison operators. We're not going to look at every one of them individually. And we're going to take
a look at a little bit. So the actual example we're going to be looking
at is, for example, you have a score at, or maybe you made
an exam, right? You wrote an exam and
your score is 98. Well, thank you very much. That is a very good
score and it's actually actually your score
day, you go in. Then you can say, well, we could write in a Boolean that is called
past class, right? And you pass this
class when exactly. We can think about this. Well, of course you need
at least 50 points. Let's just say for the
sake of argument here, you need 50 points
to pass this class. Well, it's very easy. You can just say
your score has to be bigger or equal, 50. Does that make sense? So that should make
intuitive sense. All things considered is it this would be
true in our case, of course, but if
your score changes, then the answer here
changes, right? Because as soon as
this is no longer leg, if it's 49, you no longer
pass the class, right? So that should be thought
of fairly self-explanatory. So we can even just
print this out. So just system out, print line, let's
say for example, you asked, let's just put this in so and then
pass class, right? So we're gonna get
a true if it's true and a false if it's not. And we can even say
something like with your score plus points,
something like that. We can say this.
And if I now run that and see you pass
true with 98 points. If I were to put this to 49, which of course, in this
case now is no longer true. So no 49 is no longer
bigger or equal than 50. Well, this now will return a false. You will
see, there you go. You passed false with 49 points. Let's keep this as 1998 DOE. And let's think
about this as well. So let's took another idea here. So we can also have a boolean, for example, has
perfect score, right? And this could be
then be equal to your score is equal to a 100. This is the equals operator. Very important that those
are two equal signs. And that's something
that sometimes people get confused
on knowers at all. One equal sign is the
assignment operator where we're assigning a
value to a variable. And two equals signs is the comparison operator where
we're comparing whether or not this value of this variable here is equal to the
value of this one. And that's very important. And here of course,
this is false. As of course 98,
not equal to a 100. That should also be fairly
straightforward overall. And we can even do something like this
that's very interesting. We can even negate something. So this is basically this the declamation
mark here, though. We can also say
something like, hey, we pass the class here, and then we can make
another Boolean that's called failed class, failed us. And this can be equal to, well, not pass class, right? So we just negate whether
or not we pass the class. And of course that,
that makes sense. So if this is a
little confusing, you're write it out, like actually write
a writer text. If failed class is true, has class is false, of course. So those always need to be
opposite of each other. So we can always
just negate this. This could also be an idea. So negating year is of course, negating basically meaning the two put the exclamation
mark in front, means that true turns to false. And then if it is false,
it turns to true. It returns true then right? That's sort of the idea. Comparison operators. You can also think of this. They return a
comparison operators. You can think of it like this. When we had a plus rating, we took in an
integer on the left, plus integer on the right
and return an integer. Again, it makes absolute
intuitive sense. You don't even think
about it when you're, when you're working on mathematics
and calculating stuff. When you do 5 plus
5, like of course it's going to return it
to 10, which is a number. Well, the comparison operator
is pretty much the same. You just put in, for example here an integer and an integer, and you return a Boolean. That's all there is to it. But the only thing
that really changes is the return type, so to speak. Thinking about this
and that's it, something to keep in mind here. And that would be the
comparison operators. I highly recommend just playing around a little bit with this. It shouldn't be too crazy. It really is just comparing two different values
to each other. And that is then
expressed as a Boolean, which should actually make
sense is that there are only is ever a one right answer
in this case, right? Either the score is
bigger or equal to 150 or not, implies that. But whatever the case may be, this is it for this
lecture right here. I hope you've found this useful and learned
something new. And I'll see you in
the next lecture. So, yeah.
10. (Java) Booleans & Logical Operators: All right, welcome back to the Java introduction here
for microwave modeling. And in this lecture
we're going to be looking at a logical operators. So I have prepared a few
Booleans right here, watch lectures, asked question, finished assignments
and engaged review. Those are of course related to a course like
scenario, let's say. And we're now going
to take a look at the logical operators. And there are three of them, basically which we're
going to take a look at. There's the end, there's
the OR and the not. So we've seen previously
where we were able to negate something and the AND, and the OR are also
very interesting. So the logical operators take in two Booleans and give
you a new boolean. So for example, for the
end of the Booleans, you have to give it,
have to be true, and then it returns true. Otherwise it returns false. And for the, or either
one of them has to be true and then it returns a true. So this only returns false
if both of them are false. So for example, you could
think of it like this. So Boolean finished
course, right? So if you want to
finish the course, you have to have
watched the lectures and finished the assignments. That should make
sense. That sort of a good concrete example here. And then you could also
say, well, a fan, right? So, so let's say
it's fan, right? So someone who is a fan
would finish the course. So finished cores
and Eva review, that also should
make sense overall. And now someone who
might be learning, like maybe learning a lot, they watched the lectures
or they asked the question. So this is something someone
who's learning, right? Either watching the
lectures or ask a question. So either of them could be true and then learning
would be true as well. Let's sort of a
general idea here. And there's one more
thing that I have and that is going to be
this right here. So this is just a
general overview of what basically happens. You can also download
this as a cheat sheet. This is available
in the resources. And the idea here
is that it just shows you what the
different types of outcome, that's basically what
the results are. So you have a and B. And then depending
on what they are, this is the return
that is given, like I said, both
of them have to be true for the answers
to return a true. And here, if either
of them is true, then this returns a true. Otherwise it's false. You can also think of it,
write a or B towards sort of, it's sort of really
baked into the language when you think about the
negation, like I said, we've already talked
about that is sort of the general adjust when it comes to the logical operators. There is, of course
a little bit more there as well over that, is this really a good
beginning for this? And then of course, the real thing that
you can think about is that when you have one of
those which returns a Boolean, you can of course, then
chain those together. So you can then also say, for example, end ask
question, right? So you can see that because this of course
returns a Boolean, we can now use the
AND operator again. So this pretty much works very similar to like the
arithmetic operators were. Of course you can also
plus, plus, plus. You can have 5 plus 8
plus 7 plus 9 plus 15. That works totally fine. In a similar way, you can chain the
logical operators together as well, right? But that would be it for
this lecture right here. I hope you found this useful
and you learn something new and I'll see you
in the next lecture. So, yeah.
11. (Java) If and Else Statements: All right, welcome back to the Java introduction
for Minecraft modeling. And in this lecture, we're going to be looking at
the if and else statements. Now in this lecture, basically we're going
to start really having some interaction
with the computer. A lot of the previous lectures
were very theoretical, is sort of showing
some concepts. But in this lecture, we're going to be really well interacting
with the computer. Let's just start by
making two integers. Exam 1, Let's say for
example 65 and exam 2, which is going to be
51 for the time being. And we could imagine that let's say we have
to write a program that evaluates those
values of those two exams. And basically says, Hey, you have failed or past exam 1, you have failed or past exam 2. And then at the end, maybe when people have passed both exams, maybe something is printed out Like you have passed the
class or something like that. So how can we do this? Well, what we can do is we
can make an if statement. And for that we literally just
like right if, right here. And then we can
do the following. We can put in a parentheses. And if you put it in
an open parenthesis, the closing parentheses should
automatically generate. And inside of those
parentheses we have to put in a Boolean value. So we remember back to the previous two lectures where we had
comparison operators. So what we can say
is that, well, if exam 1 is bigger
or equal than 50, then we know that
we've passed the exam. And then we put hidden here is after the closing
parentheses, we put in a curly bracket. And if I put the open curly
bracket in and I press Enter, the closing curly bracket should automatically
generated for you. And now what we can do is we
can write something else. So we can say system
out, print line. And then for example, you
have a past exam one. Though, this all of the code between these two curly brackets here is going to happen
when whatever is inside of the if statements. So inside of these
parentheses, true. So if this is true, then this is going to happen. So that's pretty cool actually. And then we can sort of
supercharge this by adding an else here at the end and also putting in
a curly bracket. And once again, we put the open curly
bracket in any press Enter a closing curly bracket should automatically
generate here. And then for example,
we can just select this control C control
V to paste it in. And then we can say you
have failed Exam 1. So this year, right
from the else actually happens
when this is false. That actually works
out very well for us. So we can basically
use this to, well, take a look at
whether or not Exam 1 was passed or failed. So let's actually
run this and we should get a U past exam one. And of course we
are getting this, as in this case, exam 1 is bigger than, bigger or equal than 50. So this is being called. So that's pretty cool. Now we can basically do exactly the same thing
for the second exam. So let's just copy all of this selected Control
C, Control V. And then here we're
going to say Exam 2. Here we're going to say Exam 2, and here we're also
going to say Exam 2. That's actually pretty cool. All things considered. And then the question
becomes in, well, I mean now we want
to outputted when you have actually
passed both exams. So how can we do this? Well, now we're
getting pretty crazy. So the last two
lectures will seem a little more coherent,
so to speak. We're gonna say exam 2. Exam 1 is bigger or
equal to 50, right? So that's still passing
this End Exam 2. So, right, this exam 2 right
here is bigger or equal 50. And then if this, if both of these are true, then we know you've passed
the class so we can copy the system out here and then we can just say
you have passed, let's say the class just for
the sake of argument here. So that is really
freaking cool, right? We have now if statements
and if else statements, and what you can
also do by the way, when you have an else
statement that you can put another if statement
on here, right? So you can just put
this one in there. Basically if this is false, then else and then put another if statement is where
you're going to basically, just for the sake of argument, just say true here. Of course this would also
work, but, you know, and then we can say
else and basically chain those together so you
can make if else, if else, if else, and the last one is always going
to be else or you can also just not have an else here as well.
That also works. I wanted to mention
that as well. But now the really
cool thing is, well, let's think about this. Let's say this is
actually a program where the professor comes in and actually writes in
the results of your exam. Oh what? Well, we remember
how can we read something in we have
to write in scanner, scanner, scanner
equals new scanner. And then system.out.print. And then this sort of
just works for us. We remember that we don't want to worry about too
much what this means. Then we can say something like
system out print line and say results or exam one. Right? And then let's
just duplicate this. Make results for an exam 2. And then we can just say that
Exam 1 is actually equal to scanner dot next int
right here, right? So we're going to read
in an integer and then save it in the
exam one variable. And the same thing we're
gonna do for to go. Now what's going to
happen is really cool. And we start this and
now it's actually expecting us to put in an exam. Well sadly, 32, actually
not 320 but 32. Well, and then the
results for exam two, they were actually
very much better. There were 68, sadly, just a little bit, not
quite enough for 69. And then you can see you failed
exam 1 and past exam too. So now we're really starting
to go into a sort of part of this java
introduction where you are able to really do
something with the computer. And you're really
going to see this in the first assignment as well for the next lecture is going to be a sort of a alternate
version of the if statement, which can also be
very important. And then the first assignment, I highly recommend doing the assignments here for
the Java introduction, especially when you're
just a beginner because they can be
really, really useful. And with this, of course, the core is available in a
repository or a just as well. But take a look at
those in the resources. And I highly recommend playing around with
this a little bit, just reading some numbers
in comparing them, doing some if statements, just making a whole bunch
of cool stuff like this, you can already pretty much
make a really cool game. So, but for the time being, this would be it for
this lecture right here. I hope you found this useful and you learn some of the new. And I'll see you in
the next lecture. So, yeah.
12. (Java) Switch Statement: Or I will come back to the Java introduction here
for Minecraft modeling. And in this very short lecture, we're going to be looking
at the switch statement. The switch statement
is sort of like the little cousin to the
if statement, so to speak. So it is very similar. Let's just take a look. So we're going to
make an integer called a metal placement, which is for the time
being just one in. You could imagine this one
representing the placement in, for example, the
Olympic Games, right? So one would be the gold
medal, silver, bronze. So two is silver and
bronze is three. And then anything else
as records, no metal. And we could do this by just
making some if statements, whoever we could also
make a switch statement. You can see if I
type in switch here, then inside of the parentheses, I put the variable that
I want us to evaluate. Then once again make
the curly bracket or the second one should
generate automatically. And now I have to
actually specify in each, inside of these curly brackets, each of the cases that
this variable can take. So I can say case 1. So this means that it
has taken on value one, system out print line and then for example, say gold medal. And then I can say case two. And then I can say system out
print line, silver, metal. And then once again, at the very end here I can
say case three, system. The system out print
line. There you go. Bronze medal. However, it is formatted,
that's totally fine. And then we can
also say default, meaning that this is
going to be called if it's neither this case,
this gets more this case. So we have predefined
cases here. And then in the default case, it's actually going
to be called if it's anything else that
we can say no metal. And the first thing
that you will notice is wait a second. We have to define
every single case. Yes, here, the issue
is that you can use something like
bigger or equals, which immediately makes it much easier to narrow something down. If I wanted to make the
exam evaluation here, I would actually have to
go through each case. So I have to go
through cases one through 50 or one
through 49 for saying, hey, you failed and
then the other ones for you succeeded or you passed. So the switch statement isn't
always the best choice. It can be however, sometimes. So let's just take a
look at this list. Should of course, actually
print out gold medal. But the first thing you're
going to say is wait a second. It's actually printed
out everything exactly. Because there's one more thing that we actually need to do. And that is when
you have the case, the very end, you have to
end with a break right here. We have to put in this break. Otherwise, it will just
basically go preserved. It will just go through
the switch statement is just going to continue along and just pull
out all the cases. And if we have the break here, then you will see that
only the relevant one is actually going to be taken. Let's just put in three just for the sake of argument here. So as you can see,
that now works. So this is very important for the break keyword here has to be used with the
switch statement. This sometimes can be
a little bit annoying. So the switch them usually for integers is okay, can be used. It's usually used
for enums because enums have defined
values that they can take and that usually
is easier for the cases then what is very rare or
which is basically impossible. You shouldn't use floats
in switch statements because here you of course
have to define the exact case. And because of the
floating rounding or errors that can occur, this might actually
just never work. So never use floats
and switch statements. Basically, that's a very
important thing to remember. Otherwise, a switch statement, even if you are not going
to use it yourself, might of course come up
in someone else's code. You will have, at least have to have seen this before, right? But that would already be it
for this lecture right here. I hope you found this useful
and neurons and the new, I'll see you in
the next lecture. Oh yeah.
13. ASSIGNMENT 1: Trivia Game: All right, welcome back to
the Java introduction for Minecraft modding here
with the first assignment. In the first assignment
is going to be a create, a simple trivia game. I will explain shortly
what that entails. Though the idea is
that you should define at least three questions. I recommend doing
three questions, three answers, that's
going to be enough. Otherwise, the code will get
very cluttered very fast. And what I want you to
do is I want you to prompt the user to
type in their answer. You can use the
scanner for that to basically get what
they typed in and then evaluated with an if
and else statements to check whether or
not the answer that the user typed in was correct. So I recommend rewatching the output input lecture is that was very important
in that case. And the if else statement
lecture might also be very interesting to
look at it one more time. So if they were correct,
output that they were, and if they were wrong, then tell the user
that they were incorrect and also output
the correct answer. Another thing you
should do is basically just increment a points total, meaning that when the user has a correct answer that
appoints increased by one, then at the very end, you just have a unique output for each of the
different point totals. So basically three,
basically saying, hey, you've done everything correct to something like 0 minutes, okay, one mistake, one
and so on and so forth. So basically from 0 to three, having some if else if
statements at the very end, there are two things
to keep in mind. So those are some tips that
you will have to keep in mind when you are reading
in a string from the user, please use scanner dot next and not scanner
dot next line. Because if you're using
scanner dot next line, that sometimes messes up the
way that this is read in. But I highly
recommend doing this. And then when you're reading
in an answer from this, ended up next, we have a string and you want to
compare that to a string. Don't use equals, equals, but use the input dot equals
and then put the answer, the correct answer inside
of parentheses here. This will also return
a Boolean value, and it will make this
a little bit easier. So otherwise, because there's sometimes does not work and
this will definitely work. So that's keep that in mind. And that is pretty much
the assignment right here. This is also written in
as text here as well. And I suspect that
for a beginner, this is something around
about 45 to 60 minutes. I would definitely recommend
taking your time with this. Probably going back
to the old lectures, taking a look at the
output input lecture, if and else statements lecture. And with that, you should
almost be completely done. Basically, that is pretty
much what you need. And then once you're done, you will have access to the, to the solution, of course, and I will also step through the solution in another video. So that would be it. N, Good luck.
14. SOLUTION 1: Trivia Game: All right, so you've
made it through the first assignment and here is the step through solution. So you've probably
already seen how it looks like an hour just
going to go through. So of course, the questions
here in this case are actually done as strings. That of course makes a
lot of sense, right? Otherwise, you can really save
the questions in any way. And the one answer is actually in an integer, that does work. However, I do also see
the point in making this a normal string as well. Over answers would be
correct. So no worries. There. We have an integer
points and then a scanner, and then we just start, we
output the first question. We then say the user
input number 1. We're just going to
put this in here. We're going to see if that is
equal to the first answer. If it is, we're going to
increment the points, output that it was correct and
you have that many points. And then otherwise we're
going to say incorrect and output the correct answer. After that, we're pretty much doing exactly the same thing. I'll putting the
second question, getting the user input again and equalling
it or saying, Hey, is this equal to
the answer here, incrementing the points
if it's correct, outputting that and
then saying no, it's incorrect, this is
actually the correct answer. And then the third time again. And then at the very end
here you can see that it basically goes through
sort of a cascade here. So points going
through three to 0. Then I also have sort
of an Easter egg here. When you have less
than 0 points you get, how do you even get
negative points? Because there's no
way to get those. You could of course also
something where you get some negative points
if you make a particularly like stupid
answer or something like that, that would also work. But I've not implemented
anything here. It was just an example. So that's actually
how that might work. So this is one example. Once again, if the actual
program works right? So if this works for you and you can play this
game and it works, but it looks different to this. That's absolutely fine. Like No worries at all. So that's the beauty here. There's multiple
ways to do this, and we'll see this in the upcoming assignments
as well as we are going to basically always use
this trivia game as well, sort of a template. And we're going to redesign this next few assignments
basically in a different way. And that's, I hope that you
will be able to see that it gets easier and different, let's say in the future lectures and the
future assignments. But that will be it for
this solution right here. I hope you found this assignment useful and you learn
something new. And I'll see you in
the next lecture. So, yeah.
15. (Java) Strings & String Methods: Or I will come back to the Java introduction here
for Minecraft modeling. And in this lecture, we're going to be
looking at strings and some string methods. Well, basically all around
the string so to speak. And we're going to first of all, start by making a new string
variable called sentence. And this is going
to be equal to, it's a wonderful
Dava introduction. Well, let's hope that
that is also true. But whatever the case may be, this is what the value of
our string variable here is. And we're just going
to print this out. So sentence right here, system out line sentence. And now the question is, what else can we do here? Well, the first thing
that we're gonna do is we're going to
actually duplicate it. Let's align. And what we're going
to say this is done by Control D by the way. And what we're gonna do is
we're going to say length is, we're going to say
something like plus. And then we can say
sentence dot length. So as you can see, I can call the dot length with
the parentheses here, meaning this is a method call. We're not a 100 percent
sure yet what that is, but we've seen this
before a couple of times, and this is basically just
returns us the length. And if I ever actually
hover over this, you can see in an integer returns the length
of the string, length is equal to the number of characters in that string. So this is basically
Unicode units. Let's not worry about that. It's just basically equal to the characters in that string. Let's see. Length is 35. So that's
interesting here. And then also of course we output the actual
string as well. But what else can we do? We have to be able to do
some interesting stuff. Of course, we can. Let's actually get
this output here. Let's actually just duplicate
it three times y naught. And the first thing is
going to be shouting, well, that is going to mean
that everything here, I'm going to turn
into uppercase. How do we do this?
Well, we can do sentence dat to
uppercase right here. This actually already suggested. And then of course
the same thing just would be whispering, right? And then we're going
to do sentence that to lowercase right here. So that's just going to first of alternate uppercase
and lowercase. And then just for the
sake of argument, let's also just output the
sentence one more time. Oh, let's also add a
commentary, right, so this is upper and lowercase. So fairly straightforward. We can just turn the entire
string to uppercase, an entire string to lowercase. And then here what
we should just get the lowercase
string as well, right? So if we just put this out, you can see shouting
everything in big letters, so everything in uppercase,
then everything in lowercase. And then here it's,
it's the normal string. That's strange, isn't it? Well, here is the very
interesting part about this. These methods actually return a copy of this
sentence variable. They don't change the
variable in themselves. So when we had things
like x equals x plus 1, we actually changed x-ray, EEG plus equals one. That changed the x variable. In this case, we're
returning a copy. So that's very important and you have to really
keep that in mind. But onto the next
thing, Let's say, I'm telling you,
Hey, what position is that Java found
the word Java. You're gonna be like, I don't
know, it's like exactly. So what we're gonna do
is we're going to just copy over the print line again. And we're going to
say the following. We're going to say the
word Java or something like this is found at position. Now we could count, we're
not going to call just yet. We're going to count
in just a moment. We're going to say sentence
dot index of the can see there's a couple of different
types of index of here, but we want the string 1. It doesn't actually
matter by the way, which one you choose your, you can see that as soon as the cursor is inside
of the parentheses, it's actually going to suggest
which ones you want to do. We're going to take basically, and I'm gonna say Java here. So Java, Let's just
see when is that? Like where does it happen? 17, okay, let's just count. So I'm going to start here. So my cursor is
always going to be on the left side of the character
that I'm counting on, 123456789, 10, 11, 12, 13, 14, 15, 16, 17, 18. And everyone's gonna
be like Wait a second. But that said 70, didn't it? Yes. It did say 17. Now why is this 18 though? Haha, see this is a very
interesting thing because in Java or in most
programming languages, we're actually counting
starting from 0. Now this might be
absolutely crazy to you, especially if you were
very much a beginner. That's totally fine.
Don't worry about it. The thing about it is that you get used to it
very quickly actually. And there's a few other places
where we have to use this. But if we start counting at 0, you can see the 0123456789, 10, 11, 12, 13, 14, 15, 16, 17. All of a sudden, the j is
exactly the 17th character, or rather it's the character
with index 17, right? So because this is
of course the index, the index of this, the index of this word. And we're basically looking
for the first character here. That's very interesting. Indeed, when we really
think about this end, well what if, well
actually we're not, this is not correct. Where we add is actually we
want to replace something. So system out print
line and we want to say a sentence that replace, and we want to replace Java
with, let's say C Sharp. But why not? Right? So you can see the target that we want to replace as Java, and what we will replace
it with is C sharp. So if I were to run this now. We'd see it's a wonderful
C-sharp introduction as not right, That's not okay. But in this example, of course, that's totally fine. So this is the replace method and that's also
very interesting. Once again, this is not
replaced it in the sentence. It has returned a new string, a copy of this that
basically replace this. Very important, right? Maybe we want to
see whether or not a certain sentence starts
or ends with something. That's very easy actually, we're just going to duplicate the replace your once again with Control D. And what we can
just say it starts with, you can see, and I
could just say, hey, I write and that would
be true in this case. And then we can also, can you guess it what
the other one is, of course, ends with,
which would be, let's say an uppercase a, which is of course
false in this case, this would be true,
this should be false. So let's just see for
the sake of argument. And there you can
see true and false. Very easily done. Now what is if we have
an, a string, right? And we're just going to call
this S for the time being, and it's just going to be
an empty string, right? So a string with nothing in it. How can we check
that this is empty? Well, we can make
a Boolean empty. For example, we just
say S is empty. And there you go. That's pretty much
all that we need to. And if we were to system out, print line that is empty, we could of course also put S dot is empty inside
of your butt. Why bother? That's totally fine. And they go, this is
actually where is it true? It's true, of course
it's true. Sorry. There you go, Right? Of course, it's true
because this is empty. And there's one more thing that's really
interesting when it comes to sort of the Boolean
methods for the strings. And that is the contains, one. That's very interesting. So system out print
line sentence that contains, let's say Java. And this is of
course true, right? Because this contains Java, we should see r2 year as well. Beautiful. What about the other way around? When we think about
index overhead? What about a certain character
at a certain position? Absolutely no issue whatsoever. System out print line, sentence, char at what position? Let's say 17. So we know that
it's going to be a. So they know that
it's going to be a j. That's going to be very
important and there is a J. Easy enough. Once again, we start
counting at 0. Therefore, while this
is the 18th character, is the character with
index 70, very important. That's, it might be hard, but after a little
while using it, I'm sure that you
will get used to it. And let's just do
one something else. And that's going to
be the substring. Interesting substring. What is that? Well, let's do system
out print line, and let's just say
sentence dot substring. And where do we begin? Well, let's begin at index 17. But what it's now
going to happen is it's going to take
everything starting from like 17 and it's just going to return
everything afterwards. So this now the substring 17-year should say Java
introduction, exclamation mark. And of course it does as well. That's very nice. So if we take another look sentence that you
can see that there are of course a bunch more methods
that you could call not, this is not an exhaustive
list that I've shown. I've just shown a few that
might be interesting here. I always recommend
trying out a little bit. You're trying out
a bunch of stuff. This great thing here is that it really is only typing
out a bunch of stuff, clicking the Run button and
just seeing what happens. And if something happens, that's cool, even better. And if not, if
there is an arrow, but the work through it and
see if you can't fix it. But that would pretty much
be it for the strings. And these strings
method lecture. I hope you found this
useful and you'll learn something new if you did, I would very much appreciate
a review from you. Otherwise, I will see you in
the next lecture. So, yeah.
16. (Java) Casting: Or I welcome back to the Java introduction here
for microwave modeling. And in this lecture, we're going to be
looking at casting. You can also think of that as converting datatypes
between each other. What does that really mean?
Well, let's take a look. For example, we want to have
an integer loan, which is, let's say $750 Euros, whatever the case may be. And then we have
a interest rate, which is of course
in float, right? And this is going to
be 0.0525, let's say. So this would be equal to 5.25% interest rate
at this point, should all make sense. So now we want to actually
calculate the interest. Now the interest, we should calculate that as a float
for the time being. And I'm going to show
you why in a second. So interest is equal to the loan rate times
the interest rate. That should also make sense. You can see that even
though I'm taking a, an integer times a float, it all works because we're
saving this in a float. Interesting. Okay,
Let's do system out, print line and just print
out the interests, the sea. And it should be something
like 39, that's okay. Then of course,
if you sense here as well, That's totally fine. Now the question is, how
can we just make like multiply an integer and a float and get a
float out of it. That's pretty crazy, isn't it? Well, what happens
is basically that this integer in the background
is converted into a float. We can make this
explicit by typing mode in parentheses in front
of the actual variable. And then we have
this explicitly. So this is an explicit cast before it was an implicit cast. Now, the thing about
it is that we're going here from an
integer to a float. What happens if we make the
actual interests in integer? First of all, what's
going to happen is that this is going to show an error because as soon
as we have one float in a, in a mathematical
expression here, everything is going to
be turned into a float because flows have more
information, right? Because everything after the decimal point is
more information, therefore, everything gets
converted into a load. Now, let's actually explicitly
cast this to an integer. Now let's know Mori,
the background here being yellow
means that this is a, is basically a warning. We're not going to worry about this because I actually want to show you basically
what the warning is, warning us because
all of a sudden it's a big fat 0 and
you're going to be like, wait, how did they
turn into a 0? Well, when we cast a
float to an integer, what's going to happen
is that everything after the decimal
point is just cut off. So basically it's like this. So all of a sudden, interest
rate is going to be 0 when we cast it
into an integer, meaning that you're
just going to say loan times 0 is of course 0. And you can see that this is also what the warning here says. That's why we want
to get back to the float right
here. So they go. And then instead of
making this an integer, we're just going to keep this at the interest rate and normal. And that's going
to be fine though. This is sort of
the idea when you go from integer to a float. So from a, basically from less information to
more information, that's usually fine. Go from flows to integer. So for more information
to less information, that can have some
consequences, let's just say. So that is always what
you have to keep in mind. And this is also a thing. So basically this
idea of writing a different datatype in
front of a variable to cast it into a different datatype is something that we are going to see a little bit later
in a later lecture as well. So that is something to
basically also keep in mind. Well, but that would
already be it for this lecture right here. I hope you found this useful
and you learn something new. And I'll see you in
the next lecture. So, yeah.
17. (Java) Ternary Operator: All right, welcome back to the Java introduction here
for Minecraft modeling. And in this lecture
we're going to be looking at the ternary operator. Now the ternary operator at first glance sounds like
something completely crazy, really complicated, but in
fact, it actually isn't. So we're going to
make two integers. One of them is going
to be the exam. This is just going
to be the exam result as an example here. And then an integer called gift. But this is, let's say
our Father wants to give us a gift of X amount. We're going to specify that when we actually pass this exam, though, how we could do
this as the following way. We can say if exam is
bigger or equal to 50. So basically we're
passing the exam, then we're going to
say gift is equal to 10 and then else
gift is equal to 0. Now we wouldn't necessarily
need this else here, but I'm just going to
add this just in there. And then we're just going
to system out print line. If so, no worries there. This should all make sense. But now what we can
do is we can actually write all of this
year in one line. And what we can do is we
can say gift is equal to. And then the first thing
that we have to do is write a Boolean expression. So for example, exam
is bigger or equal 50. Then we're going to
write a question mark. And then what we
want to return if the Boolean expression
here is true. So 10, then a colon, and then whatever we
wanted to return if the Boolean expression
is false, so it was 0. And this is the ternary
operator, question mark colon. And that pretty much is the
exact same thing as this. So what we can do is we can basically just copy this over. Let's just comment
out both of those so that regardless of
what happens here, this isn't assigned to. We're going to first have
a 0 output and then a 10. Let's see. There you go. So the
0 is of course this 0 right here that we've
assigned up here. And then the 10 here is
the ternary operator. So that's actually pretty cool. Now usually the ternary
operator is used. I wouldn't recommend using
it too much basically, but sometimes with like fairly
simple things like this. You could also think of maybe taking this Boolean expression, making a Boolean out of it
saying like asked exam. And then this reads a little
nicer right past exam, are that it's 10,
otherwise it's 0. So you can think
of this as well. So I probably wouldn't
keep it like this because this is something like
this not to redouble rate. There's too much
brain power that goes into looking at exam equal, little bigger equals 50. Okay? Okay. Oh, I get it. If you have something
like an is, does pass exam or
something like that as a Boolean that makes
sense in this case. But whatever the case may be, this is the ternary operator and basically the same
thing in if statements. Now, just because this
is all in one line doesn't mean that it's
necessarily better as well. Line count is no indication
of quality code at all, okay? And I want you to, I want
this to be very, very clear. It doesn't matter. A great
program can be 1000 lines. If it has to be 1000 feet long, it has to be 1000 night long. Just because you can
make that program 800 lines doesn't necessarily
mean that it's better. That's very important. Because the most
important thing when writing code is that you can read it and someone
else can read it, which includes you
six months from now. Because you're in six month, is going to be a different
person because you will have forgotten everything
you wrote in your code. Therefore, you have
to make your code readable or other people, that's the most important bit. And if a ternary operator makes sense in that
case, that's great. I would never, I would
definitely advise you to never put multiple terminal
operators in the same line. Because of course
you could put in another ternary operator
on the true or false here. Definitely don't do that
because then it gets very, very complicated, very fast. Stick to if statements. In that case, whatever
the case may be, this would already be it for
this lecture right here. I hope you found this useful
and you learn something new. And I will see you
in the next lecture. So, yeah.
18. (Java) Arrays Explained: All right, welcome back to the Java introduction here
for microwave modeling. And in this lecture, we're going to be
looking at arrays. Arrays are definitely
the, let's say, most complicated topic
we're going to be looking at up until this point. However, what I first
want to tell you is that if you struggle with this, no worries at all. This is totally normal. I also struggled with this
when we learned this. And at the end of the lecture, I'm actually going to tell a little bit of a
story about that. But for the time being, Let's remember back we had
the three strings, right? We are at question
1, question 2, question 3, and answer one,
answer to answer three. Now, granted, the first answer
was actually an integer, but in this case it's a string. That's totally fine
because that's for demonstration purposes. It's a little bit
easier to show. And what we had here
was the idea that, well, we had those questions. Let's just say, I tell
you, you know what, your trivia game that was
in the first assignment, you should actually make
this have a 150 questions. Now you're going to be
sitting there going to be like, excuse me. Yeah. A 150 question. Well, okay. Then you start duplicating this and then changing
every one of them. Now, then maybe, you know, I, I know thing you can
keep all pressed and then change multiple
things at the same time, but then they all change
to the same number and it's all sorts
of just screw it up. It's not very good. So that doesn't quite work. Okay. How else might we
be able to do this? Well, what we can
use is an array. Now an array, you can
think of that as a list. It's not a 100 percent
a list, right? It's a little bit
different because there is actually something called
a list in Java as well. However, we're going to
think of it as a list. And you were going to
make a string array of questions and it's
ring area of answers. And we're just going
to take a look at what that basically entails. So how do we make an array? Well, we just type in
the type that we want. So the data type that we want, and then these brackets here, and this is going to be questions
and it is equal to new. So we have to take the
new keyword and you can see that this is already
being suggested to us. I'm going to type this out
string and then once again, the angle of the brackets here and then ending
with a semicolon. Now this is not done yet because inside of these brackets, we actually have to supply
the length of this array. So how many elements are
going to be in there? Three, in our case? Well,
that's pretty much it. So that's pretty cool. Now. That's it. It's like yes, that's
pretty much it. And now of course we need
to assign something. So what we can say is questions. You can see that I basically autocomplete that with
the Tab key, right? The brackets again
and then assign, for example, one equals two. And then let's just take
this right here, right? So something like this. And then I can just
continue with this, right? 23. And then let's just, well, how can I
output this right? How, how is this possible? Well, IT system out print line, and then we can
just say questions, no questions, there you go. And then for example, three-year know at my mean is
all the same, right? Now, let's just change this,
actually copy this over. So select this
control C control V, like this Control C Control V. And let's just bring
out the three here. That's just C and O know
what happened here? Well, what happened here
is that we maybe forgot. Now I didn't forget, I actually
wanted to show you this. But what happened here is that we have to start counting at 0. So this is where we
get back when we saw the strings where we
start to count at 0 year, we counted 0 as well. But this means that when we have three elements in
this questions array, the first element is of index 0, the second is of index one, and the third is of index 2, meaning that three
doesn't exist here, and then we get an exception. We're going to see this at
the end of the lecture again, because I want you to like see the exception and I want you to understand what that means. But for the time being, this is how you assign
different strings, in this case, different
values to the array. And you can also read it
out pretty much like this. So that's actually
what all it takes. And let's also just
copy this over for the sake of
argument and call this the answers, right? And then we're going
to copy the swell. So I'll select this RP
here, here and here. And then we're just
going to change this to the answers here. So this is going to be 50. This is of course
going to be London. And then the last one
is going to be F e. Very interesting indeed. And then what we can
do is, for example, we can output the answer 0. So we're just going to see
answers one in questions 1. And then all of a sudden
it says something like, well, what is the capital
of the United Kingdom? London? Very easy. And let's actually
change this to, actually, we don't need
to change this to 0. That's totally fine. All we can do is
now, well, okay, Then can we just
like reassign this? So we can take this, I'm
just gonna take this. Actually, I'm going
to write it outwards. So questions, once again, bracket 0 equals, for example, how old is Ian? Mick Jagger, right in 2021. That's just, let's date
ourselves. Why not? That's totally fine. And then we just
output this again. Now the 0, let's
say, and the 0 here. The question. We've reassigned here, and then the answer is still
going to be correct. By the way, that is
something I have checked. By the way, as I did
want this to be correct. That's pretty cool. All things considered. The really cool thing is that here everything is sort of
in one datatype, right? So questions now has
all of the questions. Instead of having three
different strings, we actually have everything in this questions string array. That's pretty cool. We can also get the size of the length of this
array, of this list, so to speak, by doing
questions that length, as you can see here, we can
just take a look at this. This is of course
3 because this is what we have supplied
right here, right? So in this, we had to
supply the length. Therefore, this is
pretty much it. And you might have also seen
a lot of suggestions here. We're not going to worry about
any of those at the time being because all of those
are very, very complicated. And we then also
have is I'm actually going to copy over just
the tiniest bit here. But this is the array index out of bounds exception right here. It's pretty much what
we've already seen, but I'm going to show
this one more time. So if we put a number
into the bracket, then actually it does not exist. We're going to get
an array index out of bounds exception. So you can think
of it like this. Well, this is an array and it has a certain bound,
okay, fair enough. Like an index. So the index
that we're passing in, this is the index rate three. I want the question with index
three, okay, fair enough. But that is out
of bounds because this only has three elements
and we start counting at 0. So therefore, the index or the element with index
three does not exist. And once again, you get the really nice stack
trace here so you can get the exact location
where the issue has occurred. So that is also something
I wanted to mention here. Otherwise, that
would pretty much be the general gist of arrays. And now of course, the sort of thing I told you
at the beginning. So when I learned
areas in university, the interesting thing was that I didn't understand them fully. So I said, You know what, I don't need areas. I'm never going to use areas, ever. It doesn't matter. I'm just going to
stick with this. I'm going to make
individual variables. But of course, you're
going to run into very hard issues as soon
as someone says, well, then make like 20
different ones and then just like if
me get them out, put them in a random order, it's not going to work because these things
definitely have to be learned. This is also not
the right approach wide. Oh, I don't understand it. Therefore, I don't
have to learn it. Therefore, it's not
important, none. And of course, if it exists, there has some merit to it in that sense in the
programming here. So I definitely highly recommend taking
another look at this. Just staying calm, trying a few things out to sort
of understand this. And also once again, if you get any errors, no worries at all. Errors are totally normal
to get when programming. There's nothing like
there's no shame, doesn't like it's
totally normal, genuinely it every programmer, it gets multiple arrows
every day when they program. Even veteran programmers still get arrows every day though. Never feel bad
about that at all. And yeah, so that's sort of the general idea of arrays here. I hope I was able to
sort of get the idea across that this is really
much like a list, right? It's not a 100 percent ellipse, but you can think
of it as a list. You put different elements into, basically with different
indices or indexes, something like that, right? But otherwise, this would be it for this lecture right here. I hope you found this useful
and you'll learn something new and I'll see you
in the next lecture. So, yeah.
19. (Java) For and While Loops: All right, welcome back to the Java introduction here
for microwave modeling. And in this lecture
we're going to be talking about loops. What we are going to need
for this lecture are both of the string arrays
that we've made previously for the
questions and the answers. But before we do
anything with the areas, first of all, I want you
to do the following. Output. Every number from
0 to 99, right? You're going to be like, Okay, system out, print line 0, then you might be like
duplicate one, duplicate two. Now you're going to
be sitting there all along time like that. Let's just be honest, that's
gonna take a long time. Well, and then come loops. Loops are something
where you can execute a piece of
code multiple times. And the first type of loop we're going to be looking
at is the for loop. For that we're going to type in four and then parentheses. Once again, the
closing parentheses should generate automatically. And then we're going to
type in int I equals 0 semicolon I is smaller
than a 100 semicolon I plus, plus closing parentheses and
then an open curly bracket. Then the closing curly bracket should generate
once you hit Enter, when you take the system
out print line and put it inside of the
curly brackets here. And I'm going to change
the 0 to an eye and now see the wonders
of programming. As you can clearly see, everything is output from
0 all the way up to 99. So what is happening here? Well, in a for-loop, the idea is that what we're doing is we're defining,
as you can see, we're initializing a, an
integer i e to the 0. And then we're saying
we're having some sort of Boolean expression here
and then an increment. What happens is
that I is set to 0, whereas being checked
is whether or not I is smaller than a 100. If this is true, we are continuing
with this loop. So if this is true, everything inside
of you happens, then we're going to increase I and then this
is checked again. And then we're doing this
again, increasing I, check increasing i and
so on and so forth. So this is basically done
forever until this year. This Boolean
expression is false. And once it's false, meaning that I is no
longer smaller than a 100, which happens once i is a 100, then this is no longer executed and
everything afterwards, after the curly bracket
here starts to happen. This is why it stops
at 99 and not a 100, because when I is 99,
this is still true. 99 is smaller than a 100. Everyone agrees, yes. But as soon as it's a 100100
is not smaller than a 100. It actually is in
fact equal to a 100. Therefore, this no longer
basically is true. Therefore, this is no longer
executed for armored. That's sort of the idea and
that's really cool, isn't it? Like we can very easily do this? And now I'm going to
absolutely blow your mind. So now I'm going
to tell you, well, output all of the questions and answers and you're just
going to occupy system out. Print line question 0, answer 0, just like
we had before. Well, this is going to be
easier for int I equals 0. I is smaller than questions
dot length I plus, plus. And then what I'm
going to do is I'm actually going to
copy this one twice. And then instead of
this, I'm going to call questions I oh, that's interesting, isn't it? And answers I. Now this,
that's pretty cool. So you can basically
pass in the integer here into the brackets and access whatever index you want and whatever index
this integer takes on. Another really crazy
thing is because we're actually looking at the
length here, right? Because we have the length, this immediately saves
us from any errors. Now the only error
that might occur is if we all of a sudden make
this four here, right? Because we're taking
the length of the questions while the
answers is not the same. So then we could
run into an error. Once again, the area out of bounds exception or the array index out
of bounds exception. But for the time being, when we use the lengthier, that's going to be totally fine. And if I just run this, you can see it prints
out everything. Harmony sits at the
US AIR 50 capital of United Kingdom, London. And then chemical
symbol for iron is phi. So that all works. So that's pretty, that's pretty insane, right?
That's pretty cool. Or loops insanely valuable and can be used for all
sorts of stuff. There's another
type of loop which is very similar to the for-loop, which is the for each loop. Now you can see if I can
actually type that in and I could press the Tab key
to autocomplete this. However, I will not, because the formatting is
a little bit weird for me. I don't know, quite know
what that is the case. We're just going to
write in for that. I can say string Western,
olden questions. And the way to read this is, or each string question in questions, this is
how you would read it. And then you can just do a system out, print
line, question. And I can just print out each
individual question here. Once again, that's
just going to work. So as you can see,
there you go, uh, basically now have access to what the individual elements inside of that list or
array in this case, and I don't have to specify
it via the index here. I'm actually getting all
of them well individually. So this is the for each loop
and this for each you go, That's another type of
loop that's interesting. And then the last
type of loop that I want to show you
is the while loop. Now I have a personal
preference to very rarely used the while loop
simply because of the fact that it can be, well, it can get
you into trouble. So we can say
something like while true and then curly brackets. So what happens is
that everything inside of here is going to
happen while this is true. Now obviously, when you think about this for a
second, wait a second. If I put in true, then this is always going to be true exactly. This is now a while loop and a while loop and endless, right? So this is an endless
loop and this is the danger you might run
into with a while loop. You could run into the issue with for loops as
well in theory, but it's very rare that
are actually happens. But in while loops, it's very often the case or it can be the case that you
have an endless loop. Now everyone has to go
through that at some point. I'm just saying that my bias is that I don't really
like while loops. But what we can do is, well, let's do the following. Let's actually add an
input for the person. So Scanner here, scanner equals new scanner system.in
and then done. And what we're gonna do is we're just going
to say something like the following
system out print line. Do you want to continue? So we're just going to say, Hey, does the person want
to continue to use? We're going to continue and then we're just
going to say, hey, if scanner dot next, right? If that equals yes. Then what we're gonna
do is we're just going to continue, right? So continue the, the actual keyword else
we're going to break. This is an example here of the Continue and
the break keyword, the continue keyword that basically ignores everything
that comes after it inside of the loop and
jumps back to the top of the loop while the break
keyword breaks out of the loop. So basically it goes
to the end of year and everything afterwards
is then executed again. This would be the same if this all of a
sudden turns false. In this case it is of course,
an endless loop, right? So, so as long as I type in, yes, this is going to continue. As soon as I type
in anything else, it's going to break out of it. So that's sort of the idea
of this while loop here. Let's just actually take a
look at this so I can type in. Yes. And I can type in, yes.
And I can type in. Yes. And then I'm going to make a mistake
here and an OH no, All of a sudden he
called this stops. That's sort of the idea. So this could be an endless loop with sort of a braking system. Now what's very important
is that the continue and the break keyword
should probably only be used sparingly because there are a lot of developers
who don't like this. Because if you have like, let's say a longer FOR loop
or longer or while loop. And you have a lot of
Continue and breaks in there. Sometimes can be a
little bit confusing. Like to read it, right? Because you're going to have
more branches so to speak. So you can think, if you can think of way of
doing it in a little bit of a different manner
that usually is better. Whatever the case may be. Those are the loops that
I wanted to show you. Really pretty cool stuff. And we're really starting
to get some very, very cool tools in
our toolbox to really work with code and to just program something
that's really cool. So, but for the time being, this is it for this
lecture right here. I hope you found this useful and you'll learn something
new if you did, I would very much appreciate
a review from you. Otherwise, I will see
you in the next lecture. So, yeah.
20. (Java) Java Methods: Welcome back to the
Java introduction for Minecraft modeling. And in this lecture, we're going to be taking
a look at a methods. So first of all, we once again require
the string areas here. We don't necessarily
require them, however, we are going to use
them in this lecture. And well, methods. What are methods? Well, we've seen
this word thrown around a few times before
with the string methods. And also something like system out print line is also a method. And I might have said once
or twice before main method. So there is something to this. We've seen the math
methods as well, so we've definitely
heard that word before. What is it really? Well, in theory, a method, you can think of it as
a few lines of code, one line of code or a 100
lines of code in theory, that are executed when
you call that method. So you call a method
like for example, when we type in a system, system out print line, right? And I say Hello, read this. It's something in the
background, happens, right? So this print line,
when we call this, this method here, something
in the background happens. Now we don't, in this case necessarily know what
exactly happens. But something happens to
that this hello, right? Once I run this, so
that when this happens, something happens in the
background that this hello is now being displayed
in this Run window. So we don't really know what, but something in the
background happens, so some code is executed. So if we have a piece of code that we might
want to reuse, let's say a 100
times in our code. Then you might say, well, we can just make a for-loop,
you know, a 100 times. Well, but what if I want to do this at different locations
in my code, right? So maybe I want to ask a
question in this case, right? And an output and answer and
then check for the answer. Then I want to ask
questions again. It's like, well,
I mean, you could do a for loop, but well, maybe we want to make some
if statements in there. It's going to get a
little bit complicated. So this doesn't always work. So let's say, for example, what I wanna do is I just want, I wouldn't just
something that I can type in that I can give, let's say a, an array here, red. So the string array
of questions, a string area of answers, and that just outputs meet all of the answers and
all of the questions. So all of the questions,
answers just in enroll. So I could of course write
something like this. Right eye for loop
int I equals 0. I is smaller than
questions that links, Let's say I plus, plus. And then I could just say system out, print line questions. I write something like this and then duplicate this
and then say answers. I could do that. Well, let's say once
again, I want this to be done a 100 times
throughout our code. Now the observant of
you might say, well, why don't we just put this for-loop into another for loop. And you would be
absolutely correct. You could do that as well. However, let's not
get too clever. Let's just think about this
and make this a method. Now, what we're going to
do is I told you before that we are only operating between these two
curly brackets. We're, we're expanding our world now and moving outside
of these curly brackets. Because now our
new curly brackets are those two basically. So now this is our new home. And this, you might have
sort of thought about this. Well, this is the main
method that is basically being executed when we
press the Run button, then the main
method is executed. Now we're going to
add a new method. And first of all, going
to write this out. And then I'm going to
explain what happens here. So we're going to write
public static, void. And I'm going to call this
output questions and answers. Then I'm going to type
in a parenthesis, the closing parentheses should
generate automatically. And then I'm going to
make a string array here. So this is going to be
the questions and then a, another string array
answers, right? And then I'm going to
make a curly bracket. And you see that the
second curly bracket has already generated. I can just press the
Enter key and then the formatting should
also be complete. And with this, a newer
method has been created. So for the time being, we will ignore is this
public and static. We don't quite know
what that is yet, but we're very close
to figuring this out with in a future lecture. We're going to actually
figure out what that means for the time being. We just know this is
an access modifier. We don't know what it does yet. We just know that we
need to have public static written here and then everything is
going to be fine. There's void here is actually the return type of this method. So some methods return something and we'll see
this in just a moment. So after we've done this method, we're going to make
another one that actually will return an integer. Then we're going to have
the name of the method. Now this is something that
you can decide yourself. Usually, naming variables and naming methods should
be very expressive. So even though this
might very long to you don't shy away from long method names or
long variable names. If they exactly describe
what they are doing, that is going to
be the best thing. Then after the name, come, the parentheses here. And inside of the parentheses, we basically also define
a variable sort of speak. And those are called parameters. So we have two parameters here, and both of them are
of type string array. And overall, this
entire thing here. So all of this, right, the access modifiers,
the return type, the name of the method, and the parameters is what's
called the method signature. So because we need to know this, method signatures have to be. Unique meaning I can't
have the same thing. So I'm going to
select all of this. And then I'm going to say
Control C and then Control V. And you can see that
if I hover over this now we're going to say is
already defined right here. So this is exactly
the same thing and it's already defined. That doesn't work, right? So that's very important. However, if I change
the method signature, meaning for example, I make one less, I put one less parameter
in here that works. You will, they have
the same name, they have a different signature. So this, in this case, would now be called method overloading because we
have the same name, this with a different
signature off. So for example, different
number of parameters, different types of parameters,
different return type. That's sort of the ways you can alternate year for having
methods of the same name. This is going to
get interesting, maybe later down the
line for the time being, we're going to delete
this one and we're just going to keep the one
method right here. And what we're just going to do is we're actually
just going to take this Control X to cut it out, Control V to paste it in. And all of a sudden you can see everything is working totally
fine because of course, we are having the parameters
here, Westerns and answers. And the idea is that we're
going to pass those in. So because right now of
course this questions, this answers, those are
not the same as these two. I can call this, let's say Q0, Q, Q u, e, just for
the sake of argument. And I'm going to call this E&S just so that there's
no misunderstanding. This year is not the same as this because I could
call this with, of course, a different
string array of questions in a different
string area of answers. So this is going to
be very general. This is just going to do this for any area
I'm gonna put in. So that's the really cool thing. Then what I can do is I can
call this, I can say output. And you could see as
soon as I type in out, the actual method is being
recognized by the program. It actually suggested here. So I can just put
in the tab key. I can press the tab key and
it automatically generates your and I can just
say Q0 and ANS. So now I've passed in the
questions string array as the question perimeter and the answer string array
as the answer parameter. You might, what you've also
might have seen is that the method turned
from gray to yellow. This simply means
that this method is actually being
used, so being called. And that's also a,
an important idea. And if I now run this, you will see that it actually works. You
can see how many sets. The US, they have 50 capitals, United Kingdom,
London, and chemical symbol for iron is F, e. So it outputs this and it just basically calls all of the
code of this inside of here. And now of course,
methods can call methods, and methods can
call other methods. So this, of course, does get quite complicated
at some point. However, for the time
being, this is really cool. Now, we're also going to
make a method which is, might be very complicated. So what we're going to
have as one's going to public static int. So we're now going
to be returning an integer and we're going
to sum two numbers together. So for that, what do we need? Well, of course an integer
x and an integer y. Now, once again, the
names of the parameters, by the way, also can be
whatever you choose to. Usually you want them also to be very expressive in general. Now we have this sum
method right here. And what we're going to
do is we're going to type into the return
keyword x plus y. There you go. So we're just going to return x plus
y because that's of course the sum of
these two integers in that case, nothing
too spectacular. However, what I did want
to show you is basically the return keyword
and that you can return different types as well. So the SAM method in this case, we can just take a
look at this, right? So system out print line, and then we're going to say
some ten and let's say 12. And then if I run this and it should say 22, there you go. So no worries at
all, that all works. And that sort of the general idea here that
you have with methods. So it can either
return something or it can nab return something, then you have to
write in a void. But that's sort of a
tentative look at methods. Of course, once again, you really have to
also apply this a little bit to really get
the understanding here. However, that is a great segue to the assignment which
is going to be up next. I highly recommend
making like doing the next assignment because that's going to be
basically methods. And even if you don't get Sue will basically do
everything in there, at least looking at
the question and then the solution to
it will hopefully illuminate also the way that you can use methods
in your own code. But for the time
being, this is going to be it for this
lecture right here. I hope you found this useful
and you'll learn something new and I'll see you
in the next lecture. So, yeah.
21. ASSIGNMENT 2: Trivia Game with Methods: All right, Welcome to the second assignment of
the Java introduction here. And in this short video, I basically want to
explain the assignment. So overall, the assignment
is not actually that complicated over I still want to basically walk
you through this. So the idea is that you should recreate the trivia game
from the first assignment. So basically pretty
much the same thing. But this time you should have five questions and five answers. And the way that you should
save those is in two areas. One for the questions
and the answers. And what you should also do
is you should at least create two methods to make the code more readable
and easier to follow. And basically as a hint, you're going to think
of it like this. When you have some
duplicate code, you should probably make
that into a method. We'll think about that. Think about where you
might be calling something twice and then you can basically make a
method out of that. And what you should also
do is you should make an endless loop and then some if statements in there
in some capacity. So some logic, who make
the user to prompt the user to keep playing or not if they don't
want to anymore. I highly recommend
taking another look at the loops lecture
again because they are actually had a very
similar use case that they are aware we
had an endless while loop that you can stop with
them IF statements and the break and the
continue keywords. So those might come
in very handy here. Otherwise, overall, this should be fairly
straightforward. The game in and of
itself should play very similarly actually
than the first one. It should just look a
little bit different. So overall, that would
be the entire idea. Of course, don't forget things
like the points as well. Also the, you know, add those as well. Otherwise, this is pretty much all that you
really need to do. I suggest round about another hour or so
for this assignment, depending of course
on your level, you might also do it
in like 30 minutes, 45 minutes, who knows? But don't stress yourself. Take yourself some time
to really dig into this. Watch a couple of lectures
again, the loop lecture, I highly recommend
methods lecture was very nice areas if you don't quite fully
understand those, I highly recommend this. And otherwise, of
course, the solution will be available
to you as well. So no worries there. Otherwise, I wish
you the best of luck for this
assignment, though. Yeah.
22. SOLUTION 2: Trivia Game with Methods: Or I welcome back to the
second assignment and the solution to the
actual assignment here. So once again, the code is
of course available for you. And as a, well, basically
disclaimer here, if your code doesn't a 100 percent match the
code that I have, that is of course totally fine. There's no shame in that because there's always multiple
solutions to this. And I do think that my solution may be uses a few,
too many methods. Actually, interestingly enough,
but for the time being, we're just going to
step through it. So of course, the string arrays, questions and answers should be fairly self-explanatory here. Same with the scanner once
again to read stuff in, and then a points total
here, just core points. So that's fairly
straightforward. We have a while loop
that is always true. So you can see this is basically the entire
while loop here. And let's first of
all take a look at the very bottom here. So this print play again, method prints out, Hey, do
you want to play again? If you put in a y here, then it basically resets the points and then continues
with this while loop again. Otherwise, it just breaks
out of the while loop. And then prince de goodbye here. That's sort of the idea. Otherwise you can very
easily actually follow this. Does the names of the
methods almost entirely describe what they are doing and then see Print
title, Fair enough. And then we're gonna
go through for each of the questions here
for this for-loop, very, fairly
straightforward as well. And we have the print question here for the question
that currently is basically being asked BY then
read in the user answer. And then we have an if statement that calls another method here. So is correct answer
from this user answer. And it basically compares this to the answer that is
correct for this question. If this is the case, so if
this method returns true, we are then printing out, you had a correct answer
where then increasingly points total and writing that back into the points variable. And then here we're
also printing out the current points
total basically. And if this was not
the correct answer, then we're printing out that
you had an incorrect answer and we're also printing out
the actual correct answer. That pretty much is all
that we really need here. And you can see then at the end here we're just printing out the point total and then asking the player to basically whether or not they
want to play again. So that's the entire logic here. And then if we go down, we can see that there are
a lot of methods in here. And all of them are very,
very simple, right? Almost all of them
just one light, basically all of them
just a one line. Now, you can make a
very good case that, that might be a little
too much of a good thing, can also be a bad thing
in this case, right? Or too many methods
might be too much. However, this definitely is
very easy to follow here. There's also points in saying, well maybe we could just take this entire IF statement
and make a method. Are that as well, we could maybe take the entire for loop, make an entire
method out of that. We can take this part and
make a method others. So there are multiple ideas that you can follow
and you could still, of course make more methods
out of this or fewer. That's totally fine and
that's totally okay. As long as it works, you
have a few methods you made, then it's going to
be absolutely fine. So once again, if this is
not exactly your solution, do not worry about
that in the slightest. Once again, the
beautiful thing about programming is that
there are always, I mean, there's a million different ways that
you can do this. Of course, some of
them are going to be more optimized than others. But at the end of the day, when we really think about it, this is totally going
to be fine usually. So if this isn't a 100 percent correct like you have
it, that's okay. If it works, I'm already
very happy with that. Otherwise, this pretty
much is my solution. This code is of course, also available to you. Otherwise, I hope
that this assignment was useful to you to dig a little deeper into the idea of methods and how to use them. I can always, of course, also just suggest playing around with it in your own time, just trying out a
bunch of stuff. At this point you have a
lot of different tools. You have if statements, you have loops, you
have methods, arrays. So there's a lot of stuff that
you can play around with. You can read stuff
in from the user. You can write out
stuff to the console, which at this point actually just opens up a whole
bunch of stuff to you. So if you want to make sort of like a choose
your own adventure, just a little tiny thing, right? Go ahead, right, just try
out a bunch of stuff. I highly recommend just
being experimental with it. You, you can't break
anything here, right? As long as you write your
code in here is just for you, it's all going to be fine. Like I've already said in the
lecture about the errors. If you get some errors,
no need to worry, this is not the end of the world and everyone gets arrows, right. I get arrows anytime, like when I program, of course, there's going to be arrows
and that's totally fine. As long as you
work through them, you try to understand
why did I get this error? How did that happen? And sort of something like that. But this would be it for
the solution right here. I hope you found this
useful and you'll learn something new and I'll see
you in the next lecture. So, yeah.
23. (Java) Java Collections: All right, welcome back to the Java introduction here
for Minecraft modeling. And in this lecture,
we're going to be taking a look at collections. This will include a
realist maps and sets. Though especially sets is
something that is used quite extensively in Minecraft
modeling in general, but in the Minecraft codebase. So sets are very
interesting things, but we're going to first of
all start with an ArrayList. Though. We will think back
to the string array, which we were able to
define like this, right? So questions for example, here, with a new string array, let's say of size two. And then we were able to assign those questions
kind of like this. How any states, no States? Does. The USA half goes
something like this. And we could
duplicate that line. The other one as well. For example, making this a
little shorter capital of UK. So that works totally fine. No issues whatsoever rate. However, one of the things you might ask yourself is right, but what if I want to
change the number of questions inside of this area? Well, you have to change
this number right here. And that can be a
little annoying, right? Because then you have to go
in here, have to change this, makes sure that if you then
have a area that has answers, you also have to change the size of that, and
so on and so forth. So kind of not the best thing. And for that we're going to
take a look at a list now. So we're going to
type in lst, so list. And you can see that it already basically suggests
us at this one. And we're just going
to press the Tab key, which is now going to import
something at the top here. If that doesn't happen,
I'm going to show you in just a moment how
you could fix that. And then you're going to put in the angle bracket right here. So angle bracket and the other one should
automatically generate as well. And then we're gonna put
in a string right here. And then afterwards we're going to call this the question list. And this is equal
to a new ArrayList. You can see that this is already being basically suggested to us. Once again, I'm going to press the Tab key to
automatically generated. And we're going to end
this with a semicolon. And the first thing that you're
going to see is that we, we have not defined any
length for this list. And this is exactly
right because there's no need to define
a length for a list, because a list is sort of dynamically while
Lengthen solar speak. So basically we can
just add stuff to it, add elements to it and the list we'll just
expand dynamically. So that's really cool. That's the first
very cool thing. So we can say question list, dot, add, and then put a string. So for example, what language
is spoken in Germany? As a question here. And then I can just
duplicate this. And for example, say, what is the capital of Canada? And then at the end here maybe
something like, you know, let's just say in
what hemisphere? Hemisphere is Brazil. But just for the
sake of argument. So those three
questions examples, just add it to the list, and this will now be the
element with index 0. This will be the
element with index one, and this will be the
element with index two. So that's really cool. And the first thing
that we can basically say is that lists, right? They are basically add entries
or elements dynamically. So that is really
freaking cool, right? So we can add and well,
even remove stuff. How would you remove stuff? Well, that's actually
fairly easy as well. We can just say question
list dot remove, and then either I can put
in the index that I want to remove or I can put in the actual object that
I want to remove. So I could also pass in
the actual string here, or I could just say one. And then it's going to
remove the question, what is the capital of Canada? That's pretty cool.
Now, the next question you might have is, well, how are we able to basically
get the length of this? Well, we can say
question list dot. First of all, you're
going to get a lot of things suggested here
as you can clearly see. A lot of things most of which don't interests
us at the moment. We actually have to use the
size method right here. So size with the parentheses, meaning of course that
this is a method call. And this returns as the length
or the size of this list. And how can I get a, an element out of this list? Well, we can just
type in system out, print line to print this out. And then we can say
question list that GET. And then here we have
to pass in the index. So in this case 0 for example. And if I just run this, you will see that
we're going to get two for the size
because of course we have removed the first question or the string with index one. And then the element
with index 0 is still going to be what
language is spoken in Germany. So that's pretty cool. All things considered. Now, let's take a look
at something else. And that's going to be a list of integers, for example, right? So numbers is equal
to a new array list. And what you're going to see is that this some issue here. So ArrayLists rates
something like that. And then you can see
that it's sort of, you know, it doesn't
behave quite right. There's like a red
underlines here. What is going on? Well, if we hover over this, you can see type argument
cannot be of primitive type. That means that
we actually can't use in Boolean and
stuff like that. However, before you. This may and say, Oh my god, that's the worst thing ever. No worries. There are wrapper classes
which you can use so you can actually
see replace it with Java Lang integer. Well, I can either click on this or I can just type an
integer right here. So this one, in this case. And if you use that, then everything works fine. So these are this list and these angle brackets are
what's called generics. And the idea is that you can
put any datatype into here, except for the primitive ones. That's very important for those we need those a wrapper classes. So there are wrapper
classes, right? We can use, can use
instead of the primitive, a primitive datatypes the u. So this is very important to remember here there are
wrapper classes and they should exist for every one
of the primitive datatypes. So no worries there at all. And here we can very easily
just say numbers at, you know, were 20 for example. And numbers add
something like 42. No worries at all. As you can see, we can
just add those numbers in here and they're normal integers and we can basically use o. That is totally fine. But I did want to mention
this that you can't use the primitive data types in these generics as
they are called. Like I said, generics are these tour of these
angle brackets, right? These angular brackets. And everything that's
inside of it is called a generic because, well, it is generic in the
sense that we can put in any other class
or any other object, any data type that
we want into here. And it will just work. This by the way, includes
a list as well, right? So we can have a list of a list. Of course, why not? Right? We multiple lists
that would also work. But for the time being, that
will be it for the lists. Let's take a look at maps. So maps are very interesting. Read, a map is the
following thing. A map contains a
key and a value. And the key, the
key actually maps, right key maps to a certain value that
all should make sense. This is called a key value pair. Okay, fair enough. What can we see? Well as just type this in
map as you can see, and we have two different things in the angle brackets this time. So let's import this, right? So you can see that this
is also imported here. If those aren't
important automatically, you can see that things turn red and you can very easily
do this yourself. You can just click on this
and press Alt and Enter, and it will import this class. You can see I have
also had to do the same with the ArrayList. And then down here for the map, actually don't have
to do this just yet because I'm not done yet, but we will see this
in just a moment. We're going to have
a map that maps a string to another string. And we're going to call this
the country to capital map, which is going to be equal to
a new HashMap in this case. And then what we
can do is we can just press Alt and Enter. And then it's going to be
important here as well. But those are very important,
those imports basically, so that the program knows that we are using these
datatypes, right? So the list, the ArrayList, the map, and stuff like that. And what we can do
now is we can add to this country to
capital MAB as well. So we can just say put and
that puts in new values. So for example, Germany
would be Berlin. Hopefully you knew that one. Let's do another one. So let's actually just duplicate
this a couple of times. And we're gonna say France. You know that one that
is Paris, of course, early straightforward, Italy, Wu now it gets interesting
Rome of course. And then we're going
to have a USA, and that is going to
be Washington DC. So very straightforward. All things considered here, as you can see, I can put
in two strings, right? Because this is what
I've defined here. Those do not have
to be the same. I could put in an integer
year, a float here, I could put in a string here, a list here.
Anything would work. This does not have to
be both of the same. That's very important. I also wanted to mention that. And how do we now get
a value out of a map? Well, let's say system
out print line. And then we're going to say
country to capital dot get. And you can see I have
to supply a string. And what I'm going to get out
is of course a string here, but this is what
I have to supply. And then this is what
I get out of it. So the return type
and I put in Germany, and then Berlin
will be output as Germany is the key to
the key-value pair, Germany, Berlin should be
fairly straight forward. I can also ask whether
or not the map contains a certain key or
contains a certain value. So I can say system
out print line. And then just so
that everyone knows what we're asking here
contains key Germany. And then we're going
to say, country to capital dot contains key, Germany, which of course
is going to be true. Then we're just going
to duplicate this. Then we're going to
say contains a value. So we can also ask for
values, London for example. And then we can call the contains a value
method right here, pass and London right here. And then if we just run
this, we should see. First of all, right here, Berlin rate is the capital of Germany and
then contains key. German is going to be true because it does contain that
key and then contains value. London is going to be
false because of course we don't have London
urine here as a value. We can also remove
things from a map. So once again system out, print line and connect to say, I can say country to
capitalize, dot remove. And the cool thing about
the Remove you can see is that I can either pass in the key or I can also pass in both the key and of
the object as well. And then it's going to return a true if that has
been removed because maybe those don't
match and you want to a specific
functionality here. Otherwise you can just pass
in the key and then you will actually get
the return as well. So you will get a last, last store of value year. So this should now say Paris. And after that, brands is
actually, as you can see, and after this is basically
removed from this map, that's a very interesting
idea of maps. They can be incredibly useful. However, it is, of
course sometimes it's hard in this
abstract sort of ways when I just show those where you can really use them. Using these data types, sometimes can be, well, it's not an exact
science, right? So sometimes you want
to use something. I'm not sure if this fits. Once again, just try it out. Steve works and then
you're going to be fine. And then last but not least, what we're going to
take a look at sets. What sets, as I've mentioned, are things that are used heavily in the
codebase of Minecraft. And a set is just a collection, a collection that
contains no duplicates. Well, that's the most
simplest definition of a set. It just is a, well, a list or a collection that
doesn't contain duplicates. So a set, for
example, of string, we could have this as
usernames, for example, with each issue which is equal to a new
HashSet in this case, then you can see this has also been imported
and now this has turned into a story here
because all of those are in, under the util package. So it actually doesn't have
too many imports here. It's sort of does
that on its own. That's very nice. So now we have a
set and we can of course add to that
user names dot add, for example, cotton job. Or we could say
usernames dot add, nano tech right here. And then we can say, well, okay, fair enough, This
is really cool, but what else does a set do? Well, once again,
if we now want to add something twice, so you can, for example, say something
like usernames add, let's say FV, right? And then I duplicate this, and I want to add it the
same name twice, right? We're actually going to
get returned eight faults. Here we get a true,
here we get a false because this is
already in there, the string is already
inside of the collection. And because it contains
no duplicates, we can only ever have it once. If I actually all this, you will see that the
first one is true because of course F or V
was not added yet. And then after it has been added and we try
to add it again, we're going to get
a return false. So that's a very interesting. Over all the sets, you can't really call individual things
inside of the set. The set is really a collection that should be used
sort of together. And I just wanted to just gently introduce the sets here just so that you've
heard about them. So once we see them inside
of the game basically, or inside of Minecraft code, then you're not going to be
completely caught off guard. So the last section here, arrows you might
run into, right? So that's always a, an
important thing though. You can just, let's
just do this. Uncomment were arrows. I just saw where errors, please, not for terrorists
that, that would not be good. Lets actually copy this over for the sake of
argument and we're just going to change this C to a small c and n are
going to be fine. So the first one is the index
out of bound exception. So let's just do the following. Let's uncomment this. And first of all, this
is the question list. There you go. No worries at all. And if we do this, then you will see we get an exception here, the index out of
bounds exception. So this is a very, very similar exception
to the array index out of bounds exception
is just with a list. That's pretty much all there is. So we tried to pass in an index into the getMethod that
doesn't exist for lists. So of course, when we
only have two elements, the first one is of index 0, the second one is of index one. So very important
here that of course, passing any two would
not work, right? So that's the first exception. And then, well, the other thing is not
really an exception, but it is going
to return a null. So if we pass in a key into
a map that doesn't exist, we're going to get a
null returned, right? And that might lead to
an arrow down the line. So if I do this, then you
will see that if I do that, we'll get a null at
the bottom here. And this is basically
right, of course, Malta, we don't have that in our
country to capital Mab. This is actually going to
get us returned a null. Therefore, it might be
very valuable to see if it contains a key before
you actually try to get it was great. Getting returned a null is
not the end of the world. Of course not over if you then, if you don't expect
this to be null or you don't handle this to
be null possibly, then you might run
into some issues. Well, those are some of the
errors that I definitely wanted to mention here as well. So those would be, well, the sum of the collections. Of course, there's plenty more, there's plenty more datatypes
that you could use. You know, there's
not only list's maps and sets, There's plenty else, but for the time
being is going to be enough to basically
get you started. So this would be it for
this lecture right here. I hope you found this useful
and you learn something new. If you did, I would very much appreciate a review from you. Otherwise, I will see
you in the next lecture. So, yeah.
24. (Java) Java Object Oriented Programming Explained: All right, welcome back to the Java introduction here
for Minecraft modeling. And in this lecture, we're going to be talking about object oriented
programming. And as you can see, we are actually on PowerPoint.
In this case. We're actually going
to have a little bit of a PowerPoint
presentation here. So let's actually
just start with the idea of what is this
object-oriented programming? Well, in this lecture,
we're going to go through a little bit of the
theory and some of the terms that you
will well basically need to familiarize yourself with in order to know what is
going on and to understand the parlance when
talking with people that know programming and when I continue along with this, so especially in
the Minecraft part of this lecture or this course, you're going to see that
I'm going to basically always use the terms that
are necessary to use. So classes, methods, objects, stuff like that, and you
should know what those are. But the first thing
that we can think about is everything is an object. Okay, let's, let's store
that as an information, as a piece of information
and we can create custom objects with
custom functionality. Interesting, Okay, and these
would be called classes. So a class is, we can create an object from
a class, okay, Interesting. And then classes can
inheritable functionality, which would be methods,
variables from other classes. We're going to see two basically
Theory examples of this. And then in later lectures, we're going to take a look at some practical examples as well. But first of all, let's go through the very
important terms here. So a class, or classes are custom or
user-defined data types. But now we get actually
to the point where you can make your own datatypes. And those classes then
can basically be used as templates to create objects. And these classes include methods and fields which
are called members. Let's take this one
step at a time. So a class is a custom or user-defined data types
that pretty cool. And those include
methods and fields, which we're going to
talk about right here. These are members and how they can be used to create objects. Now what is an object? An object is nothing else than an instance of a particular
class with defined data. We're going to see an example
of that in just a moment. So this will get a much clearer. But first of all, let's
talk about the members. Those should be fairly
self-explanatory or way easier than the objects. So members of a class is
either a method or a field, and you can also call
methods functions. Now, people who are a
little bit more into Java might know that this
is not strictly necessary. So functions are tiny bit
different than methods. For our purposes,
it's totally fine. Some people still say functions, even though there are methods, it's going to be fine
and no one's going to go crazy with this. We don't have to be too
pedantic on this, right? So methods or functions basically defined
specific behavior for an object and methods can be called for specific objects. So one example of this, which we've already
seen is something like the size method for
a particular list. Of course, every
list is going to have the same size method. What is going to be returned is specific to a specific list. So for that object, but that's the general idea. Eagles or attributes as they are also called our
variables that are defined in the class that store some data related to that class. So for example, if
we were to have a person class that might
save a string called name, that should also make
sense and should be fairly self-explanatory
as this example here. And once again, all of
this we will of course also see live and in action, I believe next lecture
we're immediately going to start to jump in to
classes and objects. So no worries there at all. So let's first of
all take a look at the idea of inheriting stuff. So this, I want to, first of all preface
with the idea that if you don't fully get this,
that's absolutely fine. Inheritance is very complicated. I just wanted to mention this so that you have
heard it once before. So the idea is that we might
have an animal class, right? And that actually
basically inherits all of its functionality and all of its variables down
to two classes. So the two-legged animal and the four-legged animal class, and these are related
in the following way. The animal class is
the superclass of the two-legged animal and the superclass for the
four-legged animal. While the four-legged animal and the two-legged
animal classes are subclasses of the Animal class. You can always only
have one superclass, but as you can see, you can
have multiple subclasses. And then here we can
even go further down and inherit even a more stuff
and add more functionality. So you sort of go
from a very generic or very abstract,
very specific, right? Animal is a very
abstract category. Two legged animal. We're starting to really get
into more specific stuff, human and an ostrich. Now we're very, very specific. So that's one idea you
can think of, right? So let's think of a
dog class now, right? So we have a class
which is called a dog, and that might have
some attributes or some are fields, right? Which is going to be a picture, a name, and an age. And we're going to be
like, Okay, that's fine. That's okay, that there's good enough to describe
a particular dog. And well now we want
to create a new dog. So we want to create a new
instance of the dog class. We want to create a new object. Well, let's just do that. There we have it. Right now
we have created a new dog. Benji was seven years old, and here is a very
cute picture of him. Isn't that just nice? Yes, if I do say so myself, I think that this is a
very cute picture here, and this is a
particular dog, right? We haven't really
changed anything here. The only thing that
we've done is we basically created
an object rate. When we go back here once every dog has a picture, a name, and an age, and this is a particular instance or a particular object
of the dog class. Now let's just
create another one. For example here, Gracie with five-years old and also has a very cute picture right there. But as you can see, those are two different objects or two different instances
of the Dog class. However, they are both dogs. So this is sort of the separation
that I sort of want to get across when it comes
to classes and objects, that the class is the template. And then once you create
a particular object, that then becomes an
instance of that class. So that's sometimes
can be a little weird, especially for beginners. But no worries at all at once. We're actually going to start programming with this
eerie or when we actually put this
into practical use is going to be way more clear. I'm sure of it, right? But that would already be
the end of the lecture. Actually. The most important
thing of this lecture, let me just quickly go back here is this one right here, right? So this slide is probably
the most important one. The slides actually are
also available to you as a resource so you can download this as well. So
no worries there. So you do have access to both of these cute dog pictures as well. So that's actually going to
be a very big plus of course. Otherwise, this would be it for this lecture right
here, like I said, a little bit more
theory and the next lecture we're going to put
all of that into practice. So that would be it for
this lecture right here. I hope you found this useful
and neurons are the new, and I'll see you in
the next lecture. So, yeah.
25. (Java) Java Classes and Objects: All right, welcome back to the Java introduction here
for Minecraft modeling. And in this lecture
we're going to basically apply the theory that
we've learned last time. In the last lecture, We're gonna be talking
about classes and objects. So first of all, of course, we need to create a new class, a custom class now. And for that, we're
going to go into this project window right
here inside of our package. So this is the package, right? Net helped Monroe was the package that we created
or other I created. Hopefully this is your name. Then in your names package, you right-click new Java class. And then you're going to
call this the dog class, making sure that
the class here is selected and then press Enter. Now this year this window only appears for
me because I have a GitHub repository
associated with this project. If you don't have that,
that is absolutely fine. Don't worry about that at all. So I just wanted
to mention this. And now instead of
these curly brackets, oh, add members to this class. So for example, we could
add some fields, right? So we can say
something like adding, adding some fields, right? And then let's think back to the PowerPoint presentation
that we've seen, right? We had a public String picture. We were thinking
about a picture. We're just going to
say that a string that's totally fine
for the time being, a public string name. And then let's say
a public integer, which is the age variable. Now that's all fine
for the time being. We're once again going to
ignore the public here. We just have to set
this to public once again in a very,
very short time. Actually, we're going to
see the access modifiers. So that's literally the
next lecture as well. And then we will understand what this means for
the time being. We have to set it to public. And what we can also do is, for example, something
like a public void. And then we'll for example, so we can make both fields
and also methods, right? So this is a method
here, and this is, of course this was fields here. Then I can do something
in that method, which is just for the
sake of argument. I'm just going to say just
at that, at this time. Okay, So now this is all set up. Now, what are we doing
with his dog class, right? How are we making a
new object out of it? Well, we can do the following.
You could say dog, right? Logo. And now this might at first we can say something
like this, for example. Now this might, for the first
time be a little confusing. Maybe like wait, but I mean, I sort of should
recognize this, right? This is just a normal variable that we have declared
here, right? Is just a type of dog. Now, like I said,
because you're now starting to use custom classes. So custom basically datatypes. This might be a little weird, but this is just the same as
if I were to do this, right? Really when we think about it, it's just a variable. This time of type dog. And another way I can actually initialize this is I can say new dog and you can see that it actually generates this
automatically for us. And now I have
created a new dog. So this is the general idea of how you can
create a new object. So you need to use
the new keyword, which we've actually seen
previously a few times. For example, with the scanner, we had to create a new scanner. And now that also makes sense. Scanner is just
another object or another class which
we can instantiate a new object or a new instance of an inch
can basically use that. That's sort of the idea. Now, the real question
though is that okay, Like I have this dog here, but like i the fields, what are, what are they now? Well, let's just try it out. Write system out, print line, Togo, dot name for example. Let's just see, well, what is that dog was named as a dog? No, actually the
name is null because we have not assigned
any of those values. Therefore, they are all null
because here we have used, right, used the default,
default constructor. So what does that mean? Well, the constructor
is another part of a class which
is very important, and this is actually
not classified as a member in this case,
this is something else. So the constructor,
as the name suggests, is something that constructs an object from this template, from this class, right? So the default constructor, every class that you create
has something like this. So it is written like this
with an access modifier. And then the name of the class immediately followed
after by parenthesis, which have nothing in them. And then basically just
almost like a normal method, just without a return type or rather the return type
is the same as the name. You can also think
of it like this. And this year is the
default constructor. And this is what
we've been using for this doc here, right? So this is the default
constructor now. And the real issue here is of course you can see that
nothing happens in it. So none of those things have
any value assigned to it. We can, however, also create
our own constructors. Right now we can create
a custom constructor. So for example, public
dog, string, picture, string name, and age, write something like this and
then we can assign those. So this picture equals picture, this.name equals name, and
this dot age equals age. And you will see,
all of a sudden, everything still
works totally fine. Now the first thing
you might ask, what is this, this keyword? Well, this refers to the object
that we're creating rate. So for example, you can think of it when
we call those Wolf method. If we were to call this, we would have to call this
on a particular object. So every time I use this
inside of this method, that particular object is
basically being referred to. So you can think
of it like this. Same way with the constructor. When I use this, that particular object we're just
now creating is being referred to because the parameter name here has
the same name as the field. They don't necessarily have to, but in this case they do. Then we want to use this
tool very much specify, hey, this is the field
and as the parameter. And now what I can
do is instead of creating one with the
default constructor here, I can actually do something
like, for example, dog and Benji, let's say
equals new dog, right? And then you can see if
I wait a second here, can basically take
a look at this. There it is. So now we actually get
a suggestion here, either no parameters or string, picture string, name,
string or int age. So we actually get
the suggestion here. Let's say Benji dot PNG, right? Let's say Benji for the name
and then seven for the age. And you can see this is
pretty much almost the same as just a
normal method call, but in this case it actually
creates a new object. And then we can do
system out print line. Now Benji dot name, and then let's say Benji dot h. And now this will output is Benji and a seven
as you can see. So that's actually
really freaking cool. There's one more thing. Let's just say for the
sake of argument here, when we have a lot
of fields, right? Sometimes it can be a
little tedious to put all of them in here
in the constructor. So what we can do is we can also right-click
generate constructor. Then you can just select all of the fields that you
want to initialize, you'd see by the constructor
and we say, okay, and this generates
exactly the same thing that we've done previously. I wanted to mention
this because that can be sometimes very useful, right? So there's a lot
of things in here that can be generated
automatically. So keep that in mind as well. But let's also
make another dark. So just to illustrate this, so dog Gracie is equal
to a new dog, right? This is the greasy
dot PNG, Gracie, and I believe Gracie was
five or five is fine. Now let's actually
output that as well. So I'm selecting this Control C, Control V to paste it
in and then changing the variable here and
sort of Benji to Gracie. And this, of course now also works and it's going to
have different values. So once again, those
are both dogs raid, but they are a two
different dogs. So there are two
different objects. And I hope that the theory
from last lecture sort of carries very easily over to this illustrative
example here, once we're actually using it, it hopefully becomes very clear. And we will also do is we'll just change this
wolf you're actually to this dot name, just waft. Then what we can see is also that when we call this method, once again, this
method in particular, we actually have to call on
a particular object, right? So we actually have
to save Benji dot or racy dot should
all make sense. And now what's going to
happen is that it's not going to be the same for each
one of them, right? So Benji just moved
or Gracie just Swift. So this once again refers to the actual object where this is being called on so to
speak. So that's the idea. And then one last
thing that might be a little bit different
or a little weird. It's like, well, wait a second. Benji dot age, right? Okay. Can I just like assign this to something? Yes, I can. Well, that's very
interesting, right? All of a sudden, right? Benji has become 10 years
old and you might be like, Wait, that's not, that doesn't
make any sense, right? Is only seven them. That's not right, Is that yes, this has now saved. And this is something that
we're going to look at the next lecture when it
comes to access modifiers. Because all of this being public basically
means that, well, you can change this and access it from
anywhere in the code. And that is sometimes
not what we want. You sometimes want to restrict the access to certain fields, variables, methods, all
of that jazz basically. And like I said, we're gonna take a look at
that in the next lecture. However, this would be it
for this lecture right here. I hope you found this useful and you learn some of the new. And I'll see you in
the next lecture. So, yeah.
26. (Java) Access Modifiers: All right, welcome back to
the Java introduction here for Minecraft morning
and in this lecture, we're gonna be looking
at access modifiers. So you will need all of the
code from the last lecture. No worries, of course, this is available to
you as a resource. So definitely take a look
at that and then well, we'll just jump right in. So the idea was that, well, we had all of our fields
here as a public, right? So everything here was public. And we were thinking,
well, okay, so how are we going to use this? Or how will we be able
to not make some Thiel's changeable or like modifiable
here outside of this class. Well, let's just go
through all of the, well, let's say
access modifiers. So there's public, There's protected, and there's private. Then there's two more things
that we're also going to see which is static and
the final, well, it's not really
access modifiers, but they're also sort of
modifiers that you can put in front of fields and, or methods. So when it comes to making
the name, for example, protected here, this
actually will do nothing. Now the reason why
it does nothing is that a protected field or a protected method can be
called in the same package. And because the dog and the main class or in
the same package, we can still refer
to this field here. And the protected
keyword also works or classes that extend from this. So basically, assets that
inherit from the dog class would now also be able to
use the name variable. What about the age variable? Well, let's do the following. Let's make this private. And all of a sudden we
can see related problems, right? Everything's going crazy. Everyone is freaking
out because all of a sudden we can
actually access this because a private variable and only be accessed
in the same class, meaning that we can't
directly access this. However, we can do
something which is going to be a method, returns this value. So this is what's
called a guitar. And what we can do is
we can right-click Generate and you
can see that we can actually generate
getters and setters. Setters are pretty much the same thing where you
set the variable rate. So where you can
basically set this and a getter is just very much
the thing where you get this. So I can select the age
variable and say, okay, and see it generates
a method for us public integer because of course that's the return
type here, get age. So this is the way
that you would phrase this or the
name of this was usually get and
then just the name of the variable or the field. And then we return
age in this method. And then instead of
calling it directly, we can say At age, at age, if age. And now here's the
interesting thing. Of course this does not
work because we can't assign something to a method. Therefore, this does
not work, right? So we can say doesn't work. So we can't assign a new
value to this age variable. So that's really the cool thing. And then we can also have a
static and a final keyword. Okay, What is that? Well, static is going to be very interesting. So when I have a
public static int, and I'm going to
call this the dog to human ear multiplier. Multiplier, which is equal to seven
if I'm not mistaken here. And this is what we can
think of it like this. Does every dog have to have
a specific field to them, which is this multiplier. I mean, if we're really honest, not really, right, when
we think about it. The doctor here, dr. Human year multiplier really is something that works
for every dog. Exactly. That's why it's static. Is static variable or a static method and actually be called on the class and it doesn't require a specific objects
to be created. So what I can do is, for example, instead of
calling Benji that HE, I can say dog, dot, dot, human, doctor, human
year multiplier. You can see I call this on the actual class
and not the object. So that's a very
interesting thing. And that might be breaking
your brain a little bit here, because first of all, getting into static is a
little weird and it seems very counterintuitive
at first glance maybe, but no worries at all. When we're really using this, It's going to be fine. And the general gist
is that, you know, if something static
usually is something that is the same for all of
the objects, right? Because once again, you, Dr. human year multiplier
doesn't change from Dr. dog. Now let's ignore the
fact that maybe it changes if there's different
breeds and stuff like that. Let's just ignore that. It's just an example
here, of course, right? And then the question also
is, well, wait a second. This really doesn't
need to change, right? Because now we have the same
issue once again, right? So dogs, your multiplier and
all of a sudden equals ten, we can just change this
and it's like that's not really smart, right? That doesn't have to happen. Well, luckily there's the
final keyword as well. And that makes it
so if I actually press Control Z to go back, you can see that cannot assign a value to a final
variable because one is a final variable than the value can never change after
it has been assigned. That's also very interesting. However, there is of course, a distinct difference between a private and a final
variable rate. Because a final variable we could in theory
change, right? We could say something
like, for example, let's just make a
public, public void. Public void birthday, right? For a dog, where we
say age plus plus. But that still works even
though it's a private, we can change this variable. We could never change this
variable once it's final. So that's the difference there, which is hopefully understandable
in that sense, right? So let's actually take another look at the
following rate. So we can also then say
something like, Well, I mean, let's just add a, let's
just add one more thing, something like a public int. So getAge in human years, right, where we can use the multiplier
here that we're going to return the age variable
times the doctor here, human doctor, human year
multiplier right there. Now we can just call this usually you can of course
also say dog dot this. We don't have to do that because we are inside
of the dog class, so we can just call
it without that. That's very much
personal preference, just whether or not
you want to do that. But what we can then
say, for example, is we can then say Benji
dot get age in human years, and that will then
be, what is that? 49? Yeah, 49. There you go. So easy enough. But that's sort of
the general gist. We have public, protected and private for the
access modifiers. And then there's also
static and final. And we will definitely be, we're going to encounter all
of those in future lectures, especially when we get
into microwave modding, that's going to be
very relevant here, especially something
like the final keyword and the static keyword, those are going
to be used a lot. Once again, if they are a little bit unclear, that's
absolutely fine. No worries at all. Once you start
working with them, it's going to get away clearer. And once again, I
can very much just advise you to try out
a bunch of stuff. Just fire up intelligent, make a bunch of classes, and just try out
a bunch of stuff. Make a few classes, make a few fields,
whole bunch of stuff. You can't break anything. Not really. So it's just really a matter of being open to
experimenting basically. So that's very much an
advice that I can give you. But otherwise, this would be it for this lecture right here. I hope you found this useful and you'll
learn something new. And I'll see you in
the next lecture. So, yeah.
27. (Java) Inheritance & Polymorphism: All right, welcome back to the Java introduction here
for Minecraft modeling. And in this lecture we're
going to be talking about inheritance
and polymorphism. Well, first of all,
a polymorphism and inheritance for very
large words rate. But overall, they're concepts
are fairly straightforward, especially polymorphism
isn't that crazy of a concept actually? Now, another disclaimer
I want to say right out of the gate is that
because this is an example, the actual sort of concept might not be a
100 percent transparent, which is absolutely fine. By the way, this is
something that once again, has to be built with just trying out a
bunch of stuff, right? I usually have think
about the same. I hear. I forget. I see. I remember. I do. I understand. So there always has to be some doing that goes along with it. Whatever the case may be. Let's say, for the
sake of argument, someone says, You know what? I really want a
cat class as well, because I'm not a dog
person, that's fine. That's totally okay. Well, let's add a cat
class in here as well. So a new class, cat. And there you go. Now, what you will quickly
realize is that, well, like let's be honest,
the cat renal should also have a picture
and a name and an age. And you might be like,
well, I mean let's just copy those fields over. And then you might be
like, well, I also need to get age that the getter and then the
wolf, maybe the baby. I'm Mimi Chao and you
come to a point where you're copying
over a lot of code and usually tabbing
over a lot of code is a sign that you can
optimize something. Now, premature optimization
is the road to hell. I understand that. However, sometimes this just makes a lot of sense where you have like this copied over, this copied over, this
copied over, and it's like, let's just make a method or a class out of it
or something else. And that something
else is actually going to be a superclass for the cat and a dog
being the animal class. So we're going to make a
new class called animal, and that is now
going to store this. So I'm going to cut that
out with Control X, Control V to paste
this in right here. And now all of a sudden, what we can do is we can extend the dog class by
the Animal class, meaning that the, let's
just do it right? So we're going to inherit everything from the animal here. We're going to say
extends animal, and this now is inheritance. So the dog class is now
the subclass of animal, and the animal is now
the superclass of dog, meaning that everything
here has been inherited. Now I can actually
literally delete this. The only thing that
is going to turn red is going to be the age, because I actually have
to make this protected here so that it can be
accessed in the subclass. But we've seen this in
the last lecture where I said that when it is
a protected variable, then you can actually access it from the subclass as well. So that's sort of the idea. Let's actually get
rid of a few of these comments here as well. We can also get rid of
the default constructor that is also no
longer necessary. So now we have this
animal class, right? And that's pretty cool. Now, you can see that
via this Dog class, everything here is being set. However, we want to make
sure that everyone, that every class that actually inherits from the
Animal class also work. So we're just going to make
a new constructor as well. So right-click,
generate an instructor, making sure that
everything here is selected and then press Okay. And then we're
immediately going to be greeted with an
arrow right here. Because if we hover over this, you can see there is
no default constructor available in a net
com zoo animal. What does that mean? Well, when you actually add
a specific constructor here, that is not the
default constructor. The default constructor
no longer works. So once you have one
constructor that is, isn't the default constructor, you have to add it
like manually again. So I could, for example, say public animal, right, with nothing in it, right?
So something like this. However, of course that doesn't. Now, you know, that once again, we don't
actually want that. So this is going
to be deleted and then the default constructor
no longer works. And now what do we
have to do here? Well, what we can do is we
can call the superhero, and this basically
calls the constructor. So we can actually put
in PI, as you can see, it actually already suggest, say let's just take all of the parameters here and
put them into year. And now this super is now calling the Animal
constructor right here. This is actually
perfect in this case. Then something else,
maybe for example, the, both the get age and birth. They could also be in the
animal class, for example. That would also
work totally fine. And the rest here is
actually totally okay. I'm going to just make this
a little bit different. So I usually want
the constructors at the top of the class, right? So first-come the fields and then the constructors and then all the methods and
stuff like that. Although the order of
course is something that is completely up to you, but this is usually
the convention 0. Now what would happen if
I now were to say, well, the cat now also extends
the animal class. We'll, we're gonna
get an error here, which is there is no default constructor available in animal. And then we have this
were possible solution, which is the create
constructor matching super, which is something we're
going to see a lot of times. Because if you click this, you will simply get a new
constructor here with all of the needed parameters
that you need in order to call the constructor
of your superclass. And that's pretty much it. That's really freaking cool. And now we can actually
create a new class. You can see everything
here works. So we can say the cat
whiskers is new cat, right? So new account here. And this is for example, then whiskers dot PNG. And then the name is going
to be whiskers, right? And then maybe, maybe they're like 12 years old or
something like that. And then we can simply
call, for example, whiskers dot ns can see I
can call everything get age. Now I actually have access
to the age variable here. This is simply the case because we are in
the same package. This usually should
not be the case. I just wanted to
mention this because usually when you actually are extending a particular
class is very unlikely that you are
in the same package. So just wanted to mention this. And that is a, well, I wouldn't say a limitation, it just is a reality basically. But now the real question,
communicating about now, what is so interesting
about having this? Well, let's think
about this, right? So we have the wolf
method here, right? Let's just delete
that or actually let's be even smarter rate. Let's just copy this
or cut it out, right? And then add this to the animal. Now first of all,
you're going to say, wait a second, not every
animal, Wolf's right. Yeah, that's fair enough. So let's just call
this makes sound. And then we can say this name, just, let's say
just made a sound. So we can't do this. And other really
interesting thing is this is defined in
the animal class. However, I can still say
something like whiskers, dot-dot-dot makes sound right? So because whiskers is a
cat and a cat is an animal, I can call all of the
public methods here still. And if I call this, you can see whiskers just made a sound. So that's pretty cool. But now we're going
to supercharge this because while every
animal does make a sound, a cat makes a different
sound from a dog, right? So what we can do is we
can actually override the implementation of this
method in the subclasses. So that's pretty frequent, cool. But what we can do is we
can either start typing the actual name of the
method as you can see, or we can write an
override, right? We can start to write that. And then you can see all of the possible methods that we
might be able to override. We're going to of course,
choose the mic sound method here and it will get
this annotation added. This is not strictly
necessary, however, it is very valuable
for you if you have this and I definitely
recommend keeping it, because if you go through
the actual classes, you can very clearly see, okay, So this was overridden from one of its superclasses. So that's very important. Then I'm actually going
to just take this one. So I'm actually going
to take this and just modified a tiny bit, right? So I'm going to say
this, Just me out. Let's say I'm gonna
do the same thing. Copy this over to the dog here. And I'm going to say this name, just waft the slurry, have something different here. And what you will then
see if I actually call, for example, Benji,
don't make sound. And I'm then also going to
Gracie, don't make sound. What will happen now? Well, very interestingly enough. Meow, woof, woof. So as you can see, the overridden methods
are now being called instead of the one by
the actual superclass. So that's really frequent, cool. And now this is sort of the
idea of inheritance, right? We can inherit both
methods and fields here in this just makes
it so first of all, everything is a little
nicer separated, and then also we don't
have duplicate code. Now the real question is,
what is polymorphism? Polymorphism is a
big word for a very, very easy to understand concept. Actually, in the very easy to
understand concept is that a dog is simultaneously a dog and an animal
should make sense, right? So you have a dog class is both a dog or an object of type? Dog is both a dog and a animal. Fair enough. Okay. What does that mean? Well, I can save this
in an animal, right? So I can save animal, animal
is equal to a new dog. Let's just say jeoneun dot PNG. Jenny. Maybe Guinea is like 15. All dark, but that's okay. And now what would
happen if I do this in a mole dot make sound. What is going to happen now? Well, I mean it's an animal. So obviously it should say Jenny just made a sound, right? Because that's the
most logical thing. Wait a second in the background,
it's a dog. Exactly. Then he just moved. Because even though we
save this in an animal, polymorphism makes it so that the dog object can take
on multiple forms, or any object really can
take on multiple forms. That's what basically
polymorphism means. Multiple forums in a very
loose translation, let's say. And the great thing
what I can also do is I can make a
list of animals, for example, rate
called animals. And I can make this
a new ArrayList just for the sake of argument.
Let's import this. And then I can just
say animals, not add. And I don't only have to add an animals because of
course Benji is a dog, but the dog is also an animal. And then I can also add Gracie, and then I can
also add whiskers. So as you can see, even though they are all save
as animals, right? If I want to get those back, animals get one, for
example, make sound. So it makes out there, yeah. Oh, right. And the get method here
gets you back an animal. But once again, we've
seen that calling a method on this
actually caused the, what, what do we say the most specific method that it can. So even though this is
being saved as an animal, Gracie is being saved
as an animal here, the mic sound is going to
make it so that Gracie, just, so that is pretty cool. Once again, if you don't clearly see the application for this,
that's absolutely fine. This is a very abstract
just introduction for this, of course. However, this would,
for the time being, be it for this
lecture right here. I hope you found this useful
and you learn something new. And I'll see you in
the next lecture. So, yeah.
28. (Java) Interfaces & Abstract Classes: All right, welcome back to the Java introduction here
for Minecraft modeling. And in this lecture we
are going to be taking a tentative look at interfaces
and abstract classes. So we're actually going to start with the abstract class first because that's a very
illustrative example actually. So what we can think
about is the following. What is a dog? Well, I mean, you've seen
have you seen a dog before? Yes, of course. I mean, either as a picture or somewhere in the world you might
have seen a dog. Have you seen an animal before? Now you might say is that well, I mean, I've seen a dog
before it but no, no. Have you seen an animal before? And you're going to
meet and fuse, right? Because it's like, what is
an animal at the moment, what we can do is
we can say animal, let's just say a is equal
to a new animal, right? With, for example, just like x, p and g x and that just like 10 years old or
something like that. And then you might be like,
what is an animal like? What does that represent
really rate in animal is a very, very
abstract concept. And abstract classes, right? See the congruence there, right? So really we shouldn't
be able to create new objects from
the Animal class because what really
is an animal like? Things can be classified
as an animal, but the object animal
doesn't exist, right? So what we're gonna do
is we're gonna make a public abstract
class out of this. And you immediately
going to see that we have a related problem, which of course is
exactly this right here, because we can't create a
new animal if it's abstract, you can see animal is abstract, cannot be instantiated,
meaning that we can't create objects from in abstract class in
the cat and the dog. Literally nothing has
changed because of course, the animal is still at
everything here, so works. Now what we can also do and
that is really cool for an abstract class is that we can make certain methods abstract. For example, the mic
sound method right here. So we can just basically
just, let's delete this. And then what's
going to happen is that we can say public, abstract, void,
make sound, right? And now look at
this, we just ended. So we still have to have a
normal method signature year. However, the actual
implementation is left to the subclasses. And if we were to
not override this, what you can see is
also would find that class dog must either
have declared abstract. So either this has to
also be an abstract class or we have to implement
the abstract methods from animal that can just
hover over this into the implement methods and then this will get
added as well. So I'm just gonna go
back with Control Z here and then everything
just works fine. So that's sort of the idea
of an abstract class. And a interface is amine, something that's very
related to this as well. So what we're just
gonna do is we're just going to add an interface, so a new class here, and then we can
select interface. We're going to call this
the petal interface and the IP edible interface. You're in interfaces. We also just define
a method signatures. So void, pet For example, rates of symbol like
this, and that's it. So no access
modifier, just this. And if this interface is
implemented now for example, in the cat right implements, we have the right,
then I palatable than what you will see is a very
similar error than before. Implement methods, the
method and the ego. And now I have to
have some kind of implementation in
this cat class. Why do we have
interfaces and classes, you know, couldn't I
just make another class? Edible animal and
stuff like that? Yeah, of course,
that also works. But the limitation
here is that you can always only extend
from one class. You can't, however, implement multiple different interfaces. So that's really the
interesting thing here. And then also the interface basically is what
the name suggests. It's an enables you to interface with something
in a particular way. So when something
implements an interface, you sort of have a, I mean, you could think of it as
like an unwritten contract that everything inside
of this interface is definitely has a
certain implementation. So for example, I could say
something like, you know, just this name was pet,
something like that, right? And then I can just copy this over just for
the sake of argument. I'm going to also implements
this in the dog here. So I pedal and I'm just going to add this
and then we're going to say something like
was scratched and scratched behind the
ears, for example, right? And now what I can do is
instead of, for example, making a list of
animals, now I could, for example, also make a
list of iptable, right? So now we have these pets
rate new ArrayList of that, and we can add those
as well, right? Pets dot add. And then let's just say Benji, and then let's just
say whiskers, right? And now we can make a
petting zoo if we wanted to. That's really cool. And it doesn't matter. Once again, with polymorphism, it doesn't matter if
they're saved as I petals. Once again, their actual
real implementation is being called When
we were to call, for example, Pets dot get one. Then what would
happen is that of course the actual
implementation is being called whiskers was
patched instead of whiskers was scratched
behind the ears. That's sort of the
general idea here. Once again, interfaces
abstract classes. Sort of in the same vein as the inheritance and the
polymorphism in general. Where it might be a little weird because in these examples, it sometimes it's hard to
really get across the idea. Once again, trying
out a bunch of stuff really can help or
following the assignments, also a worthwhile endeavor. But otherwise, for
the time being, this is going to be for
this lecture right here. I hope you found this useful
and learned something new. And I'll see you in the
next lecture. So, yeah.
29. ASSIGNMENT 3: Update Trivia Game: All right, Welcome to
the third assignment here for the Java introduction. And this is actually a fairly
straightforward assignment. As you can see,
it's not that long. Over once again,
the time it takes it and make this
might be round about an hour or so as usually a very conservative
estimate as well. So there's a little bit
of wiggle room they are you might be able to do
it in 30 minutes, right? No worries at all. But for the time being, let's just go through here. So trivia game with
classes and objects. So once again, we wanted the
same trivia game that we've been making in the last
two assignments as well. I basically want you to modify the trivia games that it
uses classes as well. Now this can be in any way, shape, or form that
might be the case. Think about like
how you could make some custom classes that, you know saves the answers and the questions
may be together. Maybe you can use a list,
something like that. It really is up to you how
you want to structure this. But just think about
how you can make this way easier with
classes and objects, and then just try that out. Of course, once again,
the solution will be available to you
once you're done, I highly suggest really taking a crack at it and
really trying this out. And I guess I'll see
you in the solution.
30. SOLUTION 3: Update Trivia Game: All right, Welcome
to the solution for the third
assignment right here. And well, I mean, I guess let's just take a look. You can see I have
actually only two classes, a trivia game class
and a trivia class. And the trivia game
class basically contains all of the
logic and the game loop. And the trivia class contains the questions and the answers. So let's take a look
at the trivial class. First of all, let me
zoom in a little bit here so we can see I
have a string question, a string answer, and just a constructor that passes in both of these shrink
variables here. And then I have a
bunch of methods here, right is correct answer
would basically puts out a Boolean and also makes sure that everything is in lowercase. So the input as actually being
put to lowercase, though, that you can basically put in uppercase letters and it still counts as the
correct answer. Here we have the print
question, the print answer. We also have validated answer
which then brings a, Hey, this was a correct answer, or this was an incorrect
answer as well. And this is pretty
much the trivia class. Once again, if this
doesn't look exactly like yours, that's
absolutely fine. This is just one example
of how to do this. And then same with the
trivia game, right? We have a list of trivia here. So those are all
of the questions basically which are being
populated right here. So this is actually called, sorry, in the start
game method, right? So this is the first
thing that happens, populated trivia list. And this is done right here, where we just have
a new ArrayList and then we add a bunch of those trivial right there
to the actual list here. And this is really cool
because this now could also be done via a reading in, from a file or, you know, downloading
stuff from the internet. So this method here could very easily be replaced
with something else. And this is really
the power when you do this separate
in these classes, right before we had those
individual string variables, there was no way that we could
change this very easily. In this case, we could change this wooden database onto that. You could put, like I said,
something on the internet. You could do almost anything, read it from a file. And that's really the thing that you wanna do with classes. You want to make this sort of generic in the sense that you can very easily add and
subtract stuff from it. Usually add, of course, right? And then there's a bunch of other stuff here as well, right? So the game loop is the
main thing where we have this infinite while
loop right here, where we just go through
each of the questions, validating the
answers by getting the user input and
then increasing the score if the answer
is actually correct. And then we will just print the score after each
of the questions. Then at the end here we asked, Hey, should we abort the game? And if the user says yes, then we just break
out of it and print the final score at the
end of the game as well. That's pretty cool.
All things considered, this is pretty much
all you really need. Once again, if your
answer differs, no worries at all. But hopefully you have
this answer that you can walk through and sort
of try to understand, okay, well, how would I do this? Why was this done? You know, methods, okay, That's very interesting classes. So that's sort of the idea here. But for this solution,
this would be it. And I hope you found this useful and you learn
something new. And I'll see you in
the next lecture. So, yeah.
31. ASSIGNMENT 4: Bank Management System: All right, Welcome to
the fourth assignment here for the Java introduction. And in this assignment, you are supposed to create
a bank management system. Now overall, this
might first of all sound very complicated,
but no worries. I'll step you through the
idea that I had here. So the bank management
system should have something like
these components, a person, a bank and
a checking account. And then to open a
checking account, you should go via a bank, right in it might require a
certain initial deposit here. And the individual components or classes that you have rights that a person
might have a first, middle, and last name, and age. Maybe it's something like
a social security number is not necessarily required, but you know,
something like that. A bank might have a
list of customers. Their checking accounts may be a maximum overdraw mount,
something like that. And then a checking account might have the current value and the methods for taking out
and depositing money overall. That's sort of the general idea. There's a bunch of ways
that you can approach this. So I'm very interested to
see what you come up with. And of course, the solution will once again be available to you. I think this is probably
a little bit harder. I would imagine something like 1.5 hours is probably
best to set aside for this so that you
can really dig in and try to understand and make something
that's pretty cool. So good luck.
32. SOLUTION 4: Bank Management System: All right, Welcome
to the solution for the fourth assignment. And as you can see, we have three different classes, pretty much like I said
in the actual assignment. And well, let's just go through. So we have a person class which is fairly straightforward, read first, middle
and last name, and an age or private this time, and basically accessible
via ghettos here. And then we also have
a boolean right here, which basically just
returns whether or not a person is older than what
has been supplied here, which is very interesting. And the account here is
also interesting, right? We have a balanced,
we have account ID. At this point is not actually
really used all that much, but it's very possible
that you can do something with this
as well and then an account holder as well. And that is used in the bank to basically get a
specific account here. So we can see ever have a
list of accounts, right? And the way that we
can get an account is get account by person. But that's the way that
I personally right now to get the accounts here. And the rest is pretty much
does the bank account, right? So basically, if you can open this account, is that the case? And it basically validate
whether or not someone is 16 or older than 16, and also whether or not the minimum deposit
has been actually hit. There is actually a little
bit of a bug in here, right? In this method, that's
very interesting. You can try to find
that yourself. Just a little bit of an
interesting exercise as well. But otherwise, you
know, overall, this is once again just
one example of this. We can just take a
look at this, right? So what we're going to have
is I have some code here, so nano tech is
not old enough to open a bank account
and then ten, say euros or dollars
is not enough. We need at least a 150
and then we actually get the balance from Maria's
account, which is 2000. Then trying to withdraw
3000 doesn't work because the withdrawal
amount is actually 500 or the overdraw basically. And that is why
this doesn't work. So that's sort of the
general idea here. Once again, There's
plenty of ways that you can do this if it looks
completely different to yours, but you're still works,
that's totally fine. Regardless of that,
I hope that this was a useful exercise or
useful assignment two, you end and I'll see you in
the next lecture. So, yeah.
33. (Java) Anonymous Classes: All right, welcome back to the Java introduction here
for Minecraft modeling. And in this lecture,
we're going to be looking at the anonymous class. So what is an anonymous class? Well, when we inherit
from something, so we think back the
dog class, right? That had a name, right, and inherited from
the animal class. And now what we can
do is for example, we can make a
person here, right? So I still have the person class from the last assignment. So for example, personnel
is equal to a new person, but it's so nano attack
and eight years old, let's say just for the
sake of argument here. Now, this is all fine. If now I wanted a class that extends this person class,
which is a manager. Now the only thing that we're
going to do is actually just make it so that when
you get the full name, you're gonna get the name like Manager printed
out as well. Okay, So, so how
would we do this? We'll make a new class, right? And all of that. Well, let's just say that we actually only
really need this one. So what we can do is we can
make an anonymous class. So we can say person manager
is equal to a new person. But let's just say
John Smith, right? Let's say 42. And then we end this. Now what we could do
instead of ending this with a semicolon,
after we're done, we're actually going to
make a holy bracket and end the ending curly
bracket with a semicolon. You can see that
there's no arrows here. Because inside of here
now we've created this anonymous
class because it is a class that extends
the person class. However, it doesn't have a name, therefore
it's anonymous. And when we can do
is, you can see if I start writing
an override here, I can actually override
everything that is inside of the person class
that is over writeable. Prefer example, I can say fullname and then I can say
something like Manager, and then plus get the full name. So this is now what this
particular anonymous class does. And then I can, if I
system out print line, for example, nano
dot get full name. And then I can also
do the same for the manager dot getName. You will see that nano is
just going to be nano attack. And then it's going to
be manager John Smith because we've added this
manager right here. This example might not be
the most illustrative. I find it very hard to really show you a very
illustrative example of anonymous classes. It's usually the further
in you go, you know, with interfaces and inheritance
and stuff like that, it becomes very hard if
you're not in a very, in an actual
environment where you actually have some classes
and some functionality. But this is definitely
something that we will see in the modelling section
of the course as well. Because there's plenty of stuff here that's going to
be needed for that. But whatever the case may be, at least you've seen
this even if we are not going to go into too
much more detail here, I hope you've found this useful and you learn something new. And I'll see you in the
next lecture. So, yeah.
34. (Java) Enums & Advanced Enums: All right, welcome back
to the Java introduction here for Minecraft modeling. And in this short lecture, we're going to be taking
a look at enums and also advanced enums,
overall, enums, you can think of those as a certain data types that
have predefined values, and you can only assign those values to that
actual variable. So let's just
create, for example, a difficulty enum, right? So we can make it a class and then just change this
to enum right here. And then the way that an enum basically is structured is it has the actual values that it can take it
just inside of it. So for example, easy,
medium, and hard, for example, as the difficulties
of a game could be. And then to create a
new variable for this, it's pretty much just
once again difficulty. Then let's call this the
game difficulty, right? Under like this. And then this is equal to 2. Assign this, you can
see difficulty dot, and then we just have
these three values as possible options. So let's just say
difficulty medium here. And we can then normally
just reassign this right? Again, difficulty equals to 2. Difficulty, difficulty
hard for example. And then two. For example, we can also
make IF statements out of a retro game, difficulty
equals, equals. Now that equals something, for example, difficulty easy. And then we do something here. So that's pretty much all it
really is for normal enums. And there is
something interesting for what I call advanced enums. So for that, we're going to
create a new Java class. Again, that's the tool tier, and that is going to be also
renamed to an enum here, I'm actually going to
copy over some stuff from the other
monitor right here. So this is actually also of
course available to you, a GitHub repository
or adjust as well. You can see that while
this is an enum, it has a constructor here and
we have some fields rate. That's very strange.
Yes. So the idea is that you can
have enums defined. So of course this
is an diamond enum. And just for general
examples here. And the cool thing is that those work exactly the
same as the other ones. So I can say a two
tier tier is equal to, let's say, for example, the
tooltip diamond, right? And what I then can very
easily do is I can say system out print line
tier, for example, git tag multiplier,
which then gets me the attack multiplier
of whatever the tier has been assigned to. So I can basically have a, I don't want to call
it a list necessarily because a list is a little
something different, but you can have predefined values in this enum here,
in this enumeration. So that's the enumeration and you can then
access those as well. So that's actually
really will end, can be really useful. And we will definitely see this example in when
we're making tools, custom tools or Minecraft. That's definitely something
that we're going to see. But otherwise that's pretty
much it for the enums. I just wanted to show
you this and mention is that you have at
least seen this before. Otherwise this would be it
for this lecture right here. I hope you found this useful
in neurons of the new, and I'll see you in the
next lecture. So, yeah.
35. (Java) Exceptions & Try and Catch: All right, welcome back
to the Java introduction here for microwave modeling. And in this lecture, we're going to be
taking a look at exceptions and the try
and catch statement. So overall, this is not
the most interesting, or what would you say, the most exciting topic? However, it is, it can be a fairly important
one. Nonetheless. Though exceptions we've
seen a few of those. For example, the something like the IndexOutOfBoundsException and the NullPointerException. So there were a few
exceptions that we've seen before that were
thrown by the actual code. And what we're gonna do
is we're now going to throw our own custom exception. So in our package we're
going to create a new class, which is the test exception, because it just
really requires us to have a test exception here. We're just going to extend the exception class right here. And I'm actually
going to copy over the two constructors that we're going to need here for this. So this is of course,
all available to you in either the GitHub repository
or energised as well. We're going to have is
we're going to have a scanner where we can just quickly scan in some
stuff system in right here. And then we're just going
to save the following. So we're going to say next int, and we're just
going to basically save something in
an integer here. And just for the
sake of argument, what we're gonna do is
we're going to throw this exception when we pass in a number 0 into a
specific method here. So private, static,
void check for 0. That's very straightforward
in the number. And what we're just gonna do is we're gonna say if the number, if the number were
passing any residual, then what we're gonna do
is we're going to throw a new exception.
How do we do this? We're going to write throw
new tests exception, and then we're just going
to say number is 0. For example,
something like this. And that's pretty
much all that we really need to do here. What you see is that this
actually throws an error here because Add exception
to method signature. So we actually have to have
this at this method here. So we have to add the throws test exception to the
method signature, otherwise it doesn't work. And if I call this now, right? So if I check for 0, i, what you will see is that
this also has to be added to the main method as well because this is not
handled properly, so we're not handling
this exception. So what you can do is we're
just going to run this. And if I, for example, type in a one here,
nothing happens. The program ends normally
over if I put in a 0, you can see exception and main thread count and
your test exception, very interesting numbers 0. And then you can even see where this has been called, right? So here first and then here was the exception
that was thrown. So that's very interesting. Let's first of all, a
comment this out and get rid of the artistic
section up there. And what we can do now is
we can say, for example, let's just say z is equal to
the scanner dot next int. Or actually just skip
it the I here for that. That's fine. We can now make a try statement. So this is going to be a try
with the curly brackets. And then here it's going to have an catch with an
exception e inside of it. And this is basically
handling an error, right? So the try and catch statement is there to handle an error. So we're going to
try this right here. Write a check for 0 I. And if an exception is
caught or thrown, right? And we can catch it here. And then we can do
something with it. For example, we can just basically just do
something like this. So GET message
then just for now, basically just print out what is actually
happening here, right? So the actual exception, there's of course other things
that you might want to do or have to do if an
exception is caught. And then you also have
this finally here, which we're just gonna
do the following. We're just going to
basically print out finally, just to see that
this is printed and then we're actually
going to copy the out. And this is going to be,
this happens always. But now the interesting thing
is when you actually handle exceptions properly with a
try and catch statement here, then what happens is
that the program does not just break or it
doesn't just end, it actually continues along. So what you can see
is that first of all, when I call, when I put in
a 1 for example, right? So one day you go finally, and this happens always. So the finally, as you can see, is always cold and then this is always also called, right? And then the
interesting thing is that when the exception thrown, you can see we're
printing out the message. But finally still happens. And the, you know, this happens always,
also still happens. So the rest of the
program continues along. What's very important
is that in general, you want your code to fail
as loudly as possible simply because of the
fact that you want errors to be seen
very, very early on. That's why throwing
exceptions can be useful. Now, granted in
microwave modeling, you're very unlikely to have to, especially in the
beginning, right? I mean, most of this, I'm assuming for
beginners, right? This is not going to be very
important for beginners. This is something way
more for advanced people. When you're really sitting
there, you're like, Okay, I'm going to make like a
giant mode now, right? I want to make it like the
next thermal expansion, Let's say on that level
something like that, then making some
custom exceptions. Very smart idea, definitely. But whatever the case may be, this is it for this
lecture right here. I hope you found this useful
and you learn something new. And I'll see you in
the next lecture. So, yeah.
36. (Java) Java Lambda Expressions: All right, welcome back
to the Java introduction here for Minecraft modeling. And in this lecture, we're going to take
a tentative look at a lambda expressions. So lambda expressions
can be very complicated. I just want to give you a very brief overview of the ones that we have and
what lamda expressions are. So in general, and the veteran people are
going to three methods. They are basically functions
or methods as variables. Now that's pretty cool
when you think about it. And we're going to take a
look at these five just in very, very sparse details. So we're not gonna go
into any detail at all. I just want you to
have seen those n to basically store
that in the future. Because especially
in 4D modeling, this is something that is very important actually in fabric, not so much, well, whatever the case may be. So a supplier, for example,
right here, right, is something that has no
parameters but a return value. And it could be written
something like this, right? So no parameters in
the parentheses and an arrow and then the x could be whatever
is being returned. You can see supplier of type integer means that
an integer is returned. And then this is
how it looks like. The cool thing about
this is that this also means because when we can
make a variable out of it, we could also pass
it in into a method, meaning that we could, we could pass in these
suppliers in there, which might have
different functionality. So that is fairly cool actually, this is also used in afford programming a lot or
enforced modeling, especially because
when the supplier, when you have something
inside of it, this is only called when the
getMethod here is called. So you can sort of delay loading of certain variables
and stuff like that. That's pretty much the extent of my knowledge in
that area as well. So we're not gonna
go too much into it. And then after we've fixed this mistake here per
meter, of course, right? So the consumer sort
of in the name really consumes a parameter but
doesn't return a value. Here is an example for the
consumer for a string, which simply basically
is where you pass in a string and then it does
something with that string. A callable is no perimeter
and no return value. So very similar to a supplier, however, it throws an exception, so a callable, it's
possible for that to call an overthrow
an exception as well. That's the general idea. You can also always hover over this and you can actually find a very nice summary of what
they actually are, right? So here we're calling the
callable in this case, then a runnable is
something that has no parameters and
no return value. Then a function basically is literally like a
function that maps a certain input to
a certain output is just the function
for the circle, basically where I just
have the pi here. But that's pretty much all
that there is really to it. So overall, like I said, I really just wanted
you to step through this once I've seen this before, when I say, Hey,
we're going to make a supplier that you don't
sit there and you're like, oh, I have no idea what that is. No. A supplier basically is
a datatype that has, that sort of more or less saves in a function or a method. It's not quite that, but it's very close to
it so that, you know, especially for beginners, it's enough to think
about it like that. Whatever the case may
be, this is actually it for this lecture right here. I know that this was very
short, but like I said, it's really just a
very brief overview rather than really explaining
every detail of it. But I still hope
that you found this useful and learned
something new. I'll see you in the
next lecture. So, yeah.
37. (Java) Java Generics: All right, welcome back
to the Java introduction here for Minecraft modeling and for this last lecture of the
Java introduction section, we're going to be making a
tentative look at generics. Generics, of course we've
seen those before, right? A list was a generic,
for example, where we could put in an integer like any class basically, and basically have the numbers, for example, with a
new ArrayList here. So that all worked out
very easily and very fine. That was well, fairly
straightforward. But what if we have generics
that we want to use ourselves for that
we're actually going to create a
new class here. We're just going to
be the pair class. And you will be able to save
two different values in it. So we're just gonna make those angle brackets and then x, y. And the idea is that X and Y are now placeholders for
certain datatypes. So we're going to have a
private x squared first and a private lie
called second, right? And this is, the idea is that you now have to
think of this like, okay, those are generics, meaning that those are just placeholders,
like I said, right? And let's just generate
a constructor for this. So right-click
generate constructor. And then for both of
those we're going to just read the constructor. And then actually
we're also going to do right-click Generate getters and setters for both of them. And there you go. That's basically the
entire class already done. And you can see it
always uses the x and the y because those
are basically just placeholders for
the actual data values or data types that
are being used. Now what's very
interesting, what you can also do is you can say that a certain data type as to
extend from a different one. So we can, for example,
say extends float, meaning that the y now
has to extend the float, meaning that it can
either be a float or any other subclass of that
class that were defined here. That's very interesting as well. It is something that
you can do and that is done in Minecraft modeling
extensively as well. And what you can also do, let's just make a new
pair here, right? So pair, Let's say
are like integer, integer float for
the time being, like this term equal
to a new pair of them. We're going to say
some like 2250.55. Sure, that's okay. Making sure that this is an
f here, then it should work. There you go. This is now working
totally fine. And what you can also do, instead of passing in a certain actual value
or a certain data type, you can also make
this a question mark. And then the generic will
just sort of figure it out. This is what's called
a wildcard generic. We're not gonna go too much
into detail about this. This is something that
you will also see in Minecraft modeling
a little bit as well. However, this is, there's no real need to understand this. It's entirely because generics definitely is something
that is way, way advanced, like very advanced
topic that even like skilled programmers don't like a lot of them don't
even understand this. Like I wouldn't include myself in that description
by the way, like, I know generics good enough so that I can basically
deal with them. However, making like a
real generic class myself, I will be honest, this is very, very hard, right? So this is a very
complicated topic, so no worries there at all. I just wanted to mention this
and wanted you to see that this exists and that you can
also make your own generics. But that would be it for the Java introduction in
this section of the course. I hope you found this
useful and you learn something new if you're
a complete beginner, I hope that you now have the Java foundation that
you're going to need in order to continue
along with microwave modeling. So best of luck to you, and I hope that you will enjoy the microbiotic section
of this course.
38. (Basics) Installation, Setup & GitHub: All right, Welcome to the Minecraft fabric
course here for 118. And in this first lecture, we're going to go through
while a few prerequisites that you will need in order
to start modeling Minecraft. Now we're going to go
through everything, downloading everything
that you need, the programs, setting
up the fabric project, and then even setting up a
GitHub repository so that you can either share your code with someone that
might help you. So for example, if you
run into an issue, you can then upload all of your code and then can
send it to someone else. For example, me in the Q&A. And then I can very easily
try and find the error, which is just going
to save a lot of time between the basically the
question and the answer. But first of all, if you
are an absolute beginner, I highly recommend if
you haven't watched it, watching the Java introduction, I just cannot
recommend this enough. It is going to help
you immensely. Because if you don't have that, especially going
through the Minecraft modeling part of this course, you're going to feel
very lost very fast. Because at this point, I assume that you have at least
seen everything in the Java introduction
and you are reasonably familiar with the concepts
that we've discussed there. But whatever the case may be, Let's start with
downloading the JDK. So we need a Java
Development Kit, and this is going
to be Java's 17. Actually, this link is
linked in the resources. Despite having used Java 16
for the Java introduction, we now have to download Java 17. That is no issue by
the way whatsoever. So this is linked
and this should in theory detect what your
operating system is. If this is wrong, you can
go to other platforms. You're making sure that
you select tamarin 17, and then you can basically just select your operating system, the architecture here as well, and then just download,
download the MSI year. And when you download this, this is just a normal
insulation so that you can install this on your
PC like any other program. And once you've done
so you can then continue for the next
part is we're going to need an IDE that is an integrated
development environment. And for us we're gonna
choose Intelligent idea. If you are once
again a beginner, I highly recommend just
sticking with this because otherwise there's gonna be a few things that might
look different to you. So for example, if
you wanted to use Eclipse or VS Code,
also totally fine. However, do keep in mind that if you run into
any issues there, I might not be able to
help as good as I might be able to with intelligent idea because I know all of the legs, Let's say shortcuts and all
of the buttons you have to press when something
goes wrong in idea, I'm not 100% familiar
with Eclipse or VS code, so just keep that in
mind and download the community version.
Very important. This is free so you don't
have to pay anything. The community version
on the right side here. So just download that once again and then install
that to your PC, just like any other
program as well. Now we come to the
next thing and that is going to be the
fabric example more. Now you can see that this
is a public template, so there's a few things
that you can go about this. You can either use
this template and just make a new GitHub repository. That's not what we're gonna do. We're gonna do is
we're going to go to the code here and
click download a zip. This is going to download
a zip file with all of the required files that
we basically need. And I've already
prepared a holder here where I want
this to go into. I'm just going to right-click
here, extract here. This is just for this
I'm using wind rawr. You can also use seven zip or another ZIP program to
basically open this up. Well now everything is in here. I'm actually going
to Control X this to get this out and Control
V to paste it into here. So I'm just wanting everything
to be in this folder. And now two things that
we can do immediately. We can delete the
license and the README file so that we are not going to get the same license
here because this is basically the public
domain license. And that is actually not something that I
personally want. Of course you can stick with
it however you would like. And then I also
highly recommend just deleting the GitHub
folder right here, the dot GitHub folder, because that basically
contains some workflows. Here you can basically
see automatic bills the project and run any
configure tests for it. You don't really necessarily
need to do this. You can keep it. But this is something that sometimes might be a
little bit confusing for, especially once again beginners. So I highly recommend
just deleting that and not worrying about
it for the time being. Now we have the fabric
example mod in here, and this is actually
all that we need. We can start intelligence
for the first time. Now it's probably
not going to look exactly like this to you. However, it will have three
components that we need. And this is the new
project, the open. And they get from VCS
for those three buttons, basically Arthur, things
that you're gonna need. And we want to click the
Open button and then basically navigate
to this directory. So we're just going to put
this directory in here and you can see the
fabric horse 118, and it actually has this symbol here and we're
going to hit Okay, and then crossed the project
and then a new window here will open and you can see some things were
already start here. That's totally fine. Just keep it going. If you get like red here, arrows, no worries at all. We're gonna fix all of
those in just a minute. The first thing that
you will probably come up with if you, for example, have a different
version of Java here, you can see that you are using an outdated version of Java. That is correct for
me because I have multiple versions
of Java installed. Now, how do you fix this? Very easy. You go to
File project structure, and you can see here
in the project SDK, you have to select Java 17. And then here in the
project level language or so 17 hit Apply and Okay, and there's a second thing
that you need to do, and let's go to File Settings to the execution deployment
built tools Gradle, and make sure that this
year is set to project SDK. That is also very important. It apply if that is
not the case, okay? Then you can hit this
little elephant here again and let us
run through again. And now you should not get
any arrows in that case, but it should just run
through correctly. But you can see I got a
build successful here, so that's actually really good. And then what you will also
see is that you will have three of those orange
folders generate. And then if we, for example, open up the source folder, so SRC stands for source. If we open that up,
you can see that we also get some colors here. Now the next thing is that when I opened this java folder, you can see that
everything here expands. If you're using intelligent
for the first time, this might not be
the case for you. Go to this gear up here
and make sure that both flattened packages and compact middle packages
is turned off. So this might be the case,
how it looks for you. Just make sure that both fly and packages as well as
compact middle packages is turned off and
then everything looks exactly the same for you as
it does for me right now, we need to modify a few things inside of the Gradle
dot properties file. So you can see there are
some properties defined, so there are some
fabric properties, there are some more properties, and then there's also
some dependencies or a little interlude
right here. So what's very important
is that there are two ways that you
can go about this. Number. One, you can either take the just example mod and
then you will be on 1800s. Please note that a
few things do not work exactly like in 101. So this name, you're
going to be the tags, the advanced item, which uses tax basically and
world generation. You're going to have
issues there at the end of this, at
the end of the course. So there's gonna be an update video where we're
going to update the 1800s things to one 1800s. However, if you want to follow the course in its entirety, mainly words or iteration, I highly recommend
thinking about possibly choosing one 1800s one. Here. I will probably add a section at the end of
the course for 1800s. And not only the changes, but probably also
different lectures that will replace
the, not replaced. But there's gonna be corollaries
for the 1800s lectures. So either you can change the Gradle properties file
to these values right here, or if that's not your, if
you don't want to do this, if you want to use 1800s, you're of course,
welcome to do so. But please keep in mind
there are gonna be some differences versus what you're going to see
in the lectures. So just keep that in mind and I guess back to the lecture. So overall the
fabric properties, you can see that we
actually have a link here and we're going
to look at that page in just a moment. And we basically just specify what is the Minecraft version, what is the version of the
mappings that we're using? This is basically to translate
the code so that we can actually read the method
names and things like that. And then the loader version is just the version of the
fabric loader basically. Then we have some
more properties, those we can define ourselves and we're gonna do
that in just a moment. And then we also have
which fabric version we are using at the
very bottom here. If we open up the link fabric
MC net slash versions, then you will see that we actually have some updates here. So what we can do is we can
just take this control C or right-click copy and
then go back here and then basically just paste it in. So let's
just paste it in. We're gonna get a
few arrows because there's multiple ones here. But what we can do is we can
just replace this down here. So I press Control X to cut it out and then Control V
to paste it back in. Now we've, we'll update to 0.44. This might actually be a
different version for you, which is totally fine. Usually while there are some
differences in versions, there shouldn't be
crazy differences. And if there are, I
will try to keep up with the best I can
and probably add another lecture after this or somewhere between
the changes. And then it will basically be caught up with
that as well, right? And here we're just going to
delete all of those and then also just make sure that
they are written correctly. So basically hitting the
tab key to move them. And now you've seen that
we've basically updated on profit on six to
12.8 and from 431, I think to 440,
that's totally fine. Once again, we can click the little elephant
here up in the corner. And if we expand
this build window, you can see it's downloading things like crazy,
but no worries. Again, this might take
a couple of seconds. Once again, maybe
a minute or so. I have seen it take a lot
longer for some people, but this depends on your internet connection
and how good your PCS. So sometimes it might
take like 20 minutes, I've seen that before, but that's very rare. Very rare. So there you go. 21 seconds, actually
already done. And now we can start to, well, go ahead and see what we
can change for our own MOD. Basically, all of our
changes are going to happen in the Gradle
dot properties file. That is basically very
easy for us to do this. And the general idea is that we have to change our model
properties here and then also change a few things here in our folder structure
or packaged structure. The general gist
is that right now we're using this example
MOD where there is, of course not quite
what we have. We have a specific
math that we want. So if I double-click on
this example mock class, you can see it says example mod. It even has a few
comments in here. That's very nice. But overall, we need to change a
few things in here. The first thing is that I want this to be in
my own package. What I do is I go up here and I'm just going
to change this to net account and rho naught Mc
course, that's the package. I want this to be a
highly recommend not calling this cotton job because you're in
a coulomb joule. And second of all, just
use net your name. And then MC course for example, I highly recommend
doing this because it's just very weird to use
someone else's name if you're making your
own code because it's just gonna get confusing for people who are like
you didn't write that, that was by cotton row
and it's like, well, what I can do here is this, of course now going to
have a red underline. I'm just going to hover over
this and you can see move to package net Cotton
joe MC course. I'll just click this
and you can see a new package has been created. And this has now been
well basically done. What I will do then
is I'm going to take this mixed and package and just move it right into EMI EMC
course package refactor. And there you go.
Now I can actually delete the fabric MC here, just hit the delete
key and then confirm. And then what I can do is I
can now right-click this. This is very important. Don't
just change this name here. Right-click Refactor Rename. And then this is going to
be the MC course mod class. Now, this is what
I will refer to in the coming lectures
and in the answers for some questions
as the main class. So this is the main class. The main classes, the
one that implements the more initializer
interface, very important. This is what I will refer to as your main mod class will also delete all of the comments here because they're not needed. And then I will introduce
a new field here. And that is a public
static final string called mod underscore ID. And there's going to be
equal to a new string, which is called MC course, because this is going
to be our model ID. Now the more ID is
very important. So once again, listen
carefully here, the more ID can only contain
lowercase characters, underscore dash and numbers, nothing else, no spaces and
no uppercase characters. So that is very important. No uppercase characters. I've seen this multiple
times for your model ID, you cannot contain
uppercase characters. And then instead of
calling the model ID here, we're just going to say more ID. So now everything here
is fine and dandy. So this is actually
all that we need to do in RMC course math class. Now let's go into the example mixing because we're
gonna get an error here, because this is still trying
to use the example mode. No worries, We're just
gonna say MC course. You can see as soon
as I type it in, it actually gets
suggested to us. So I can autocomplete
this with tab, and then let's open the
import here and you can see they actually get
an error here as well. We can just delete
this import and then all of the arrows
here should go away. Well then let's navigate to
the greatest property again. And here we have
the mod version. I highly recommend what you
should do is you should put the micro version either
at the front or the back. So you can, for example,
say something like this is version of 0.01 dash 118. So then the user
is, knows, okay, this is version
0.01 for your MOD. And then for micro version 118, they may even group of
course is just going to be net.com row dot IMC force and
then the archive base name. Not actually sure how
important that is, but this is just
going to be for us, fabric verse 2018, right? And now this has been modified. That is fine. And now we need to
modify something else, and that is in the resources
folder right here. So open that up and
you can see that it actually is a model ID icon. We can actually delete this. We don't need that
at the moment. And there's a
fabric more JS file and a model ID
mixed illustration. First of all, we're
going to go into the fabric moderation. And here we have to actually
specify a lot of things. The first thing that
we need to do is we need to change the
mode idea here, of course, to MC course. This is the model that we've
chosen right here, right? So this has to be exactly
the same everywhere. And then the name of Ahmad,
I'm just going to choose MC course fabric mod. That's fine. We can also add a
description here. So we can, for example,
say mod, teach others. Fabric morning,
fabric, microphonic. Sure, pagan authors
is homeroom course. Once again, put
in your own name. Now me, I'm not the
author of your model, and then you have some contact, for example, I can change this to come to the net
and then sources. I will probably change this in a little bit because
of course right now we don't have a
GitHub repository yet, but we will of course make
this in this lecture as well. The license I'm going to choose, the MIT license that
I personally think is the best one formats
usually that's just, you know, it's still open source than the entry point here. We have to change this
as well as you can see, this is net count
and rho naught Mc course and then not example
more about MC course mod. Very important once again,
that you changed this. Exactly how you
have it right here. You can see net out
and row MC course, MC course model.
That's very important. Same with the mixins. We changed the model
ID here to MC course. And now everything here has been done at the Icahn doesn't
work at the moment. We could of course also
add on new icon here. We're not gonna do that
for the time being. Then let's open the more
I the mixins, Jason. And what you can
see is number one, what we want is right-click
Refactor Rename and then change the model
ID here to MC course. And then the package
here you can see also has to be changed. The net accountant Joe at MC
course, mixing, that's fine. Then the example mixing
here is also fine. This is just an example
of the actual mixins. We're gonna take a look
at that in the way later lecture because mix-ins
can be quite complicated. So for the time being, we're just going to
basically ignore the entire thing here.
Same with this one. We're just going to ignore
it and say That's fine. But now actually all of the modifications that we
need to do have been done. We've specified
RMC course MOD ID, exchanged the name here, we've changed the things
in the fabric mod Jason, very important, you do not
change the name of this Jason. You only change them name of this Jason has also a
very important thing. And now we still
have the elephants. So let's just click this
one more time and let's see everything done
in 940 milliseconds. That's very fast. And how can we start
in Minecraft will be go to the top right
here to the Gradle, expand the tasks fabric, and then run client unless
you see double-click this. And then in the future, you will have this up here. And then you will
also have sort of a, just a play button that
you can basically click. And that's also
then going to work. But for the time being, we're just going to
wait a few things. This arrow here is
absolutely normal because we are in a
development environment, we have not logged
into Minecraft, therefore, we're
gonna get this error. That is totally fine. And Minecraft will already
have started hopefully, and you can actually hear it. I'm actually going to
turn down the music because that can sometimes
be a little distracting. And there you go. So
fabric is actually in, we can see fabric model
also works totally fine. When this happens,
you're actually through, we have set up the
development environment. Let's actually quit the game. And let's do two more things. Number one, what I want
you to do is I want you to also click this Jen
sources right here. So just double-click this. This is going to generate
the source files for Minecraft and fabric, just so that we can take a
look at those in more detail. Basically, I'm going
to show you what that means in basically the
future lectures is gonna be very important
that we have access to the source files for
Minecraft and for fabric. Because there are a lot of great examples on how to do
things in there as well. Now this will actually
take a little longer, but no worries, just be patient, waited for it and then we'll see after everything has
been done, There you go. So almost a minute and
then Jen sources is done. You can also click
download assets Just in case Sometimes
you need to do that. Sometimes you don't. Sometimes the assets, usually they should be
already downloaded, but there might be
some issues there. And once you've done this,
you can close it and then make sure that you select
the Run client here. You can also select the
Minecraft client here. You can select either of them, or you usually choose this one. And then you can basically
start microphones again with this Run
button right here. Right now everything
has been set up. So now let's move on to how
to add the GitHub repository. Highly suggest not
skipping this step making a GitHub repository because if in the future you
run into an issue, I'm just providing me your
GitHub repository with, for example, an
error log and say, Hey, this didn't work, is gonna make my
life and your life a lot easier because
I'm gonna be able to respond the way faster to an issue or a question
that you might have. So how do we do this? Well, first of all, you need
to have a GitHub account. I highly recommend
making one on GitHub. It's totally free.
It's very good. It's a website used by
almost anyone that codes. There's a few
others, but I highly recommend just making
a GitHub account. Once that is done,
you can then go into your back into
intelligence here and go to VCS and then say share project on GitHub that
we need to choose a name. I'm okay with fabric dash
course month 18, that's fine. I'm going to choose
to make this private. You don't necessarily need to. Remote origin is also okay. I'm not going to add
a description right now. I'm gonna say Share. Now you can see Account
can't be empty, Fair enough. So I'm going to add
a count and you can see login via GitHub. I'm just going to
press this and it will then open this
JetBrains account. I'm gonna say authorized
in GitHub and then you can see successfully been authorized because I'm already
locked in here. Now I'm going to go
here and you can see github.com slash cotton
row and then say share. Now at the bottom here you can see it's starting to do stuff. And then here it
basically suggests hate. What do you want to push? Like? The idea is that we have
two different things. You have a commit and a push, and a lot of stuff
will turn red. So the files will turn red
and we'll say initial commit. We're gonna say Add. And then it's going to continue doing stuff here at
the bottom right. And you could see successfully
share project on GitHub. I believe I can just click
this and there you go. So now actually the
horse course get a repository has been created under columns row slash
fabric course 118. And this will also
be available to you. So in each of the lectures, you basically will find a link to the branch for that
particular lecture so that you can always take
a look at the code compare and make sure that everything you've
done is correct, just like we have here. I also highly recommend, especially when we go into
the more complex topics, I'm going to start copying over a lot more of
the code because it's not fun to watch someone
write 300 lines of code. And then basically just looking, watching someone, right, that it's not actually
very interesting. It's far better for me to copy some stuff over and then
explain what is written. That's actually
how easy the setup for the GitHub
repository here is. Once that is done, you can see at the bottom here I now have the master branch and if I
were to change something, so I'm just going
to, for example, add a Hammond, the
comments, right? You can see that the
file turns blue. This means that a
change has occurred. How can I now will mark this? Well, I can go to
this commit tablet right here and just say, yeah, every old changes, right? I wanted to, I
wanted to mark them. And then I'm gonna
say added a comment. Then what I want to do
is I'm gonna commit. Now this change has
been committed. If I go back to the
project window, you can see it's no longer blue, but it is not yet on line. Because what I need
to do is I need to go here to this push button, to the arrow that points
to the top-right push. And then it says
Master origin master. This basically means that
you're going to push the changes that you've
made on your local machine. That the origin and the
origin is basically online and there to the
master branch, push. And you can see hopefully
what can happen is pushed one commit
to origin master. And if I now go back
here and reload this, you can see added a comment
has just been committed. If I don't want to go
into too much detail about how Git works
and all of that. However, it is very important that basically
you do set this up. I highly recommend this. I cannot recommend this more. Getting help by either me or either or even other people will make it so much easier if you have a GitHub repository
that you can share. So please do this and also very important that all of
these files are in there. You have to have
the Gradle w file, you have to have the
builder Gradle file, the Grail properties, all of those things have to be there. Very, very important, right? But whatever the case may be, this is already it
for this lecture. I understand that this is
quite an extensive one. We have done a lot of things, but if Minecraft works now, congratulations, you've
started mindful of mourning. It's going to be a crazy and
cool journey along the way. And I'm sure that you
will learn a lot. If at any point you run
into any issues, of course, feel free to use the
Q&A to ask a question. Otherwise, I also highly recommend just checking
everything again for spelling mistakes and making sure that you've done
everything like I have. And then hopefully
everything might work. But that is it for this
lecture right here. I hope you found this useful and you'll learn something new. I'll see you in
the next lecture.
39. (Basics) Create a Custom Item: All right, welcome back to
the fabric course for 118. And in this lecture, we're going to be adding
our own custom item. So this is very exciting. We're starting off with
adding items because they are a little bit easier
than adding blocks. But let's just start.
What do we have to do? Well, inside of our
MC course package, we're going to right-click
new package actually. What item so that the
package structure in general is highly subjective
and it can change. It's basically a
individual organization. How you want to organize this, you can select that
basically however you want. I highly recommend sticking
with something that you like. Basically you and
if you have a team, your team, as long as you can find everything,
that's fine. I'm going to stick
with basically how I do it for inserting
the item package. We're going to right-click
new Java class called more items. So this is a new class
here and this window will appear if you have GitHub
repository initialized. So basically this
is at the file to GitHub and usually what you
want is you want to say Yes, Add, and then it
will turn green. So this is basically a
new file has been added. If you have not set up
a GitHub repository, then this will not appear and
everything is fine as well. So to add a new item, we need to register it. Now, there are two things
that we need to do. We need to have a
public static boyd or register more items method. And this is just going to
say system out print line. And it's going to say
something like registering, registering items for mod items, mod items, or plus MC
course mod that melody. So this will be
called INSEAD side of our uninitialized method to initialize the static items
that we have in this class. This is actually
strictly needed because otherwise the items will not properly be
registered basically. And then we'll have a
private static item or register item, register item with a string
name and an item, Item. Now you will see
that this item is red here, no worries at all. What you can do is you
can click on this, press Alt and Enter to import the net Minecraft
item, item class. As you can see, we're still getting an error here because of course we have to return an item that's no
worries at all. What we're gonna do
is we're going to return the registry, not register with the
registry dot item all in uppercase AMA, new identifier from
net Minecraft util, MC course MOD that
model ID name. And then after the first
parentheses comma item. Once again, the registry kras
is not being imported yet, so click on it all into two important at Minecraft
UTI registry, registry. And this call basically will register the item
under our namespace who are under our model ID with the name given here as
the first parameter. And it is going to be this item. So this is basically
a helper method to help us register our items. And what type of items
are we going to make? Well, we are going to
make or recalc them. Well, this is already
calcium in goods and nuggets and raw
or recalc them. And then later Oracle can
blocks and all of that jazz. So how do we make an item? So we're gonna say
public static final. So this is once again
just basic stuff, right? So that static, so that we don't have to make a new
more items class. And then final so that we
can't change it afterwards. And this is going to
be the recalc income underscore English. And this is going to be
equal to register item. You can see I'm
already getting this and then the first
one is a string. This name here will actually
generate automatically. You do not have
to type this out. Zoom in a little bit. You
can see that this looks a little bit different from
what I've been writing. So this generates automatically, you do not have
to type this out. And this is an oracle come underscore ingot and then comma, and then a new item. So you will actually already
get some suggestions c, We want a normal item here, new item with the new
fabric items, settings, that group, item, group
that Misc, write this one. And then at the end
here, a semicolon. This is the entire thing
to make a new item here. In this case, we're
basically making a new item, the name or the calcium English. The oracle come in, get here. This is the name of the
variable of course, and this has to always be
written in caps lock and also underscores separated
boundary scores basically. And this all has
to be a lowercase, just like the model ID. So the name here, the string
here, always all lowercase. And usually I highly recommend sticking with one
way to write this. Basically having the underscore
here is fine, right? In New Item requires item settings and you
can see that we've just call it the group method and given it to the item
group dot miscellaneous, so that this item is actually added to the
miscellaneous group. And I can actually put a dot
in here as well afterwards. And it put in more
stuff to this. You have a little
more Java knowledge. This is a builder
pattern and you can see I can actually do
a few things in here, a change, a few things
up for the time being. We're just going to stick
with basically selecting the group to be
group miscellaneous. And that is pretty much it. We're going to stick with
this for the time being. But towards the end
of the lecture, we're actually going to make another item just so that
you see how that works. That some people have been
a little bit confused with. How do I add a second
item to have to make a new mode items
class, No, No worries. We're just going to basically
stick through it in our MC course mod class in
the initialized method, where now we're going
to call more items that register mode items. And we can delete
the logger info. That's going to be fine. And now we need to venture into the assets folder and
basically make the JSON files. Well, JSON files are
something that is, I mean, I wouldn't say
necessarily annoying, but it can get very
annoying because for every block and for
every item you add, you will have to add
these JSON files. We're gonna go through the
item JSON files right here. And then next lecture when
we talk about blocks, we're going to also go
through those as well, so no worries at all. So in the assets folder, Right-click new directory
called MC course. So this has to be your MOD ID. Please make sure that this
is written correctly. Everything here that I'm doing right now has to be
written correctly. Otherwise it will not work. Say this one more time. Please make sure
that your folder structure is written correctly. Check this eight times, really, I mean it MC course, right-click new
directory called lang. So this is the first directory
that we're going to need. And then there's another
one called models. And then there's one more
which we're going to need, which is the textures. But very important, Lang models with an S at the end and
textures with an acid the end. The models folder will also have two directories,
one called broke. This is singular. And then what I can do is I
can take this folder and when I press Control and drag
it into the same folder, I can make a copy of it
and just mean that item. Now we're going to take both
of these and actually make a copy of them into
the textures folder, because we're going
to need a block, an item folder in there as well. But this is at the moment
how this should look like. Make sure that everything is
in the correct place so that nothing like the models folder is inside of the assets folder. Everything has to be like this. Resources, assets,
MC course models, M, C corps textures, MCQs, Lang. Now inside of the leg folder, we're going to right-click
New File and underscore us dot-dot-dot Grayson it
Enter and once again, of course, add
this to the GitHub repository if you have one. And now this is the
translation file. So this is going to translate the name of items into
different languages. Now for our purposes, we're only going to use
e and underscore us, Jason, because we only want to translate this to
the English version. However, you can
very easily find out the other types of
languages that are supported and then
translate to those as well. We need to do is
we need to put in curly brackets here
and then a string. So this is going to be
item that MC course, that recalc underscore ingot and then a colon or
a calcium score, a no null underscore
space in it. There you go. So this year is the
not translated name. Basically this is
the translation key. You can think of
it like this item because this is an item
because MC course, because this is our model ID. And then the silicon ingot
right here is the name given in the mod items
class right here. But this is the general idea. And this thing is
going to follow basically to almost any
other thing as well, the blocks, different things. So yeah, this is then
the translated name. So this is the name that you're going to see when you hover over the actual item
in the inventory, right then under models
item, right-click, new file or pre-calc, underscore ingot that
Jason are important like this and also making sure that this
is written correctly. Now the Malcom can
be a hard word, so just double-check that
it is written correctly. It enter and I'm actually
going to show this one time, basically writing this out. I usually don't write this out because there's no need to. Most of the JSON files
are going to be the same across the board. Basically, what you're
going to have to have curly brackets and
then a parent colon, item slash generated
comma textures, colon, early bracket,
layer 0, Olin, MC cores. So your motto De all an item, flash or Malcolm or recalc
m underscore English. What is happening? Well, the parent simply
makes sure that this is displayed as a normal item
inside of your inventory. Then textures simply provides textures for this
particular item later, 0 simply means, hey, we're
going to just use one layer. We don't need to worry
about it too much, but this is just how this is basically going to
have to be written. And then this specifies the location inside of
your textures folder. We're going to see
a deep dive in JSON files after the
block lecture as well. I sometimes feel like
it's good to lay sort of the general
groundwork first. So basically making
the items end of the blocks and then talking about each of the
individual JSON files in a later lecture as well. That's going to happen
as well, right? So because this is item sludge, silicon ingot, this has to go, the texture hasn't gone to
the textures of MC course in the item folder and
it has to be named Henri calcium ingot dot PNG. So I of course have
this prepared already. I'm just going to copy
this over or a PNG, okay? And of course added to
the GitHub repository. And of course, this is all
available to you in the wrist. The GitHub repository
and the extras are also all available for you
to download as a zip file. If there are multiple ones and if they're just single ones, then they're
probably going to be as single textures as well. Right now that is actually
all that we need to add the item
properly to our MOD. So now we can actually start the game and
see if it works. Make sure that you've
selected run client where the Minecraft client
here, either one is fine. And then pressing the
Run, Run button there. And then it's just a matter
of waiting until it starts. All right, so we find
ourselves in Minecraft here. Just make sure that your
own creative, of course, that we can basically
will easily see whether or not
it is working. And let's just see once
we're in game for it. So here we are in-game
and let's just see. So let's go to the
miscellaneous tab and let's go at the
very bottom here. There it is. The already calcium in good, absolutely amazing. And I do love the
texture as well. So for all transparency, by the way, the textures, you can actually
use them, however, they are under a
specific license. I'm going to show you
in just a second, but that is actually
really cool that you go, the item has been
added successfully, but in here we are
the credits notice, so that's very important. All textures were done by nano attack and they
are distributed under the CC BY SA four-point
zero international license. Make sure that you follow this. If you want to use them
in your own repository, just add this file to it. I'm sure actually that
this will be fine, but make sure that this is done. Otherwise, you are actually
infringing on copyright. So I'm just wanted to make
sure that this is the case. Otherwise, the textures
here are actually all great and you can use them. No worries at all. Just to immediately
show you how you can add a second item here, we basically are
going to copy this, so I'm going to select
all of this and press Control D to duplicate it. And then what we're
gonna do is you can see that just have to change
this about a bit. We have to change the
name here of course, to oral calcium nugget. And then under here
as well nugget. And now the second item is actually already in the game of yours course also need to
have a new item model. So what we're gonna do
is we're going to copy this one by just dragging it into the same folder while
holding Control, right? So something like
this. And then we can immediately rename this
to Oracle com nugget. Okay? And then inside of here as well, for
a calcium nugget, then we're gonna take
the calcium nugget, extra rugged in here as well. All right. And then
in the EN underscore us Jason file, we're
going to copy this. So basically what I've
done is I've just, you know, press Control C, Control C, Control V, Control V for paste
it in multiple times so that everything here
works and the nugget, and then here of
course also nugget. And now that's actually all
that we need to do to add a second item and every new
item is basically the same. It's just a another
public static final item right here with a new name. So that's very
important that this always has a unique name. If there are names
that are basically used multiple times,
that's not going to work. So just for completion sake,
let's see if it works. All right, friends have
black in Minecraft. So let's go to the miscellaneous
tab and let's see, there it is, the
oracle come and knock. It also has been
added to the game. So everything worked perfectly. Isn't that great, right? And this is it for this
lecture right here. I hope you found this useful
and you learn something new. All of the code for
you is of course available in the
GitHub repository or in individual just as
well, linkedin and resources. So I will see you in
the next lecture. So, yeah.
40. (Basics) Create a Custom Block: All right, welcome back to
the fabric course for 118. And in this lecture, we're going to be
looking at adding custom blocks to Minecraft. Or custom blocks are similar
to adding the custom items, however, they require
a few more JSON files. But first of all, of course, we need to code them in. So inside of our
MC course package, right-click new
package called block. And then inside of there
we're going to create a new Java class
called MOD blocks. Now this will once again require the public static void called
register mode blocks method that is going to just output
basically something like registering monologues
or MC course mod, mod ID that we're
going to have to call in the MC
course mock class. But this will also require, I'm going to create two
different helper methods here. The first one is going to be the private static item
called register block item. Now the reason I'm
going to do this is because when we create a block in item is not created for it and we actually have
to create an item for it. So the first parameter
is the string name, then block, block, and
then item group, group. And then we'll also everything
here red, totally fine. Click on it and
enter to import it, altered and enter the important, very important that we import
the correct block class. You can see net Minecraft
block, very important. And then the item
group, the same thing, just Alt and Enter. And then it's going
to be important. And then here we're
going to return registry dot register, registry dot item with
a new identifier, MC course MOD that mod ID name. And then once again after
the first parentheses comma new block item, this time block item. Right can press the Tab key to basically autocomplete this, passing the block
parameter here. And then once again new
fabric items settings. Once again, also just
autocomplete with tab. There are group and then
pass in the group parameter. And then the three
parentheses and then a semicolon to end the line and they you go the register block item
method is completely done. And then we're going
to have a method that basically calls this. So for the block,
we have to register a block item and of
course also the block. So we have a private
static block or the register block method, which is going to be
a string name block, block, and then of course
item group, group. And the first thing
that it's gonna do is it's going to call
the register a block item method with the name
block and the group. And then the second line
here is just going to be returned once again,
registry that register. This time registry that block. The block right here
with a new identifier. Identifier MC, course
mod, mod ID name. And then after the first
parentheses again block. So just like this, the
code here is of course, also available to you. You can take a look at
the GitHub repository or the just as well. In the idea here being
is that for each block, we're basically going
to call the register block method so that we can then immediately have an item that is registered
for that as well. And then what we're
gonna do is we're gonna make a new block here, gonna go through everything, take a look at whether
or not it works. And then after the first
block has been added, where they're going to also
add a second block as well. So public static, final block, or 40k Malcolm underscore block, which is equal to register block with the name once again, of course, recalc come underscore block or
written in lowercase. And this name here once again
generates automatically. And we're going to
make a new block. You're just a normal block. With this time fabric
rock settings, you can see that of that. So this basically
copies a material here. This is going to be material, actually material that's known. And then we're going to say
that actually the block, now the block will
actually have metal for my not so of material metal. And then once again
dot and you can see all of the different
settings that we can set. There's a lot of them, as you can clearly see, some of them are have to strike through. So for example, you
know, break BI tool. You can see that if I were to actually add the tool tag here, and you can see that
this actually is a red strike through as well. So we can't use that one. So the ones that
have breakthroughs shouldn't use the
other ones we can use. No worries. So for example, something like this
strength can be used, which is basically the
hardness and resistance. Basically how long it
takes to break that block. We always wants to call the requires tool
method for every block. Basically, it is very important. Then after we have the block, we also have to pass
in the item group. So item group miscellaneous
right here in this case. But in basically
the next lecture, we're also going
to see how to add our own custom item group. This is why this is very
important that we have this as a possible perimeter here is just going to make our
life a little bit easier. Right now this is actually
the block defined. Let's go to our MC course
class and let's go to here. So this is going
to be the blocks dot register mode blocks. Make sure that this is
called after the items. This is just the order
that I like to do it in. I do not specifically think that this is always necessary, but it just makes sense. Sometimes the order here is very important for the time being. We're just going to
stick with this. And let's actually
first of all open D in underscore us JSON file. And let's see. So what
would be the block? Well, that is actually
fairly straightforward. Block dot AMC course that
recalc underscore block. And then of course once
again the translated name or Malcolm block right here. So this of course now starts with a block and
that's Oracle can block here is once again just the name given in
the mud blocks. Now the JSON files
are a little bit different because we
actually need a new folder. So inside of the assets
and an armada D, in our case MC course, right-click new directory
called Bloc states. Also very important that
this is written correctly. And so there we're going
to need a new file called recalc underscore block, the adjacent the ego. And I'm going to once again do this one time manually
and then I'll explain. So we need curly brackets
and then we're going to need a variance. Make sure that this
is written correctly, all in curly brackets again. And then empty quotation
marks, curly brackets, model, Olin, MC course, fallen block, or a cow come underscore
block, right? So exactly like this. Now this is very interesting
block situation. Like I said, we're going to
see this in a future lecture. I'm going to go
through what each of these JSON actually means. The general idea is that, well, there are different variants
that we can define. Currently we have
nothing to find because our block doesn't have any
block state properties. So there are
different properties that we can define later, which is something
that we'll see in the intermediate
section of the course. And then we can point
to different models. So for our case, we
actually need a model under the block older call
or a calcium block. So inside of the
models folder Block, right-click new file for a calcium underscore
blog.js, JSON. And the block model
looks as follows. This is going to look
similar to the item model. So curly brackets and
then parent block slash cube underscore
all this simply, this parent basically
just says, hey, the textures is going to
be the same all around. Then we're going to once
again have the textures here. Colon Record. And then all fallen
MC course colon block or a calcium underscore block. So you can see once again, we have a texture and
this is going to be the texture for all
six sides of the cube, but this is why it's cube all. And then this is under MC
course block or unblock. This is once again the name of the file that we have to have. So that's pretty much
all there is to it. And we're actually going
to copy that over as well. I already have that prepared. You can of course, also
get that as a download, but please also make
sure that you follow the license in the
credits right here. So all the textures are actually licensed under a
particular license. So make sure that you
follow that as well if you use that in a public
setting, right? And we actually also
need an item model. This is the thing
with the blocks. It actually requires three
different JSON files, basically all named the same. A block 6's Jason, a block model Jason and
an item model Jason. I'm actually not going
to copy this over. I'm actually going
to make a new one. So in the item models folder, right-click or recalc come
underscore loc Jason. And this actually
looks different from the other item models because a block item model is
actually different. So this is going to
have curly brackets. And then it's going
to have parent colon, MC course block,
or unblock slash, or a calcium underscore Block. Now this right here
refers back to the block model and makes
it so that the item instead of the inventory
is displayed in this 3D way that blocks usually are
displayed in the inventory. But once again, we're going to see this a little bit more in detail in a later lecture when we go through
all the JSON files. But now we have the
three JSON files. We have the texture and
the translation done and what blocks register mobile
UX method is also called. So let's see if it works. All right, we are in Minecraft, so let's go here. The earliest the
Oracle can block, and if I set it down
there, it also is. So everything works
totally fine. So I wanted to mention
one quick little thing. There are basically two sections where you can have an issue. Either the texture inside
of the world doesn't work. So once I set the block down, it might have a black
end pink texture year, or the texture inside of
the inventory doesn't work. There are two different things
that might be going on. If the texture in the
world doesn't work, it is most likely the
block stays JSON file. That is too lame. If the texture in the
inventory doesn't work, it is the item model
Jason, that is to blame. And if both don't work
well it then can, it could be any one
of those reasons. So very important. That is basically the
general idea, right? And just so that it
is shown how you can add a new block will basically I select this and press Control C and then
Control V to paste it in. And then we're going to change
this to Oracle or here, and once again here
as well, right? The name is also very important. The rest, if you want to change those things that you
can, of course change them. Let's, for example,
say the volume or it's actually not strong. And also it actually isn't
metal or it really is metal. It's more like stone. That's also totally fine. And this, I'm actually
very happy with. Now, the block is in the game, but it doesn't have a texture
yet and all of that jazz. But we need to basically also
add a block C Jason for it, a block model JSON
and item milk Jason. Now what I usually do is I
just take one of the already existing Jason's and just copy
it over like this, right? Drag it in while
holding Control, and then you can
change the name here. So Oracle or, and then
the same in here as well. Recalc OR, and then the same for the block model
as well, right? Instead of Oracle can block, we're going to have
pre-calc or a year. And then this is
going to point to the recall or texture instead
of the block texture. And then the last
thing is going to be the item model also is going
to be renamed or here. And then over here as well. That's usually how I go about
adding new blocks, right? Just copying over one. The basic example of this, then the same here
in the language, just going to duplicate this, add the comma here, and then making sure
that this is or, and or everything working fine. Then I'm also going
to add the texture, which is of course available
to you or download as well. The ego and now the calcium or block is
also added to the game. So just for completion sake, let's see if it works. Right, we are back in Minecraft, so let's just go to
the miscellaneous tab and let's see there it is already calcium or
now also in the game, let's just set it down,
everything working totally fine. That's also one of the benefits. If you have a already
working block and you copy over
the JSON files, usually when it
works for one block, it's hopefully also going to work for the other
block as well. So that's once again,
pretty cool, right? But that will already be it
for this lecture right here. I hope you found this useful
and you learn something new. All of the code is available
to you in the resources, and I'll see you in the
next lecture. So, yeah.
41. (Basics) Adding Custom Item Group: All right, welcome back to
the fabric course for 118. And in this lecture
we're going to be adding our own custom item
group to Minecraft. Now this is actually
a very easy exercise and doesn't require a lot of, well, basically
changing of code. Inside of our item package, we're going to right-click
new Java class called the mode item groups. And then inside of here
we're going to make a new public static
final item group. All course. So this is just the name of
the variable here, and this is equal
to the fabric item. Group builder built
a new identifier, MC course mod that model ID AMA horse as the name
of like as a string. And then after the
first parentheses, we're gonna make a supplier to open and close
parentheses followed by this arrow here
with a new item stack. And then we're going to
pass in more items or a calcium ingot and then
ending with a semicolon. So this is now one item group. If we wanted to
add a second one, we just could copy this over. Just, I'm a Course 2, I guess something like that. Then of course also change
the name here as well, right? That's very important, but
this is how you would add a second one and then you can
just refer to that as well. But for our purposes we're
just going to add one. And then of course,
how do we call this? Well, instead of the
more blocks class, we can just replace the
item miscellaneous here with more item
groups that course. And then the same
thing goes right here. So I'm just going to
copy this Control C, Control V. And then the
same thing goes for the more items right here will be called
the miscellaneous. We're just going to pass in
the course group right here. And that's going to be fine. Also, just remove this as well. There you go. So now
everything is nice and tidy. And of course, the
item stack here, this refers to the
actual thing that is being displayed in the
actual tab, right? So now it's going to be welcome item or a cotton England
that is being displayed. You could, for example,
also say if you wanted a he or a cotton block
to be displayed, you could also put that in and that would also work as well. But we're going to
stick with the ingot, That's going to be fine. And then this course here
is actually very important because we also want to add
the translation for it. So in the ear and
underscore us JSON file, we're just going to go
at the very bottom. This is going to be
very interesting this item and then group the gate g. The g actually
written in uppercase. Very interesting with your
MOD ID MC course in our case. And then course is the name
that we've given there. And this is just going
to be the Course tab. That's going to be fine. This is now the
name that is being displayed when we
hover over the tab. And once again,
this course here, exactly this right here. So now after we've
added this and added in the blocks
anymore items, classes, Let's see if it works or if answers back in
Minecraft and let's see. So this is a very
good indication if we have a second page right
here, and there you go. The course tab,
Course tab and all of our items or our
box are in there. But that's actually great
and we can take them out and use them
however we would like. So that's actually really cool. But in the future, of course, we're going to use
the Course tab. So I highly recommend making
your own tab as well. So this is basically an abused
in all future lectures. But for the time being, this is it for this
lecture right here. I hope you found this useful
and he learns of the new, and I'll see you in
the next lecture. So, yeah.
42. ASSINGMENT 5: Custom Blocks and Items: Welcome to the first assignment here in the fabric
course for 118. And your assignment
is going to be to add a row or a calcium
item to the mode items. And of course, all of the necessary JSON files as
well as the textures as well. The textures will
be provided to you. Please note that they
are licensed under CC BY SA 4
international flights. And so if you want to use
them in your project, in an open project, make sure to give proper
credit there. And then also, you're
supposed to make two blocks, a deep slit or a calcium or, and the robbery
calcium or block. So once again, the
textures there are provided under the same license. The textures are also provided and everything is also
written on this page, you should see the
assignment written somewhere as an
actual assignment. I had to guess this
shouldn't take more than a round,
about 20 minutes. Maybe you have to go
back and watch the previous lectures one more time. We'll basically
really solidify this. But otherwise, this
shouldn't take too long. And I would say, good luck and see
you in the solution.
43. SOLUTION 5: Custom Blocks and Items: All right, so let's
take a look at the solution to
adding the two locks, the droplet or calcium or in
the rock record can block. So of course, it's basically just an exercise in
copying those over, changing the names here and
making sure that we are choosing the item group
force here, of course. And then in the model items, adding the Rory calcium, once again, just copying it over and changing the name here. And then of course, just the JSON files are all
fairly straightforward. They're basically exactly
the same as the other ones, just pointing to a different
model in this case. All of those are of course, once again available to you in some capacity in the
GitHub repository and also in a just so that you can take a look at each
of them individually. And I believe I will also have
them for download as well. So overall, this
shouldn't be too crazy. This actually should be a fairly easy exercise
for you to follow. And I hope that you
have managed this. If any questions arise along the way or have
arisen along the way, don't hesitate to
ask questions using the Discussion Question
and Answer system. I hope you learn something
with this assignment and I'll see you in
the next lecture. So, yeah.
44. (Basics) Add Custom Recipes: Or I welcome back to the
fabric course for 118. In this lecture,
we're going to be looking at a custom recipe. For custom recipes overall, you might say, Well,
they're going to be probably really complicated. However, that is
actually not the case. Some people of you might
have already played around with data
acts in the past. And it's pretty much
the same thing. So we go down to our
resources folder. And instead of putting
this in the assets folder, we actually have to
create a new one instead of the resources
folder called data. And then inside of there, we're going to create a
new folder with our model. In our case of
course, MC course. And then inside of there, we want to create
the recipes folder. Now once again, it's very
important that everything here is written
exactly how it is, so that has to match exactly
your model ID and recipes also has to be written like
this or lowercase hour. Just wanted to mention
that one more time. And inside of here now, all of our recipes will go. Now, how do they look like? Well, I'm going to
write out one recipe. You're just for the sake
of argument, though, I'm going to right-click New File and we're
going to call this the oracle income
underscore Block, underscore from index.js. And what sometimes might
happen is that at the bottom right here you can see Jason Minecraft recipe Jason, that basically the schema
is automatically detected, but you can also
go in here, right? So for some JSON files, I'm just going to open this one. For example, you
see no JSON schema. You can always go in there
with red and click on this and then basically search
for a recipe and setups. You have microwave data recipe. So there is some stuff here. You don't necessarily need it. The only advantage you're
gonna get is if you start typing stuff in C that you
get some suggestions here. But in a moment I
will show you how you can actually copy
over vanilla recipes, which is gonna make all of our lives hell of a lot easier. So no worries there. So we start with the curly
brackets and then a type. Now the type is basically what
type of crafting this is. And you can see
there are a bunch of stuff for this
shaped, shapeless, lasting camphor
cooking, smelting, smithing, smoking
and stone cutting. Overall, what we're
going to take a look at is basically the
shaped, shapeless, the smelting and
the blasting over the rest very much are
pretty much the same. There isn't that much of a
difference in all of them. First of all, we're
going to take a look at a shape recipes. So this is a shape recipe. We actually need to
define a pattern here, but this is the pattern
that's basically a list, and it contains
usually three strings. And usually those three strings
have the length of three. So these rings represents
the crafting table. So if I do this, right,
so I fill all of the, all of them up with ash extras for the
sake of argument here, then what you should
notice is that, well, that's a three-by-three. That's literally
the crafting bench. And that's exactly
right. So the pattern here represents the
crafting bench. So if I were to do
this, for example, then I will have to fill
the outside and leave the middle slot basically empty. And then, you know, you could do the same thing
with something like this. So that's a general sort of idea on how you can
do this pattern. Now you don't necessarily
have to have three strings, and they also don't have to necessarily be of length three. So something like this, which would be the
door, for example. Because you can graph the door either on the left side
of the crafting table, on the right side of
the crafting table. And this would basically
take care of that. There once again,
a little bit of experimentation is of
course, very smart. And also towards the
end of the lecture, we're going to take a look
at the vanilla recipes so that you can also
then copy from those. Then we need to define a key. Now the key here is very
interesting because of course, this has to somehow
related something, right? What does the Hashtag alarm? I don't know exactly. So we have to define this. We're gonna do hashtag colon and then once again
curly brackets. And inside of here, we're
going to define an item. This is of course going to be MC cores or a calcium
underscore in it. And this now means that the hashtag here is supposed
to be this particular item. But also be not too crazy, then we can make a
result here at the end. And that's going
to be MC course. Or a calcium underscore block. For nothing too crazy
should be in here. This should all be fairly
sensible way we're going to put the oriC welcome
Ingrid here as a key. And then this is basically
being recognized. Hey, we have to put in nine or calcium Ingles to get one or a calcium
blocker as the result. Now the question will come in. What about the other way around? So if I put in an Oracle can block into the crafting bench, how do I get nine or a
calcium ingots out of it? Well, I'm just going
to copy that one over. All of the recent files will of course be
available to you. So we're gonna take
a look at this in C. This is now a shapeless type. Instead of a pattern, we now have ingredients. And you can see we have, only have one ingredient here. The Oracle can block
and it would turn into nine for calcium England. So you can also specify a
count here that by the way, also works for the
shaped recipe as well. That is no issue
there whatsoever. So that also works. So those are two
examples of these shaped in the shapeless recipe. Now let's actually take a look at the smelting
and the blasting. I'm going to copy those over
as well. Right here we are. So you can see the
type here is just blasting and then here
is just smelting. And once again, you have
to define an ingredient. In this case, you can only
define one ingredient. Does you, of course,
only have one input slot in either the blast furnace
or the normal furnace. Then you can say, hey,
what is the result here? You can even define how
much experience you get from each
individual smelt here, and then also the cooking time. So how long in ticks this
is basically going to take. You can see that of
course the blasting one is faster than the
actual smelting. One. One more thing I also wanted
to show you is for example, here I have this stack diamonds from another star custom recipe. And you can see that I'm using both my own items as
well as Minecraft items. And you can see that there's no issue with that whatsoever. You just have to specify Minecraft namespace here and
then the name of the item. So that pretty much
is all there is to it for crafting items
that are not your own. You can craft Minecraft items
that works totally fine, though that is one
example of that as well. And now before we
take a look at this, Let's actually go down so we can take a look at all of the data and asset files from Minecraft by going down
in the project window, the external libraries, opening that up and
then going down. And you can see that basically this one right here, right here. So we have the net Minecraft, minecraft project mapped
and so on and so forth. This one before
the Black big list of which all look the same, right, to above that
we have this one. We're going to open
that up and you can see there's
an assets folder, there's a data folder, and
there's even a net folder. In the net folder, all
of the code is written in what we can basically take a look at all of
the code as well. But we're not gonna do
that for the time being. We are interested in the data folder,
Minecraft, then recipes. And you can see, I could
now take a look at every one of those recipes legged wouldn't even
matter here, right? So I could take a
look at anything. But for example, Oh, how does the smelting from coal or oh, that that's how it works. Okay. Fair enough. We can go to the composter. How do you craft that? Oh, yeah, of course, that's
how you crafted that. You can see that
you have access to everything in here
that you might want. So genuinely you should
be able to almost do anything in terms of the recipes that you would
like with this equipped, you basically have
access to anything. I highly recommend
if you then want to basically take one of those. So let's say, for example, the cook salmon here
you're like, okay, I want to take this. What you do is you just
elected press Control C. Then you can move up back to your own recipe folder
Control V to paste it in. And then you have it in there. And then you can
basically change it however you would like. But that's the general
idea of how to do it. I'm just going to
delete it again because we're not going
to need that one. That's going to be fine anyway, after having added all of those, Let's see if it works or
if ourselves in Minecraft. So let's first of all see
whether or not we can craft the block with the oracle coming minutes
and there you go. We can very easily done. And what you will also
find is that as soon as you have the recipes
will made once, you can see that they
are also available here in the actual recipe
books. So that's pretty cool. Let's see if I can
smell the robbery, count them as well here. And of course I can, and it should work in
either the normal furnace or the blast furnace as well. Now, yeah, this one actually is definitely faster so
they go easily enough. And you have seen I can also
after the other way around. So like that also works. That's pretty cool if
I do say so myself. Now of course, all of
the blocks that we have, there might be some more
recipes missing over. We're actually
going to have those in the next assignment, which is going to be after
the next lecture actually, where you basically have to add the rest of
the recipes here. And those will, of course,
then also be available. So no worries there. And of course you always have access to the
recipes right here. So in theory, this should be a very, fairly simple exercise. But for the time being, this is it for this
lecture right here. I hope you found this useful and learned something new if he did. And I'll see you in
the next lecture. So, yeah.
45. (Basics) Custom Block Drops with Loot Tables: Or I welcome back to the
fabric course for 118. And in this lecture we're
going to be looking at custom lose tables though what
our custom route tables, well, those basically define the things that drop from
a block when you mine it. So we have in our blocks, the Oracle can block and
the orbital OK. And if you hopefully have done
the first assignment, then you will also
have the deep slate or more and the row
or a column or block. Now we're going to now implement drops for the block
and the, or, the, or is of course special here because there's going
to be some differences whether or not you have a tool that actually has
cell touch on it. And if that is the case,
then of course the actual or block drops. Otherwise the raw or
a calcium will drop. Though there's a couple
of things that we need. Once again, in our data folder, in the MC course folder, Right-click new directory
called loot underscore tables. Once again, very
important that this is written exactly like this. Then inside of there in new
directory called blocks. But I'm going to make
a new file in here called the Oracle come underscore
block dot-dot-dot JSON. Now what's very important
is that this name right here has to match the
name given right here. But this is different
from the recipes because the recipes we're not really dependent on a particular thing. We were able to define the
result in the side of it, while this time in
the luge tables, the name of the file once again has to match the
name given here. Very important, right? We're just going
to go through, so we're going to have a type. And that is going to be
Minecraft colon block because of course this
is a block loot table. Then we're going
to have a wills. And this is a list. And then basically a
curly brackets here again, roles, roles one. And then we have
some entries here, which is another list. And inside of there,
we're going to have a type which is Minecraft items. So we want to drop an item here. The name of that item is MC course colon or a Malcolm
underscore block, right? So this might look pretty crazy to you and that's
absolutely fine. Because overall,
the general gist of the luge tables is that
they can be quite complicated. This is definitely an
example of a very, let's say easy or symbol 1. However, the, they can definitely get way
more complicated. For example, the old one,
I'm actually going to copy this over right here. So a recap them or, and
you can see that this is a little more complicated
as you can clearly see, that you can see that while
we only have one entry, this is now of
type alternatives, which means that basically, well there's two alternatives. We either have an item where if a particular
condition is met, we're going to choose that one. And otherwise we just have an item with a
particular amount here. These lewd tables can
get very complicated, very fast, as you
can clearly see. And the general idea is that, well, there is a good resource. There was actually two
good resources that I can highly recommend. One of the resources is
the Wiki entry right here. So this is the Minecraft
Wiki loot table entry. I highly recommend taking a
look at this because you can basically look at all of the different things
that are in there. So this is basically
how this is described. Now, overall, this is a little complicated
to read for the first time, but I highly recommend
if you really want absolutely
custom route tables, you'll have to take a look
at this and just have to take a look and go
through this basically, then there's another
thing and that is the loot table generator
by a missile GitHub IO. This is incredibly useful and you can basically just choose everything that you want, right? So you can say, I
wanted to stone to drop only if there's
a specific things. For example, you can have
a random chance in here. Once again, location
check, even match tool. There's a lot of stuff
that you can do in here, and I just highly, highly recommend it
when you look at this link as well,
generating some stuff, make sure that you are 11, 18 up here because there are differences between
the version sometimes. Now if you do not require
anything that is to, let's say, out of the
realm of vanilla, then you can also
of course go to the external
libraries down here, to this one right
here, net Minecraft, minecraft project at,
and so on and so forth into the data folder,
Minecraft loot tables. And then basically
take a look at all of the luge tables that the
normal blocks have as well. For example, I mean,
what might it be? The chest are not actually
interesting because the dropping of the of the chest was handled
differently in that case. But where else do we have? I mean, what might
be interesting? You might, grass might be
an interesting one, right? The grass block
actually right here. Once again, we have
alternatives, right? If you have silk touch on it, you get the grass block,
otherwise you get dirt. So I highly recommend
once again, if there is anything that
already exists in vanilla, just taking a look at
the external libraries is gonna make your
life way easier. But just adding those
to lose tables is actually not everything
that we need to do now this is
very important. Do not skip this step
under any circumstances. Otherwise it will
not work, right? So we actually need to
add some tags as well. We've not talked about tags yet, but we will very soon. However, for the time being, we can just think of them
as sort of a list of items, blocks or whatever we
can think of that has a common purpose or is
grouped together in some way. So inside of our data folder, we're going to
right-click new directory called Minecraft. Now you might have
heard of that before. Now, inside of there we're going to create a new
directory called tags. And then inside of there
we're going to create a new directory called blocks. And then the last but not
least in terms of their, we'll also need a new
directory called mineable. Mineable actually
they ago and now I'm actually going to copy over the or mineable tags right here. And I'm going to explain
in just a moment, we also need three
tags or the blocks. This is of course, all
available to you in the GitHub repository or an
individual just as well. And this is also to be found right here again in
the external libraries, right in the data folder, we go to tags blocks, you can see mineable. There's exactly those
four JSON files as well. And then in the box folder here, the other four are, the other three actually
are also available. So what does this mean? Well, we have to be able to set the inability or our blocks. This means that if you can
take a look at this rate, I have added already the
oracle comorbidity block, the raw recalc and block
and the deep slate or a telecom or to the
pickaxe adjacent. This means that this is, these blocks are mineable
with a pig acts. That should make sense, that should be fairly
sensible here. Nothing too crazy. Now the same thing
goes for the needs Diamond needs iron
ore, needs stone tool. We can basically
define what level of tool that it needs in
order to mine this. So the iron tool here, I've actually have basically defined it as
needing iron tools. At least each of those
blocks would not be mineable with a
stone tool only. So that's actually
very interesting. So it needs iron ore up, and that is basically
what you need to add additional
things in here. You can literally just add
a new one here, right? So I don't know MC course test. And then basically
just make sure that we have a comma here as well.
And that's pretty much it. So that is all that
you need to do. Make sure that all of the
blocks that you define inside of these tag files
are actually valid. So you can't just like
I did the test one. If that doesn't exist, then you might run
into an error. So that's very important, but you will need those tags and you will need to
define everything inside of your for them to
drop their loot basically, that's a very important thing. I highly recommend you do this. And once again, of course
this is all available to you. Otherwise, making
those files really isn't that complicated
as you can clearly see, they're not that crazy. But for the time being, let's see if it works or
faster back in Minecraft. So let's just try
to mine this with the stone pickaxe
and you can see it already takes a long time. And it, It's, this should
not yield a result. And of course it does not. When you use the iron pickaxe, it works and it also
drops right here. But let's try the
same thing here. And you can see that our
raw or a telecom drops. And we can also try this with the nether write X for example. I mean, this is actually
taking so long. This is a very good indication, usually of course, that
this does not work, right? And then diamond of course, also works because it works up, well, basically iron or above, That's the general idea here. So that is pretty cool. And then just for
completion sake, a diamond pickaxe
with silk touch. And you can see that
now it actually drops the Oracle CRM or
here as well, right? One more last thing I
wanted to mention is that if you have not called
The requires tool here, then this might also
not work as well. So this is another prerequisite
that is very important. I just wanted to
mention that because I am not a 100 percent
sure whether or not I mentioned that in the
block tutorial as well, but this is definitely needed as well for each of your blocks. So that is very important. But otherwise, this would be
for this lecture right here. I hope you found this useful and you learned something new. I'll see you in
the next lecture. So, yeah.
46. ASSINGMENT 6: Custom Recipes and Loot Tables: All right, Welcome to the
second assignment here for the Minecraft
portion of this course. And in this assignment, you are supposed to do
the following things. Now of course you
have the actual tasks hopefully in front
of you as well. But the idea is
that you should add loot tables for both the block, the deep slate or a falcon or, and the row or a
column or block. Those should be fairly
straightforward as we've seen two examples which are
almost exactly the same. Well, that should be, I think,
fairly straightforward. And then when it
comes to the recipes, I actually want you
to do a few things. I want you to add
the blasting and the smelting recipe for
both the or blocks. That's number one. And number two, I want
you to be able to, I want you to be able
to get a nuggets from an ingot and then also crafting nuggets back
into an ingot as well. And then last but not
least for the recipes, I want you to just any recipe
using some vanilla items. It can be anything
that your mind can basically dream
off of, you know, getting 64 diamonds for like 2 third blocks or something like that
could be anything, as long as at least takes into Minecraft items in the
recipe, I'm fine with it. That would be basically it. If anything is unclear,
you should, of course, have the tasks available to you to basically double-check, but good luck and have
fun on the assignment.
47. SOLUTION 6: Recipes & Loot Tables: All right, let's take a look at the solution for the
assignment here. Of course, the
robbery calcium block was fairly straightforward. Hopefully it is pretty much the same as the normal or recalc. Unblock. This here. Dropping the rock
record can block that should hopefully when
very easily here. And then the div
slate or a calcium or is almost the same as
the normal one as well. We're down here, it drops the
Rory calcium over up here. It actually drops the deep
slate or a calico or that is just one tiny change that
you would need to do in the oracle or
loot table, Jason. So hopefully those
were not too crazy. But let's take a look at
the two blasting recipes. Of course, you're
only the ingredient really needs to change. So the result is of course
still going to be ingots. And then for the smelting amine is pretty much
almost the same. The only thing that here, the changes for the blasting to the smelting is
the cooking time. And then here once again, the items That's pretty
much all there is to it, the nuggets might
be a little more interesting because
of course one of them is a shape recipe
and the other one is a shapeless recipe that
returns a count nine as well. So that might have been
very interesting here. And then of course,
there's no solution for your custom one. As long as it works, it is fine. You can of course,
always take a look at the stack diamonds from
nether star right here, which is a idea or a, one example of a possible thing that
you could do as well, but that will be it for
this solution right here. I hope you found this useful and you learned
something new. I'll see you in
the next lecture. So yeah.
48. (Basics) Making an Advanced Item: All right, welcome back to
the fabric course for 118. And in this lecture
we are going to be looking at an advanced item. So what is an advanced item? Where would I call
advanced items are items that have their
own item class. So if we go into our
more Adams class, we can actually see that neither the ingot Northern
nugget nor the row or a calcium have their own classes because they're all
new items here. Now this is going to change. Instead of our item package, we're going to right-click
new package called custom. And then inside of
there we're going to right-click new Java class, and this is going to be
the dowsing rod item. Now a few things
to mention here. Usually you want to end this
with the name item here, whatever the name
is of your item, and then ended with item, just so that you can easily see that this is
actually an item. This is now going to
extend the item class. So we're going to choose
this one right here. And then we'll hover over this creed constructor
matching super. And now we're actually very happy with how the SR and out. We can now already
be using this class. Of course, however,
we want to add some custom functionality to it. Namely, when I right-click
with this item, I basically want to check
every block below a block that I've just clicked and see if there are any
valuables in there. So how are we going to do that? Well, let's just first of all, middle mouse button
click on the item class, and here you will find a bunch of things that
you can overwrite. So this is number one in appeal. Once again, if you are
not familiar with Java, to take another look at
the Java introduction, I highly recommended because now as we're getting into more
and more advanced territory, I will basically assume
more and more that you just know what
inheritance is, at least on a basic concept and an overriding of a method. You just aren't sitting
there and you're like, I don't know what that means, but you at least have
a general idea of it. But we can override
methods and basically create our own
functionality for them. So as you can see,
there are a lot of methods that we could
overwrite in theory. And that is also one
of the cool things. So what I can do is I can
start typing override. And you will also
get basically all of the suggestions that are
possible for us to override. Now there's a bunch of them. So the US, for example, is the right-click method without right-clicking on block. There is something like
the append tooltip, which as a tooltip which
we're also going to see in a future lecture as well, the inventory tick, which
is executed every tick, This item is in your
inventory usage tick. I'm actually not a
100 percent sure, but I think that this is
executed every time you have this in your main hand and you right-click
something like that. Although also if we were to just import this and I
middle mouse button click on this on
the Super one here. Sometimes they have
some indication above them, so some comments. That is not always the
case, but, oh, well, but what we're going to
use is we're going to use the US on a block method. As you can see, we'll
just type that in and double-click and then
it will generate this. The add override here is an annotation and this is
not strictly necessary. However, it does give you on a normal glands through
this class the idea that, oh, okay, So this is
an overridden method. That's why this is here. So that's actually
very important. And now comes the custom code that we will write basically. And this once again has a lot to do with Java
knowledge basically. And we're going to
start by, first of all, checking whether or not we're on the client or the server. Because in this actual case, what we actually want
to do is we wanted to only do something
here on the client. This is not always the case. Usually we want to start
to happen on the server, but that is sometimes the thing. We're gonna go into the
little bit more detail, however, not too much. So for the time being, what we have is we have
that context here, has a whole load of stuff. So for example, the world, which is exactly what we need, the autocomplete that with tab. And then we're gonna
say is client. And I usually take
the method over. This doesn't really
matter if whether or not you take the method or the
field is totally fine. And now what we know is that if we're inside of
this if statement, we are definitely on the
client, so that's pretty good. Now what we want is we
want the position of the block that was
clicked and we get that as a block Pause. And this is just
the position lift. And this is equal to context dot get blocked path
as you can see. And then we want the player, this player entity layer, which is equal to context
dot get player right here. And then we can also
have just a Boolean, which is going to
be the found block. This one just checks whether or not we
have found the block. We're gonna do that
in just a moment. But the idea is once again, when I right-click on a block, I wanted to check every block
that is below that block, going down all the
way to bedrock. And basically checking, hey, has this found a valuable item? Those valuable items we're of course going to define
in just a moment. But for the time being, let's just make a for loop. So for int I equals 0, I is smaller or equal
than position clicked. That gets, why actually get y? And then I plus, plus. And then what we wanna do is we want to do something
very interesting. We want to get the block below. So block, the
block, block below. And that is going to be the
context dot-dot-dot world. But to get block
state at position, clicked that down and
then passing in the eye. And then here we're
going to get the block. So, and then of course,
also import of this class. So now this might
be pretty crazy. Well, let's just
think about this. First of all, we're just getting the world that
should be too crazy. And then we're getting a
particular block state. Now we haven't talked
about blocks and versus block states just yet. However, the general
gist is that block states are
the representation of blocks inside of the world. While a block is sort of like
a perfect idea of a block, the block state
is the thing that actually exists
inside of the world that has coordinates and have different
properties, for example. So this gets the block state
at this particular position. And then of course, when we have the position that we clicked, we're just going down by I, which at the first
time is nothing. And then as we increase i, as the for loop continues, we go down further and further. So this is basically
always the block below. And then what we can
do is we can check, hey, is this a valuable book? And for that we're
actually going to make a new method for that. Because that actually makes, because that actually makes
it a little bit easier. So we're going to say private
boolean is valuable lock. And then we're
gonna just going to pass in the block here. And then we can basically
return a Boolean. And what we're gonna do
is we're just gonna say block equals blocks dot
col, or for example, coal or, or LOC equals
locks dot copper, or let's just add a few more. So block equals Langston diamond or an Last but not least, let's also add the
iron ore as well. So blocks the iron or the ego. And now this method here, if this is cold and a
block is passed in, if it's either of
those four blocks, then it will return true. And what we're gonna do
is we're gonna say if is valuable block here, and then pass in the
block below, right? Then what we wanna do is, let's just say what we
wanna do is we want to output the actual
coordinates of that block. We also want to turn
found block to true. And then actually what
we wanna do is we want to break out
of this for-loop because we have found the first valuable block and
that's basically then done. So that is the general idea. Now the first thing
that we wanna do here, like I said, is the outputting
of the coordinates. Now for that, we're going to
make a new method as well. So the idea is that
let's first of all write this out and then take the written thing and
make a method out of it. So we can say
player sendMessage. This is actually a very
interesting way to do this. Then we're going to
say New literal text. Though, a literal text here. This is basically a string. We can find where we
can put stuff in. We can say something like found. And then we can say
block, block below that as item that gets
name, that get string. So this is a pretty crazy one, but this basically gets the
actual name of the block. And then we can say at, and then at the particular position. For the particular
position is going to be something lake. Open parentheses and then pass to the position
clicked dot getX. Plus comma. Position clicked. Why? Then plus once again comma, then plus position
clicked dot get z or z. And then closing the
parenthesis in the string here. And then after the
literal string component, we want a false here
are the ActionBar. Now you can see this is
very unwieldy Rayleigh. So this is like, first of
all, it doesn't look good. It's very unwieldy. So what we can do is we
can just select all of this right-click
Refactor Extract Method. And we're going to do that. And you can see that now we have actually extracted all of this. And it has, well basically just done all
of the work for us. Now we just have to set a name. We're going to set
this name to output valuable ordinates right here. And then inside of
the actual method, what I wanna do is I want
to just maybe change the names here so I can click
on Control and Shift fx, something like for example, the block paths here. And then the rest,
I think is defined. So this, of course could, we could change this
even more, right? But for the time being, I think that this is
going to be fine. This will simply output the coordinates of
whatever we give it. That looks pretty good. Now what we are
going to get here is we're going to get a while
an argument because hey, player could be null. So you can see argument
player might be null to either assert. We can also change around a bunch of stuff.
The time being. I would not worry
about this actually. And there's one more thing with that we want
to do, of course, and that is if the block
has not been found, right, then we want to
output something as well. But for example, something like player dot-dot-dot
sendMessage. And then we're gonna do is
we're actually going to make this one the radar
translatable text component. And then let's set the
action word false as well. So usually I highly
recommend using the traits legible
texts components here whenever possible. So you could use a translatable text
component here as well. However, it doesn't make this a little harder to
actually properly do, but you could do it. I highly recommend using
this whenever possible, where we basically
define a key that we can then put into the E and
underscore us adjacent file. So for us I'm going to do it
like this item, MC course. So I'm going to stick with that. And then we're going
to take the name of the item dowsing rod, not know underscore valuables. Lets the name that we're going
to define in just a moment in the end underscore us adjacent file, but
that's going to be it. And then outside of
this if statement, we're actually going to say
contexts that get stack. So this is the, the
actual item stack, the item that we have in
our inventory, dot damage. We want to damage
this by amount one. We're going to say
contexts, dot get player. And then the last parameter
is going to be a consumer. I believe this is
going to be a player exactly player consumer
of player entities. So we're just going
to call this player. And then we're going to
say player dot sind, sind tool and tool bricks status with the player
dot get active head. But this might also be pretty crazy to you, but no worries. Well, this all does
is simply says, hey, the actual item we have just
right-clicked a broke with, we're going to damage
by the amount one. So this is going to decrease
the durability of it. And then we just pass it the
player, that's totally fine. Then the last thing
here is just what type of tool break animation
it should send when the damaging of
that item stack is actually going to result
in the item being broken. Now. And that is basically the
entire class right here. Though, it is pretty crazy. And once again, without some Java background is probably going to
be very complex. I highly recommend you
have this, of course, all available to you in
the GitHub repository or in an individual just as
well to take a look at it, try it out, you know, to put it in your own math and just try it out a little bit. Just change a bunch of stuff, see what might happen. And let's not forget
to add this to our E and translation file here. I'm just going to add
this at the very bottom. This is actually going
to say the following. This will simply say,
no valuables out. So that's all that
this one says here. And now the great thing is
if we had, for example, another language file, we could translate it into a
different language. That's why usually
the translatable text is the thing that
you want to use. So keep that in mind. Now, just having
added this class, of course, is not enough. We also have to register
it in our mod items class, and we're gonna do that as well. So let's just copy
over the rock outcome. Like I said, I usually
just happy over old old items because they
are almost always the same. This is the dowsing rod. And then here as well,
of course, dowsing rod. And instead of new item,
this is very important. This is a new dowsing rod item. So this is the main thing
that we need to do here. So very important
that you make this. We also want to set the
max damage right here. So max damage is going
to be, let's say 32. So we can use this 32 times before the actual dowsing
rod breaks because of course we're
damaging it right here inside of the
use on block method. So this should be totally
fine right now also, let's add this to the un
underscore use JSON file. So dowsing underscore rod and then here as
well, of course, dowsing, dowsing rod
without the underscore. And then last but
not least, we need the item model as well
as the item texture. So let's just copy over
the role or calcium for this dowsing rod and
then your dowsing rod. But once again, this is the
normal way I go about user, usually adding items
when I already have some existing models here is very much way easier
than anything else. Writing it out is
absolutely crazy. And if there are any typos in
yours, you can, of course, always take a look at
the GitHub repository or the jurists as well. And let's copy over
the dowsing rod as well. There you go. Of course, also available. Please note the
credits notice though, that you follow
the license there. So overall, that is
actually totally fine. And I would say We're now ready. Take a look at whether or not it worked or finds us back in Minecraft fans can
see the dowsing rod has been successfully
added to the game. And what you will
also find is that I actually can't stack it. That is exactly right because of course we've added
the max damage. And if you add max damage, then, well basically the stacking
will no longer work. Now let's just go over here and let's actually just
right-click and you can see upper or found
there an hour for their, uh, no, no valuables
found right here. And you can see that
the actual durability decreases as I'm
continued to click here. Let's see, maybe we can find some diamond before it breaks. Wouldn't that be pretty crazy? We sadly didn't. But there you go. Now at broke in and now we have
the other routes, of course available as well. So we can just go
through this and see if we can find
anything below here. But that is pretty much the general idea of the
dowsing rod, right? But that would already be it
for this lecture right here. I hope you found this useful and you learned something new. If any questions remain
for the advanced item, please don't hesitate to ask. Otherwise, I will see you in
the next lecture. So yeah.
49. (Basics) Making an Advanced Block: All right, welcome back to
the fabric course for 118. And in this lecture we're going to be making an advanced block. So just like we've
seen last lecture with the advanced item, now we're going to
do an advanced block for in our block package, right-click new
package called Custom. And then inside of there
we're going to create a new Java class
called the SPD block. Now this will extend
the block class, making sure that we choose the correct one, net
Minecraft block, block, and hover over this creed constructor
matching super. And just like before we
can middle mouse button, click on the block class and basically take
a look at all of the possible methods that we can override in our
custom block class. And as you can see, there are tons of things that we
could override here. And I can also put in
the word override. Any will see there is
a bunch of stuff here. Now one thing I
wanted to mention is that things that are have this strikethrough that are
basically deprecated, right? So if I take a look at this, you can see that this one
right here is deprecated. Usually. What that actually means
is that you can just, you can override those methods, however, you
shouldn't call them. So that's the general idea in the block and the item class, things that are deprecated. I don't mean that they're
deprecated and they are not be available
in future versions. In that case, actually it is
about them not being caught. And that includes the
super for example. But we're going to see
that in just a moment. What is the SPD block gonna do? Well, the SPD block is going to have two different
functionalities. Number one, if you step on it, you get the speed effect
added to your character. And then just so
that you've seen it, the right-click functionality, when you right-click the block, we're gonna just output
a message into the chat. That is going to be it. So let's first of all do the stepping stone method that
is called on, stepped on. And you can see there you go. And what we'll do in here
is actually very simple. We're first of all
going to check if world is client and are
very, very important. We're going to add
a exclamation mark in front of it to say, we don't want to
be on the client, we want to be on the server. As when you add, for example, a status effect, you can
only do that on the server. Then we're going to check
whether or not the entity that has stepped on this
is instance of living entity because
only living entities can have status effects
applied to them. And then we can, without issue, get the living entity right here and just cast
the entity to it. So entity dot cast. And then usually it fills up with living entity
are here already. And we can take the
living entity and we can call the Add
status effect method. And what we can then do is make a new status effect
instance, as you can see. And that takes in
the status effect, that is effects that speed
and a duration to a 100. The duration here is,
of course in ticks, therefore this would
be ten seconds. It would of course
change this as well. That is of course
totally up to you. But that is actually all
of the method that we need for the step on
speed effect here. That is literally it. That's all that we need to do. But now let's actually
take a look at the right-click
functionality as well. And that is the
owner use method. And you can see that is one of those ones that has the
strikethrough that is deprecated. So we're going to make sure that we do not call the superhero. And we're going to
say action results. That success, that's
going to be fine. Right here. There you go. And then in here, what we're gonna do is we're
going to say if world, that is client, the ego. And then inside of here
we're going to say hand equals and that main hand. And then we'll do an else here. So what, what is happening? Why am I doing this?
Well, we're going to copy over a little comment that
I've already prepared for. The idea is that the unused
method is called for times. When you right-click the block, It's called twice on the server, one for each hand, and then twice on the
client for each end. That is the very
interesting thing. Then what we're gonna do is
we're just going to output, this is why not the ego, that's going to be fine. But this is just once
again players and message with a little text. This is something we've
already seen, of course. And that's pretty
much just an idea. I just wanted to have
this in here as well, just in case that
you might want to have a red click
functionality of your block, you will use the unused method. And this is very
important to keep in mind here is, for example, if you were to change
something in the code, knowing that it actually
happens twice for each hand is actually
very important. So please keep that in mind. And that is pretty much with
the SPD block class done. We don't need to do
anything else here. The next thing that we need
to do is we need to go into our model blocks class
and then of course, make the actual block
and register it. So we're just gonna copy of
the raw or a calcium block. And we're going
to make this easy speedy underscore
block right here, and then of course here as
well, speedy underscore block. And then right here, this
is now the SPD block, the new speedy rock here. Very important once again, that we make sure that this is correct and not just
a normal block. Very, very important. And otherwise we just need
to add the JSON files. And those are of course
available to you in the GitHub repository or in
individual just as well. I'm just going to copy those
over because those are very much just normal everyday. Jason files, right? There's nothing interesting
really going on here. The block model looks exactly the same order
Brockman rules we've seen the item model is pretty
much just the same as any other block
item model here. And then we'll also
copy over the texture, which is of course
also available to you, please not the credits file for the specific license
to these textures, but otherwise
that's actually it. Let's also add the translation. Of course, let's
not forget that. Let's just copy this one
over and we're just going to say is the block. And then here the same thing. Speedy block, the ego. And now everything
has been set up. So let's see if it works. Or funds back and
microfinance can see the SPD block
has been added to the game and I can
set it down so the texture is just normal. So like I said, right? Even though this kind of looks a little bit sided to where it
would change the texture. It actually doesn't. This
is something we're going to see in a future
lecture actually. And let's just, let's just,
for the sake of argument, put it down so that
the arrow looks in the direction we're
going to move into just so that it's
a little nicer. And as soon as I go
on top of the block, you can see that I have the
speed effect applied to me, and this is now for ten seconds. Now if I keep standing on this, see that it keeps applying the facts to me and
resetting it to 10 seconds. And then I can basically just
run with a speed effect. And that is pretty
much it, right? Actually, we have to return here is an actual result pass. And then the actual calling for two times for the server and the client will
actually work. So that is just a little
bit of a difference there. So let's actually just see
if that works as well. All right, so now
if we right-click, you can see I get a
message in the chat for both the main
hand and the offend. And also we can still
place blocks next to it. That's also a very
interesting thing. I highly recommend
playing around with the actual results
that you return. Because depending
on what you return, they'll have a different type of interaction when
you right-click. So you can see when I
actually place a block down, by clicking on that block, you can see that
it actually only gets called for the main hand. While when I click with
nothing in my main hand, then it gets called for both. Take a look at what
you can change by changing what you return
in that method, right? But that is already it for
this lecture right here. I hope you've found this useful and he learns that the new, if he did, I would very much appreciate a review from you. Otherwise, I'll see you in
the next lecture. So, yeah.
50. (Basics) Making a Custom Food Item: All right, welcome back to
the fabric course for 118. And in this lecture,
we're going to be adding a custom food item to Minecraft. Now that is actually a very
straightforward process and we won't even need a
custom item class for that. Over we are going to
make a new custom class, and that is in our item package, right-click new Java class. And this is the MOD
food components class. And this will hold all of our food components because we basically have to
add that in our item. So for the time being, let's just go in here
and let's add this, so to say public static food
component called turnip. Because what we're going
to add a turnip here. And this is equal to a
new component builder. You can see right there, I'm going to press Tab
to autocomplete this. And then you can see this is a builder pattern once again, so it can add multiple
different things. The first thing I wanna do
is I want to add the hunger, though this is going to restore one piece of meat
in our hunger bar. And then the saturation modifier is basically how
much saturation, saturation you have in the
background, so to speak. Then we have to end
this with a bill. And then the food
component here is built. Now what you can also
do is you can also add an a status effect
here as you can see. So I could add a status
effect that this is exactly the same idea as before we've seen
with the SPD block. So we just have to pass in
a status effect instance. For example, of effects, status affects not as a generation or something
like 200 takes. And then here we actually
have to pass in a lot was, which is the chance you have on getting this
effect right here. So this is just an example here. We're not going to
keep it like this, but you've seen it. It's actually very,
very straightforward. Or vanilla examples
what you can do is you can press shift twice in rapid succession and then you
get this search window up. You can search for the
food components class, make sure that you check this, include non project items
and then here item. Click on here and
you can see all of the food components that
Minecraft already has. And you can basically also see all of the different
things that are in here. So there's actually like
everything already in front of you and
you could just take a look at how this all works, right now have two, we've
added the food component. We now need to add the food item in our model items class. What I'm gonna do is
I'm going to copy over the row or a calcium. And this is going
to be the turnip. And right here as well turn up. And this is a normal New
Item, completely normal year. And then we're just
going to add after the group, we're
going to add food. And this is going to be the mode food components that turnip. And that is pretty
much all that we need to do that of the food item. Now we should be
able to eat this basically when we
are hungry in game. Now of course, we
still do need to add both the translation here in the year underscore
us JSON file, as well as of course adding it the texture and the
item model JSON file. The item model JSON file
is of course once again just a normal item model Jason that points to
a texture right here. And the texture is right here, so no worries at all. And now everything
has been added. So let's see if it works. Or farms that back
in microfinance can see the term has
been added to the game, so let's start eating
it and there you go. It fills up exactly
one hunger bar. So to hunger is basically
one meet symbol right there. So that is pretty much it. And yeah, that's actually
how easy this to add a custom food item
to Minecraft, right? And there's already it for
this lecture right here. I hope you've found this
useful and he learns of the new, all of the corners, of course available in
the GitHub repository or an individual just as well. And I'll see you in the
next lecture, though. Yeah.
51. (Basics) Making a Custom Fuel Item: All right, let's continue with
the fabric course for 118. And in this lecture, we're going to be adding a accustom fuel
item to Minecraft. Now, this is also a fairly easy and
straightforward process. But we're gonna go into our
more item class and we're going to just copy over
the turnip right here. And then this is going to be
the coal underscore sliver. And here of course as well, the coal underscore sliver. So it's just a sliver of coal. And we're going to remove
the food of course, because in this case, the causal verse
should not be edible. And what the item once
again has been added. But now of course, we
need to somehow add the functionality
of it being a fuel. And for that, we're
going to go into our MC course package, right-click new
package called util. Now this is not strictly
necessary to create this class. You could also just
call the method immediately in our
MC course mod mass, but I like to have
everything separated out. So this is the registries class. And inside of there, we're going to create
two static methods. The first one is a public, public static void called
register mode stuffs. And this is going to call the other method
which is going to be a private static void
or register fuels. And every time we add
a fuel to our model, we can basically
call it right here. And we're gonna do
register fuels in the register mode stuffs method. And then we're going
to write in something like system out print line, but register during you will, or MSE course plus
MC course, RID. And then we're gonna
say fewer registry, exactly this one, which is the registry is equal to u will registry
that instance. And then we can just
say registry dot add. And then a more items
dot whole sliver, then a value of 400 case. Now the calculation
goes as follows, right, for 400 is 400 once again
and takes of course, for a 100 divided by 20, which is 20 seconds, this is exactly 1 fourth
of a normal coal. So that is basically that. And then of course
we need to call that in the initialized
method as well. So more registries that
register mode stuffs. And then if anything
else happens to warrant a registration, then we can basically
add that in the modern registries as well. So that's pretty
cool. And that's basically all that we need to do to make the coal
sliver be a new item. Now of course, we
do still need to add the translation right here. So let's copy this and call
it, call underscore sliver. And then of course
here, cool sliver. And then for the item
I'm going to copy over the turnip here. This is the coal
underscores liver. Then here the coal and
of course liver as well. Just a normal item model file. And we're just
going to copy over the texture here as well. And now actually
everything has been added. So let's see if it works or it's and we
find ourselves back in micro events can see
the coal sliver has been successfully
added to the game. And let's just see. There you go. We can even shift
clicking in here. And just like specified, it will take 20 seconds
to burn and then consume a new cause
liver from right here. That's pretty good. And that's actually how easy it is to add a custom fuel item to Minecraft wherever that is already for
this lecture right here. I hope you found this useful
and he learns of the new, if he did or very much
appreciate a review from you. Otherwise, I will see
you in the next lecture. So, yeah.
52. (Basics) Adding custom Tooltips: Or a welcome back to the
fabric course for 118. And in this lecture
we're going to be adding a custom tooltip who
are dowsing rod item. So this can basically
be done for any item. So what we're gonna do is we're
just going to override a, another method in here. So this is going to be the
append Tooltip method. And this is actually going
to be very easily done. So the only thing that we
need to really do is we want to make it so that when
you hover over the item, you get something
like of the effect of press Shift to see
more information. And then when you press Shift, then you get some more
information about this item. What we're gonna do is
we're going to make an if statement and we're
going to call a screen, shot has shifted down and then make an else
statement for that as well. And then how do we add a new, something new to the Tooltip
will we'll just do Tool to add and then make a new translatable text
component or text here. And then we will pass
in a e. In this case, this is going to
be item MC course dowsing rod housing
underscore rod, that tooltip, that shift. Now of course, you can
make your keys as long or as short as you want. I'm going to stick with this. I actually think that
that's totally fine. We're going to put the
tooltip here as well. And what we're gonna do is
we're going to change this. You would not include
the shift here. Let's copy this one
more time and let's go to our ear and underscore
us adjacent file. And let's just put this
at the very bottom here. As I feel feel like that's
a good place for it. And then when we actually
are pressing down Shift, then what we can
do is we can say right-click to find valuables. Valuables they go. And then the other one, we're just going to have
to remove the shift here. And then this is just
going to be rest. And now we're going to try
something very interesting. So this, we're going to
be a paragraph symbol E, theft, paragraph symbol
R, or more information. And there's two ways
that this can go. So this is something
I want to explain. The paragraph symbol
starts making a, making the, starts making the text into a different color. Now, usually the paragraph
symbol e should work, but sometimes there are some
bugs associated with it. And I just wanted to show
you both versions of it. So sometimes this works. So the E basically
starts making this yellow and then the
paragraphs are, makes it so that
everything is reset again. But this is actually all that
we need for the tooltip. So let's see if it works or
it has a deck and Minecraft. And if I hover over
this, you can see press shift for
more information. And when I press shift
or a whole shift down, right-clicked
find valuables. So everything working absolutely perfectly for this is
exactly what we want. And even at the coloration
here works perfectly fine. So that's amazing, right? I will also link a Wiki article on the formatting
codes for Minecraft. I highly recommend
taking a look at that, but that would already be it
for this lecture right here. I hope you found this useful
and you learn something new. And I'll see you in the
next lecture though. Yeah.
53. (Basics) All about Tags: To the fabric course for 118. And in this lecture, we're going to be
taking a look at tags. Now, what our tags will, I'm not talking about
a tags that you put onto animals
like the name tag. I am talking about a
tags like we've seen previously for the minor balls. And we'll basically what tools
you need or your blocks. And what we're gonna do is
we're going to add a new class that basically enables
us to use tags as well. In this will basically make our MOD more compatible
with other maths. So in our util package, we're going to right-click
new Java class, and this is the mode
tags class writing. We're going to have to
static classes in here. The first one is a public
static class, four blocks. And then the second one is a public static
class called items. And in the blocks class, of course the block tags go and then the items
class, the item Texaco. But for that we are
going to need to a private static methods here. So private static tag dot
identifier of type block, in this case, making
sure that we choose net microwave block here
would create a tag. And this is going to have a string name
parameter right here. And this is going to
return the tag factory that broke that create. And then a new identifier
with EMC course mod, mod ID and the name
of the parameter. Then we can just copy
this one over n. This is now a create
Harmon tag like this. And instead of passing
in our old model ID, we're going to pass in
just a lowercase c, because this is a
namespace under which the common tags basically
are going to be set. And then what we can do is
we can just take this copy both of those methods into
the items class as well. And basically just
replace this with the item from net
item right here. And then of course a set
of blocks, this is item. And then instead of block
this is item as well. This item as well. And then the rest actually
is totally fine. So as you can see, that's
all that we need to do here. And now we can define those tax. So there's basically two
things that you can do. You can, number one, define your tags in this class, and that is fine. And you could also define them in your will, in your data for. And what's very important is that even though we're going to basically make one custom
tag that's specific to us. And then we're
also going to have four common tags that
we're going to use. We actually always
need the tags in here. So the data JSON files, we always need those, but we don't necessarily have
to have this class here. This is only so
that we can access our custom tags
inside of the code. So the first example
of this is going to be a public static final tag dot identifier
of type of block, which we're going to call the dowsing underscore rod underscore detectable
underscore blocks. This will basically replace the Boolean method inside
of the dowsing rod, where we have currently hard-coded what is a
valuable item right here. And we're going to make this
expandable with the tag, which allows, for example, other modes or more
pack makers to add different things
into that tag as well. And that is the beauty of it. So we're going to say
create a tag with exactly the same
name in lowercase. So dowsing, rod underscore, the tech bubble, protectable
underscore blocks. And let's actually format this
a little bit differently. So day ago. And then what we're gonna do is we're actually also going to add two more block tags right here. One of them is going to be the oriC outcome
underscore blocks. And the other one is going to be the Oracle underscore ors. And what you would
have guessed is those are actually Aman tags. Well, let's just
do it like this. And this is going
to be the Oracle come underscore blocks. And then let's just copy
this over for the worse. Now, the reason we're
going to have those is if any other MOD, ads or a calcium as well, then they could share the, that they can share this. And we're actually
going to see this in just a moment with
the items because the items actually are really
frequent, useful and cool. So what we're going
to have is a public static final tag identifier. Once again of type item
here in this case, and this is recalc
underscore ingots equal to a new common
tag or outcome. Underscore England's. Let's just duplicate
this with Control D, and this is the nuggets. And then the same
in here as well. Recall come nuggets. And we're going to
use is we're going to use this ingots here as well. Now once again. Having this in this class
simply makes all of these tags accessible inside of the code
is not strictly necessary. Where it is necessary
is just in a moment because now in the
dowsing rod item, what we're gonna do
is actually instead of having this
hard-coded in here, we're going to return
the following. We're going to say
mod tags that blocks. And then import this with old enter dowsing rod
detectable blocks that contain block, contains block. There you go. And this is going to return
true if the block that is passed in here is
inside of this tag. Now our own tag. We have to add in MC course, Right-click new
directory called tags, and then right-click new
directory called blocks. Then inside of there. Or I'm gonna do is I'm
actually going to go here and copy over
the name here. So Control C or
right-click new file, Control V to paste
it in dot JSON. And then we have this, I'm actually going to
copy over the contents because there's actually
quite a bit in there. This is of course
available to you in the GitHub repository
or in a just as well. So this is basically
all I've put in there, including my own Oracle
com or of course. And then what we can
do afterwards or next is now we can add the
Harmon tags as well. And we're gonna do
that by going to data, right-click new
directory called C, just see lowercase
c, nothing else. And I'm actually
going to copy over the entire folder here. So this is once again
just tags, blocks, items. So everything normal
and the names here actually also just have
to match the names here. And what we're gonna
do is we're going to actually use one of those tags. So specifically the
oracle ingots tag inside. And this is going to be crazy. Our recipe, that is exactly something
that is really cool. Because what can happen is
that if we, for example, have something like the
Oracle can block from ingot instead of
having a Item here, we can actually make this a tag. And then this will of
course be c because this is a different namespace and instead of England, It's ingots. So we can specify a tag and then just normally the
tag where it's at, at sea and it's an item. So this is very
important by the way, that this only takes
item tags in here. So it just basically looks for an item tag or recalc ingots. And then everything that
is inside of here would be viable as a possible
rafting recipe. So the cool thing there
is that if there are three different mass that
and Oracle commingles, then in theory, our block could be crafted with
either one of them. So that's sort of the
general idea there. And also allows more
pacemakers, once again, to make our model just a little bit more compatible
with other maths. So that's very important. And of course, this year, right? This just allows us to make
this way more, way easier, expandable, and
also allow us more peacemakers to make this
extent expandable as well. Because of course,
in our case we, we haven't added
something like 10 or, or titanium or, or
something like that. If another model would add that a more pack maker or even
that mod could just say, hey, if that, if the
MC course models, they're just add this as well. So that's really freaking cool. But that is actually all we
need to do for our tanks. So number one, let's see
if the dowsing rod with the new is valuable
block method works. And also let's see if we can
still craft or a calcium blocks from ingots or
inferences back in Minecraft. So let's see, right-click. And there we have it. There we have it
some copper ore. And let's just continue. Maybe we're going to find
some deep slate as well, copper or iron or I'm sure that we'll find
some at some point, of course, the durability
is not going down. Oh, lapis lazuli, so that we definitely didn't
have that before. Now, let's just see if
we could find something else here somewhere,
no valuables found. The durability isn't
going down because we're in creative
mode currently. That's also considering
other areas. Deep sleep, lapis, lazuli
rate or is it there? There it is. So there we go. That's actually really
freaking awesome. And let's just see. So recall
coming good and they go, we can still craft
the RCA can block, like nothing ever happened here. So that is pretty
frequent, cool, reputable or EBIT for
this lecture right here. I hope you found this useful
and it learns the new. All of the code is
available to you in the GitHub repository or in
individual just as well. And I'll see you in
the next lecture. So, yeah.
54. (Basics) Adding Stairs & Slabs: Or I welcome back to the
fabric horse for a 118. And in this lecture
we're going to start our or lecture series on what I usually referred
to as a non-block. Blocks. Of course that doesn't
make a lot of sense. However, what we want to add basically are stairs,
slabs, buttons, pressure plates, fences, fences, gates, walls, doors
and trapdoors. And we're going to do that
in the next four lectures. They have all some similarities, but there are some crucial, important steps that you need
to take on some of them. So let's just get started. And the number one notice I want to give in
beginning is that I will definitely copy over
all of the JSON files here. So you will definitely
need to open the GitHub repository or the jurists and copy
those over as well. I highly recommended
writing those out. You will see in a moment
is not really possible. Well, it is possible, but you could spend a half
hour doing something better. So we're going to see
that, no worries at all. And what we're gonna do is
we're just going to copy over the SPD block twice. And the first one is going to be the oriC calcium
underscore stairs. And this is going to be the 40k outcome underscore
stairs as well. And this is going to be the
Oracle income underscore lab. And this is going
to be the Oracle come underscore slab as well. Now neither of those are
of course, speedy blocks. So the oracle com stairs to be steers block and the slab
is supposed to be slab. Now you will see
that the slab lock works absolutely fine. No Roy's whatsoever
already recalc upstairs here with the new stairs
block doesn't work because it has protected access. What does that mean? Well, if we middle mouse
button click on this, we can see that the proof that the constructor here
is actually protected. Therefore, what we need
to do is we need to make a custom class out of this, which is kinda weird. I personally, I'm not
a 100 percent sure. Wider that is the case. However, it is what it
is, so we need to do it. Let's also change
this material here to metal because at the end of
the day this is a calcium. And then after we've done that, go to the custom package, right-click new Java class. This is the model stairs block. And we're going to extend
this from the stairs block. Let's hover over this and create constructor
matching super. And then we'll change this
from protected to public. And now we are done. And we will basically
never have to look at the more stairs
block class ever again. But every time we are
going to make a new block, that is a stairs block, we're going to use this instead. And you can see that
the first parameter is actually a block state. So what we have to
pass in here is just the mode blocks or block. So this is basically
dot git default state. So basically what we
have to pass in here is the block that the
stairs are made out of. But that's the general idea. But for that your books are registered and
would be ready to go. However, of course, it
can never be this simple. Because really like the
kicker thing for all of the non-block blocks are
going to be the JSON files. Well, like I said, I
will copy all of them over forever and will of
course, also explain. We're going to
copy over the slab and steers block says Jason, and please don't fall out
of your seat when you see this because
this is quite a lot. So let's actually
start with a slabs because that is not
too bad at all. So what you can see is that now we actually have different
variance, right? We have three different
types of slabs, bottom, double, and top. And each of them point to a
different model Jason file. This points to the slab Jason, this points to the Oracle can block because of course
if you have two slabs, it just looks like
a normal block. And then this one
points to the slab, but at the top portion or the top half of
the actual block. That's the general idea. This type here is
what's referred to as a block state property. We're going to look at those
in a future lecture in far more detail for
the time being, we can just think of
those variables as having some sort of values
that they can take. And depending on their value, we change the model that the
block states pick points to. That's pretty much
all there is to it. Now for the stairs,
we actually have multiple different
blocks a properties. And that is why it
looks like this. And I will keep scrolling and you will say,
this is madness. Yes, this has 209 lines. That is the reason why you
should 100% copy this over, under no circumstances
should you write this out, because that's absolute madness. Now one quick trick I do want
to share with you is that if you were to use a
different mode ID right here. You can do is you can select
this and press Control R to replace this and then
replace this with your MOD ID. Basically, this hit Replace All. And you can see that all of a sudden everywhere
it has replaced the actual thing with the
melody that we put in here. This is Control Z
to go back here. And the same of course
goes for the calcium. So if you're using Arnold
titanium for example, you could just replace all of them and then that
would work as well. Where's don't forget to rename
the JSON files as well. But that actually makes
everything way easier. And you can also do
this by the way, when you select the
folder here and press Control Shift R, then the, this replacing file comes
up and you can see I could now replace or a calcium in
all of those files here. Same and then basically replace it with titanium,
say Replace All. And that would work as well. But that's a very
important tip and I highly recommend doing that
if it is needed. So now we need to copy over the block model files and this is where it
gets pretty crazy. And this is also, you will
see now why I say, Well, we're going to copy
everything over because these are going to be
five different files. Now that's actually still not too bad All things considered, but it is still quite a few. Let's just open the slab ones first so you can
see that overall, what is written in here is
actually not too crazy. We basically just have three different textures
that we point to wherever, both for the laptop
and the slab, those are going to be
the same textures, whatever the case may be, because we always want this to look like the oracle block. And the only
difference between the two based on files
is the parent here. Either is slab horse
laptop, that's really it. And when it comes to the stairs, while they look a
little bit different, but also very similar, we have three different
textures that we pointed to. And once again, the
only thing that changes here is stares, inner stairs and outer stairs, or the parent pretty much
is all the changes or all the differences there
in the item model Jason? Well, those are luckily actually just normal item model
Jason's four blocks. This points to the normal slab here and this points to the normal or a telecom stairs
JSON file right here. So no worries there at all. And the crazy thing is
we don't need to add any textures because the stairs and the slabs wolf just use
the oracle block texture. So that's really cool. The only thing we do need
to add is a translation. Of course, what we're
gonna do is we're just going to copy
this over here. I'm gonna say, or a cow income. Underscore stairs are going
to be the Oracle Malcolm. There's and then
this is going to be the recalc them slab. Slab. Also please note that
these stairs with an S, So plural and slab singular, that's very important
here as well. But actually, I know you won't believe
me, but that is it. The crazy thing is
definitely going to be here. The JSON files for the
block States Jason. And this is going to continue
for basically all of our different non-block blocks that we are going to add n. So I highly recommend just
taking a look at those in the GitHub repository
and copying those over. And then it's going
to be way easier. But now, let's see if it works. Or I functions back in microfinance can
see the oracle come stares and the slaves have
been added to the game. And we can set
them down and just make a nice, Well, I mean, basically whatever
we want with them, we can just set them down and everything here
works as well, right? We can see the inner and
the outer stairs or work. You can set this down
at the top and also at the bottom here and put them together to make a normal block. As you can see,
everything here works. So that is pretty cool, right? But that will already be it
for this lecture right here. I hope you found this useful
and learned something new, and I'll see you in
the next lecture. So, yeah.
55. (Basics) Adding Buttons & Pressure Plates: All right, welcome back to
the fabric course for 118. In this lecture, we're going to be adding custom buttons and pressure plates and continuing
with the non-block blocks. So let's go into our
Mort blocks class and let's just copy over the
oriC telecom slab twice. And let's just
start immediately. So this is going to be
the Oracle come button. And this is of course
once again here the case. And then the other one,
this is going to be the telecom underscore
pressure underscore plate. And once again, the same just
in lowercase right here. Pressure underscore late. Now the calc button
here is of course going to be a button block, which you will see also
gives us an error. And the slab a block is
going to be a pressure or rather the pleasure
played Brock is going to be a
pressure plate block, which of course is also
going to have an error. This means that we need to make two new custom classes here. So in our custom package, the mode button block, which is going to extend the
stone button block class. We're going to hover over
this creed constructor matching super. Want to change this
to public right here. So no worries there. And then we never have to
look at this class again. And then in the custom
package one more time. The mode pressure plate
block right here. One extends this by the
pressure plate block. And we're going to
hover over this again and also make this public. Now it's using the
normal vanilla classes. We're going to use the mod
stone button block right here. And then here we're going to use the mod of pressure
played block. Now the first
parameter of that is actually going to be
an activation rule. This is going to be the act. They shun rule everything. So basically
everything that goes over this pressure
plate will activate it. Let's actually middle mouse
button click on this and the middle mouse button click on the pressure plate block. And you can see that we
have the Redstone output. This is basically
the method that is responsible or checks
what the actual type is. So you can see this.tab
is being switched here. So as a switch
statement and you have everything or moms, though, if you want to make your
own custom activation type, once again, highly recommend. You need to some Java
knowledge to actually do this. But it isn't too crazy. What you can do is you can make, basically you don't even have to make your own
activation will hear because the activation of
all you can see is a enum. You don't even need to do this. What you can do is you can
simply override this method in your custom pressure
plate block class and then have the
following here. But you can see that the
non spectating entities, and you basically pass in a
particular class in here. So what is the class of
what we're going to get? And that is a list of
particular animals or of particular mobs
that we then go through. And that is the general idea. So in this case, everything that is a
living entity, right? So mobs everything
that's a living entity, then we're going to return 15. If the entity that is above
this living entity class, otherwise we can pass in
something else here as well. So this is something
to keep in mind if you don't want that,
that's totally fine. But I definitely recommend
some Java knowledge for it. Otherwise you're
going to struggle with it probably quite a bit. Well, the blocks
are now registered. However, of course, once again, sadly the Drazen
files are the thing that is going to be
the crazy stuff. And in this case, the button JSON file for the block state is actually going to be the crazy thing. You can see. The
pressure plate only has a powered either false or true. And then either we have
the pressure plate or the pressure plate it down. That's fairly straightforward. The button, as you
can see, is insane. Once again, as we can either base it on the
floor or the wall. We can have it facing east, west, south, or north. And it can either be on or off. So this is basically what
all of this craziness does, is it actually is pretty crazy. So overall, this year basically
just rotates the block, and this year makes it
so that the texture rotates with the block as well so that they don't
rotate independently. That's the general
gist of all of this. However, once again, it's
actually pretty crazy. Do not type this out of. This is available to you in the GitHub repository or in
the individual just as well. This of course, will
also be available in the external
libraries down here, which we've already
previously seen. So I highly recommend just
copying this over if needed. And you can of course, always
use the trick to select this and press Control
R to replace something. And then you can replace, for example, the MOD ID year. And you don't have to do it
a lot of times individually. But let's actually go to the
EN underscore us JSON file immediately because this is something I tend to
forget sometimes. So let's not make this a habit. We're going to say the
oracle Comma button and the Oracle can
pressure on the plate. And this is going to be
the recalc and button and the pericardium of pressure on not underscore
but a normal plate, the ego and then the
block models we've seen, of course once again
there are a fewer, more, but luckily for the
button and the retro plate, once again there are five. So let's just take a quick look at those because once again, they are actually not
that interesting. All things considered. You can see that the
button here just has a different parent every time and the texture is always pointed to the
already Kalikimaka block. So that's pretty much
all there is to it. Same with this. Points to the Oracle
can block texture. And it basically just has the, either the pressure plate up or pressure plate down as a parent. That really is the
only difference here. And for the item models will, there is a like something very
particular for the button. But also that is not too
crazy because we have a specific button
inventory block model, which of this points to, but also nothing to quit. But overall, this is
actually not too crazy. And once again, we do not
need to add any textures here because the textures
are always going to be, the Oracle can block for
either of those blocks. Though now let's
see if it works. Or pharmacist back in
microfinance can see both. The pressure plate as well as
the button has been added. And let's just click the button. Of course it works and
here just the same. And because we've
put everything, even the item entities here, dropping on it will still work. So that is pretty
frequent, cool. And that's actually
how easy it is to add either one of
those blocks where I, but that will already be it
for this lecture right here. I hope you found this useful and you learn some of the new. Remember of course, that all
of the code is available in the GitHub repository or an
individual just as well. And I'll see you in the
next lecture though. Yeah.
56. (Basics) Adding Fences, Fence Gates & Walls: Fabric course for 118. And in this lecture, we're going to be
adding custom fences, fences, gates, and
custom walls, Minecraft. So this will basically
continue with the non-block blocks as
I like to call them. Well, let's go into our
more blocks class and let's copy over the custom
slab here three times. So we're going to have an
oral calcium ends of course. And this is going
to be an Oracle come bends here as well. And then we're going to have
a fence underscore gate. And here of course as well, or a CalcSum underscore
fins AND gate. And then right here,
we're going to have an oral calcium wall and or a calico male
wall here as well. There you go. So this is going to
be a friend's block and it actually works. And this is going to
be a fence good block. And it actually works. End grief or three? Yes, a wall block. And it also actually works. So that's actually really good. We don't have to make
any custom classes here in this case. So we can basically just
continue to the JSON files, which once again are going
to be pretty frequent crazy, but no worries at all. We'll get through this. So three blocks
States, JSON files, and you can already see the things starting to
absolutely turn crazy. So first of all, the fence
gate, as you can see, has a three different block
state properties here, facing in wall and open. And depending on that, we're basically going to choose a different luck model again. And then of course
we're going to rotate it and the
UV lock it as well. Nothing too crazy here. Once again, a very good tip
is to press control shift, or if you have a different or a calcium if you don't use
a recap come but titanium, or if you have a
different mode ID, right, you can just type in the
mara DMC course here and type in your own melody
and replace it like that. Once again, Control Shift and are when you are on a folder. And also of course, all of the files are
available to you for download in the
GitHub repository or in individual just as well. And the wall and the fence here are actually a
little bit different. Those are multipart
as you can see. And there the idea
is that you apply a certain part of the model
when something happens. So you can see that when
there is something here, then we add a side to it
on a particular direction. Then we add the
extra model as well. So let's actually go into the un underscore us JSON
file and let's just add all of
them immediately. So there's going
to be the fence. And then we're going to have the Oracle income underscore, underscore, underscore gate into this fence here AND gate here. This is going to be the
Malcolm wall as well. Welcome wall. There you go. So now we've added all of that. So that is also
going to be fine. And let's now add it
the model JSON files, which are going to be plenty. Actually, we have
four for the gate, we have three for the fence, and then we have another
four or the wall. So like I said, a lot of files, 11 of them in total. So overall, all of them pretty much look
exactly the same. We pointed to a texture, namely the block texture. And just the parents
are different. So you can see that
there really is nothing crazy going on here. It's just about having
the correct parent and then having the pointing
to the correct texture. That is all there is to it. I don't think that it's really necessary to go
through each of them. It all looks the same. Sometimes the name, year of the texture is a
little bit different. But overall that most of the time is all of
the difference. And you can of
course, also always go down to the
external libraries, red to this one here in
Minecraft, minecraft project. To the Assets folder,
Minecraft blocks States. We have the models, the models, and then in here also all
of the models or as well. You can see the Enscape
wall here for example. And that also is available, so no worries there at all. You can always take a look at
that and use those as well. And basically copy them over. Now, let's copy over the wall, the fence gate and the
fence item models as well. To concede this points to
the wall inventory model, this points to the
fence inventory, and this points to the end gate. So nothing too crazy. In one more time, we do not need to add a texture over what we do need
to add our tags. So in our data folder, Minecraft tags blocks, right-click new file
called fences data JSON. And then we're
just going to copy the contents of
this year over for just a moment so that we have the correct formatting
for the tags. And then this is
going to be MC cores for recalc underscore fence. And then we're just
going to drag this into the same folder while holding
control to duplicate it. And we're going to call
this the walls tag. And then this is going
to be the recalc wall. This is needed for the defenses actually
connects to each other. That's very important, right? And after we've
added all of that, Let's see if it works. All right, we found
since back in mind prevents can see all of the three blocks have been added and they all
connect totally fine. So that is exactly what you
want to see right here. Let's just set
this down as well. There you go. So everything is
working totally fine. And well, I mean,
they're all added and that's actually how easy it
is to add the fence gates, the fences and the
walls to the game. Rubber. That would already be it for
this lecture right here. I hope you found this useful and you learn some of the new. And I'll see you in
the next lecture. So, yeah.
57. (Basics) Adding Doors & Trapdoors: All right, welcome back to
the fabric course for 118. And in this lecture
we're going to be adding a custom door and a custom
trapdoor to Minecraft. Now, those are actually going
to be very interesting. Let's just go into our
motto blocks class. And with this basically
conclude the non-block blocks. So what's going to be interesting
here is that those are actually not going to
be made out of calcium, but there are going to be
made out of cherry blossom. Now, cherry blossom is of
course, the actual wood. So we're going to have a custom
would in a later lecture, but we're already
going to see the door. So cherry blossom
underscore door right here. And then the same thing goes for the Sheri underscore blossom,
underscore trapdoor. Just going to copy
this over here, make it a little bit easier
for the ego trap door. And now we actually need to make a motor door block and a
mod trapdoor block as well. Well, let's just create
those door block, which extends the door block. Let's hover over this creed
constructor matching super, and make this public as well. And now we never need
to look at the class. Again. The same thing for
the model trap door block. We're just going to extend, of course, the trapdoor block. Also hover over rate
constructor matching super and making the
constructor public here. And then we're fine. So the door is of course going
to be a motto door block. And this is going to be
a model trapdoor block. And we actually need to
call a another, well, I think the fabric
settings and that is going to be the non opaque here. Because this actually the, both the door and the trapdoor contain alpha values
in their texture. That means that you
basically have a portal that is see-through
in the actual book. And if you have that,
then you will need to add this non
opaque right here. That's very important. And there's even another thing that we need to do for that. And that is going to
be, we're going to make a new class in the
MC course package. So right-click new Java class
called MC course client that is going to implement the client mod
initializer right here. We're going to hover over this
and implement the method, the uninitialized client method. And this will not contain where we set
the renderer layer. So we're gonna say
block render layer map. That instance. Instance dotplot block. What blocks? Dot door, exactly the cherry blossom door with the render
later dot get cut out. Then we're going to
just duplicate this and put the trapdoor in here. And what we also need to
do, and this is very, very important that
you follow this, we need to go into our fabric. Dot adjacent right here, and below the main entry
point right here, right? This is very important. We basically need
to copy this over. Well, the CIA client. Then we need to say MC course and then make sure that this is
written like this. So MC course, client, that is very important and this definitely has to
happen otherwise, the client last year will not be recognized and we
will have a well, an arrow in how this
is being displayed. But after having added this were fine and the code is done. Now we simply need to go
on to the JSON files. Of course all the JSON files
are once again available to you either in the
GitHub repository or as individual gists. Now, after doing all of
those non-block blocks, we've seen this multiple
times rate simply points to different models right here in either the trapdoor
or also the door. Nothing too spectacular
to be honest. So let's also add the
translation here. So this is not already calcium, but this is Sherry underscore
blossom underscore door. And then we're gonna do
the cherry blossom door. And the same thing goes
here for the trapdoor. We're just going to add
the trap at the frontier. And then the same goes for
this one trapdoor, right? So the goal, and
then what we can do is we can add
the model files. Now there are actually
quite a few of those. Let's copy those over. You can see that there
are seven of them. But once again, even though
there are seven of them, overall, they are
fairly straightforward. You can see it's once again just the parent that
is different here. And the same basically
goes for the trapdoor. The only other
interesting thing is that because the door is
made up of two blocks, we basically have a top and a
bottom texture here that it points to what that pretty much is the only interesting thing. Now the item model, especially for the door, is actually very interesting. Because when you will
see this is that this is actually a
normal item model. Or a, for an item not a block. That is because the
door actually has, isn't displayed in the
inventory as a block, but rather as an actual item. The trapdoor, however, this point strain
normal trapdoor here. So for this one, we actually do need to add
it to different textures. Will actually three
different block textures and one item texture. So those are of course,
also available to you. They have the door
bottom, we have the door top and the trapdoor. Then in the item, we also have the
door right here, so we're just going to
copy this over as well. So the ego, the ribosome
door for the item. And now everything
has been added. Now after having
added all of this, Let's see if it works or if so, we find ourselves in micro
lens can see both the door and the trapdoor have been successfully added to the game. Now if I right-click
you and see it actually does not
work to open those. That's very curious, and
I can actually open them. Well, I mean, let's
just do it properly. Here. There you go. I can
actually open them with a Redstone if I directed
correctly basically ago. So that is something that
we still need to change. And I will show you how you can basically will determine
whether or not it is only openable with Redstone or openable
with the hand as well. But it's actually a
very, very easy fix. Instead of putting in
the material metal, we simply put in material wood. And that is all that we
need to do to change here in order to now
open them with the end. So no worries there at all. But this pretty much concludes the non-block block portion
of the lecture series, and this would also conclude
the first section here. So hopefully you found this useful and you learn
something new. And I'll see you in the
next lecture, though. Yeah.
58. (Tools) Creating a new Tool Set: Or a welcome back to the
fabric course for 118. And in this lecture, we're going to be creating
a custom tool set. And what I mean, I guess let's just start to go into our model
items class here. And we're going to be making
a pick ax and ax a whole, a shovel and a sword. And it's actually going
to be in that order. First, what we're going
to find is when I just copy over the all sliver here, we're just going to
start to make the, it's actually also cool
to be able to name here because I don't want
to have to type out or it can come every
time the code is, of course available to you in the GitHub repository or an
individual just as well. But if I'm going to start
to make a borehole can pick x here and we're going to
make it a new pickaxe item. Of course, we're going to
find once again, Well, tough love, it's going to be
protected access once more. So in our custom
item package here, we're going to make
a mod big acts item, which is going to extend
the peak next item. Read constructor matching super. And I'm gonna change
this to public. And then we're immediately
going to do the same thing for the mod acts item, which extends X item. Also hover over period
constructor matching super, making this public as well. And then we'll also need
the mod whole item. Extends whole item. Once again, hover over a quick read
constructor matching super and making this public. And then once again, we never have to see
those classes ever again. That makes a lot of sense, whatever the case may be. And you will see that it actually takes in
four parameters. The first one, which
is a tool material, that's actually something
we also need to create. I'm going to do that
in our item package. So right-click on
that, a new Java class or mod tool material. And this is going to implement the tool material interface
from net Minecraft item. And we're actually not
going to hover over this. The first thing we're
gonna do is we're going to change this to an enum. That's very important. We're actually going to
do is we're going to click on this and then press Control H to bring
up the hierarchy. And you're gonna
see that we have tool materials right here. Let's double-click on this. And you can now see these are the two materials from vanilla. And there's a very funny or There's actually
very easy trick. And that's going to
be, we're going to go at the very bottom here, not in front of this, the last curly bracket, but the second-to-last
curly bracket. Then we're going to hold
Shift and click here. And then we're going to
press Control C to copy, and then Control V to paste in. And then there's one thing
that we need to change, and that is the name here. So we're just going
to copy this name, paste it in here, and then we shouldn't get
any more errors. Now the reason why we're
doing this is because at the actual tool material
is pretty much going to be exactly the same no
matter what you do. Therefore, I usually
just like to copy it over from the
tool materials class. This, it just makes
a lot of sense. And then the added
benefit here is also that you have
immediate access to all of the different values that
the materials here half. So that's also really cool. So you can just immediately see basically what is going on. That's pretty good. So what
we're gonna do is we're just going to get
rid of a few things. So we're just gonna
do something like this and then
something like this. So we give a name
here to this red, of course all recalc
them in this case. And then the mining
level, we can even do this in a different way. Mining level or mining
levels that iron they ago, which had just
returned the tube, but it's a little bit
easier to read here. Then we're going to change
the durability to 450. Of course, the
durability should be fairly self-explanatory. That's just the base durability
of the actual items, then the mining speed. So you can see that's 64. For that we're just going
to do something like 4.5. And maybe the damage is
actually going to be 3.5 and then the
intangibility is even more. Maybe it's something like 25. And here we actually don't
need all of that jazz in only need a supplier
of ingredients. So we're just gonna
do with this. And then we're going to
say ingredient of item. I'm going to say mod items, more items that are calcium ingot and then close
this properly. There you go. Now if we were to add
another one here, I could just copy
this and you will see that this does not quite work as the last one always
has to end with a semicolon, while each one individually has to be separated
with a comma. So that's very
important to note here. This is basically just
an advanced enum. If you've watched the
Java introduction and you should recognize that the issue here with the lazy should actually
not be too bad. So this still is actually used by Minecraft at themselves. So I'm actually. Okay. With using it as well, I believe that the
deprecation there should be totally fine like using this. And if at any point something changes
here, we can always, you know, basically
take another look at the mode materials class
and how that works. So totally fine. But that is pretty much like we don't need to do anything here. We just define these fields. And these fields are
basically defined for each of the different material
levels, so to speak. So if you want to
change something, you basically just
change it in here. And then that carries
over to all of the different tools that you might have in
your model, right? And then we can
do the following. We can say mod tool
material.org calcium. And the second parameter is going to be the
attack damage. I think that that's an integer. And then the third parameter is the attack speed,
which is a float. And then once again, just the normal
fabric item settings. Now because this is a MOD item pick ax here, in this case, the risk going to change
the numbers a little bit, the numbers here, we'll have
to tweak around any way. Like if you have
your actual mode, you're going to be
probably tweaking the numbers quite a
bit because of course, balancing everything is not
as easy as you might think. But otherwise we
don't actually need to add anything else. So what we can just do is we
can just paste this in five times here and then just
start changing stuff. So acts here, acts as well. So the XP is probably going
to be something like 1. This is additional speed, by the way, this is
not the actual speed, this gets added onto it, but more damage here
for the more acts item. And then we're going to have
the whole underscore WHO and then underscore
hole here as well. This is the mode all item. Once again, I'm
actually not unless of course zeros or I'm not
a 100 percent sure why. Some of them you
need the mode item and some of them you don't. It seems very inconsistent,
but it is what it is. This is a shovel item with
the name or a calico shovel. And of course here as well, or a telecom shovel. Very important that you change
the names here everywhere, just so be aware of that. And then the sword here. And then last but not least, the oracle comes sword. And here this is a sort item. And maybe that attack damage
is a little bit more. And the speed is also three,
that's going to be fine. Now the items are
properly registered, but now we of course need
the JSON files which have one tiny thing that
is different with them, but it actually is now
shouldn't be too crazy. So let's get the model
files copied over. And overall, this is
all fairly standard. The only thing that you
need to take care of, and this is very important here, is the parent is actually
item slash handheld. And the reason for that
is so that you get a 3D look when you are
in a third person. So that basically when
you have the sword in your hand and someone else
looks at it on a server, then it of course
looks like it's 3D. So that's what you need there, that's very important here. And then let's also go to
the underscore us JSON file. And I'm just going to copy over the translations here
once again, of course, everything available to you in the GitHub repository or an
individual adjusts as well. Same of course, with
the textures here. So those are the five item textures that
we're going to need. Acts at the whole, The pig acts, the
shovel and the sword. Let's just copy those
over a year ago. And that should pretty much
be all that we need to do. There actually is one more thing that is very important to add, and that's going to
be the tool tags. So under data, we're
going to create a new directory called Hambrick. And then inside of there
we're going to create a new directory called tags. And then inside of there, we're going to create a
new directory port items. And then we basically
need access to Jason. And let's just copy this over to this gamete big axis adjacent. And we're just going
to copy one year. We're going to fill
this in just a moment. We have this big axis. This is going to be shovels. And then we're going to
have OS and then sort. So at this point in 118, I believe that
those are no longer necessarily required or ever. I believe that it is still a
smart idea to add it to it. Just adding basically
the particular axis, shovels and all of that. With those tags. There really isn't a reason not to do it at the
end of the day. This is a fairly
straightforward process. Once you have done
it, once for one of your two materials
than adding it for the other ones is
pretty much also just a very
straightforward process and a highly recommended
just adding those. So in the fabric,
namespace, tags, items, and then basically access holes, pick axes, shovels, and sorts. So that is a very smart idea to basically do that
and add it in there. But that is pretty much
all that we need to do. So let's see if it works. Or Francis back and microphone. As you can see, all of the tools have been added to the game. But let's just see,
this all works, so that's very good. Let's see if I can even
right-click with this. And I actually can. So that's a great
sign here as well. And also skip this. This also all works. I can also right-click
with this, I assume of course I can. And then we don't really
have any wood out. You look at that, That's
how fast would can appear. I'm going to right-click
it and I can also mine it properly. So everything here
should work fully fine. And everything has
been successfully. This, by the way, is what
I mean with the hand-held. So that it basically looks
like you're actually holding the tool in your hand instead of just having
the item like this. And that's why you need
the handheld parent or a bot that would
already be it for this lecture right here. I hope you found this useful and you learned something new. I'll see you in
the next lecture. So, yeah.
59. (Tools) Creating a Custom Multi-Tool (Paxel): All right, welcome back to
the fabric course for 118. And in this lecture, we're going to be adding a
custom Paxil item to the game. So this is of course, something that is
completely custom and actually requires only
a little bit of extra work, but it's actually fairly
easy, All things considered. So what we're gonna do is we're
gonna make a new class in our custom item package
called the mod packs or item. And this is actually going to extend because of course a
Paxil item doesn't exist. This is going to extend
the mining tool item. And we're just
going to hover over this create constructor
matching super. And we're gonna
make this public, we're not going to need here
is the effective blocks one, the parameter and we're also
going to choose to take the tool material parameter and move it up to
the front here. And then the effect
of blocks, right? If we were to, for example, press Control H here and just take a look at the
pickaxe item for example, you can see that this takes in the pickaxe mineable block tags, which is exactly what we
have been right here, right? So we've basically added
our blocks to end this. Now, Paxil, we wanted
to be able to be effective on travel
acts and pick X blocks. How would we do this? Well, we're going to
make a custom tag. So in our model tax class, what we're gonna do is
we're going to make a new tag up here. So this is going to be a
tax of our own actually. So a normal creates tag here. And this is going to be the
Paxil underscore mineable. And then here packs actually
mineable, lash, Paxil. And then this actual tag
will get cold right here. So we're going to
say moderate tags, dot blocks, not Paxil mandible. And now we can basically use this class and it should
work totally fine. We of course, still need to add this to our MC course tags. So in our blocks folder, in the tanks folder, Right-click new directory
called mineable. Then inside of there Right-click new file, Paxil dark trace. Let me just quickly copy
this one over here. So from the pick X1 and then
this is going to be very interesting because we can even put different tags in here, so we don't have to list out every single thing that
is in the mineable tags. Or we can just do is
we can say hashtag. And that signifies that
this is actually a, another tag that we
want to put in here. Then we say Minecraft,
mineable, lash x. And this, just copy this
and say, thanks and shop. Now what the packs item will not have is right-click
functionality. However, that is something
if you really want that, that he could of course, add yourself as well. It shouldn't actually
be that crazy. Basically taking a look
at the shovel item here, you can see there's
some stuff here. And the item as well, there is some things
that aren't too crazy. However, we're going to
stick with this. For now. We're just going to copy
over the oracle comes sword and we're going to rename this
to the oracle come Paxil. Then same here as well. Paxil, the damage and the speed is just going to
be reduced a little bit. And then this is going
to be a mod packs item. As you can see, all works. Very important is
that you change the parameters here to
be exactly like this, then it should
work totally fine. And then we only
need the JSON file, a translation as well. So let's actually do
the translation first. That's going to be
very straight forward. There you go. So the translation and all of the files are of course
available to you as well, individual interests or
the GitHub repository. And let's get the oracle
compact soil over. And the texture as well. Then we pretty much have
everything that we need. So they ago, now everything
has been added 0. Let's see if it works. Or I found this back in Minecraft and as you
can see there it is. The Paxil has been added to the game and it
doesn't it look great. So we can see basically here, I can easily mine this and I
can also easily mine this. And we do have some mood left, and I can also
easily mine at that. Now once again,
right-clicking functionals, he actually does not
work neither for the path basically or the
stripping of the wood. If you really want that, then that should actually
be not too crazy to add. If you have some Java knowledge, I'm sure that you will manage. And if it is really
highly requested, I might just add a follow-up
lecture on that as well, whether that is actually
how easy it can be to add a Paxil item to the game. So I hope you found this useful and you learn something new. And I'll see you in the
next lecture, though. Yeah.
60. (Tools) Making Weapons that Apply Effects: All right, welcome back to
the fabric course for 118. And in this lecture,
we're going to take a look at how you can add an effect to an entity when you hit it with a specific item. And that's a very wordy
way of saying basically, you're going to add a
fusion effect to an entity. And the way with that we're
gonna do this is we're going to create a
new class here. And this is going to be the
mod lowing stored item. Just as an example here, we're just going to extend
the sort item class. I'm just going to hover
over this create, constructor matching super. And then we can leave
everything in here. And just like with
a normal item, there are methods
to override, right? So I can put an override and you could see
he was on block, use as glint a pen tool tip. There's a bunch of
stuff that I can override and no worries there. And there is a specific method that we're going
to override and that is cool as the post hit method, which is called
after we have hit an enemy or rather after the damage has been
added to an enemy. And what we can do is we
can say target dot status affect new status
effect instance. Let's say status
affects that slowness. Let's say four
seconds at level two. And then we also pass in the attacker does That's
basically going to be the source because we are the attacker and the
target is of course that, which is being hit
like the entity that is being hit here. And now we can just go to
the More Items class and just change this to the MOD
slowing sort item right here. For example, you don't have
to necessarily do this. You can also make a new item, but we're just going to change the calcium source to that. And I mean, that's
pretty much it. That's all that we need to do. We need to override the OS hit method and then
basically just add this, the status effect to the target. And that's actually
how easy it is to add an effect on hit. So just for completion sake, Let's see if it works or
inferences back in Minecraft. So let's see if I hit
a sheep. There you go. The sheep that was actually hidden now has Sloan
as applied to it. And the one that
basically was caught in the crossfire
actually does not have it applied because it
is only applied to the direct entity that you're hitting that would
include a fish. I do believe that they were probably going to
die after 100 yeah. Slt they're going to die. But you actually
saw that it also had the slowness apply to it. Though. That's
pretty cool, right? And that is already it for
this lecture right here. I hope you found this useful
and he learns of the new. I'll see you in
the next lecture. So, yeah.
61. (Armor) Creating a new Armor Set: All right, welcome back to
the fabric course for 118. And in this lecture, we're going to be adding a
custom armor to Minecraft. Now, this is a exercise
that is going to be very, very similar to adding
the tools to Minecraft because we're going to need a armour material in this case instead
of a tool material. That's going to be the
first thing that we're gonna do instead of
the item package, right-click new Java
class called the mod, mod armor materials a 0. And this is going to implement the armor material
interface right here. And once again, we're
not going to hover over and implement the method, but we're going to middle
mouse button click on this, or rather even just click
on it and press Control H to get into the arm
materials of another class. And then once again,
we're just going to select at the
very bottom here. And then hold shift and
click at the very top here, and then just Control C
and Control V to paste in. And that's going to be it. The only thing that
we need to change here is the class to an enum. And then we're gonna take
the name of this class. And it changed it to
here as well so that the constructor actually
works properly. And we're just going to
format this a little bit differently with the
parameters here. And then that's
going to be fine. You can also format this a little bit
differently so that we can actually read words
written there. And here. Once again, we're just
going to delete everything except for the iron right here. And we're going to call this
the ORE calcium, of course. And then the name also Malcolm. And then once again, we can just play around with
this a little bit. We can see of course, the, the null values right here. So that's the general idea. The durability multiplier should be fairly
self-explanatory. It's just the multiplier
for the durability. So for example, you can see
that chain is 15, iron is 15, diamond is 33, total 25 and 37. So I think that's
sort of like an 18 is going to be good
for every calcium. Then this here is a very
interesting int array. This is the protection amounts
for each piece of armor. So every piece of armor has a different amount
that it protects you. And this goes by the way, from bottom to top. That's very important. But this is boots,
leggings, chest plate. But that's very important. So we could, for example,
say something like three, we're going to stick with the
five-year 7 and then who is actually fine so
that we're going to just make it a little bit
different than the other ones. For example, Goal is also a
little bit of an outlier. So you can of course think
of this as you want in the agenda ability is just
how unchangeable this is. I'm going to crank
this up to when D5, which is even more than gold. Because, you know,
or a calciums, It's a very fantasy like or so I think that,
that makes sense. And then the sound event,
we're actually going to use the gold equip here. So item armor, gold right here. Does that makes a little
more sense in my mind, we're going to keep
the toughness and knock BEC resistance the same. You can just change this and then you will add
toughness and not pick resistance to your
armor that should just work and you don't need
to do anything else. And then here of course, instead of having
all of this here, we just want more
items.org, calcium ingot. And we're just going
to make this a little bit easier to read. No worries here. So we're just gonna do this. And then no returning. So there you go. And
now it looks very nice. And once again, of course, if you want to have
multiple armor materials, they need to be
separated by commas. And then of course also
named differently and then end with a semicolon width. The last one, that's
just general idea here. And if we just take a
quick look at this, you will see we have this inquiry year, the
base durability. This is the base durability of each of the different
armor pieces. And then this gets multiplied with the durability multiplier. You can see this right here. So we have the durability
multiplier here. And getting the
durability just gets you the base durability based on the slot and then times with
the durability multiplier. That's the general idea here. These numbers, of
course, you could also tweak if you
really wanted to. We're going to stick with
this for the time being. This is going to
be totally fine. Right now the actual class your husband set up so
we can switch over to the more items class and now start to basically
create our armor. So we're going to make a
oracle come element first. And then here as well
or a calcium helmet of course they ago. And this is going to
be an armor item. And you will see the first
slot here is going to be the mod armor
materials.org calcium. And then it actually only
has three parameters. The second one being the
equipment slot dot head, and the settings here are fine. So let's copy this four times. And then we're
going to have the, actually the school chess plate. This plate and this is
your equipment slot chest. Very important that we
change that as well. Otherwise, of course
we would be able to add that to the wrong slot, which is not something
that we want. We're going to do
leggings here as well. And again here legs. The ago and then last but
not least, are the boots. And then the boots here as well. And this is of course, the feet. They you go. And now all four pieces of
armor have been registered correctly with our more
our material of calcium. And now we just need
to add the item model, Jason's and of course here the translation very important. There it is. This is of course also all available to you in the GitHub repository or an
individual adjusts as well, so you don't have to
type everything out. You can actually copy
this over as well. Once again, most of the stuff
when you've done it once, you can copy a lot of it inside of your
own project as well, I highly recommend doing that. Most of these item models, they're going to be
very, very similar. So between those, they just all orange to a tax that is literally
all there is to it. We're going to add the
texture files as well. There you go. And then one more thing, which is very important is
we're actually going to need the 3D look of the texture. And that is actually done
in the Minecraft folder. We're going to need to make a new folder in
our assets folder, Right-click new directory
for the Minecraft. So little game, maybe
you've heard of it before. I've already done
that, drop whatever. Right-click the microwave
folder textures. And then inside of
there Right-click again new directory
called models. And then one more time
Right-click directory called armor. This is written with only an OH, so it is the American spelling. And then here we are going
to put in two files, but these are the armor files. This is how the actual
armor we'll look in 3D and we should
actually be able to take a look at
that if we go to the external libraries
to here into the assets, Minecraft, textures
in the models, armor. And then you can see this
is how it looks like. So this is the layer for iron, for example, layer
one and layer two. So you could also, by the way, copy those over, ended up a little bit and then
have those as well. Now what's very important
for those is that the name here has to be
exactly the right thing. This is very important. So when you have the name that is given here inside of
your armor materials, this right here has to
match exactly this name. Underscore layer underscore
one and then the other one, underscore layer underscore two, very important, that can't
be any spaces in between. There can't be any parentheses 1 because you copied
it over and we'll have the same name
and none of that. It has to be exactly this
under the Minecraft, textures, models, armor directory,
very important. Make sure that this is correct. But after you've made sure
that everything is correct, Let's see if it works or are in first-class
backend microgreens. You can see the
armor has been added and it looks amazing. So let's just see how it
looks when I put it on. And there you go, ready to go to battle with. And that's actually how easy
it is to add the armor to Minecraft wherever that will already be it for this
lecture right here, I hope you found this useful
and you learn something new. Everything of course
it's available to you in the GitHub repository or an individual just
including the textures, please note the creditors
file by the way, you see under which license or textures have been distributed. Thank you very much, but
whatever the case may be, I'll see you in the
next lecture. So, yeah.
62. (Armor) Making a Full Armor Effect: All right, welcome back to
the fabric course for 118. And in this lecture, we're going to take a look
at how you can implement a full armor effect or your map. Now what does that
mean, full armor effect will it basically
means that you get a status effect applied
to your character when you wear a full suit of
a particular armor material. And the way that
this will work is in the custom package
right here I'm going to right-click
new Java class. And this is going to be
called the mod armor item. And this will extend
the armor item plus. And I'm actually going to copy over the entirely of this class. This is available to
you once again in the GitHub repository
or in the just. And we are going to
get through this, like I'm going to
explain everything as we basically go through this. So then we just have the
more armor materials, your.org, calcium they ago, and that should work, right? So what is happening here? Well, the first
thing that you can see is we have a field, a private static final field, or the material to affect map. Now this map maps a armour material to a
specific status effect. Okay, that's fair enough. So this means that if you have this particular set of armor on, that has this material, then this effect
is applied to you. Now the reason why we're using a status effect
instance is because the instance or also saves the duration
and the amplifier. And we can basically
change that individually. This particular instance we're actually never going to use. Down here, we're creating
a new instance just with the same values of
this instance has, because otherwise it
wouldn't actually work. Because once an instance
here is used up, you can't use it again. But that's just
for the people who would have already
jumped and been like, wait, that doesn't work. That's totally fine.
It actually will work. You will see, and this year has of course only one
armor item in it, but actually very easy
to add another one. We're simply going
to take this foot right here and just put
it in one more time. So you can see that's
actually how easy it is. It status effect instance I
highly recommend always going above 200 or the
tick duration here. Because if you are
at ten seconds of your sentence effect
starting to deplete, then it's going to
start to flash. And this basically
means because this is applied every single time
over and over again, that it will constantly flash in the top-right corner and
that can be very annoying. There is also a point in saying, well maybe once the
armor is taken off, every effect or this
particular effect should be taken away. There is a point in doing that. We're not going to do
this in this example. Like there's a little bit of a limitation in this example, but I'm sure that is
going to be fine. So what happens then? Well, we override the
inventory tick method, which is called every tick. If this particular
item or one of those items is inside
of the inventory, we're first of all going to
check whether or not we're on the server because we wanted to be on the
server for this. And we're making sure
that whatever entity has this in its inventory
is actually a player. That is the case, then we
can be sure that we can the cast to the entity to a player. And then we're going
to check, hey, does this player have a
full suit of armor on? So this is a method
that I've made it right here where we
basically just get all of the different
armor stacks and making sure that
none of them are empty. So basically saying, Hey, if the player has a
full suit of armor on, at this moment in time, we're not checking
for the material, just that each one of the armor
slots is actually filled. And if that is the case,
then we're going to continue to the evaluate armor
effects method. And inside of here, we
are basically going through the entire
material to affect map and basically just getting both the armor material
entity status effect instance that is inside of the map. And then we're going
to check, hey, does the player actually
have the armor effect on, that is, right now that
we're basically looking for. There's of course a for loop
that's going to go through. If we had like eight of them, then we're going to go through and it's going to be
like, Hey, does the, does the player have this armor material owners have
this material on, do they have this
armor material? And only if the material
for every one of the helmet breastplate lagging
in Boots actually matches. Only then are we going to add the status effect for the
particular armor right here? And just so that we have it, again, we're actually
checking for this. Again, this is not strictly
necessary right here. What is however strictly necessary on highly
recommended doing this is the player effect Boolean that I basically
put in right here. And the idea here is
that this basically only gets added if the player does
not have the effect again. Otherwise this would be added every tick 20 times a second. And going through all
of this 20 times a second might actually slow down the game quite
significantly. Therefore, it is a very
smart idea who basically not do this and absolutely
stop this here. Also adding the effect
multiple times. It's just not a good idea. And you can see here
we're actually making a new effect instance with the
effect type, the duration, and the amplifier of the actual status
effect instance that we have defined up here. So that's what I've been saying. We're actually
never going to use that instance in and of itself. We're just basically getting the duration amplifier
and the effect there. And then there's
something that is possible that you don't necessarily need to
implement. And that is here. I have it, so that there's a 40 percent chance of damaging
the armor every time a, an effect is basically applied. Now you do not need to do this. So I can also just
uncomment all three of those lines and then we're
going to be fine as well. I just wanted to
add this as well, just if some people do
wonder this than they can. So where have we
gotten this code from? Well, most of this
is pretty much just Java knowledge with a little bit of modern
knowledge mixed in. And this is something
that you can do once you more intuitively understand Java and
modeling and then combine the two and then create something
custom like this. I wouldn't say fairly easily, but without too much hassle. So this really boils
down to knowing Java. So this is like one more
appeal to you that, you know, especially in
the coming lectures, especially when we
move on basically from the tools and armor section
to the intermediate concepts, we're really going
to pick up with the inherent understanding
you're going to need for Java. But let's not go too crazy
with this preamble here. Let's actually get rid
of those two imports. And then what I'm gonna
do is I'm going to go to the more items class. And I usually only
make the helmet, the mode armor item. You do not need
to put everything in more armor item in one
mod honor materials set. You only need to put one. I personally choose the helmet because I think that
the helmet makes the most sense to basically watch out for
the rest of the chest. But it might also make sense, but whatever you prefer, of course, but only one
for each material set. Very important, right? And that actually is
all that we need to do. So let's see if it works or are referred
to as a Minecraft. And as you can see,
I already have the haze flight to me because of course I am wearing
the full armor. And this is pretty cool. So this is Haze too because
we put the amplifier to one. Let me just quickly put up
the helmet so that we can see that this is going to
basically be gone. They ago it's gone. And this haze to, because the amplifier
basically is a, an additive amplifier, right? So if I didn't have anything in there, it
would be haste one, amplifier of one, phase two, and an employer fire of today's three, fairly straightforward. And you can see, even though
I have the rest here on, as long as I don't
have the helmet on, it doesn't work and as soon
as I put it on the ego, now, of course does happen
as soon as I take the armor off, the
haste persists. This is something
that you could, for example, add
if you wanted to. This is a functionality
that you could do, right? One quick thing that
is very important. This goal here actually
will not work, but that is another limitation is that this of course
doesn't work because we don't have an MOD
armor material item in there at that moment. So that's actually
not going to work. So this actually
does only work with custom mode armor materials
for the time being, whoever, maybe in the future
I will update this class and then it might have that functionality as
well. Who knows, right? But whatever the case may be, this is it for this
lecture right here. I hope you found this useful and you learned
something new. I'll see you in the
next lecture. So, yeah.
63. (Armor) Creating a Custom Horse Armor: All right, welcome back to
the fabric course for 118. And in this lecture,
we're going to be adding custom horse armors,
have Minecraft. Now, custom horse armor is actually a very
interesting thing because there is
one little twist in there that we need
to keep in mind. So let's open the
more items class, and let's just copy over
the oracle gum boots. And this is going to
be renamed to worry CAL come horse,
underscore armor. And then the same thing
in the name here, or underscore armor, and
this is a horse armor item. Now this also takes
in three parameters. The first one is the bonus, so this is the Arab bonus
that the horse receives. And the second is a string. That is the name of the
actual horse armor, which is going to be
important because this name has to match the
name of the file. So if we actually middle
mouse button, click on this. You can see that this
is searching for the texture under textures
entity, horse armors, horse armor underscores,
underscore, armor underscore,
whatever the name we put in as parameter here. Now this once again
actually has to be put under the Minecraft namespace, but no worries,
we're gonna do this. We're going to see
this in just a moment. And if I middle mouse button
click on this, right. So that's the general idea here. And that pretty much is all
that you really need to know. So what is very important
is that the bonus here. So just so you have
some comparison values, the iron has five bonus, the golden horse armor
has seven bonus, and the diamond horse armor
has 11 board with 15. The calcium horse armor is
actually very, very strong. But of course, once again, the numbers can be tweaked
any way you would like. Let's first of all go into
the E and underscore us adjacent file and add the
translation. There you go. All of the JSON files and all of that is also of
course available to you in the GitHub
repository or an individual interests as well. Because we're going
to copy over the item model one more time, because of course,
it's simply points to a normal texture in
the textures folder. So nothing crazy year, this is the actual item. It is displayed
in the inventory. And then the 3D armor once again has to go into
the Minecraft folder, but no worries at all. In the textures folder, we're going to
create a new folder or directory called entity. And then inside of
there, Right-click new directory for horse. Inside of there Right-click
new directory called armor, once again, only with an O, so the American spelling. And then we'll copy
over the file here, or it's underscore armor
under screw or a calcium. Once again, the name here has to match with
this name right here, and then it will be
displayed properly 0. Now, let's see For works or I found as a
microtrends can see, the horse armor has been
successfully added to the game, as luck would have it. We have a tamed horse
right next to us. So let's see. And there it is, the horse armor in
all its beauty, the oracle come horse armor. So that is pretty awesome
if I do say so myself. Rubber, that is already it
for this lecture right here. I hope you found this useful
and you learn some new, and I'll see you in
the next lecture. So, yeah.
64. (Armor) Adding a Custom Enchantment: All right, welcome back to
the fabric course for 118. And in this lecture, we're going to be taking
a look at how you can add custom enchantments,
who Minecraft. So for that we're going to go
into our MC course package. Right-click new package
called enchantment. And in there we need
two different classes. The first one is going to
be the mode enchantments. And the second one
is going to be the lightning
striker enchantment. This is the actual enchantment that we're going to implement. And the other one is basically to register the Enchantments. But what we're gonna do is
we're going to extend this by the Chen class right here,
reconstructor matching supra. And we're going to
change this to public. And then very important
that we change the array right here,
the three dots. This simply allows us to pass in multiple equipment slots at the very end and they
then get converted to areas automatically
basically. Now the enchantment
class actually has quite a few methods that you
can override whoever for us, the number one thing
is, first of all, the GetMax level method, which is very
important because we actually need to return to here. So the GetMax level method
returns how many books will be generated and how many levels of this
enchantment exist. So this is very important to overwrite the books by the way, you get generated automatically, so you don't have to
do anything for it. This level basically
signifies that this level basically defines
how many will get generated. And now what is this
enchantment gonna do? Well, when we have this
enchantment on our, on a weapon. Then what we're gonna
do is we're going to spawn one lightening if it's level 1 and 2 lightnings
if it's level 2. So the method to
override for that is the target damaged method. And what we're going
to say first of all is we're going to say if user dot world is client, very important here with a exclamation mark in the front being that we wanted
to be on the server. Then we can say server world. World is equal to user
dot world that cast. And then usually when you order completed for the server world, it usually that basically
you have that as well in, suggests that N
in there already. And then we can also say player entity layer is
equal to the user dot cast. Once again, hit the tab key to auto-complete and then put in the player entity right here. And then that is fine. We're also going to
get the block paths, which is the position
equals to target dot, get blocked position
or blogposts. Let's click on this and press
Alt and Enter to import it. And then we need to
check the level. You can see that the level
here is given as a parameter. So this is the level of
the actual enchantment. And other big question is how
do you spawn a lightening? It's actually fairly easy. We're going to say entity
type dot lightning bolts that spawn with the world. Null here, and null for the
name, the player parameter, the position, then spawn reason that triggered
rule and true. And that is pretty much
all that we need to do here in order to
spawn a lightening. By the way, this works
for any entity type. So you could basically replace
this lightning bolt with, for example, a pig, and it should still spawn
at that moment. So that would of course
be very interesting. That would be the pig
striker enchantment. But that's of course
now what we're going to implement right now. We wanted the lightning
strike or enchantment. Then we're just going to
say if level is equal to two and we're just going
to spawn to linings. So that is pretty much all that we really need to do here. And that is the enchantment
class basically done. So now let's move on to the
modern champions class. And inside of here
we're going to have two methods that
we need to define. One of them is the public
static void called a register mode Shetlands. And this will be later called
in the MC course mod class. This will once again just
system out print line registering mod enchantments,
mod enchantments. For MC cores mod, mod ID. Then we need a private
static enchantment will register with a string name and an enchantment put in Shetland. And this will simply return
the registry data, register, registry dot Pentland with a new identifier of MC
course mod mod ID, a name. And then after the
first parentheses, as in the Enchantments, perimeter and ego, this will
register the enchantment. This is very similar to
how we've basically done it in the more items or
the motor blocks class. And then we'll make
the Enchantments. So this is a public
static enchantment or lightening
underscore striker, which is equal to
the register method. The name here is lightening
underscore striker ammo, and then a new lightening
strike or enchantment. So this one right here. And then we can pass
in the enchantment that rarity uncommon. For example, comma
enchantment target is going to be weapon
exactly this one. And then the equipment slot
is going to be main hand. And then ending this
and there it is. So this is all there is to it. One of the corners, of
course, available to you in the GitHub repository or in
individual adjusts as well. And that actually is the
enchantment already done. We now only need to call us in the MC course, multi-class. So right here, more enchantments that register modern shipments. That's actually very
important if this is not added to them,
it does not work. That's very, very important. And then there's one
more thing in the ear and underscore us JSON file. We're also going to add
at the very bottom here, the translation. So this is enchantment and MC course lightning
underscore Stryker. And this is of course, a lightening breaker,
very important. We only need one of
those translations here. So you might see is this and
this for each of the levels, we actually only need
to translate this once. And then it will translate for every level of the Enchantments. But in, after
having added all of that, Let's see if it works. Or are we fans back
in microfinance, you can see the lightning strike or Chairman has been
successfully added. Let's just add it to
the oracle or here. One for the first one and
then for the second one. Right, So let's try it
out on those sheep. So let's see. And there you go. It actually worked. And let's do the other one. But this will basically
on to lightnings. It is not too noticeable,
but it does work. You can see there you go
in and do the other one, it damages a little bit more. But for example, for the sheep, they're going to die in
almost one hit any way. So it is not that noticeable. Well, yeah, the treatment works. So that's pretty cool, right? And that is already for
this lecture right here. I hope you found this useful and you learned something new. If he did, I would very much appreciate a review from you. Otherwise, I will see
you in the next lecture. So, yeah.
65. (Intermediate) Blockstate Properties: Or I welcome back to the
fabric course for 118. And in this lecture, we're going to be taking a look at block state properties. Will block state
properties are something we've seen previously already. And that was in the
door, the stairs, and all of those
non-block blocks, namely in the JSON files
for the block states here. So for example, if we
take a look at the door, those here were the block
state properties in. Now we're going to take
a look at an example. But first of all,
we're going to go through a little
bit of the theory. And for that we're
going to break out of the PowerPoint slides. Of course. The first distinction
we have to make is between a block
and a block state. This is very
important because it block is actually a type
of singleton pattern. So this means in
our mailbox class, or for vanilla in
the blocks class, each block field is created
once for each of the blocks. Therefore, this is a sort
of a singleton pattern. Your question outcomes
of how, for example, what we save a block
inside of the world? Well, we do that
with Bloc states. And these are
basically instances of a particular block
inside of the world. They say, for example, the block position,
the block property. So those would be the
behavior that we pass into the block whom we created and the block state
properties as well. But this is the main
thing that we're gonna take a look at in the
following slides. And the idea is that block
states are basically saved by the world and they can also
only be changed by the world. And that is done
by, for example, doing world dot-dot-dot block state and then passing
in some parameters. Right now let's move on
to the idea of block, say properties, or how
to store data in blocks. Now, sort of second headline
here is not quite right, but it's right enough. So we have an example here of the public class,
Redstone or block. And you can see that it has a Boolean property called lit. And this year is exactly
the block say property. We define that in
the block class. So at first you might be like, that's kinda weird, right? However, this is a
specific yield here. This is why we can't use just a Boolean inside
of the block class. Does the block class
only exists once? So the Boolean field, if you only have a
Boolean field there, it would actually be changed for every block state inside of
the world for that block. And of course that's
not quite right because whether or not a
specific or block inside of the world is lit, is independent of every other or block except if they might
be next to each other. That's totally different thing. So you can see that
we need to call the append properties method
and have to basically override that and add all of our properties to the
builder right here. And that basically then does all the heavy
lifting for us. The property always has a
value that's very important. So it can't be null. Block can have multiple
different properties. We've seen that in the
door as well, for example. Then the block state
property I used to refer to different models inside of the block States
Jason or a block, like the stairs block
stays Jason or like we've seen the door Brock
situation as well. And then this is the
difference here. So if LET is false, then it looks like this
and I've lit is true, then it looks like this. And we change the block state. Well, we can just
call the, well, we just have to have the world
variable here somewhere. And then we set block state at a particular position
with the new state. And then this year
is just a flag, basically which notifies all
of the neighbors in all of the ways that they need to
be notified for n. Yeah, that is pretty much
the idea that we're changing a box that happens
in the world, right? And this is also
happens on the server. So that's also very important. And we pass in the position, this is the position of
the actual block state and socket parameter is the new
state or that block position. And then the third
parameter, like I said, is just the lagging behavior, is just updating basically
the neighbors and such. This presentation
and he cheat sheet is of course available to
you for download as well. But now let's go back to
intelligence and its press shift twice and start to type
in a Redstone or block. And if you have this, this year and then we can
go into the actual block itself and you will see that it pretty much is
exactly right here, right? So public static, final
Boolean property called lit. And this is exactly right. And if we go down here, we can see that
this year world set block state paths and
then it basically, it's the state lit. And now turns to true. This three here is
pretty much exactly the same that we notify
behavior that we've seen. You can do either three or
something else in there. We're not going to worry
about the updating behavior too much for our purposes. 3, we're always going
to use three, right? So I highly recommend
taking a look at the Redstone or class
because this is probably one of the
easiest examples to actually take a look at. But for the time being, we're actually going to make
our own custom block now. So with a customer
block state property. And for that we're going to
go into our custom package, right-click new Java class. And it's going to
be the Oracle come lamp block that we're
going to make a lamp. And this is going to
extend the block class. Of course, I mean, let's hover over create, constructor
matching super. And then at the very top
here we're going to add a public static final
Boolean property from net microstate property. And we're going to
call this clicked, which is equal to
Boolean property.gov. And then a, and then a
string parameter clicked. So I'm calling this clicked. This is not the same as LET. We could of course
also called the slit or on or something like that. But clicked is going to be fine. Because what we can do is we are going to be able to right-click this block and then basically
turn it on and off. So that's the general idea here. And of course, first of
all, we need to call the append properties
method or override that. And this is actually as easy
as just taking builder dot add and then adding the
click property to it. If you have multiple properties, you can just separate them by commas and then
add them as well. So of course this doesn't
make any sense because adding the same property
twice doesn't make sense. But if you had another one, then you could just add
that in there as well. Another thing we're gonna
do is we're gonna say this dot set default
block state, this dot get default block
state that with licked holes. And this, what this does is that whatever the default block
state of this actual block is, once we set it down
for the first time, we're going to make sure
that the clip property is always false at that time. So that's just the general idea. And then we're going
to override the own use method right here. We're going to return
the actual result pass as one with this
a little bit nicer. And then we'll
check first of all, that we are not on the client. So once again, this
makes sure to see the formation mark here
so or not is on client. And we want the hand
to be and main hands. So this is only called once. Let's get a Boolean in
New York called clicked. And this is going to be state dot get and then
clicked like that. And here of course you can see that we're already
getting the status. So this is the actual
block state that we right-clicked and we're
just going to get the value of the
Boolean property clicked of the state that
we've just right-click. But that's the general idea. And then we're going to say
the world set block state at the position that
we clicked with the state dot width licked. And then we just
basically do a VAP. So then a comma heroes course that's very important actually. So there you go. So set lock state
once again at this, at a particular position. Then with the state, with the clicked variable being the opposite of
what it was before. And then we're just updating all of the neighbors as well. And that is, I know
pretty crazy actually, all that we need to do here. Of course, if you have more complicated for
blocks and blocks, this that you wanted
to implement. Well, it's just a matter of trying out a bunch of
stuff, definitely. And then also a bunch of Java knowledge
definitely does help here. So if we actually
middle mouse button, click on the Boolean
property and then go to the property here, press Control H. We
can see that there are Boolean properties in properties and also enum properties. So those are basically the three big block state property values or types that you can
put into a block. I highly recommend
also taking a look at other vanilla blocks
and how they do it. But let's continue
and actually get the block registered for that. Let's just take in the stick
in the fence right here. And this is going to be the
calcium lamp of course. And, or calcaneal
lamp here as well. And this is a new
or a lamp block. The ego. And the rest of this
actually can stay. But I wanted to add one
more thing to this. And that is going to be basically after the
requires tools here, I want to add the
luminance here. And this basically is a and C, a to Int function
with a block state. Now what is that? That
sounds very complicated. It actually is not. So we're just going
to take this and I'm going to format
it like this. And the general idea is that
this is just a hype of, you can think of it
as a supplier, right? So remember, supply was this
and then return something. However, in this case we
actually write something into the parentheses and that
is just the state here. And then we can do state dot, get the outcome,
outcome lamp block. And we actually have a
typo in here, no worries. So if you ever have a typo, you can basically just press Shift F6 and then
you can change it. And then we just change this
to already calcium lamp. Luck, there you go. And then we can pass
it in here as well, or it can land block clicked. And then we're going to say
question mark 15, Poland 0. Now what does this do? What is going on here? Some of you might say
that is absolutely crazy. This actually is not that crazy. So luminance takes a to Int function of block
state as you can see. And the general idea here is that the two int
function, right? Right here, we're not
getting anything. So what is this? Well, it is simply a, it requires an integer to be returned and we pass
in a block state here. That's pretty much all that we really need to know a year. So we have a block
state that we can use, and then we somehow have
to return an integer. So it is pretty much the same if I were to write
something like this, right? So, and then I say block state, this is pretty much
the same thing. We return an integer and
we pass in a block sit. Now, this is just
done way easier, all in one line. In the idea here is that
so with the actual, let's say function that
we write here is just a, we get the value of
Clicked of this state. And if it's true, we're
going to return 15. So then we basically turn on the luminance so
we try and bright. And then otherwise we're
going to return a 0. So that's all that we do here. If you just want something to try and you can also just
do this and return 15, and then the block will always
give off a light right now the other interesting
things are of course going to be the
block States Jason. So once again, I will
actually copy this over, but this is of course
available to you in the GitHub repository
or in individual GIS. And you will see that it
actually is not that crazy. We simply have clicked equals false or clicked equals true. And then depending on that, it points to two
different luck models. So that's pretty much it. The length file. I mean, that's actually going
to be very easily as well. It's just a block
recalc come under a lamp and then sit here or a underscore,
no underscore lamp. That sometimes happens there, your Oracle VM
lamp, nor is there. And then let's copy over
the block model files as well worth for the lamp
on and for the lamp off. And those both just referred to two different
textures as you can see, either lamp on or lamp off. So nothing too crazy. And then let's actually get the, the lamp item model as well. Nothing too crazy, just
refers to the lamp off here. And then let's get
the block textures. And then, and then we're
pretty much done with this. And now let's see if it works. Or offensive attack
and microvesicles see the Oracle can land has
been added to the game. And if I right-click
it, they, you go, it turns on and it turns off
for that is pretty cool. Now the reason why
we don't get any, like the right-clicking
functionality, the hand basically moves in is because we put in
the right-click pass. And that is of course,
so that we can more, better basically placed
down blocks added. Because if we don't
have the pass in there, then, you know, that
is a little bit weird. So you can of course also change the actual result that you
return in the unused method. That is also always
something that you can just try out and see what the
different functionalities. But as you can see, it
works totally fine. And I can just change the of the extra as well as of
course turning it on. So if I just do times at night so that we have
this and see bam, bam, bam, there it is. I can just turn on the
light or turn it off. So that's pretty cool. Rubber, that will already be it for this lecture right here. I hope you found this useful and you learn some of the new. And I'll see you in the
next lecture though. Yeah.
66. (Intermediate) How does NBT Data work?: All right, welcome back to
the fabric course for 118. And in this lecture,
we're going to be taking a tentative look at NB TY data. Just like the block
state properties are basically data that you
can save on a block state. In BT data is data that you
can save on item stacks. So item stacks are two items as Bloc states are two blocks. So the item stacks
the actual snack that you have in your inventory, while an item is the
general idea of that item. But once again, a single
pattern in a way. And the way that we are going
to take a look at this is we're going to make a new
item called the data tablet. And that is going to save the last result of
the dowsing rods. That is the general
idea for that we will copy over a bunch of code. This is all available to you in the GitHub repository or an
individual just as well. Just take a look
at the resources. I highly recommend
taking a look at them, helping them over with
me as we go along. And first of all, for this, we are going to
need the new item. So this is right-click in the
custom package and this is the data tablet item. This is going to
extend the item class. Of course, this was hover over this create constructor
matching super here. And this one is actually
fairly straightforward. So the things that
we wanna do is we want to make this
glimpse a week, basically one to
that shining effect when this actually
has in VT data. So we can override
the has glint method. And then what we're
going to return here, you can see that we're actually
getting the stack here. And that is great because what we can do is we can just return stack dot has MBT,
exactly right? So each time that a data tablet
has NVT data added to it, then we're going to
make this will shine. Then what I also want to be
able to do is I wanted to right-click this dust in the air and deleted
the data offered. So as you can see, we're going
to use the US method here. And what we're going to just check is we're
going to say, hey, if user.name get stack in hand with the hand that
was just clicked, right? If that stack as NVT than what we're just gonna do is we're just basically
going to reset it. What we're going to say is
we're gonna say user dot, stack and end with the hand. We're just going to say set in VT. We knew in BT compound. And that's pretty much
the general idea. The has NVT in the set and VT. And then in just a second here we're also
going to see the, basically they get NVT. Those are the three
big methods that you need to basically keep in mind. So we're also going to
make a tooltip here, and this is going
to be displayed when the actual
stack has MVT data. So stack dot as MVT again. And only then do we
want to add a string. Let's just say call this
the current or here. And we're going to say
stack dot-dot-dot, yet NVT this time. And the way that we
get different values here you can see for
putting get in C, I can get a few different
types of data here, and I always have to
get a key in there. I'm just going to
use MC course dot. Or this is just how I'm
going to call this key. What I highly
recommend is always starting with your marr ID
and then a dot and then whatever the actual name of that stored variable
is supposed to be. And then we can just
straight tooltip dot add. And then we say
new literal text, in this case literal text with the current or as a
string and they go, and that's pretty much the
data tablet item class done. Let's immediately just read this year because that's
going to make this a little bit easier
so that escape take the recalc horse armor. And this is going to be the
data underscore tablet. And here the same data
underscore tablet. And then here is data
tablet item exactly right. And we only need the
normal settings here, of course, they ago. And we'll also add the max count here so that we can only
have this stack to one. So this is going to be the
Max Stack size of one. That's very important. And now of course
we need to somehow define what some stuff, add the NVT data to
our dowsing rod item. And for that we're actually
going to create a util class because that's going to
make our lives a little bit easier to in a util package, we're going to right-click
new Java class. And this is going to
be the inventory Util. And I'm going to copy
both methods over here. And this is just to save
some time basically, because those are going to
be probably reused a bunch of times you can see as
player stack and inventory, this checks whether or not
this particular player has this particular
item in its inventory. And then they get first
inventory index checks through this player's inventory, gets the first index inside of that inventory where
this item is present. That's the general idea here. And we're going to use
both of those actually. So let's go to the dowsing
rod item mass here. And what we're gonna
do is we're going to add one particular thing. And that is basically inside of the US on a block method, right? What we wanna do is
we wanna say, Hey, if the layer has the data
tablet in its inventory, then we want to basically
add NVT data to it. So we're going to say if. And then we can say inventory, util dot as player
stack in inventory, we can say player, and then the item is just
more items, dot data tablet. So if that is in the inventory, then we want to add
the NVT data to it. Well, let's just
think about this. I'm going to copy
over the method for this because I actually
have a method for that. And this is a
private method here called add vt to data
tablet. You can see. And what this does is actually
fairly straightforward. It's actually not too crazy. For first of all, going to get the data
tablet stack here. By getting the stack
and by getting the first inventory index
of the David tabular. So we're gonna get the
first data tablet that is inside of the inventory
as very important. So we're, if we had two data
tell us in the inventory, we would override the
first ones in VT data. That's very important. Now how do we set the NVT data? You can see right
here, we're going to create a new compounds. So NVT compound is what
we need to create. I'm going to put a string
in there with the key. Once again, MC course
dot underscore or. And then here is the string. So this is pretty much
the exact same string that we had in here
in the output. And then we say data
tablet at set NVT data. And passing this NVT compound, we would have just
put a string on. And then inside of
the if statement, we're just going
to call this add NVT data to data tablet
with the player. And I'm gonna say the
position clicked dot add 0 minus I 0. And then the block below, it's very similar to what we had in the output coordinates. But for the time being,
this is going to be fine. And that is pretty much
all that we need to do. So that's basically
all there is to it. In this particular
method that's private, where we add that data to it and then the inventory
util by becoming an useful in some
other area as well. So that is also a
really frequent cool. And yeah, that's
pretty much the idea. Once again, NVT
data, unlike this, the most important methods are the set and VT
data on the stack. The get NVT data on the stack, and the has NVT
data on the stack. So those are the
three main methods. And then in the NVT
compound itself, you can basically see I can
also put in some other stuff like and these are
basically all of the datatypes that I
can store in there. And those usually are
way more than enough. Oh, that's pretty much all that we really need to know there. And then, and we're
gonna do is we're first of all going to
add the lang here. Well, let's just copy over the item or let's take this one. The data underscore tablet is
of course, the data tablet. And then we're going
to need an item model. And that is of course just a normal item model right here. So data tablet simply points
to the data tablet on. So this is a very interesting
thing here on why is that? Well, is there also an off? Yes. Something we're going
to take a look at in the next lecture actually, because they're all going to
change the actual texture depending on whether
or not it has MVT data and actually
is not too crazy over it does require some
interesting setup. Let's say. Now the data tablet has
been added to the game. So let's see if it works
or if bounces back in microfinance can
see the data tablet has been successfully
added to the game. And let's just take an only one. That's right.
67. (Intermediate) Item Model Predicates: All right, welcome back to
the fabric course for 118. And in this lecture,
we're going to be taking a look at a modal
predicate providers. So if that is something that you just have no idea
what that means, no worry at all. We're going to go
through this in detail. So we're going to
press the Shift key twice and we're gonna put in a model adequate provider
registry, exactly this one. Let's just click on this
and you can see that this has some well interesting
things in here. Namely, for example,
for the bot, the pole and the
pulling inwards, which is very interesting
because those are two predicates
that the bot needs in order to change the item texture inside
of the inventory. And that is exactly right. So we need to register our
own custom one so that our data tablet can
change the texture. We basically want a
data tabulated that is turned off when there's no NVT data on it and turn on when there
is in BT data on it. That's the general idea. And what I can also say
is let's press the Shift key again and let's type in
a bowl underscore pulling. You will see that there are some JSON files
associated with it. And this, for example, you can see refers
back to the item. So this bowl
underscore pulling 0 is referenced in the
bot data JSON file, which is going to be of the, which is the bolded
JSON file right here. But you can also always go down to the external libraries in assets than under models item, and then just go down
to the bow, right here. There you go. So
this is the boat adjacent exactly the
one we have open. And you can see under here, there are overrides and if
a particular predicate, so those are the modal
products that we've just seen. If they have a particular value, then we're going to
actually take a look at a different model than this one. This one just shows
the normal bowl. However, if pulling is one, then we are going
to show this model. If pulling his one
end of the pole is at 65 percent going
to show this one. And then if we're pulling
and pulling is at a 0.9, then we're going
to show this one. That's the general idea, year. And that is why
will be how we can basically change the textures. And this is actually all
fairly straightforward. What I'm gonna do is I'm going
to make a new util class, which I'm going to call it the mod model predicate provider. And inside of there, we're
going to make a public void. Register models, models,
coolers, yeah, mod models. And this is going to call the fabric modal predicate
provider registry that register with the
mod items dot data tablet in new identifier
MC course mod, mod ID. And then we're going
to call this on. And then after the first
parenthesis, a comma. And then what we want is a mile in unclaimed
model provider. You can see if I
start writing and stack here, we can
just take this. So we're going to
autocomplete it like this. And then what we're going
to say is we're gonna say stack dot has MBT. Once again a question, mark one, f colon 0, f. So the idea is that we're
going to return a 1 4 on if the stock has MVT data
and we're going to return a 0 if it does
not have MET data. And that's pretty much
all that we need to do. Now. We also need to write
register correctly the ego, and then we recall this is
in the client right here. So that's very important that
we call this in the client, that we want to say mod, modal predicate providers
that register models. And that's, I mean,
that's pretty much it. That's all that we
need to do so that this model is registered, or let's say the predicate
here is registered. We of course now need to
change the model files in the the data tablet,
right, So right here. So I actually have
this prepared. I'm going to copy this
over and I'm going to explain and also I'm
going to, of course, this is all available to you in the repository or an
individual just as well. And the idea is that this one right here now
points to a different model. So what we're just gonna
do is we're just going to take the other model right here. So we need two models. One of them is the normal one data tablet
and I'm one of them is the data tablet on
this is this one. And sorry, this is going
to be looking like this, so okay, No worries. Let's just step through this. The normal data-target is going to be off when
it has no NVT data. If MC cores on is one, then we're going to turn
on the data tablets. So we're going to
now take a look at this model right here, which has the data
tablet turned on. But now we just need
to also pass in the off for the item
extra right here. Let's just copy
this over as well. The ego, because by default is going to
look like it's off. And then if the predicate is on, then we're going to use this one which refers to the on texture. That's the general idea here. Nor is it. This is
a little confusing. It actually shouldn't
be that crazy. We're just basically pointing
to a different texture. If something is different, pretty much almost the
same as a block state just in the item
model says time. And that is actually
pretty much all that we need to do in order to change the item texture of an item depending on
if something happens. So now let's see if it works. Or I, so if I am SoftBank
and microRNAs can see the normal data tablet
is now turned off. And when I find
something you can see now it has turned on. Now, that is actually
a really cool effect. And if I right-click
it and delete it, the NVT data, you can see
it turns off as well. So that is actually something
that is pretty frequent, cool if I do say so myself, I really like that. This is something
that basically, well, it's actually more
easy than you might think. Of course, the
particular details might look a little
crazy to you. But once again, with
some Java knowledge, it shouldn't look too crazy. But this is actually
very, very cool. Remember that would
already be it for this lecture right here. I hope you found this useful
and he learns of the new. Like always, all of the
code is available in the GitHub repository and
an individual just as well. I'll see you in the next
lecture though. Yeah.
68. ASSIGNMENT 7: Blockstate & NBT: This exercise for the
fabric course for 118. And well, I'm just
going to give you a general idea or explanation of what
you're supposed to do. So this time, there's
really no solution because basically your
creativity is asked and you should just
run wild with it. Are you supposed
to do is they're supposed to make a new block and a new item that somehow incorporates both the
block States properties. So one particular block, block say property, and
then one NVT data example. It can really be
anything that you want. It can be as easy or as
complicated as you would like. You don't have to do
this necessarily. This is something just
for you to try out. So this really is just
an optional assignment, but I highly
recommend still going through with this
and just making something that is symbol
and not too complicated, don't think, hey, I'm
just going to make a crazy contraption like
a create construction. Don't go too crazy. Make something very simple, that works and work your way
up as always, a great idea. So good luck on the assignment.
69. (Intermediate) Adding a Custom Crop: Or I will come back to the
fabric course for 118. And in this lecture, we are going to
be adding our own custom crop to Minecraft. So adding a custom crop is
a very interesting thing. Luckily, of course,
we've gone through the walk state properties
because that's something we're going to need in our custom block package. We're going to right-click
new Java class called the mode turnip block. Now just like to start our block classes
with the name mode. Not always, but it's fine. And this will extend
the crop block class. And we're just going
to hover over this in create constructor
matching super right here. And what I will do is I will click on the crop log and
then press Control H. And you can see basically all of the blocks that
this extends from. And we're just going
to take the contents, the entirety of
the contents from the beet roots block right here. But that's pretty much all
that we're going to do. And then we're going to
change the name here to this. We do not need this first field. And then what we
also want to change is it can both of these here. And then instead
of having them in a static block at the bottom, we want to immediately do this. And then the same
for the shape here. Let's just do that and
then copy this right here. H equals h. Well, not quite the ego. Then I'll also just
at this a little bit differently so that
we can actually read what is going on here. Because the voxel
shape is something that's very interesting
and very particular. So that is something that
we have to talk about. Otherwise, all of the rest is just going to
stay like it is. I mean, this one, for example, we actually don't need to. We can also just add
up the H like this. And then for this state, it's going to be fine
like that as well. All of the proper
code is of course, available to you as well. Here we, of course, at the, of course we will
need to actually return a different item, but we're gonna do that
in just a moment as well. And just though we
haven't actually added the add override to everything here so that we know that everything here
has been overridden. And overall, this is pretty much all that we need in this class, except for, of course, the seeds item that
we have to return. And you can see that the actual age property
rights that we have an H poverty here in age
property, which is h3. We can go onto this and we can actually see the
age property here. The general ideas that
this goes from 0 to three, but there's four stages
of this particular block. And that's also why there
are four cuboid shapes. The voxel shape, when
you hover over a block, that is what is being
displayed as the, basically the outlines
of the block. And that's very important. And this is basically just being changed here
depending on the age. Though you can see that
good outline shape is returning the
age to shape array. And then it basically
just gets you a different shape depending
on the age property of this. That's the general idea here. So if you have a different crop with a different amount of ages, you can either just
change the each year. So sometimes there are some
agents available here. As you can see,
there's 123571520. I've as well. Or you can also, like
we've done in the Oracle, can land block
discrete your new, your own new in property. That also works totally fine. But let's also create the
block in the mud blocks class. And for that we're
actually going to need a completely new method. So we're going to copy the
register block method, right? Selected Control C,
Control V. I'm gonna delete the group here and the call to the register block item. We're going to call this
the register block without Block item method because this is exactly
what we wanna do. Let's just copy over the
cherry blossom trapdoor. This is going to be the
turnip underscore crop. I usually like to
call my props well, with the end crop,
turnip, underscore crop. And this is not a
register block, but this is a register
block without Block item, very important. So we can basically delete the course tab here
at the very back. And then we'll also gonna do is we're going to deal
with all of this. Instead of making it this over, we're going to actually
copy a particular block. And that is the, the blocks
that beet roots of course. And not a mud trap door block, but a mod turnip, OK, right at theorem. So why do we not register
a block item with this? Well, the general idea is that the turnip crop doesn't really have a item
associated with it. We need a seed for this
placeless block down, and that is exactly right. But we need to actually go into two or more items class and then make a
turnip seed as well. So we're just going to copy
over the data tablet and this is going to be a
turnip underscore seeds. For this one we're
going to call it burned up under
underscore seeds. And this is a new
aliased block item. So this might be, what is this? Well, first of all, we're going
to put in the more blocks that turn up crop and then
delete the max counter. Very important actually. Ice block item is
a block item with a different name from the
block that it has, right? So the turnip seed, of course, or seeds is a different name than the turnip crop right here. And also what's very important, Let's go back to the
maternal block class and then return mod items dot, turn it sees right here. That's very important, otherwise the seeds are not correct. So this is very
important that we do this and the code
basically is done. What we need to do also
actually is we need to call the render layer
map on this as well. This is on the turnip
crop right here, also get cut out. And then the code actually is completely done in
what we now just need to do is add the
translation and then the block states and the
block model files. Let's just add the
turnip crop right here. So you can see we're basically looking for different
ones that can block, say, properties values
from 0 to three, then just pointing to
different model files. So all things that
we've seen already, this shouldn't be too much
of a surprise, right? Let's add the item here. Let's just say something like the turnip underscore
seeds are of course going to be
the turn up under, not underscore seeds, once
again with the underscore. And then very
important to actually add the turnip
crop here as well, turn up underscore crop. And then here as well,
we're in a cramped, There's a MOD where you
can hover over blocks and it will actually display
the actual block here. And this will be displayed in a way that
is not translated. So translate this as well. I highly recommend doing this. It's just one line, really not that big
of a deal, right? Let's first of all add up the
four different block models here for the turnip crop, you can see they're just turn up underscore stage 0 or 2, 1. Make sure that everything
here is written correctly. When you think
back to the Jason, the idea of like how
are they related? This is the name
of this file here, and then this is the name
of the texture that points to the block models
here are all of the, basically the parent block crop. And then the texture here is also crop that's very important. And that we'd actually do
not need the item model. We only need an item model
for the turnips Aedes, and that is just a normal
item model as you can see. And then let's copy over the four turnip stage
block textures. These, everything here is
of course available to you. So let's just copy
those over as well. And C 0 to three, and then the item, the seeds here as well. So term seeds in
the items folder. Well, in the item
folder, there you go, and that is pretty much
all that we need to do. Now one of the more
important thing is what does this block drop? Because the loo tables
we've seen so far, we're all very easy. The only like crazy Lu
table really has been the orbit even that has
not been too crazy. But now, what about
the actual crops? Do they not have to be
some specific? Yes. We can go once again to the external libraries down
here to Microsoft Project, and then the whole
bunch of stuff here. And then going into instead of the assets folder
into the data folder, Minecraft looted tables, blocks. And then we're just going to
take a look at beet roots. And you can see that this is how the beet roots table looks like and just carry this over or we can also just copy
the actual file here. So we're just going to
Control C, this file, and then go into our own
MC course route tables, blocks folder. Is it in here? This is of course, the
turnip underscore wrapper. And then there are some
changes that we need to do. This is very important. Do not skip this. Take a look at this. So number 1, r max age property
is defined right here. If we were to have a rock that has the max age
property of five, we would have to put
in five-year because the actual things only dropped if this age
has been reached. So this is very important. And that is the same thing
that goes down here. Now this year, where the
block here is the block. So this needs to be
MC course colon, turnip, underscore crop. This refers to the block that we've made in our
mod blocks class, which is basically
checked this year, is the actual produce. So this is going to be
the MC course turnip. This is, this would be the wheat if it was
wheat and so on. And then this here is the seeds. So this is MC course colon, turn up underscore seats. So that's very important. Those three things
have to be changed. So make sure that
you change them up here and then below
here as well. Because down here,
we're actually basically dropping
additional seats, right? So this is very important that
you change this correctly. Please make sure that the
model ID always is correct for this is something that's very
easily overseen basically. So that's something that you very easily just
don't recognize, especially, you know,
Armada D starts with an M. Minecraft also starts with an M. Sometimes it can be something
that you might miss, but this is pretty much
all that we need to add. So let's see if it works. Or Francis back in microfinance can see the turnip
seats have been added, so let's see if I
can set them down. And of course I
can set them down. That is exactly
what I want to see. And let's just make it
so that the game rule, random tics speed is going
to be increased by a 100. And then they go
there, they growing. And this is actually
the, you know, the old growth here. Let's just reset this. Let's turn to survival
mode. Very important. If you break them in,
you have to break them in survival
mode and the ego, they even drop turnips, but only on the full size. You can see if they are not full-sized and they only dropped on a seed is pretty much
all they need to do. And of course, in
the actual Lu table, you can also change
the numbers, right? So if you're like No, that's not enough turnips that drop, that's also totally fine. You can always change that
in the loo table j's, right, but that
is pretty much it for this lecture right here. I hope you found this useful
and learn something new. Once again, all of the code in the recent files are of course available in the
GitHub repository or an individual just as well. And I'll see you in
the next lecture. So, yeah.
70. (Intermediate) How to add Items to a Composter: All right, welcome back to
the fabric course for 118. In this short lecture, we are going to be
seen how you can add custom items to the
composter block. But that basically
means that if you right-click the composter block, like a chance to increase the level that the
composter is at. That's actually all
very straightforward. So in our more registries class, we're going to create a
new private static void register MOD composter,
chances class. And this will be called here just after the
register of fuels, register mode combustor chances. And the way that we add
those is pretty crazy. We're going to say
composter block, DOD Item two level increased chance that PUT and then we
just put in the more items, dot-dot-dot turnips,
seats, for example, through a 35 percent chance. And we're just going to
duplicate this with Control D. And I'm going to put
in the turnip as well so that just the
turn of that you can eat. And that is going to be
a 65 percent chance. If we middle mouse
button click on this. We can also see the
trends is right here. So you can basically see all of the chances there
are some seeds, the saplings and leaves, and basically the chances that are associate
with us, right? I mean, that's pretty
much all that you need to do if you don't have the
mode registers class, you can also take those and just call those in the
initialized method. However, because we've created the modern registries here, it makes this all a little
bit easier and a little bit more separated and a
little bit nicer to read. And just for completion sake, let's see if it works
or if it was back in Minecraft and let's
just see, there you go. I can right-click it and
it actually does work. And the seeds also work. They have a 35
percent chance while the turnips have a
65 percent chance. And there you go. Now, got some bubble me. Well, but that is already
for this lecture right here. I hope you found this useful and you learned
something new. I'll see you in the
next lecture. So, yeah.
71. (Intermediate) Mixins Explained: All right, welcome back to
the fabric course for 118. And in this lecture, we're going to be
taking a look at mixin. Mixin is a topic that has to be handled
with a lot of care. That's why I sort of ask you to not go absolutely
crazy with this. Even if you understand
this after this lecture, a mixins should be
used sparingly and not for just everything where it might be easier to
just use mixin. Mixin, the general idea is
that you can basically change the classes of Minecraft to set it to anything
that you want. Basically, though we could, for example, change methods. You could, you could
change the access level, certain methods or
certain fields, and we could do then just change them on a whim basically. And this usually is thought of as a very complicated
and complex, complex topic wherever it
actually isn't that crazy. So if at this point
you've been just copying over stuff and not really
following with the Java. So you don't really
understand a lot of the Java stuff behind it. I just highly
recommend once again, taking a look at the
Java introduction, because mixin is a tool that if you don't
understand Java, you're going to be
completely lost. I won't go into too much detail
on how it actually works. I'm just going to mention
one thing and that is the GitHub repository here
from sponge powered mixin, the wiki on there specifically. And this has been an
incredibly useful tool to basically take a look and just understand the
mixin architecture. And as I go down here, you can see that it basically
explains everything in very good detail actually on how it works, how
we can use this, how you can then
access something and how you can basically cast something to a particular
interface and then basically use the fields and
methods in there as well. So this is really
cool and really useful and I just highly
recommend going through this. So once again, if
you don't know Java, then I don't know how
to help you with this because you will definitely
need to know some, I would say at least
intermediate to advanced knowledge in Java to really get an understand this. The general gist here
is just that, well, it is a pretty crazy tool and once again, use
it with caution. So what we're gonna do
is in our mixin package, we're going to right-click new Java class and
we're going to call this the mode
entity Data Saver. This is just the name
that I'm giving. This is going to be
totally fine here. And the first thing that I wanna do is I want to
make this abstract. And the reason I'm gonna
make this abstracts because any class we
have in this mixin, we really shouldn't use, or at least this
class in particular, we really shouldn't use
anywhere in the code. And now how do we make this a mixin is
actually fairly easy. We at mixin right here. And then put in the class, we want to change, and this is going to be the
entity, entity dot class. Now what's very important is
we're just going to import the class and
making sure that we choose net microwave entity. Now, what we're gonna do
is we're going to add an MVT to the entity class. So every entity
will then also have an MVT field associated with it so that we can save
MBT data on that. And the general idea is that what we're
going to use that in the next lecture to
add custom commands. Though, what's very
important here that while this is a prerequisite
for the next lecture, the specific commands
we're gonna do next lecture basically
require us to do this. And so I highly
recommend watching both together at the same time. So back-to-back, well, this is going to do is this
is going to have a private in BT compound
called persistent data. And then we want to, well, basically open this up with a good persistent data
method right here. And what we're gonna
do is we're just going to return persistent data, but it might also be null. And if that is the case, so if persistent
data equals null, then what we wanna do
is then we just want to set this persistent data
to a new NVT compound. So basically that we
don't return an empty, well persistent data in this method and this field
will get added to this class. So to the entity
class right here. So this will just get added, but somewhere we
don't know where, but that's totally fine. We're working with this. Those two will just
get added to it. And then we also want to interject certain functionality
into two methods. So let's open the entity class
again, and let's search. So control F, and then
we can search for the right NVT method
right here, this one. And what we wanna do is here
we want to inject that we basically put all of the data
into this NVT right here, because this one
is the one that is saved after the world
basically saves. So we want this to also
have our custom data in it. And then the same goes for the read and BT
method right here, where we actually want to
get this outside of it. So that's the general gist here. So what we want is a protected void and this is just going
to be inject right? Method. The first
perimeter of this is the perimeter of the actual
method that we want. The right MDT method had an nb t compound
as its parameter. We're going to say MVT actually
call this MBT as well. We can once again actually
look at this, right? So right, MET, MET compound. And because it also
returns an MVT compound. What we have to use
is we have to use the call back info returnable, underscore this
info, that's fine. We're actually not going to
use this one at all anyway. And then we're going to,
we're just going to say if the persistent data, so this once again
references the field here. If that is not null, but if there is data in there, then we're just going to put
the actual data in there. So not as a string, but just as a data. And we're just going
to call this the MCQ, MC coarser cotton
underscore data. That's going to be fine. And then we want to put in
deeper systems data here. So if there is something
in the persistent data, then we're going to save this
in this NDT compound here, which then basically makes it so that this is saved in
the world as well. Now we need to add attribute here on top of the method here, and there's the object
attribute with the method name. So this is right NVT. Then we have to specify
at what position we're gonna do this and
we're gonna do this at, at, and then all caps. So this means that this year is being executed
at the very start, after the method has
started to execute is going to get executed in the
first line, so to speak. That is, that's
the general idea. And then the other one I'm
actually going to copy over. This is nothing too crazy. The inject read
method here just has the read and B tier
also the head, also NVT because that's the
parameter of the method. And at this, instead of having callback in for returnable, this has a normal
callback info and then actually you change
the key year as well. So that's actually
very important. And basically just saying, Hey, if this key exists, then what we're gonna do
is we're going to set the persistent data to whatever
we find under the key. There you go. So
that's actually all that we really need to do here. And there's one more crucial
thing which is important. And that is we're going to need to implement an interface. Because at the moment, because this is an
abstract class, we can't ask anything
to this class. What we want is we want
an interface because any class in Java can be
cast to any interface. So we're gonna say I
entity data saver. And this is literally just going to have one simple thing. And that is an NBC compound
get persistent data method. So this is what
the interface has. And then we're just going to say implements I entity
data saver will also add the add override
here just so that we know that we've
overwritten this method, but that's pretty much
all that we need to do. So this one here we need
so that we can actually call this on a
particular entity. Because of course,
if we just have an entity class during the, during development, this doesn't have the persistent data, so that wouldn't work. Now there's one more
step that we need to do, and that is we need to go into our assets are resources
folder right here, actually into the
MCQs mixin Jason, and add the name of the class
right here in the mixins. But this is the mode
entity data saver. And that is pretty much all that we really need to do here to make a one mixin
in this case. So we basically
change the class that we've defined here and add
all of that jazz to it. Now, we're not
actually going to see any thing just yet though the, what happens will basically
be shown in the next lecture. However, I did want to separate
this because sometimes, you know, it's like this
is specifically mixin. And then the next one
is going to be commands and there's going to be things that are specific to commands. We will need to
use this as well. So basically the, the demonstration will be
shown in the next lecture. So once again, mixing should definitely be handled with care, especially if you are a beginner or
intermediate in a Java, I highly recommend
taking it slow. Don't go into crazy with it. There's always
examples on GitHub and also really I can just
highly recommend the wiki. It actually is really good. You just need to take your
time, read through it. Just basically just
take your time. That's the best idea here. And also don't go crazy with it because it is a
very powerful tool, but it could also in
theory, break, I mean, pretty much the entirety of Minecraft if you
add your mod to it. So definitely be
careful with it, right? But that would be it for
this lecture right here. I hope you found this useful
and learned something new. If something is unclear, please don't hesitate
to ask in the Q&A. Otherwise, I will see
you in the next lecture. So yeah.
72. (Intermediate) Creating Custom Commands: All right, welcome back to
the fabric horse for 118. In this lecture, we're
going to be adding a to custom commands
to Minecraft. Now, this is very important. The last lecture where
we talk about mixins is actually a prerequisite
for this lecture. So if you have not seen it, please do watch it and
basically put everything in their coal is of
course available in the GitHub repository or an
individual just as well. Or you will need to basically add the mixin
to your model as well. Otherwise, you will not be
able to follow this lecture. So to add custom commands. First of all, when we go
into our IMC course package, right-click new package
called command. And inside of there
we're going to create two new classes called
the return home command. And then also the at command. Now you might already
see where this is going. We're basically going
to make two commands. One for you to set your
home and one for you to basically return to
that home position. Now, I will actually copy
over the contents of both classes because
this is gonna make this a little bit
easier and I'm going to explain as we go along. Well, first of all, let's
do the set home command. And I'm just going to
copy this in here. And all of the code is
of course once again available just and
GitHub repository. And so we have a
register method, a public static void
register method, and a public static
int, a run method. This run method is called
right here in this executes. And then you can see that
we have two literals here. So this is basically what's being happy, what's
happening here. So basically you have
to type in slash and then this first
one here home. Then we add a, then here, we then have to
add this as a second words. So this is basically the
command that we have to put in ohms slash home set. And then it's going to execute
all of this right here. That's the general gist of
this and the run command. You can see the player
has gotten from the context get source player is cast to an entity data saver. But this is the interface that we've made in the last lecture. And this basically
enables us to call the get persistent data method, then put an int array with
the name home pass in there. And it's just going
to basically put in the home position
of the player. And then at the end here
is also going to say send feedback with a literary texts at home at this
particular position. That's pretty much all
that it really does. The set home command is
really not that complicated. All things considered. Sure, we have this throws
command syntax exception. This is just the case. We just need this
basically as this is a, the run command for
a well command, I also highly suggest taking a look at the
command manager right here. So if I middle mouse
button click on this, you can actually see
all of the vanilla commands right here. So as you can see,
there's a lot of them. And if you have a particular thing that you
want to do with commands. So if you want to have
a custom command, then you can basically
take a look at those. And first of all, take a
look at how they do it. So basically, okay, How does the loop command actually work? Well, this is what
being executed. So you can see execute,
insert, insert, execute block, that
there's a lot of stuff that you can see
basically how it works. There's a lot of stuff actually. And this here is the
registration for it. And this of course, is going to be the thing
where most people are like, oh my lord, of that is actually crazy. And
that is the case. If you want to have really, really complex commands, it's
going to be very complex. It just is going to be the case. One thing I will say is
that I will only help in limited circumstances
if you have a custom command and
you ask in the Q and a, because they get so complicated, it is very, very hard
to really dig down. It just is what it is. But let's just continue
with our example here. So the command manager class
I can highly recommend. And then let's actually go to the return home command as well. And let's just copy
this over as well. So let's just get
the contents here. And once again, this
is also not too crazy. It's just that in this case, slash home and then return.
And then it runs again. It runs the run
command right here, which once again podcasts
the player to the eye Entity Data Saver gets
the home position here and the length
here is unequal null. Then we know, hey, this means that contains something else. We're just going to say
no home position has been set this or that were
completely sure. Then we're gonna get the home
position here and say we request the teleport to
exactly this position. And I'm going to say
player returned home. That's all we're
really doing here, is nothing too crazy. And now there are two things
that we need, namely events. Now one of the events is
actually going to be very easy. So we're going to go into
our more registries. This right here is
specific to every command, so you're going to
need to do this for every command that you add. We basically want to make
a new private static void, pour a register commands method. And then the way
that we do this, we say command
registration, callback, that event register, said home, command colon, colon register. And we're just going to
duplicate this with Control D. I'm going to say return
home command, register. And then we'll
call this up here. So register commands, and
then everything is fine, but this has to be done for
every command basically. And now we will also
add a specific event, namely the server
player event copy from, because the idea is that
when the player dies, we actually have to copy over the NVT data from
the dead player, so to speak, to the new entity. So that's the general
idea, though. This is also a very
loose look into events. So in our MC course package, right-click new
package called event. And then inside of the
Earth, we're gonna make a new Java class. And when could call this the mod layer event copy
from a long name, but that's going to be fine. And then the way that
this works is this basically implements
a certain interface. In this case the
server player event that copy from exactly this one. And then we're just going to
implement the method here. And now this method is
now called or it will be called once we register
it when this event fires. So that's the important thing. And you can see
there's an old player, a new player, and an alive, we're actually not
going to need. I'm just going to
copy this over. Once again, there's
really just three lines, but we're just going
to get the old player and the new player casts both of them to the
entity data saver. And then we're just
going to get the new players persistent data, putting in the old layers or the original players
versus new data. That's literally all
that we're doing here. And the way that
we've registered once again in the
mod registries. And this is basically
how you register, well, all events, private, static,
void, register events. And this is pretty much exactly the same as this
because actually the command registration
callback event is actually also an
event, so to speak. We're gonna say
server player events dot copy from this time, the event here that's
very important, not the class what the
event or the interface, the event Register, New Mode player events
copy from, and that's it. We could also do
this all in line. I just recommend
doing it like this. I think that this is
a little bit cleaner. It's going to be fine. I'm think that you are
going to be totally fine, but that is actually pretty
much all that you need to do. Of course, also need to
call this right here. So register, now
register commands, but registry fence they
ago in only enough, that actually is all of it. Now this is definitely a
more involved process, especially writing this, right? So this once again, lot of Java knowledge, just thinking about this sum, okay, where do you get
the player position? How can you save it
right, in an int array? Stuff like that is
definitely more complicated. And if you have more
complicated ideas for custom commands, while it doesn't get any easier, but it's going to be fine. I'm sure of it. But for the time
being, let's see if it works or if bounces
back in Minecraft. So let's first of all see slash home and we get it suggests
that that's really good. Let's call return first. No home position has been said That's very good
that we're not getting any errors or anything
that basically breaks. And let's set it right here. Opposition home set at this
occasion does seem fine. Let's just move away from there. And let's just say home, return and we have returned,
That's pretty good. Now, let's actually
the player here. Let's just play up and they go. That's respond. So now we're basically far
away from this and then we can say home Return,
and it still works. And now last but not least, let's just fly all of
the ocean a little bit. Let's close and save this. Let's re-enter into the world. And let's see if
that also works with the slash home return after are basically well
back in the world. And it does, everything's
working great, right? But that will already be it
for this lecture right here. I hope you found this useful
and learns of the new. If any questions
remain, of course, feel free to ask in the Q&A. Once again, I will probably
not help in too much detail if you have a
specific command that you want to implement, it, you just going to have to
try out a lot of stuff and just hopefully you'll
be able to get it, right, but that would be it
for this lecture right here. I hope you found this useful
and he learns of the new. And I'll see you in
the next lecture. So, yeah.
73. (Intermediate) Adding Custom Flowers: All right, welcome back to
the fabric course for 118. And in this lecture, we're going to be adding a custom flower to
Minecraft, right? So we're going to navigate
to our model OCS class. And inside of there, we're going to just copy
over the turnip crop. Now, very important
because this has used the register block
without Block item. We have to change this. That's very important. Otherwise we're going to run into an issue and
this is going to be the pink rose in
with a name here. Think rows and underscore rows. And then of course we also
need to add the mode Group, more item group start horse, so that we have this in
the correct item group. Then this is not
a maternal block, but a flower block. And the flower block takes in
three different parameters. The first one is
a status effect. So we're going to
say that is effects that let's say glowing
and a defect ration. Interestingly enough,
this is in seconds. We actually have to specify
something not too big, nothing like 200 or
something like that. And then we're
going to copy the, let's see, the pink tulip. Why not? Right, and that is
actually the block done. Now let's move on
to the JSON files. So those are interesting. The actual block situation
is not too crazy with it. Just kind of copy that over
all also, by the way, haha, let's also add this to the initialized method here
in the MOOC course client. This is going to
be the pink rose, very important that we
add to this as well. You can see that the block
say Jason is not that crazy. And then of course
the, the translation here is just going to be
pink underscore rows. And then here pink rose
without an underscore, pink rose, there you go. But the block model is a
little bit different here. So this is going to be the interesting thing
in this tutorial, you can see that this has
the parent cross here, and then the textures
is also cross, and then it points to the pink rose extraordinary block folder. And that's also very
interesting because the item model wins to exactly
the same texture here. Instead of having a
normal item model that is associated with a
block where it's short, sort of shows the block in 3D. This time, we actually just take the same texture but use
it as the item texture. And then we're going to
copy this over as well, is added to the
block extras folder. And that is pretty much all
that we really need to do. So now let's see if it works
or if bounces back and Minecraft density can
see the pink rose has been added to the
game and I consider down. And it looks really,
really freaking cool. So that is actually amazing. Well, but that was
already it for this very short lecture here. In the next lecture,
we're actually going to take a look
at how you can add the pink rose or you're accustomed floral block
to a pot as well. And I guess I'll see you in
that next lecture. Oh, yeah.
74. (Intermediate) Potted Flowers: All right, welcome back to
the fabric horse for 118. And in this lecture
we're going to be taking a look at how you can add a custom palette
planned to Minecraft. This is actually very easy and what we're gonna
do is we're actually going to copy over the eternal
crop here because we're going to have to use the block
without broke item again. And this is going to be the
potters pink underscore rows. And then the same name here, potted underscore,
pink, underscore rows. And this is going to
be a flowerpot block. Now the first parameter here is actually going to be more blocks that grows and grows the ego. And then the settings are going to be carried
over from the part that allium the sets is going to make our
life a little bit easier in this case. Then what's very important
in the client here, we actually have to call this render later for the
product pink rose as well. And that's pretty much all
of the code that we need. Now we just need to
add a block stays Jason first going
to copy that over. Actually, not too crazy. This simply points
to a block model. Let's also add the part
that in gross here. Now this one should
only be necessary. The actual translation here, if you have a modern
stalled as well, that basically checks what the names is and displays
them at the top. So this is not always necessary. And then the block
model is actually the really interesting thing
for the audit land block. And that is going to be
this because first of all, the parent is a
flower pot cross. And then it points
to a plant texture. And that simply points to the actual texture
in your block that your plant or your flour in this case is using so
that this one right here. And now what's very
interesting, of course, is because we don't, we don't need an item
model here because, well, this doesn't have a, an item associated with it because we're going
to get this block by right-clicking the flower pot
with this particular rows. And what's also
important, Let's actually take a look at the
loot table as well. So I'm going to copy this over everything here is of
course available to you in the GitHub repository or an individual just as well. And you can see
we're just basically dropping a pink rose here as well as the flower
block, a flower parts. So that's very important. I basically just gathered that via the luge tables right here. Or we can just go in
here and we can see the IT stuff right here. And it basically is
exactly the same. So no worries, there is actually fairly
straightforward, right? And now for completion sake, let's see if it works
or funds that back in Minecraft and I've already set down some pots
and let's see. There you go. I can place the rows in there and it looks
absolutely staggering. And let's just see if I
switch back to our survival. That you go Both of the pot end of the actual flower drop. That's very, very nice. Rep, that is already it for
this lecture right here. I hope you found this useful
and you learn something new. And I'll see you in the
next lecture though. Yeah.
75. (Intermediate) Adding Custom Sounds: All right, welcome back to
the fabric course for 118. In this lecture,
we're going to be adding custom sounds
to Minecraft. So adding custom
sounds is actually a fairly straightforward
process in and of itself. Laying that sound
is also very easy. However, think the most
difficult or challenging thing might be the getting of
the proper sound files. So first of all, we need a
few JSON files for this. What we're going to
need is a JSON file in the MC course. Older right here. So right-click new file called
Sounds dot-dot-dot Jason. And then in the same folder, we're going to make a new
folder called sounds. So very important that both of them are called
sounds and sounds. So that's very important. And I will actually copy over one of those
sounds already. This is going to
be the sound file. As you can see, the
dowsing rod underscore found underscore or that OGG. It is very important is that all of your sound files have to be OGG and make sure that
they are all set to mono. But they only can have the mono sample type or
modal channel, Otherwise, they will dislike you
issues with this though, keep that in mind. And they have to be OGG files and do not just take MP3
files and rename them. You have to get a converter
to properly convert them. So keep that in mind and in the sounds Jason here
we have to define them. So let's just put in
curly brackets and then we're going to
basically write in the name. So this is actually the name. We're going to
register this under dowsing rod underscore,
found underscore. Or now I usually like to take this name and have it
be the same as the file. It just makes it a lot easier. Then we're going to
add a subtitle here. This is going to be
the subtitle colon and an MC course colon or dot actually dowsing, we're
gonna take the same name. So rigorous gonna market, copy it, Control C and then
Control V, and then comma. Then we're going to
have a list of sounds. So this is going to be a
list, so brackets here. And then inside of here
we're going to have MC Coors colon
dowsing rod found. And this is has to be
the name of this file. This is of course
just your model ID. So depending on your
melody, this changes, then the subtitle is
actually something that you can put in
the lang folder, like any JSON file, which is displayed when you have subtitles on and
this sound place, then that is being displayed. So that is something
that you can also add now onto basically
registering the sounds. What do we need? Well, in our MC course
package right here, right-click new
package called sound. And then inside of there
we're going to create a new Java class
called Modus sounds. And this is going to be actually
fairly straightforward. We're just going to need a
private static sound event, old register sound event with a string
parameter called name. And then we're just
gonna do the following. We're just going to make
a identifier, board ID, which is a new identifier with the MOOC course mod
my ID and the name. And then we're going
to return registry, that register with a
registry dot sound event with the ID and the
new sound event. You sound event and
pass in the ID. Again, this is why we're making an ID because we
have to pass it in twice, once for registering and once
for the actual sound event. And how does this look like? Well, public static sound
event called dowsing, rod underscore, found underscore or equal to a register solvent. Now seeing underscore, rod
underscore found underscore. And then makes sure
that this right here, what is written in here is
exactly the same as this. And it is. And then
it should be fine. And that is pretty much
all that we need to do to register the sound. Now of course we need
to play it somehow. And what we're
gonna do is when we find an or in the dowsing rod, then we are going
to play this sound. Oh, let's just go into here. So we know that this
is found block true. So we know that this is the
moment when this happens. And what we need is the world, like the world here. And we can just say play
sound and pass it the player, a position clicked, which
is the position we're at. The sound of him
somewhat sounds that dowsing rod found or
and the sound category, we're just gonna take
blocks That's fine. Volume 1 and pitch one as well. There's also another way
that we can place how that, that is via the player. So this should also work that you can see player
to play sounds. There's different ways,
but that is also fine. This should be totally
fine here in this case. And that should then basically
play that sound here. So I guess for completion
sake, let's see if it works. All right, Francis
back in Minecraft, let's just see and try
if we can find an OR. And they're actually was
let me just quickly get the sound up a little
more. There it is. And I can of course spam it. I can just keep it pressed down. And then at some point
it gets annoying. And the really
cool thing is that because we put it under
the blocks category. Now it does not play
anymore because, well, we've turned off
the block sounds, so that's really cool. That is something to
basically think about. And that is actually
how easy it is to add a custom sound to
Minecraft, right? And I already hear
you scream, well, what about adding it
to a block, right? What can I not change the breaking sound of a
block and stuff like that? Of course. And that's exactly
what we're going to see in the next lecture, where we're basically
going to add, well, the breaking, placing
and stepping sound. There are a few more, but that's basically going to be
done in the next lecture. So this would be for
this one right here. I hope you found this useful and you learned
something new. I'll see you in
the next lecture. So, yeah.
76. (Intermediate) Custom Block Sound Group: All right, welcome back to
the fabric course for 118. And in this lecture, we're going to be adding a customer Bullock sound
group to the game. And what is a block sound group? Well, a block song
group consists of five different towns, and those are the break, the step, the place of the
hit and the full sound. And we're going to
basically add that to make a custom sound or our
recalculate lamp. But that's the general idea. First of all, I'm
going to copy over the five different OGG files. So the sounds right here, and we're just going
to copy those over. Those are of course,
all available to you for download as well. And then we're gonna
go into our sounds, Jason and I'm also going to copy over the contents that
we are going to need. This is pretty much
just the same as this, just with different values here. We just have the telecom
lamp break here. Then for the subtitles, pretty much the same
rate or MOD ID and then dot whatever the name here is, when the sound is named exactly like the
sound right here. That's pretty much
all there is to it. So this shouldn't be
too crazy overall. And then what we need to do in our mode sounds
class right here. We're just going to duplicate this and we're
going to call this the recount come underscore
lamp, underscore break. So that's the first
one, outcome, underscore lamp,
underscore break. And then we can duplicate
this five times. The second one is then
going to be the step sound. Extra, change the name here as well and make sure it's
spelled correctly. That's also very important. And this is going to be the
place sound in with this one, place, this series sound, and hit there as well. Then last but not least,
we have the full sound. And then here, ALL as well. Right, so those are the five sound events that
we're going to need. You could also think about
saving them some other way, especially if you have a
lot of different ones, but this is going to be fine. This is actually okay. And now we of course, also need a block sound Group. Now, you know, we could
either make that in a separate class or we can
just put it in this class. That's also going
to work. So it's going to be a public static, final block sound group, or a cout come
underscore sounds. And this is equal to a new
Sound group with one F1, F. So that's just the
pitch and the volume. And then basically all
five of those sounds, we're going have mode
sounds, DOT, brake. Mode sounds, dot, step, mode sounds, dot, lays. Mode sounds Dutch. All. Actually I
believe that it is hit first and then its
mode sounds dot o, yes, in this order. But let's just double-check. So middle mouse button click
on the s-block sound group. And yet a full sound
is the last one. That should be correct here. And then this sound
block group will, how will we use it? We just go into the
mud blocks class. And then for our telecom
lamp right here, we can basically just add a another parameter to the block settings and that's
going to be these sounds. And then here we just say mode sounds that or a calcium sounds. Let's just format this a little bit
differently like that, the ego, and that would be it. That's pretty much all
that we need to do. Of course, we need
the sounds, Jason. Define everything in here, make the sounds right here, have the files in our Sounds
folder rate amongst again, correct OGG is correctly
formatted or converted. And also in mono,
very important. And then just adding the
more sounds right here. For now, for completion sake, let's see if it works. Already found suspect
in Minecraft. And let's first of all
actually move the volume up just for a little bit so
that we actually have this. Let's see the set, the
actual placing sound. That's exactly right. That's completely custom. Let's see the breaking sound. That's amazing. So that works as well. That sets, set a few down
here and let's step on it. They go. And this should also work when I followed the following slide, I'm actually not a 100 percent sure why that does not work. That's very furious. I believe that it
should work like that. And then the hit sound
would be this. I believe. Apart from the hit
in the full sound, everything seems to
work totally fine here. So I'm also not a 100 percent sure where those are called, to be honest, because usually it should be the force on that. Is this right? So when you fall on it, but there definitely
is nothing there. And then breaking it also
doesn't quite seem to work. So let's just take out
like an pick x, y. So let's see what the, okay, the breaking definitely works. But it seems to be just the fall sound that does not work. But sometimes those
things happen. So there you go. All right. So after looking at it again, I still am not a 100
percent sure why they fall here does not work
for whatever reason, this is just never called. But whatever the case may be, the full sound is
really not something that's too crazy
or too important. I would say, Oh, that's probably going
to be totally fine. Whatever the case may be. The others of course,
work which are way more important in this case. So everything should be okay and that would already be it for
this lecture right here. I hope you found this useful and he learned something new. I'll see you in the
next lecture though. Yeah.
77. (Intermediate) Adding Custom Music Discs: All right, welcome back to
the fabric course for 118. In this lecture, we're
going to be adding a custom music
disk to Minecraft. So a custom music disk, worse requires a custom
sound event as well. What we're gonna do
is we're just going to copy that over one more time. It actually is going to be
very easy to understand. You can see we just
have the name here. Once again, this is the name
that we're going to give it in the model sounds
class in just a moment. And then the name here of
course refers to a sound file, once again an OGG file. And in this case,
it is even more important that this is in mono, because if it is in stereo, then you're going to hear this basically on the entire world, in the entire server. Otherwise, like it
has to be mono, very important, very, very
important in this case. And let's go to the
model Sounds right here. And let's just
copy this over and call this D bar
underscore brawl. And here of course as well, bar brawl, making sure
everything is written correctly. Very important. And then in the more items class we're going to make a new item. However, of course what we need, first of all is a
MOD music disk item, sadly, because once again, the constructor here is
not accessible to us. So music disk item hover over, create constructor
matching super. And then we're just going to
copy the public they are. And then we never have
to take a look at that ever again, basically. And then we're just going to
copy the turnip seeds here. And we're just going to make this the bar underscore Berle, underscore music,
underscore disk. Then the same year as well, bar underscore roll music
underscored disk. And this of course, is
a MOD music disk item. First parameter is the
comparator output. So what is being output when you put a comparator next to it? And then we're gonna
say, sounds not Barbara. Now another very
important thing is here, as you can see that
this is stream true. So this has to be true because the barb role of
course, is a stream. Therefore, you love the
music disk is a stream, so that's very important. And then also we're going
to put in max count of one so that we only can
stack one of those. And then what is also
very important is the translation the E and
underscore us JSON file. I'm actually going
to copy both those over because there's
actually two. There's the barb
roll music disk, which just is the
name of the disk. And then the description
is basically what happens. You know, if you hover over it. And that usually just says
by who The song is from, and then the name of the song. And I've also added
the license here. So this is just under CC
0 or it is public domain. You could in theory use this barb role as well
in your old model, could do basically
whatever you want with it. But that's why I added
that as well. Right? That's pretty much all that
we need except of course, for an item model and
a texture for it. But that is something that we've seen so many times now that it actually wouldn't be too
crazy at this point. This points to the barber or music disk texture
in the item folder, or of course also going to
copy that went over as well. So Barbaro music disk. There you go. And with that, we're pretty
much ready set to go. And let's just hear if it works. Or I, for instance, back in
Minecraft and they can see the music there has been
successfully added here. And let's just pull it in. And there it is. It is quite loud, but it's
also because I have my music. So that's fine. And this place just normally an FI fly away. You can hear it getting less and less. And then
it's gone completely. And then if we back, there we go, It continues. So absolutely great. And we'll amine, it's all working totally fine,
just like we expected. Rubber. That would already be it for
this lecture right here. I hope you found this useful
and you learn some new. And I'll see you in the
next lecture though. Yeah.
78. (Intermediate) Adding a Custom Block Models in Minecraft with Blockbench: All right, welcome back to
the fabric course for 118. In this lecture,
we're going to be taking a look at custom
3D block models. And how are you going to
make those block models? Well, we're gonna make
them with block bench. This is a program
that is available. I will link it in the
resources somewhere. And this basically
enables you to make very cool looking 3D models
for your blocks in it's actually not that
hard by already have a prepared block model here for me as the Oracle can blaster. So it's basically going to
be like a blast furnace, specially made out of or
a calico in this case n. There are, for this
particular example here, two things that we
need to keep in mind. So the first thing is
that you of course, also will have access to
this block bench file. And what you will do
then is you will go to File Export and then Export
block slash item model. This will export a JSON
file as you can see. And you can just do this. I can override that. And then the JSON file
will look like this. So just open it up
here and you can see there's a sort of
how it looks like. You have the texture here and then a whole bunch of elements. So those are basically
the 3D elements. And then there's also things that are here in the display. We can also take a look
at the display if you go to the top right
corner here, display. And basically it's
changed how it looks like that
maybe you're like, Oh, that's maybe a
little bit too big. You can be like, Yeah,
let's just shrink that down to like like May 2.5 be like 0.25.25.25 or
something like that. Maybe that's the
size that's better. And then you can
also change it on the other side as well.
Something like this. And in first-person maybe that's actually going to
be fine with me. That's also going to be fine. When you wear it on the head. It looks very strange,
but sure enough. But if it's on the ground, maybe that's a little
too big as well. So maybe you wanna change
that pilot point for when, for, when for, so that you have it like
this in the item frame. Maybe you want to rotate
that around, right? So maybe the rotation
is supposed to be something like this and
something like this. Maybe that's a
better way to do it. And then in the
GUI, actually think that the GUI looks perfect. And here you can basically change a lot of stuff
in block bench. This is not going to be a purely block bench space tutorial, but rather how you can basically get stuff out of the
block bench here. When I also save
this as the model, the glossary is please. And then it was already
saved as the JSON files. We should have this
reload. There you go. And then it also changes in here as well so that all is fine. And this actually is
basically all that you need. So we basically need
this JSON file. I'm gonna copy this over
as a block model, right? So we're going to copy this
over as the block model that pretty much already has
the 3D stuff in there. Now what we need is we need, of course, the texture as well. So I'm gonna put this in here
into the Brock textures. However, what I am going to
do is I'm also going to make a new folder in the textures
folder called machines, and we're going to
put that in there. This is not strictly
necessary of course, because this texture is also
would be a block texture, but I just find it
a little bit nicer. And then what we need to do
is we need to of course, specify here MC cores and then Machines slash the name of this. That's very important
that we add to our model ID and
then the name of the older words at
basically here, and then the rest
here is totally fine. Of course, we still do
need an item model for it. We're going to do that as well. Let's knock out the easy things first and foremost here, right? So the Oracle can
blaster, That's fine. That just refers back to
the block model right here. And then the block
States Jason, well, for the time being,
what we're gonna do is we're just going to
make a normal one. The blast door. And this is just going to
refer to the last string. That's going to be fine. And for the same for the block, we're just going to make a
completely normal block here. We're just going to copy over, let's say the pink
rose because that's a register block and that's the oracle Malcolm
underscore blaster. Then same here or it cannot
come underscore blaster. And right now it's going
to be a normal block. But we're going to take a look
at that in just a moment. Let that we're actually going to have to change a
few things here. We material metal in
the mod item group, horse, that's going
to be totally fine. For completion sake,
let's also add the translation here or a
count come underscore blaster. So of course the outcome not underscore
blast or they ago. And now, just like a normal
block, we've added it. Now let's also add the
actual non opaque here. That's very important. And then let's also add
it to the get cut out. So this is all of the steps that you'll need
to go through in order for that to be
displayed properly as well. And then we'll basically
see two limitations with the earned way this is set up and then we'll also
see how to fix those. So let's go into
Minecraft and let's see the custom 3D model
for the first time. Or if I'm says a
microfinance can see the recalc a blastula has
been added to the game. And when I set it down, you can see that there are two things that are
very interesting. First of all, well, it's not really facing the right
direction, right? As you can see, it's always
facing the same direction, which is actually going to
be north as you can see. But that's very interesting. And also we have, well basically a very strange
bounding box around it, which is definitely not
quite what you want. So that's, that's
another one that's well, has to be fixed somehow. But those are the two
limitations for the time being. But those can both be fixed fairly straightforwardly, right? To fix both of them, we actually need a custom
block class for this. So in your custom package, right-click new Java class
called the recalc come under, non underscore, actually
blasts or block, they go. And this will extend the
horizontal facing block. Very important that
we choose that one. And we're going to create
constructor matching super. And the reason we're choosing
this is because if I press Control H
after I click on it, you can see that there are some other blocks that are
also taking this from here. For example, some of the like the bed block where it's
strong gate of like that. That's very interesting. And usually I actually expected the abstract Ernest block
to also extend from that. No, actually, okay. That's
with blocks of entity. Fair enough. But it also has the facing property right here. That's the general idea because when you place
down the furnace, but it always looks
in your direction. So what we're gonna do is
I'm actually going to just quickly copy the
direction here over. So this is nothing too crazy, just a large property equal
to property start facing. And I'm going to copy over a
few more things which are of course all available to
you in the repository, GitHub repository or
individual just as well. We need the append
properties method. We've seen this already
and we're going to use the mirror and
the Rotate method. You basically have
this rotate in the correct way and then they
get placement state method basically makes it so
that the facing is always turned into a way that
the block is facing you. Now of course, when we have
the facing blocks a property, we of course also need to
change the block States JSON. There's also something
I'm going to copy over, but this is actually
fairly straightforward. You can see it's facing north is just the
normal block model. And otherwise we
just rotated by 90, 180, and 270 degrees. And you can always also check the external libraries
at the bottom right in the assets folder,
Minecraft blocks states. And then for example, look
at the blast furnace, for example, it's sure. And this is going to be
pretty much exactly the same. The only thing that's, this
also has a lid property, but that's going to
be totally fine. So this is something where
you can basically take another look at this and
how you have to rotate it. And that basically is where I've gotten
those numbers from. Well, we're not going to
immediately jump back into Minecraft Because now, how about the bounding box? Will the bounding box is what
is called a voxel shape. And that is the one
thing that is genuinely just annoying to
do in block bench, especially with this model. It's just very annoying because usually what you would
want is you want, wanted to center
the pivot, right? So first of all, you
will see that if I center the pivot correctly, then it has like
very weird values. Highly recommend, either
going to a little bit above, right or a little bit below, basically rounding up or down. There's otherwise, you will have a bad time with the
rotating of it. Because what we are going to
have to do is we're going to have to actually rotate this three times so that in every direction we're going
to get a new voxel shape. This is just the
way that it's going to be and it is very annoying. But this is the
best way that I've found it so far to work. If there are any other
ways, of course, always feel free to reach out in the Q and a and
tell me about it. So no worries there. What we're gonna do is we're
going to, first of all, I have to go to File
and then to plugins and get the mod utils
plug-in right here. This is from JDK two to two. And whether that, that's very important, it's
just, you know, you can just go to available
search for mod utils, right? I already
have it installed. That's why it doesn't
come up here. Click the Install
button and install that on your block bench. And then what you will have is you will need to take all of the cubes and all
of the things you have and put them under
a group right here, group or voxel shapes, exactly written like this. No spaces, nothing exactly
written like this. And when you have that, you
can select all of them, go to File, Export, and then Export voxel shape. Now we're of course in
yarn we are using Rubrik, so we wanted to export
the yarn mappings. We're going to say confirm, and we're going to save
this as the voxel shape N. As you can see, I've
already save that and we can then take a
look at this as well. So I'm just going to move this inherent so that we can
take a look at this. But this is how it looks like. Sometimes you get
these crazy numbers, what you will have to do
is you will have to round them to the nearest integer. So this is just going
to be a manual process. So for example, this one is
just a 0, actually, right? Because it's negative three
to the power of negative 15, so it's 15 zeros. And then a negative, like
a 0.3, it's like that's 0. So we have to do this manually. Sometimes it's just the way that block bench sometimes exports. It is very weird. So that is just going to be, and this is just
the voxel shape. If this is setting like
looking to the North, what we now have to do
is when you have to rotate this by 90 degrees. And the first thing
that you'll notice in this particular example is that it is offset a little bit. So you can see that the
precision for whatever reasons offset we actually have to
move it back to the middle. And then this is going to be
north, east, south, west. So this is now west facing. Now we have to export again. This is west facing
once again, right? So when I replace the w, and then we can take a
look at that w here. That's going to be very
interesting as well because we have to
do this again, so 0. And then this is going to be a 14 and that is going to be 13. And what you will see
is that the numbers just shift around a little bit. And, you know, if you have enough time and
enough brain power, you can probably figure out how to change those
numbers yourself. But that's ofcourse
madness because we have so many things in here. And the more complicated
the block is going to be, the more complicated
that will be as well. We're just going
to rotate it again and then of course once again, reset it so that it works fine. So that's what you have to
really be careful about is not changed the number here, but you will have to change
it like by using the arrows, is if you change the number than every one of those
cubes just works. Just, just moves in and of themselves is very
strange block, which is a very strange program. But it is currently, at least to my knowledge,
the best that we have. Sadly, this is of course
going to be the south-facing. And then let's just immediately rotated to the east
facing as well, which can just do this
and then do that. And there you go. Now we should
have everything in here. So we're going to say
export box or shape, or the East as well. That's great. And now what we're gonna
do is we're going to take the North and the West and
immediately already use it. So we're going to take
this control C to copy it. And then what we want is we want a private static final voxel
shape or shape underscore n. So this is shaped North. And then we're just going
to import the stream class, the voxel shapes class, and the Boolean by
function class as well. And then what I'm gonna
do is I'm just going to copy this four times. Over that we have north, east, south, and west year. Make sure that you copy over the correct ones are
the correct name here. That's very, very important. There have been
people who, you know, mistaken one of
them for the other. So that's very important. And here once again, we have to clean this up,
that's totally fine. Those are some grounding arrows, floating point rounding errors. Sometimes can happen. It is just is what it is. But this is not too crazy. There's going to be the
south. There you go. Then this is going to be east. And then we have all four
voxel shapes in here. Like I said, this is a
very tedious process, but you will only need to set it up once and then
it's going to work. If you of course
changed the model, then you will have to change
the voxels shapes as well. Yeah, so that's, it
just is what it is. We can't really do
anything else with that. Then we want to overwrite the
good outline shape method, this one right here. And I'm also going to
copy over the contents. Like I said, everything
is available to you, but this should be
fairly self-explanatory. We just have a switch
statement that it looks at the facing property and
it's just going to say, hey, if the facing as North, then we're going to
return the shape north. If it's facing south, we're going to return South
and so on and so forth. So that's really all
that this method does be really complicated
thing are at the voxel shapes. And like I said, there are, sadly isn't another
way to properly or more easily do this at those, those are of course
all available to you. Same of course with
the model here. Let's just rotate it back
and then you will see that whatever reason it is
red and there it is Mac. So that's totally fine. This is like I said,
also available to you, the JSON file, all of
that you can download. And then we just need to do
is instead of making a block, we want to make this a or
E calcium blaster block. And then, oh, well of
course we also need to make this public and then
everything works, right? So this should actually be
everything that we need. Like I said, it
is quite tedious, but I'm sure that
we will manage it. Or of course also depends on how many blocks with different crazy shapes
you want to add. So that also is the case. But for the time being, let's see For works or why we
find ourselves a Minecraft. So let's set that down. The calcium last drink
can see there you go. The outlines match perfectly and if I set it down in
a different direction, It always faces me. There you go. So
everything works and the bounding
boxes totally fine. Now what I do have to say
is that if you have really, really complex bounding
boxes like this, of course you can see
is all still blocky, hasn't, it doesn't have any diagonal stuff
and things like that. If you have like
diagonal things, I highly recommend
trying to maybe make your model a little
bit easier in R2, complicated, because a crazy
complicated voxel shapes are actually going
to slow the game down quite significantly. But that is just something
to keep in mind. But that's actually
how easy it is to add the custom block
models to Minecraft. But in for complete
transparency, the Oracle can last row
was done by platinum G 17. By just tweaking the
texture is a little bit, but otherwise it is basically under the
Creative Commons license. So if you want to use this or your actual like released MOD, then please be aware of the license if you're just
going to use it for well, basically private
testing purposes is going to be totally fine. But this would be for
this lecture right here. I hope you found this useful
and you learn something new. And I'll see you in the
next lecture. Oh, yeah.
79. (Intermediate) Adding a Custom Item Models with Blockbench: All right, welcome back
the fabric course for 118. And in this lecture, we're going to be taking a
look at custom item models. Who last time we've seen
custom block models. Now it's time for the
customer item models though. For the time being,
we're just going to make a new item here and then we're going
to add the item model. So this is going to
be the Oracle Malcolm underscore staff. And this is of
course also Oracle underscore path that you go. This is just going
to be a normal item for the time being. And max count of one
is actually great. We don't need to make any
custom item classes here. We just need the
item model for it. And then actually we
are going to be fine. So let's add the
translation first of all, or a calico underscore staff. And then here as well,
recount come staff, the ego. And now the item model
is the crazy thing. For that. We're once again
going to open locked bench. And there it is, the beauty
of the calcium staff. And as you can see, we're
actually using some of the little textures as well as the Oracle can block texture. And overall, this is pretty
much all that you need. So it's just an example here. This is how it basically
looks if you are holding it. All of the other display
stuff is also done. You can also paint it
yourself if you want to. But for the time being, I'm
actually fine with this. We're gonna go to Export, Export block item model or a calcium staff I
already have this year. That's going to be fine. And then we're actually
going to just copy over the JSON file as into
the item models folder. And then the only
things that we need to change here are
basically the name. So this is going to be
Minecraft or plank. This, right? Of course with blocks slash, there they go, because those
are all block textures. And then the same for our
recalc and block as well. So MC cores block right there, and then the rest here is just going to be
totally fine for us. And I know you thought
you might be saying that, well, that can't be it yet. That's actually, that's
all that we need to do. We just need this
JSON file first, the modelling of the
actual item model. Well, that's something
that you're just going to have to try out yourself, like I said, a link blog bench. Again, it's really
not that difficult. You can simply add
cubes in here, move them around, and then make them bigger
or smaller like that. So you it shouldn't
be too crazy. I'm thinking that
maybe with an hour, an hour and a half, a
little bit playing around, you will get the hang
of it very quickly. It pretty much is
just like Minecraft, but making models with blocks. So it is very similar actually, whatever the case may be, Let's just see if it works. Or we found suspect
and Minecraft. And as you can see, the
aura calcium staff has been added and it looks fricking, amazing, even in 3D or
in the third person, it looks really freaking cool. And I really like
the small gold block at the very top there. That is just other No, I
just really like the fact that it's basically the
whole block texture, just in this tiny
little block there. Are I, I do, I do
really like it. So that's actually
how easy it is to add the custom item models
Minecraft, right? And that is already it for
this lecture right here. I hope you found this useful
and you learn something new. All of the code and all of that is of course available to you in the GitHub repository where
an individual just as well. And if you enjoyed
this, I would really appreciate a review from you. Otherwise, I will see
you in the next slide. So yeah.
80. (Intermediate) Adding a Custom Bow: All right, welcome back to
the fabric horse for 118. And in this lecture
we're going to be adding a custom
bowl to Minecraft. The customer is actually a fairly straightforward
process. We're just going to take
the oral calcium staff and we're gonna make this T or a capcom bot name
with the name here, of course, very important. So or a killer combo. And then this is going
to be a new bot item. And the registration is done. Now what we of course
need to do is we need to add the modal
predicate right here. This is the main thing. And what we're just gonna
do is I'm actually going to copy over a method
that I've made. And that's the
registrable method. You can see it basically
registers the bot. All of that jazz. This is from if I middle mouse button click on this,
and then I click on this. This is going to be the or middle mouse button
click rather. And this is the model
predicted provider registry from Minecraft
or from vanilla. And if I go down here, you should be able
to find the pole and the pulling right here. We have those two registers for the bot, the bot basically, and I basically just
copied those over, replaced the provider with our fabric modal predicate
provider registry. But this into a separate method just because it's a
little bit easier, especially if you
want multiple bows, you can just call this. And then with your bot. So basically mod items, dot oracle combo, and then
that's pretty much it. So if you have another
bowl that you want to add, you just add that as well. And then that's pretty much, that's pretty much it,
That's pretty much done. That's really the idea here. So this is pretty much
all that you need. And then of course, you
will need, first of all, the translation that's
very important here, or a cow come under
scribble, right? So, and let's not forget
that or a calico. And then the item models
are well the kicker. But once again, they are
actually not that crazy. Four of them, I'm going
to copy them over. Those are of course,
all available to you in the GitHub repository or in
individual just as well. This one just points to
the oracle gumball here. And then under the predicates, it points to the different item models that points to this one, this one or this one. And they are all apparent here. Very important is
actually going to be our own recalc, a bowl. And then the layer, once again, it's just going to be
a different texture. So that's really
all there is to it. It actually isn't that
crazy before a customer you will need to make
or different textures, one of the normal ball and then three of them that are
pulling basically. But I mean, that's that's
pretty much all there is to it. I'm actually how easy it can be, because we've already seen the, you know, the predicates
here for the models. It's not nothing
too crazy Actually, it's something that should
be too insane for you. It's just a few values that
we can basically use in the model to determine which extra should be
shown for that item. That's pretty much
basically all there is to it though, for
completion sake. Let's see if it works or
we find ourselves back in microfinance can see
the oracle combo has been successfully
added to the game. And if I shoot it, that you go, the texture changes as well. So everything is
working totally fine, exactly how we would
expect it to, right? But that was already it for
this lecture right here. I hope you found this useful. You learn the new, and I'll see you
in next lecture. So, yeah.
81. (Intermediate) Custom Fluids: All right, welcome back
to the fabric course. And in this lecture
we're going to be adding a custom fluid to Minecraft. So adding a custom fluid is
I would say a bit finicky. There's like a little
bit of weirdness there. But overall, I am sure we will manage
though, first of all, in the MC course package, right-click new
package called fluid. And in there we're going
to need two new classes, the mode fluids class and
the Ani fluid class as well. And we're going to start with the honey fluid class, though. This is going to extend
the flowable it, and we're going to not
implement the methods. What we're gonna do
first of all is where I make this abstract actually. And then what I will do is
I will do the following. I will go and click
on flowable fluid, press Control H, and
double-click on the water here. And then what I wanna
do is I want to get everything in here, basically, everything except for the constructor
and the copy this. And I'm going to
paste it in here. And we might get, We actually
not getting any errors, that's actually even better. And what we do need is the
still hear the very bottom. We don't actually need either
of those constructors, but we do need is, this
needs to be honey fluid, and this needs to
be honey fluid. There's something
that you're going to of course have to do every time you add a new fluid. So one way we can
simplify this as well. And then overall, I believe
that this should be fine. We can just format this
a little bit differently so that we can actually
read it properly. This is for the particles. And this is the sound. I'm actually going to
change the sound to, let's say the block,
honey block slide. Because of course we have
some honey blocks in there. We just don't have a
honey fluid in this case. And then those
fluids, we're going to change it just a moment. But now we have the honey
fluid together with the still and the flowing classes in there and in the mod fluids, what we're going to need
is just two things. And that's going to
be, first of all, a private That's a lower
BAL fluid will register. So this is the
register method if global fluid is the return type, a string name, and a
flowable fluid or fluid, or flow fluid, that's fine. This is going to return
the Registry register. Registry that fluid,
a new identifier, MC course mod, mod
ID, and a name. And after the first parentheses, global fluid, this is of course going to
register the fluid. And then we're gonna
say public static, final global fluid, or a honey underscore still, which is equal to register
underscore still. Then a new honey
fluid that's still. And then I'm going to
duplicate this with Control D. I'm going to say honey flowing. And the same in the
name here as well. If flowing. And instead of
still going to call flowing. And that's all great.
That's not what works. And what we can do in the
honey fluid class up here, we're going to return what
fluids and he flowing. And here, when I return a mod, fluids and honey still, we still need to make
a bucket for this. No worries at all. Actually
fairly straightforward. And I go into the
Item class and we're just going to appear
over the rainbow. And this is going to be the
honey underscore bucket. And here are those same thing,
honey underscore bucket. This is of course a bucket item. And this first one
we're going to take in the mod fluids that honey still. But usually you want to
choose the honey still. If a fluid is asked for, that's the general like I mean, I would say that
almost gist of it. We were also going to
need a mot block for this is going to be a block
without a block item. This is going to be
the honey fluid block. This is something that
we're going to need some misty honey
underscore, fluid. Underscore. Ok. Once again, this is
going to be needed for each of your different fluids. And this is going to
be a, actually this, we're going to need a lot of
fluid block class for this. So this is going to
be the BOD Lewis block because once again, we don't have access
to the constructor. This is a fluid block hover over this great
constructor metrics super. And then we'll just gonna
make this public as well. And unless it's going
to be a fluid block, and the first parameter
is going to be fluids, not money, still very important. And then here we're going
to actually say material of fabric settings over. And then we're going to
material that of water. Just to make sure
that this works, we're going to say
no collision and non opaque so that we have and
also drops nothing because, well, in fact water or in this case honey fluid
drop, block props nothing. So that is that. And then in the, once again, the honey fluid
class, first of all, the bucket item, very easy. More items that on the
bucket. Very nice. And then down here, we've, for example, can see that we
have some particles here, which we're in this moment
not going to change, but you could make your own particle types and for example, have dripping honey there. Something like that. Have this matches here, which we have to replace
it with mod fluids, honey still, and fluids. On the blowing. Then here, the two-block state. And important that
the blocks dot water replaced with more
blocks, that honey fluid. This should be fine because this is of course also a fluid block. Therefore, it's going to inherit the block States
properties of it. And I actually believe
that that is all of the changes that we
need to do here. We've referenced the block, the fluids, and the item. That's pretty much it. And now we do need to do is we need to register the fluid handler
and the fluid render handler. Now I'm actually gonna
do this inside of here. You could probably make if
you have multiple fluids, I highly suggest making a custom class
basically that OLS it. And the way that we're
gonna do is the following. We're going to say fluid
or render helper registry, exactly this instance
at register. And then this is going to be
more fluids on ISS still. So what we're going to have
to do with this four still antler blowing as well. And then we're
going to make a new simple fluid render handler. Very nice because this has
been basically provided by us or by fabric or
this actual or 118. And I'm going to say
simple fluid handler and we're gonna say water still. And what I'm gonna do
is I'm going to do a comma and I'm
going to copy this. We're going to need to put
in three different ones, so we're going to stay water
still three times here and then change this
one to water flowing. And then the last one is
going to be water overlay. Very important that you choose
the water overlay because the points basically
to the water texture, but the water texture
is actually gray. And this allows us to add a
fourth parameter in here. And that's going to be the tint. I'm just gonna take this, this is basically the tint of
the honey that I've chosen, and this is basically the color that the actual fluid will have. So this is just an
RGB value in hex. So wouldn't be too crazy. And I'm going to
say the same thing here for honey flowing. And then the last thing
that we're going to need is first of all, translation for the bucket. So honey underscore buckets
and the honey bucket there. And then a block model. Now this is actually
going to be so easy. Then I'm just going to
copy over this one. I'm going to say Honey
underscore bucket. And this simply refers to a honey underscore
bucket texture, which also going to
copy over very easily. Right here. There you go. Then there's one more thing that is very important
that we need to do, and that is under the data
folder or Minecraft tags, you're going to have to make
a new Directory hold fluids. And instead of
they're going to make a new tag called
watered adjacent. And we're just going to copy the contents of the
walls, Jason here. And we're going to change
this to MC course. And this is going
to have to include both the honey still, right? Honey underscore still, as well as on the underscore flowing. So this basically represents the physics of the whole
ordeal, so to speak. So it's going to have the
same physics as water. That's the best that I can
do with for the time being. However, that is all that
we're going to need for this, though it is quite complicated. There are a lot of things
and there are of course also still things that
you might want to change. The particle types
here, for example, there's a bunch of
stuff that you could still do in theory. But overall, I just wanted to, first of all, show you how
you can actually do it. And this should hopefully
be fairly straightforward. So for completion sake,
let's see if it works. All right, finances back
in mind, as you can see, the honey bucket has
been added to the game. Let's see if it works. And it does, it actually does work and was
very interesting is that I've actually made this infinite for the time being. But we can actually change
this very, very easily. This is actually a
very easy change. And you can also see
that I have it flowing. For example, you can see that the particles here are still
the normal water particles. That's pretty much what
I've said that, you know, might want it to be changed in a little bit of a capacity, but overall, it's
going to be fine. And then also if you go into it, you can see that the
overlay here is also blue. There's really not much we can do about
that at the moment. At least I've not found
how you can recolor that. But for the time, I mean, it's it is still a
completely custom fluid top that is actually pretty cool. And for completion
sake actually as well. Let's actually see
how to get rid of the infinite here, right? It's actually very, very easy. This boolean here is infinite, is equal to false, and that's literally
all there is to it. So that's all there is. And there's of course
some other stuff like git flow speed, you have to get level
decrease per block, a tick, tick rate, Europe last
resistance though. The level of the still fluid it, there's a lot of stuff
that you can do and you, I highly recommend once again, is playing around with
the numbers a little bit, trying out a bunch
of stuff, you know, be open to experimentation
with this, then I'm sure that
you can implement the fluid of your
dreams, so to speak. But that would already be it
for this lecture right here. I hope you found this useful and you learned
something new. I'll see you in
the next lecture. So, yeah.
82. (Intermediate) Modify Vanilla Loot Tables: All right, welcome back to
the fabric course for 118. And in this lecture, we're going to be taking
a look at how you can modify a lute tables. So first of all, you
might say, Wait, we've already done a lewd tables in the very beginning
of the course. We know how to add lw tables. Yes. But what you don't know
is how you can add lewd two blocks that
already exist in vanilla. And that's what we're
going to take a look at in this lecture right here. For that in the util package, right-click new Java class. This is going to be the
mod, loot table modifiers. And I'm actually going
to copy over all of the contents and we will
explain as we go along. Now there's of course,
all available to you in the GitHub repository or in
individual just as well. And the general idea here
is that first of all, we're not going to
add pepper seeds, but of course, turnip
seeds right here. And then the general
idea is that we have three identifier
serum those points to a specific luge table. So the Lu table, when we go down to the external libraries, this one right, net
Minecraft project and so on. In sight of the data folder, luge tables, it blocks
chest entities gambling. And you can basically say that just as you can see and
then I can see, okay. Is there a igloo chest in there? That's exactly what
that is in here, that you basically take
the name without the JSON. Very important. And
you can also have it in the houses here
as well, for example. And stuff like that. So you can basically modify
any of those tables. Now in theory, I believe that
he could take away from it. Highly recommend not doing that. Highly recommend
only adding stuff. Now how you add stuff with
this fabric loop pool builder. Now this is the thing
that's going to be the most complicated. The thing about it is that
I have one example of this here where you basically have a particular chance
that something drops. You can also put this to
one and then you have a 100% chance to drop it. And then here with
this width function, with the setCount load function and a uniform load
number provider. We can basically say this has, this drops between this number
and this number of items. But as you can clearly see
over the dowsing rod inside of the igloo chest as well as the coals liver from the creeper is going to only ever drop one, while the turnip seeds from
the grass drops one or two. And only as a 35
percent chance of actually dropping if we go to
the loop pool builder here, well, you can't actually
see what is going on here. However, it is very complicated. So you're just going to have to try out a bunch of
stuff basically. See, for example,
a conditionally, okay, what are
kinda put in here? Well, I can put the builder
in here. Okay, fair enough. So if we could take
a look at this, I have to take this
loop condition builder. So you can see this is a
loop condition builder. And I could say, for example, personally loop condition
and press Control H and see all the different load
conditions that there are. So this is one of those
things That's pretty cool, where the hierarchy here is
incredibly useful for this. For example, you have
the time check loop, loop condition, which is
really freaking cool. We have the match
to loop condition. We have the kilobyte
player loop condition and all of that jazz. So there's a lot
of stuff that you can basically put in here. It is just a matter of you have to try
out a bunch of stuff. And basically, well, it's
kind of and I will admit this is kind of just
running against the wall with your head until, you know, it basically works. So there is a lot of trying out. But if you wanted, if you have something
really complicated where you want to
add it to something, then it's just going
to be that way. But whatever the case may be. So as you can see in here, we're basically
calling the loot table loading callback event. And then you're saying,
hey, if the ID year matches the idea that
we've specified up here, if the grass block ID is
equal to the ID here, then we're going to add it to, then we're going to add all
of this to the loo table. So that's the general idea. And then we're going
to do the same thing. And the igloo and then
the creeper as well, where we add the
coal sliver here, the dowsing rod and
here the turnip seeds. And the only thing that we need to do then is go into our, well MSE course mod
As and then just call the mod loot table modifiers
that matter fellow tables. And that is it. That's all there is to it. And if we want to add something, we just copy it over, make a new identifier, add another if
statement into a bunch of stuff here around.
And that's it. That's all that we need to do. Though. I guess that's received the works for finds
us a Minecraft. So let's first of all
kill a creeper NSC. There it is. A coal sliver
has dropped from the creeper. And then let's
actually, first of all, I'll kill this creeper because otherwise we're going
to have a bad time. Also, let's turn down
the volume a little bit. It's a little loud here for me. So they go and let's put a survival mode
and let's drop in there. You can see we already got
lucky at the first time. The turnip seats are
actually dropping. And just know that
we have at all. Let's also search for
an igloo quickly. Well, Would you look at that? There's a dowsing rod. So that's actually how
easy it is to add the alluded to already existing
loot tables, right? All of the code is of course,
once again available in the GitHub repository or an
individual just as well. And this is also already it
for this lecture right here. I hope you found this useful
and you learn something new. If you did, I would very much appreciate a review from you. Otherwise, I will see you in the next lecture, though. Yeah.
83. (Intermediate) Advancements: All right, welcome back to
the fabric course for 118. And in this lecture,
we're going to be taking a look at advancements. So advancements are
done via JSON files. So what we're gonna do is
we're going to go into our data folder in
the MC course folder, Right-click new directory
and cold advancements, making sure that we're
reading this correctly. The goals that's very important. And I'm actually
going to copy over the two basic files that are already prepared and I
will explain, right. So you can see I have the MC
course JSON file advancement and the dowsing rod
advanced advancement. And those two are a
little bit different. But what is happening
here is that we have one advancement. We are, which is
basically the tab. So this creates a
new Advancement tab. If the advancement does
not have a parent, you can see this is apparent. Mc course. Mc course.
Okay, Sure enough. And then this one does
not have a parent, but that it has a background. And the background actually
has to be this specific. It's very strange, but
it has to be that they have to put in your ID
and then textures block, and then whatever
block, for example, you weren't at the background, or you could of course also put it on a different, in
a different folder, in the textures folder that
would also work as well, but the rest should be
fairly self-explanatory. You have an item, get a title, that's just the title of
the actual advancement. And then we'll have a little
bit of a description here. What is the frame is at a task? Now I believe that you can
actually just go in here. There's challenge as
well and the like that. So there's a different
view, different things. So toasters, so this is going to be whether
or not it's going to show the toast at
the top right of the screen, then announced shut. Well, that should be
fairly self-explanatory. And now they're really
difficult thing let's say is the criteria. Because here we get
into the requirements and the triggers
and the conditions, though, we're just going to take a look at this in general. We're not gonna make
any custom conditions or triggers because
that's going to be way, way harder and that's
actually something that's way more complex
in at the moment. But for the time being, we're just going to take
a look at the inventory changed trigger right here. This means that if I
get an oracle come in, get into my inventory, then what is going to happen is that I'm going to get
this advancement. And then same with the
dowsing rod, right? If I get a dowsing rod in my inventory and I'm going
to get this advancement. So that's the general idea year. And once again, I have a
great resource for you, which is once again, of
course Miss old GitHub IO, where you can basically generate the JSON files
for the advancements here, this is actually just
like insanely great. We could see, for
example, conditions. And then there's like a
few different conditions. We can say, what is
the requirement here? And you can see there's multiple
different requirements. For example, using
item even there is possibly some channeled
lightening bread animal. So as you can see, there's
a lot of stuff that you can basically put in here. Tick, even take
lists, look at tics, or there's lot of things
that you can do some entity. I highly recommend just playing around with
this a little bit. And then of course, there's also always on GitHub repositories of popular modes where
you can also just take a look at
their advancements. Highly recommended,
that sometimes you just need to think
about it a little bit. Now, while advancements aren't the most important
thing, you know, they still can be a pretty
cool addition to your mat. And just for completion sake, let's see if it works, but be sure to make a new
world first because if you ever had either of those
items in your inventory, you're going to get the
advancements immediately. Best to make a new world. That's a very smart idea, or we find ourselves
in Minecraft. So let's see, and let's just take out the ingot rate here. So let's just go
and there it is, so that we get the
advancement right here, our lies in the telecom. And if we go into
the advancements, you can see we already have the dowsing rod
advancement here, like waiting for us so to speak. I just get another advancement. So if I just get, for example, the iron England, that
we get another tab. And you can see the
Minecraft tab and here as the MC course Model
tab for the name of the tab is always going to be the name of the
first advancement. But that's basically
the general idea here. Apart from that, let's also
take out the dowsing rod, and we're also
going to get that. But it doesn't work. They're auteurs like you. That's at least what I've heard. And let's just see, right here. There you go. So everything
working totally fine over there would already be it for this lecture right here. I hope you found this useful
and you learn something new. And I'll see you in the
next lecture. So, yeah.
84. (Intermediate) How to spawn Particles: All right, welcome back to
the fabric horse for 118. And in this lecture, we're going to be taking a
look on the how you can spawn particles
into the world. Now, the specific thing
we're going to look at is basically owning the
particles in the SPD block. So basically in this
particular example, how you can spawn a
particles in a block. And then usually, for example, for entities or mobs, this should be very
similar actually. So overall, what you need is just a World variable and you
need to be on the client. And for that we're
going to override it the random display tick method. And this one basically is only called on the client and we
have a world of variable. So that's pretty much
exactly what we need. And what I will do
is I will actually copy over the contents
of this is all available to you in
the GitHub repository or an individual just, well. And you will see here, you basically have a chance. But we have a 35 percent chance that these particles
spawn basically, and we're always
making a new float. So sometimes we have all four of them small and sometimes we have
none of them spawn. That's sort of the general idea. And you can see that
the way to spawn a particle is to call world
dot-dot-dot particle. And we need to supply
a particle type. It's using the middle mouse
button. Click on this. There's a bunch
of particle types right here, default
particle types. You could, in theory
also read your own. That's something
we're not going to look at in this lecture. Wherever we might take a look at that in a future lecture, are not a 100 percent
sure just yet. And we have to
supply the position. So x, y, and z position. You can see that I always add a little bit of a
randomness here so that we don't respond at the
same position every time. And then the velocity, well, that's just the speed
at which this moves. And I wanted to move upwards. And you can see that here, it basically moves upward. But we can either do smoke, there's some other stuff
like ash, there's explosion. So there's a lot of
different particle types. But we're going to stick with
this for the time being. And just calling this four times just makes it so
that there's a little more of those particles
that are being owned wherever you
have a World variable, you can just make
an if statement. If world is client
and then you can call the particle is
that's only going to work on the client side.
That's very important. That's something in mind. But otherwise, for
completion sake, let's just see if it works. Or firms announced back in Minecraft and let's
see There they are. This small particles are already rising from the SPD block. You can see if I set it down, see some of them are rising up. And it's definitely just a random while basically calling. And of course you
could always call more or less depending
on what you wanna do, but that is always
a possibility. But that's the general idea. Spawning the particles, well,
specifically on blocks, but pretty much on
anything else is calling the world at our
particle method, right? But that would already be it
for this lecture right here. I hope you found this useful
and learns at the New, and I'll see you in the
next lecture though. Yeah.
85. (Intermediate) Custom Paintings: All right, welcome back to
the fabric course for 118. In this lecture,
we're going to be adding custom paintings
to Minecraft. And in custom paintings
is actually a very, very straightforward process
in the MC course package, right-click new package
called painting. Then instead of there
we're going to right-click new Java class mode paintings. And then inside of there, we're just going to
need a few things to methods to be exact. A private static
painting, a motif, register painting with
a string name parameter and a painting
motif, ending motif. That's fine. Let's return
registry data register, registry dot painting motif
with a new identifier, MC course mod n mod ID name. Then after the
first parentheses, we're going to pass in
the painting motif, then end it with a semicolon. Power is also very important. We need a public static void
register paintings method right here is just
going to system out print line registering
paintings for odd ID. Just so that we have
this because we actually have to call that in side of the MC course
mod method here. So in the on initialized method, we're just gonna do this right after the modal registries. So on paintings that
register paintings. And now on we will actually
adding the paintings. Well, how is this done? Well, actually it's
very simple as well. Public static final painting
motif at sunset here. And we're just going
to say register painting with the name sunset. And then a new painting motif, which just takes
in two integers, the width of the
image and the height of those values here are
in pixels basically. Yes, long as they match, everything is, should be fine. So let's just duplicate
this times with Control D. And we'll just also
going to add the planned and the wanderer as well. And then make sure that
we change the name says well-planned and wonder. And then the sizes as
well planned a 16 by 16, and this one is
actually extend by 32. This so that you have like
a couple of examples. And then the question
is, well, but where do we get the paintings from? Well, first of all, the
paintings that I have are done as well by platinum G.711. So if you want to use them,
please note the license. If you want to use them
in your like public MOD, these, note the license. Otherwise, let's just
copy those over. So those actually will go into your textures folder
right here, right? So in the assets MC coarse
textures, and then painting. And then there they are. The three paintings, the names here of course have to match
what the name is here. It will be fairly self-explanatory
at this point in time. And while the rest is just going to take care
of itself basically. So that's all that you need. You need the paintings in this class and very important that you
call this method here. Otherwise it will not work. Well. Let's just see for works. All right, we find
ourselves back in Minecraft and I already
have the paintings. Let's just set it down
and let's see if we can have some block to getting
our pitting there it is. There's the first one. But let's see what
this no, that's not. It will not our sunset or
we'll get it at some point. I am very certain, as you can see, basically
they are there it is. There's the next one. And
let's just see, Let's look. Well, that's not gonna work, but this one is going to work. So let's just do that. And let's see if we can get the small one of the 16
by 16 one as well. So the general idea is, as you can clearly
tell there it is. So is that the
paintings are basically added to the rotation
of the normal painting. But this is actually
really cool and well, you could basically now
add any painting and yes, you can make them as
big and as beautiful and as whatever you
basically want to 0. It can be any thing
that you want to, as long as they will adhere to the normal centers and there are PNG file in
your textures folder. That's actually how
easy it can be, right? But that would already be it
for this lecture right here. I hope you found this useful
and you learn some the new. And I'll see you in
the next lecture. Oh, yeah.
86. (Advanced) Custom Block Entity: All right, welcome back to
the fabric course for 118. And in this lecture,
we're going to be adding a custom block
entity to Minecraft. Now, as you will probably
have seen this as a longer lecture because this
is a very complex topic. And what I actually highly
suggest is to watch this lecture and the next receding lecture
at the same time. So basically Mac tobacco, because the next lecture is immediately related to this and actually we'll make
the block entity function a little bit better. The second thing I
wanted to mention is that if I ever
say tile entity, I mean block entity, it was basically renamed in 117. And so I still have I sometimes still use the tile entity name. It just is what it is but
then I mean Brock entity. And also I am going to copy over a lot of the
code and then we'll basically explained
through it because just writing all of this
out is nonsensical. It doesn't make
any sense though. Please be aware. There's
the GitHub repository and there are individual just where you can
basically copy over all of the code as well, though. You don't need to
worry about it at all. You have everything
available to you, so no worries there. Okay, So let's just start. The first thing that
we're going to need is we're actually
going to need a, something in the item package, and that is going to be a
new package, old inventory. Then inside of there,
we're going to make a new interface
though right here, new Java class interface. This is all the
implemented inventory. And once again, like I said, our caviar, the
entirely of this, which is all available
to you of course, in this is actually
not that interesting. The general idea is
that first of all, the John by Jews and,
or justice I guess. And this is public domain. So no worries there
we can use it. But still all credit
goes to just for this, It's actually very useful the
implemented inventory year. And the general idea
is that when we implement this interface in
our awesome Brock entity, we can basically very easily use the inventory that
is associate with it. But that's the general idea. We're just going
to need this and will basically never
to look at this again because this is almost
like perfectly done already. But we don't need
anything else there before we're going to just
dive into the block entity, I'm going to show
you a little bit of the theory behind
the block entity. And for that, of
course, we're going to break out the PowerPoint slides. This is the general
idea of a block entity. There are four parts. There's the block class II, block entity class, the
screen handler class, and the screen class. What's very important
here is that overall, the block class is probably
one of the most easiest ones. This is just where you
right-click and then something in the Brock entity happens because the block entity then
creates the screen handler. The screen handler basically
handles the screen. It sounds crazy, but the
idea is that there's a separation going on here
because the screen class, Let's start here is client only. Okay, So this means that it
is literally just this image. There's some nuances there. Of course, we can display
the progress arrows. We can display the buyers
here, stuff like that. Yes. But it is just this image. I could replace the
image with an image of my face or an image with
a dog or whatever I want. And the screen handler, like the actual slots here, they would still work. They don't need to
look like this. That is a very important lesson that you very much need to, well get into your head.
It's very important. This is just the screen, this is just the client,
just this image. Now, the screen
class here however, has a reference to
the screen handler. And the handler has the
slots in the inventory, as you can see by mark this with blue for the player
inventory and the hot bar. And then in like violet
pink, we have the, well basically the custom slots with the screen
Handler also does is it can synchronize values from the block entity, the
server and client. Now that is something that's
very important and that this is also something
we're going to see in the next
lecture actually, because this requires some
more setup, so to speak. And we're just going to
store it by, first of all, having a normal block
entity that's going to do some interesting things. But that is a very,
very important thing. And then by synchronizing
those values, we can then use them
in the screen class. For example, display the
progress arrow here properly. That's the general idea. Now the block entity itself, what this one contains data and functionality for a block. That's the general idea. And then it can also
have an inventory. For this inventory, like I said, is sort of handled by
the screen handler. There's a very tight coupling between this one and this one. And then there's not too
tight of a coupling between these two is just
basically has a reference. Then with the block class it
just has a reference here. So those two definitely
are more tightly related. There's a bit of a tight
relation between, of course, the screen and the
screen handler as they have both screen in the name, to be a very good indication that they have something
to do with each other. But overall, that is
the general idea, that's the general
theory behind it. It's nothing too crazy, if anything here is a little bit confusing, don't worry about it. I hope that I will be
able to clear it up once we're actually
programming all of this. But let's just switch
back to intelligence. And now let's make the
actual block entity. So in our block package, right-click new
package called entity. And then inside of there
we're going to need to know the clauses, the mode lock in that class. And then also the free calcium. Laughter entity, right?
And there it is. So this is going to
extend the block entity. And it's going to implements the named screen handler factory comma
implemented inventory, the one that we've already done. Let's hover over this, say
Implement Methods and say, Okay, I'm going to
hover over again, create constructor
matching super. And now we should
be happy with this. So the getItems here
you can see null. Well, we can change this very easily because
now we're going to add a private final
defaulted list of items stack with which is
called the inventory. And this is going to
be equal to a default, a list of size four with
item stack dot AMD. And this is going to
be our inventory. Those are going to
be our four slots. So it makes sense. And we can just return
this right here. So inventory, just returning it. And that should be fine
for the display text. This is the text that is
displayed at the top of the UI. We're just going to save for the time being new literal text. Or it can come blaster,
That's going to be fine. That's totally okay. So the Create menu here, we actually have to supply a screen handler as you can see. Now, what I'm gonna
do is I'm going to purposefully make this a, an error because otherwise I will probably forget it
because like I said, there's a lot of stuff
that we have to do here. Though. This is why I'm making this
purposefully and error. We're not going to run
the client for quite awhile anyway, so noise there. Then what we also
needed to do is we need to delete the
first parameter here or the other constructor. And then we have to do the rest inside of the MOD
block entities. And what we're gonna do
is we're going to say a public static block, entity type of
type or recalc and blast rent t. We're
going to call this the oracle income
underscore blaster. Now we're not actually going
to assign this to anything, because what we're gonna
do is we're going to have a public static, void, register, all entities
like this exactly. Then what I'm gonna do is
I'm going to copy over this and I'm willing to
explain as we go along. So what is this? So we're going to
call registry that register for the
block entity type. That should all be fairly
self-explanatory with an new identifier of Armada D
and the Oracle can blaster. Okay, and then
we're going to call the absolute block
entity type builder at creat with the Oracle can
blast or entity colon, colon knew, well, this
is going to create a new or a pelican
blaster entity, and then this is assigned
to a particular block. This block is going to be the block that when
you right-click it, this entity is assigned to it. And we will actually
have to change something in the block class
itself as well. So the Oracle can
blast or block class. We're going to have to change some stuff in there as well. But for the time being, we're
going to be fine with this. And I'm actually
going to make this a little bit different.
That's okay, That's fine. And then this register all entities method
has to be called in the mode MC course mod class. But that's also very important. We're just going to
call this right here. So block entities, I've registered entity,
so it's very important, otherwise we will get
not quite an arrow, but it's going to not be able
to save the data properly. So this is why we're
going to need this. And then instead of the
type that we don't have, we can see more book entities
that Oracle can blaster. And now all arrows
except for the one that I want to have is gone. And we can basically proceed
to open the broad class, which is going to be the
Oracle can blast or block. Now we've already done
stuff in here that is completely independent
of whatever we have. So basically the direction
property and all of that, we don't really care about
it in the sense that you can also have a block that doesn't
have those things, right? Those are independent
of each other. But what we're gonna
do is we're going to extend the block with entity class and we're
going to implement the block entity
provider interface. Let's hover over this
Implement Methods. Use the Create block
entity method that we need to implement here. And then the rest is going
to be a totally fine. Now we have this we can
actually already do, but here we're just going
to say new or a cow can blast or entity with
a position at the state. And then that's already
done right here. That's actually how
easy that can be. Will be also need
to do is we need to API over the render type. So I'm just going to
copy over this method. You need to override the
get rendered type method. Because when you
override this class, you can see that it's invisible. I'm not sure whether
it is the case of a for whatever reason we just
need to override this. That's okay. Then what I'm also
going to override is the on-state replace method
with some stuff in here, like I've already mentioned, all of the code is
available to you in the GitHub repository or in
individual just as well. So no worries, you can copy
all of that over as well. And this method is actually
really, really freaking cool. There's, this will just
drop all the insights of the Oracle can blast or
entity just on the floor. So this is basically
what this does, is actually really
freaking cool. And I just highly recommend
just using this as well, because that's
immediately just drops all of the inventory when
you destroy the block. And then there's one
more thing of course, and that is the US methods. So as the right-click method when I also put this down here. So you can see that what I'm basically going to do is
I'm going to say, hey, if I'm on the river, then
I'm going to say, Hey, make a new screen
handler factory. And as long as this is not null, then I can open the
handled screen. And this is, this basically
makes things in motion raise the screen handler via the block entity and
so on and so forth. And then basically
it opens the screen, but those are the main methods
that we're going to need. Then there's one more method
that we're going to need, and that is the
get ticker method. But this is the
ticker right here. I'm just going to get ticker. Then you can see what
I'm actually going to return is I'm going to
return the check type, hype and unmarked block
entities, not recalc blaster. And then I'm going to say or RCA complex entity
colon, colon tick. Now this, of course we don't have just yet because we don't have a tick method in our
Oracle can blast or entity, but this is what I'm
going to add as well. So this basically enables the tick ability for
your block entity. So take, you probably have
heard this is a 125 of a second and basically is going to be constantly
done, right? So each tick, so every 125 of a second,
something can happen. And this is exactly
what we want to do inside of our entity. Every tick we can
now do something. And the way we're
going to do this, I'm going to copy
over 1234 methods. So that is once the public
static void tick method, and then three custom
methods that are going to be needed for
demonstrating how you can, for example, craft something. Now, this is a crude example
because in the next lecture, we're going to make custom
recipe civilization and customers happy types along word for basically
saying we can make JSON files for our
own like machine, for our own block entity, which is really cool. But for the time being,
we're going to use this just so that we have
any functionality here. And you can see though,
so the tick method here, it has four parameters, world position, we
have the state, and we have the entity itself. Now what's really cool
is that the entity, we basically have
access to this and can do whatever we want with it. You can see what I do
is I can say, Hey, doesn't have a recipe and
has not reached that limit. And then I will craft
the item that's sort of the general idea here. And what I will do here, you can see is I'm
going to just going to remove the first stack, the stack from the slot 0, from stops lot one
and from slot two. And then I'm sending
the stack in slot 3 to the Oracle can pick x here and I'm getting the same count. So I'm just going to
increase the count. That's a general idea.
And then here actually we need to put three in there. So that's very
interesting right there. What is required for this? Well, in the first slot, I
need to have called sliver, and the second slot I need
to have a golden pickaxe. And in the third slot, or
the slot with index two, I'm going to have to
have an oracle ingot. That's the general idea. And if all of those are true, and if the stack has
not reached the limit, then we can craft the item and we'll then the rafter,
the item is crafted. Now this is going
to look similar in the next lecture, but
a little bit different. Because once again, this is just a very crude way of
hard coding everything. And I promise you
definitely don't do this. This is just an example
right now for this lecture, just so that you can
see any functionality. Next lecture, we're
going to do it properly. There are very nicely with the recipe serialization,
I highly recommend. That's why I said watch both lectures one after
the other immediately, because it's going to be
way, way better, right? But for the most part,
the block entity is done of the screen handler here is the last thing that
we need to do. But for that we're
actually going to need the screen handler
and the screen. So in the MC course package, right-click new
package called screen. And then inside of there, we're going to create a
whole bunch of stuff. Well, the mode screen handlers,
That's the first one. And then the second
one is going to be the recalc blasters screen. And then there's going to
be the outcome blaster in handler. And that's going to be fine. And we're going
to take a look at the screen handler first. That is going to be
the most important, one of the most interesting one. Once again, I will actually
copy over the entirety of the class and we'll go
through it piece by piece. No worries there, right?
So there we have it. And we're going to have a few
arrows theorem, no worries, because of course,
we have to set the oracle screen blaster. This is pretty much
the same thing that we had to do for
the block entity, right where we are now
referencing this one instead of just getting the type
from the parameter. And what you will also see is there's two slots right here, which are for whatever
reason read well, those are custom slots. I'm actually going to
copy those over as well. Though. They are really, really frequent symbols,
as you can see, this one is very simple. And then the results are the few slot is
also very simple. And then we can actually import those into the, into the ego. And I'm going to explain those
in just a moment as well. But overall, what is the
screen handler doing? Well, basically, we're checking the size
Hayes the size, correct? Well, it actually
has to be four. So that's very interesting. And we're basically saying, hey, this has all of the stuff
that we need to do. Just setting the fields here, the inventory, the world. We don't need the
world just yet. Well, maybe we need the
world in a later lecture. And then we add our own slots. And this is how we add them,
this dot-dot-dot slot, and then we make a new slot. And you can see that
here I'm making a new motor fuel slot because in here I actually only want fuel to be placed into. And then in these slots, I it does matter to me. And then this is
the result slot. I also don't want the player to be placing
things in there, only the tile entity or the
screen handler basically. This is very easy.
This just overrides the canon certain method right here and the mod fuel slot, I actually basically
took most of this from the fuel slot
from the abstract furnace. But you know, as an
idea or basically, but that is pretty much
all you need to do. The indices of course
just count up, right? 0, 1, 2, 3. It'll be fairly
self-explanatory as well. And then the x and y here, that's going to be
something that's very interesting because this is the coordinates from
the top left corner 000 to basically the place where the slot is going to
be on the actual UI. I'm going to copy over
the GUI that goes in the textures folder, a GUI. And then this is the
Oracle can blast or GUI. And I'm going to open this. And what I will basically
explained is that the way that it works
is the following. That if I'm gonna do
this for example, right? You can see that. You can see that, right?
So right here is 0, 0, we're going to count down. And then we're going
to come to the right. And then this pixel right here is what we need for this slot. And you can see it's exactly
18 to the right and 50 down. That's the general idea. If you have Photoshop or if
you have GIMP or paint.net, you can usually do is you
can use the Select tool to see how far away this is and you just kinda
have to count it. That's the only way that this really works, is very annoying. It can be very annoying,
but it just is what it is. And then we have these
two helper methods, which are also called the inventory and the
player hot bar. Now, those are just
nicer to read than just having this
stuff in there once. It's like, I don't know, understand why this isn't
done in vanilla as well. Because in vanilla
is just this stuff. Just like put into
the constructor. I'm like, okay, that's weird. Then the transverse lot method is something we're just not
going to look at at all. This just enables us to
Shift-click a stack into this, into our custom
entity, block entity. Whenever we're not going
to look at this because this is actually fricking nuts. This is the worst
method I've ever seen. I just don't want to have
anything to do with it, so it doesn't matter. We're just gonna say, thank you that this works
and all is well, we can use method will
basically just says, Hey, can we use this? That's pretty much it. If the player is too far
away, something like that. That's all that
this does as well. So now let's move on to
the screen handlers, and let's just put this in here. It's actually going to be
fairly straightforward. It's just a public static
screen handler type actually of type or a
blast or screen handler. Recount come underscore blast or underscores screen
underscore handler. Handler. There you go. Is equals to a screen
handler registry, green handler, registry,
registry they ago. And this is going
to be a simple one, but that's very important with a new identifier from
C corps mod, mod ID. Once again, all recalc
come on her score blaster. And then after the
first parentheses, we're gonna say recalc and
blaster screen handler, colon, colon new, and end
that with a semicolon. That's all that we need here. Once again, the code is
of course also available. You can also copy this over. Now to not write everything out. Here in the screen handler, we can see the era has resolved. Now in the plaster entity, we can also finally resolve
this arrow here as well. We can just say this is
going to be a new record can blast or screen handler with
the sink ID, the inventory. And then this as the inventory, because this is of course
an implemented inventory. Therefore, we can just pass
it in our own block entity. And then we can close
the block entity. We can close this. We can close this. And then just the screen
is left and the screen is, like I said, pretty
much just the image. Now of course, it's a
little bit of a hyperbole. There is a little
bit more to it. I'm going to copy this over as well and I'm
going to explain. So overall you can
see that this is a handle screen of oracle comes blessed
her screen handler, very important that this
is a handled screen. It also points to the
texture you can see this is a identifier that points to the textures GUI or a
calcium blaster GUI PNG, That's also has to match. And then we're basically
drawing the texture right here and in the draw
background methods. So basically this just centers the title in the middle
of the block entity. And then the render method
just renders the background, the tooltips as well. And this draw texture method is going to be very interesting, especially in the next lecture, where we're going to add the fire progress and the
arrow progress bar does. This is what you need
to call basically to add more stuff to the image, to draw more on the image. Because if we take
a look at this, you actually have the fire here and the arrow right there. And this, we need to
overlay over this and basically expanded the
size of it depending on, let's say the
progress for example. So that's the general idea here. But for the time being,
this one, right, the draw texture with x, y, 000 background width,
background height just basically draws the
entire team of the Goo here. That's the general idea. Apart from that, we also have to call one thing in the MC course, compliant method
or rather class. And that is going to be
the screen registry, registry that register with
the models being handlers dot or a Malcom last
year Sweden handler and the calcium blaster
screen colon, colon new is very important that this is
going to be the screen in the second parameter and the mode screen handlers basically reference
in the first. Very important, once again, can be a little bit
confusing sometimes, but this is the basic
way that it has to be. And then everything should
be set up properly. And they mean this point, Let's see if it works. Or you find ourselves
back in Minecraft. And as you can see, let's
just see what happens. There is that the
recalc and blaster, and you can see everything
is still working fine. We can even shift click
that, that's even better. That's pretty cool. Now, let's just put the, if we tried to put anything else in here,
it doesn't work. The course level, however,
does work because it caused liver is a fuel item,
therefore it works. And then here we also
can't insert anything. Let's just put in
a very welcoming and at the bottom, a
pickaxe at the top. And then here a recap could
pick x should appear. And there it is, it
actually did work. Now, I'm not a 100
percent sure if they're still an arrow with
this. No, there isn't. This all works. And this
also doesn't work because the stack limit here
has been reached. So we can add another one, and as soon as I remove it,
the other one is added. Though. The Oracle can blast are
basically already working. Of course, it's not
firing here and it's not having a progress
bar at the moment. This is what I've been saying. Basically making
everything hard-coded and stuff like that is
definitely not advised. It's just a way that you
can actually see, hey, it actually does work
and everything here is, well, great end
working fine, right? One more thing we need
to add to the blast or entity are two
methods which are very important to saving
the inventory when the actual world gets well, when you move out of the world, and that is going
to be the right NVT and a read NVT method. And you can see that
at the inventories are right in meaty than inventories read and Read
empty. There you go. So that would have been
fatal. Well, there you go. So this is basically
the inventory, right? Mit's just writes the
inventory default lists here to the NVT data and then the red one
just reads it out. So that's the basic idea here. And that is very
important that we also call this as otherwise, when we close out of the world, it doesn't save the inventory. So that's the general
idea there, right? So for example, right now I
have 62 calls livers in here. Well, let's just
close the world. And let's just go
in there again. And let's see if
the coal slivers remain and they are still there. And there they are
62 cause lovers, Let's go. Everything saved. Like I said, this is a
very convoluted topic and there's a lot of
moving parts in here. The cheat sheet will be available to you as
download as well as of course you have the
GitHub repository and the just where you can basically take a
look at everything you're going to need
to add in here. And overall, it just is going to be,
it is just how it is. So the entity of
the block entities are just very
complicated and you will just need to push through and just try to understand
each part of it. Hopefully, I was able to basically facilitate that,
whatever the case may be. This is it for this
lecture right here. I hope you found this useful
in the learns of the new, If you very much Appreciate
it, review from you. Otherwise, I'll see you
in the next lecture. Oh, yeah.
87. (Advanced) Custom Recipe Types: All right, welcome back
the fabric course for 118. In this lecture, we're going
to be taking a look at how you can add a assume
recipe type Minecraft a. Previously we have made our recalc and
blaster broke entity. And I've told you that it's a very crude way of
crafting right here. Because what we want is
we want to be able to use normal recipe JSON files or
our blaster entity as well. This will not only make it a
way better because we don't have to hard code
everything into here. And then also, and
this is even better. It enables more pack
makers, for example, to add custom recipes for our lock entity and
things like that. So once again, I will be copying over a
majority of the code. So this is all
available to you in the GitHub repository or
in the jurists as well. So you have everything
available to you and I will explain
as we go along. So in the MC course package, right-click new
package called recipe. And then inside of there
we're going to need two classes, immortal
recipes class. And then also the recount
come last or recipe. And we're going to
start by copying over the entirety of the
blaster respiratory costs. Now, once again, I will actually go through this
and I will explain, there should be no
errors in here. So first of all, you can see that this implements the recipe of simple inventory. This just makes sense
because a simple inventory is pretty much just this
is simple inventory. You can see there
are three fields. There is an output, there is a default list
of ingredients, which are the recipe items. This will be the inputs and
there's also an identifier. This is basically
the name that you can have in your JSON file, but we're going to see
that in just a moment. So the Oracle can blast
recipe constructor takes in exactly those three
different parameters that you have as fields. That's very important.
And then there's a very important method and
that is the matches method. Now the matches method,
as you can see, take it in the inventory and you can also get the recipe items. So the recipe items, this is the list
that has been read in from the JSON file, meaning that whatever
basically list you have of ingredients or items
inside of your JSON file. These are going to
be saved in here. And what this tries is
it's gonna say, hey, that's the first ingredient
inside of our list, like from the JSON file, match the stack inside
of the inventory. If that is the case,
we're going to continue if then the next one
matches with the, with the stack and the
inventory of the second slot. For also going to, we're
going to return this, which is hopefully going
to be true then in this basically
determines whether or not there is a recipe present inside of the inventory.
That's very important. So this is one of the main methods which
is very important. But also if you have
a bigger inventory, if you have more slots that
you need to put things into. This is the part where you have to define the functionality. Basically, this is going to be the thing that's most custom. When you make your
custom recipes or custom rock entities, basically if they look
completely different, if they maybe have like 12
different slots and then you need to put certain things into certain slots
and stuff like that. This is basically
the method where most of this is going to be what the functionality is programmed into,
like implemented. And it's very, It's very
hard to really go through, okay, how you have
to do everything for every different way. Once again, here, at this
point, Java knowledge, if you don't have
it, you're going to be lost probably forever. Um, this is not, this is very, very complex and I'm sure you've figured this out at
this point already. This specifically here is
going to be very interesting. Indeed, the rest
of the methods are actually not that interesting. You for the craft
method, we just, the output Fitts's just true. Get output is just a copy of
the output, the identifier. We'll just get ID, which is turning the edim. And then here we come to
interesting stuff and that's the recipe serializer as
well as the recipe type. Because we can see we have
two static classes in here, the type class and
the serializer class. And that was actually
just help us immensely because they just
make our lives easier. Because we have
the instance here of the type as well
as the serializer. And we can just ask those
in to those two methods here to where the type class
is not that interesting. The serializer class you can see actually has three methods. That's the read, the read,
and the write method. So let's go through
those as well. The first thing here,
this string right here, the name that it
has to be given in the JSON file. Very important. We're going to see
that in just a moment. But this is very important that this of course matches there. And then we have the
read method here. This is the read method
from a JSON file. So this is going to read
in from a JSON file, and you can see this. So this reads in first
of all, the output here. And it's going to read in a adjacent area of
the ingredients. And then it's going to make a default list once
again of size 2. Now you might say, wait, but
we have four different lots. Yes, but we only have
two input slots. We have one fuel slot to input
slots and one output slot. And this is why
there's only two year, because the inputs, there
are only two inputs. Every any, in any recipe. Basically, we're just going
to set those inputs properly. And then we're going to make
a new recipe right here. And the same thing pretty much happens with the other read and the write method does that
we use at the packet buffer. So this all works via
the year the network. Now what's very
important here is that when we write stuff, right? You can see what I'm doing
is I can see I write an integer with the size
of our ingredient list. Then I write each
of the ingredients, and then I write the output. This order has to be
exactly the same here. So you can see I read an integer which is going to be this one. Then I read each of the
ingredients and I'm done. And then I read the output, but the order that
you write it for the packet buffer has to be the same as the order
you read it in. You make a mistake there. In the development environment, you're actually not going to see anything that's wrong with
you, are going to see you. Something that's wrong is
as soon as you put it on the server and you try
to join the server, then this will no longer work. Very important, very important that you keep that in mind, that everything here matches. And that pretty much
is the recipe bus for your customer recipe. There's a bunch of
things of course, that you could change, right? If you say, Hey, I actually
have multiple outputs. Of course you could change this. You can say, Hey, I
actually only have one input or have
even more inputs, or you can, this is all. There's something we are. Probably Java is what
keeps you back because most of this stuff is pretty
much just normal Java stuff. There's almost nothing in
here that says Minecraft. The only thing that
says Minecraft is item stack basically. But that's something that
people that know a lot of Java, but not a lot of Minecraft could probably still figure
out very, very fast. So that's something I
really want to drive home. We're basically it's over like the playground is
no more at this point. We're like Indeed and yeah, it's just is what
it is going to be, but we're just going to continue
along and that is going to be in the recipes class. And I'm actually going to
copy this over as well. This is actually very
straightforward. You just have a register method and you can see first
of all, we're drawer, we're registering the
recipe serializer with the ID from the
serializer and then the instance and then
the recipe type. There's also the idea of the type and then the
instance of the type as well. So that's fairly
straightforward as well. And this one we
actually have to call inside of the MC
course MOD class. And we're going to call this. Let's do it right right here. Mod recipes, not register that you go for that we've called
this, that's very important. And then both of those classes, we can actually close because
we're done with them. And we can then proceed to
continuing to the entity. We already have this open here. And now this is going
to be very interesting, is we're going to majorly
rewrite the entity here. Because what we're going
to add is we're going to add a property delegate. So I'm going to copy
this over once again, all of this is available to
you and you can see we have a protected final
property delegate and this will be created
or let's say yeah, created inside of
the constructor. So I'm going to also
copy this over. You can see this
property delegate is equal to a new
property delegate. And then we have
switch statements that referred to the progress, the max progress, the fuel time, and the max fuel time. The general idea is that we
have those four integers or those four data points that we want to pass into
the screen handler. And then later to
the screen so we can show the progress
and also the fuel. Well, basically in the amount of fuel that's still burning. So this is going to be a little bit more
complicated once again, because we have to do this
in a property delegate because this has to be saved on the server and the client. Because once again, the
screen is client only and the rest is basically
both server and client. And if we just pass it over,
it's not going to work. You're basically reaching
over the barriers there, which you should not do. So this is very important. And then we also should add three things to the
rate in GET method. That's the blaster progress, the fuel time and
the max fuel time with the right method, basically putting it right here. So let's just put
this right here. That's going to be
fine, where we're basically reading
in the progress, the field time and
the max field time. So that is also all
saved right now, the main thing which is going to be the changing of
those four methods. Once again, I'm going to
copy everything over, but I will hopefully
explain well, in a way that is going
to be satisfactory. There's a lot of methods that we actually
have to copy over. So let's just copy them over and let's see if
everything here works. So there's no arrows,
which is good. But you can see there's
a lot of stuff in here. Let's just go through first
of all, the tick method. Once again, the tick method. I've reworked this in
the following way. So I have a method here that is called, is
consuming fuel. Now is consuming fuel basically
means that I have put in a fuel and it's still burning so that the fire
is still burning. You know that from
the normal furnace, right? The fires burning. And if I were to
put in a or block, for example, it would
start to smelt. That is the is
consuming fuel method. That's what this returns, right? If it's true, then there's
still something in there. If it's false, then it isn't. So as long as we're
consuming fuel, we're just going to say, Hey, fuel time is going to
decrease every tick, right? That's just what happens. Okay, Fair enough. So this should be fairly
self-explanatory. Then we're going
to say has recipe. Now that has recipe
method has changed completely to this end. I'm going to quickly
explain what this is. So first of all, we're
just going to get the world shouldn't
be too crazy. And then we make a
simple inventory of the size of the
entities inventory. And then we're just setting every stack that we have in
our entity to the inventory. Now this is just a shorthand to basically confirm
the inventory here. Because our entity is
not a simple inventory, but we have to have a simple
inventory for our recipe, but that's the general idea. And then here you can
see we get this optional of our recipe,
right, called match, and then we get the
world but recipe manager at first match, where
we basically say, Hey, we have this type, read the recipe type, this inventory, and
this world, right? And then we just say, hey, is there a match for this type? Is there any recipe that
matches this inventory? Basically saying, Hey, if the matches method in the
recipe right here returns true. That's the general idea, that's
what's called basically, we should actually also
be able to see this, but this is definitely more
complicated as you can see, that the general idea is that
you can see type dot match. The match method is
called and that basically caused the mattress
method in the recipe. And if that returns true, then we're going to
have something in here. And the matches present
basically just says, Yes, we have found a recipe
that matches or the recipe type inventory that was supplied.
So this is true. Then we know that
we found a recipe and then there are some more things that
we need to check. So for example, can insert
amount into output slot, just a helper method that
basically says, Hey, if the max count is bigger than the actual
count we already got that. We don't insert anything. This just makes sure that, for example, when we already
have a pickaxe in there, we can't insert
another peck acts, basically making it a
stack of to pick axes, which of course doesn't
make any sense. And then we have the can insert item into output slot as well, which basically checks, Hey, is it the same item or
is the stack empty? So we can just input
something in there. But that's basically the
methods that it also checks. Let's just make sure
that everything is fine and nothing gets basically
badly overridden. Well, that's the
has recipe method. Once that is the case,
we're going to see, hey, is it right now? Doesn't have fuel
in a fuel slot. So that is going
to be right here. It just says, hey, is the
first slot empty basically, because we know
that in our slot, which has the fuel with index 0, this is a fuel slot, so there are actually only
ever be fuel inserted into it. So that's very interesting. So we can basically say, Hey, if this is not empty, we know that there's fuel in it. And if we're not consuming
fuel at the moment, we're just going
to consume fuel. But this only
happens when we have a recipe present in
there, stuff in there. And then the cone
Zoom fuel method, actually also fairly
straightforward. We're just once again
a sanity checking. Hey, making sure that
this is not empty, is that we're absolutely
sure about this. Then we're setting the
fuel time to whatever the actual time of
the removed stack is. So if I put in a cold there, I'm going to get
returned one hundred, six hundred for the time
that it takes the ticks. And then if there's
whatever the cause liver, I'm going to get 400
and so on and so forth. So this just sets the fuel time, and then it sets
the max fuel time once the fuel time
as self as well. Because this, we
need both of them to basically be sure to display
the progress properly. We need the max, you will
the current field time. The field time is what changes. The max field time
just basically stays the same once this is set, once the fuel has been consumed, where basically
then asking, Hey, is it consuming fuel? And if that is the
case, we can progress. So the progress here is the progress of the
item being crafted. This is also going to be
displayed in the progress arrow. And then here you can
see that the time being, what I have set it up is that I always have a max
progress of 72. Now, this is something that
you could, for example, also change inside of
the recipe and saying, hey, this takes longer, this takes shorter, whatever. Also possibility
for the time being, I've hard coded it. That's just something
that I've decided to do, nothing to worry about. And then we basically say, Hey, if the progress is bigger
than the max progress, then we're going
to craft the item. And then crafting
the item once again, just for their sanity check, basically, both through says, Hey, that's a
recipe exists here. If it's present, we're going
to remove the slots 1 and 2. So we're going to remove the
rafting items are important. We're not going to remove the
zeroeth salt because that already happens when
we get the fuel. When we consume the
fuel, you can see, we can say remove stack from here and then getting the
item from that stack. Basically do the fuel stuff. That's very important. So that's why we
only remove from 12. And then we're saying, Hey,
we're setting the stack of three with a new item, stack of this item, which is exactly the item that is getting from the output. So this is what is read in, in the output of the JSON
file of our recipe or customer recipe and account is I'm just going to
be increased by one. So if there's nothing in there, it's going to be set to one. If there's already
something in there, we're just going to
increase it by one. So that's the general idea here. There's also some other
ways that you can do this. So for example, we could
make it so that you can specify a count of
how many there are. And then instead of
increasing it by one, you increase it by that
count, so on and so forth. There's a lot of stuff
that you can do, but Overall, this is the way that we're doing it
for the time being. All of this pretty
much as we go along, is very much more
and war variable, or you would say customizable. So you can do more
and more stuff here. And then we're calling the
entity reset progress method, which just sets
the progress back to 0 so that we know that everything is basically reset their right and sadly
we're not done yet. But hopefully this was
a good walkthrough of this and explains
all of this very well, identically hope so, if there are any
questions remaining, please use the Q and a, and I'll try to answer
the questions best I can. I also highly recommend just being open to
experimentation, playing around with
this a little bit, just trying out a
bunch of stuff. That's always the best
thing that you can do. Because what we need
to do is we need to go into the screen and the
screen handler classes. We actually need to
add a new parameter here that's going to be
the ROM Party delegates, so Property delegate,
old delegate. And it's just format
this a little bit differently than inside
of the other one here we're just going to say in new every property
delegate of size four. And then we want to add
this as a field as well. So when I say private, final property delegate
or property delegate. And then we're just setting
this after the inventory here are pretty
delegate, delegate. And then in the entity, we're going to get
an arrow right here, because now we have to pass in this dot Property
delegate as well. And the error here disappears, the entity should be done. Now, I believe I'm fairly
certain then here at the end, or we want to add
is we want to add the add properties and then just added the
delegate right here. That's literally all
that we're doing. And there we also need four different methods
that we want to be over. And I'm going to explain
those of course as well. We have the crafting method. This just says, Hey, do we have any progress at the moment? If we do with them,
we are crafting. You have any fuel. This just means that if
the fuel is more than 0, we know that we're having some
fuel that is being burned. And we both need
the scale progress as well as the scaled
fuel progress. Now, you will see that those methods are pretty
frequent insane, right? Well, the idea is that just, those are just the normal
things that you have to calculate in order
to get the error. For example, to shrink or the progress arrow
to increase, right? So this is progress arrow here is of course not
quite right, right. This is the fuel progress size, let's say somebody
like that, because the size of the few progress. So once again, if I
open up the GUI here, this is 14 by 14 and we're going to
basically go down, right? So we want this to be 14
if the fuel is complete, and then we just wanted to
go down there with this one. This is 26 across. So this is why this
arrow sizes 26. So this is always the width of the pixels of your
arrow or the height, depending on if you want
to go from top to bottom, bottom to top, or from right
to left to left to right. That's the general idea. Something is confusing
here. No worries. Try out a lot of stuff
by out some values, see what reacts, what happens. Always recommend, right? But overall, this should still
be some basic math here. This shouldn't be too crazy now, but we are using this. Well, we're using this in
the green box right here. And I'm going to copy over the last two things that we're
basically going to need. And that is the broad
textures right here. So this is going to be the arrow and this is going to
be the fuel texture. Now you already see there's some pretty crazy stuff in here. Yes, that's the thing. Because what happens is that
the offset here, right? The 8422 is going
to be this offset. So I'm going to show you this. So this is the error rate and the arrow starts right here, and that's 84 pixels
to this side, and then 22 pixels from
the top to the bottom. And that's where I want to
draw this arrow, right? This is where I
want to draw this. And then what do I want to
draw? Well, that's this one. So the 176 and the 14
coincide exactly here. Then the question
is, well, what is the size of what I want to draw? The height is always
going to be 36 rates, so that's always
going to be there. But then the scale progress
is going to increasing. So the width of what I want to display basically is shown
as the progress increases. And that's how the
arrow is drawn. Now for the fuel,
as you can see, this is way more complicated because what I actually want
to go from top to bottom, and because the values here
start with 0000 right here, we have to do some
math craziness right here where we increase
and decrease that stuff. I wouldn't worry
about this too much. This is pretty much always
going to be the same idea when you're using something that you want to increase
from up to bottom. Overall, playing around with this is going to show
you how it works. I hope that the
general introduction here makes sense, right? So where you basically know
where those values come from, what they're pointing to, and why we basically call
what we're calling here. Well, that, that sort
of makes sense here. But otherwise, we are
actually done with a code. It was, once again a
pretty convoluted thing. Lot of stuff in here. So let's now add a
custom recipe as well. Worse because we
have to have recipe. Otherwise we can't. Anything through this
is going to be in our data folder and
the recipes folder. And this is going to
be the recalc and pick X from recalc and blaster. So this is in the
MC course recipe they go and this is
how it looks like. Type is MC cores or
a cow can blaster. And it's going to make a warning because that doesn't exist. No. Believe me, it does exist. We just made it. And then you can see the top one is going to be a golden pickaxe. The bottom one is going to
be an a or a calcium ingot, and then the output
is going to be an Oracle can pick x and you can just literally add multiple
JSON files looking like this. And they will all just work. That's the beauty of it. This is why the while. It does seem like a lot
of work in the beginning. As soon as you can add
those JSON files in there, you have a much
easier time with it. So just to make sure, let's see if it works. Or what we find is
that in Minecraft. And the first thing
I want to say, if you already have
a block entity that you sit down deleted, like destroy it because this might have some
adverse effects in there as the NVT data that has been saved for it
might be very different. We have to actually
set this down again and we can still
open it totally fine. That is very good. But let's just get some
golden pig axis here as well. So you can basically see whether or not
this is going to work. So let's put the
coals liver in here. Let's put the oracle coming into the bottom and
then right here, and let's see if
something happens. And there it is. Look
at the progress starts, This goes down and bam, in Oracle can pick x,
the two items are gone. Let's see if we
could both in there. So this doesn't have like
nothing happens and pull out the sliver and you can now see it's still
working of course, because there's
still fuel in there. And bam, we have one, the Orca come in,
get here, remains. And then there's
one big X there. If we don't have fuel, nothing happens because
we don't have fuel. And as soon as I put fuel
in, its gonna get consumed. And we're going to
continue with this. Though. There it is. Everything is still working pretty much even
better than before. We now have progress. We see how much, how much fuel there's left. And all of this is
absolutely great. So I mean, it
couldn't be better. Everything's still working
and this is great, right? So once again, this
was definitely more complex lecture
one more time. But this is pretty
much going to be the rest of the course pretty much because now we're going to move on
to other things. And then the world generation
is going to come in, which is also going to
be very complicated. So it just is what
it's going to be. But for the time being, this is pretty much it for
this lecture right here. I hope you found this useful
and urines of the new, and I'll see you in
the next lecture. So, yeah.
88. (Advanced) Custom Wood: All right, welcome back to
the fabric course for 118. In this lecture,
we're going to be adding custom wooded
to Minecraft. So we're going to make a
little bit of an easier topic, basically covering
this in this lecture, this so that we can basically recover from the
last two lectures. And then afterwards
we're going to immediately continue
with craziness. For the time being. Logo would stripped, would
strip blog and planks. All of those are going
to be added right here. Let's just take the pink
rose and let's make this the cherry underscore
blossom underscore log. And then of course,
very important that we change this in the name as well. So cherry blossom
underscore log, then this is a pillar block. For pillar block right here. There's only one parameter. And then that is pretty much
all that we need to do. So this will copy the oak log and then
we're just going to copy this five times for that
we have on the like this. So groupings of two times
two and then one lone. And then we'll just
gonna go through. So this is going to
be the cherry blossom would cherry blossom wood. And the only thing that changes
here is going to be that this actually takes
it from the oak wood. Now this is not
strictly necessary. However, I like to do this. So why not? This is going to be the
stripped underscore cherry log. And same for the name. It starts with stripped. And then this is going to
be the stripped oak log. This one is the
stripped underscore. Cherry blossom underscore would. Once again same here. Underscore Cherry Blossom would. And then it is going to take
the same here stripped. Ok, would they ago? And then this is going
to be the underscore. Planks are important,
that is plural. Or planks are usually in Laurel. And then this is
going to be a crazy block, the normal block. And this is going to
take the planks here. So this is going to be the
underscore planks ego. And that is all of the
blocks registered. Well, that was fairly
straightforward, wasn't it? Yes. So what we're
going to need here now is what we need to
make them skippable. How do we do this? Well, that is actually
really freaking easy in the modern registries class. We're just going to add a
new private static void for the register strip
bubbles method. And this is going to call the
scriptable block registry. That register with
the mole block start a ribosome log and then blocks dot stripped
cherry blossom log. So that's very important.
We're just going to duplicate this with Control D. When change this too would, then changing this
would as well. There you go. And don't forget
to call this right here. So that's very important. Register strip
bubbles right there. And then the strip mobility, so to speak, is already done. N is already cold. And now let's move on
to the favorite part of everyone get's files,
the adjacent file. Or actually, I would
say that they are definitely a bit more complicated
than you might expect. So we're going to have
just five blocks is Js files and we're just going to take a look at them in general. So you see a pillar block
basically looks like this. It has axis, x axis, y axis d block state
properties here and the values that it can take and then just points to the same, or would it points to
the same model, however, just rotated in the log however, you can see that this points to the horizontal one
and this one as well. And this one points
the normal blog. So this is pretty much the
only difference between those planks are
absolutely boring, just normal Bloc states. Based on file. Nothing crazy going on there. Let's add the translation as well because
that's going to be, and then I, well, I mean,
I sometimes do forget it. So let's add it as well. Let's just put it right here. So that's something like this. The log, the wood a log the would often stripped
versions and the planks. And of course, all of the
code, the JSON files, all of that is all
available to you in the GitHub repository or an
individual just as well. Because especially
when we now get to the block model
JSON files, well, that's where we start
to basically say, well, you know,
probably copying over. I can now understand why
this might be sensible. Because at some point,
it just is a lot. So this is going to
be seven files again. Oh, let's just add those so
we're going to have the, let's just close
a bunch of stuff here that you go to log. This has a lock top,
right, of course, because the top and the bottom, the ends look different
from the sides. This is the cube column as well. And then the same goes
for the horizontal, pretty much the same thing. The planks are normal planks. I mean, I don't know
what to tell you. The planks are very
boring actually. The end for the wood is the same because the the wood
basically it's just the bark. So what's all around? That's the idea there. And then we have the stripped
top and the strip log. Once again, very much the same. It's, it, it all stays the same, very much like the rest
is not that interesting. All things considered, It's pretty much all there
is to it, right? And then the item
models are pretty much also just barely standard. Well, those are just
going to be 5 luckily. And also still all
available to you. So they just point to
one particular parent, basically one
particular block model. And then we of course also
want all over the extras here. Let's get all of
those over as well. They ago, those are also
just five funnily enough. And that should pretty
much be it for that. And what one other thing that we want to do is we
basically want to already add some stuff or
future-proofing, so to speak. So in the data folder, in the Minecraft folder, we're going to add some tags. So number one,
we're going to add the log logs and the
logs that burn tags. So we can see the following. So you can see that here we're using hashtag MC course,
cherry blossom blocks. That's fascinating.
What is this? Well, we're actually
going to have a custom cherry blossom
logs tag as well. So we're going to copy
this one over as well, is just normal tags
as you can see. So this just points to all
of the logs and then we can reference all of those
as a tag like this here, which is very interesting. And then in the logs that burn, we basically do the same thing. So we just do this. The logs that burn. If we have those in there, then we can basically use
the logs as you will items. So that just adds them
immediately to fuel items. Then another thing that
we're gonna do in the tags, Minecraft tags, Right-click
new directory for items. And then inside of
there, we're going to add the plank stack, but we're going to
just add this go. And we're going
to have the MCQs, cherry blossom planks in there
because that will enable us to craft certain
things with our planks. So for example, a crafting table or I think that that's
like probably almost it. I think that there's only a limited number of things that we can craft with Planck's piston, for example, would also work. So something like this. And then what's
also very important is that because we've already added those logs
to our logs tag. Once we introduce leafs, they won't display
next to our logs. So that's very important, but
that is all that we need to do to basically to
add our custom would. So let's see if it works. All right, We find ourselves
back in Minecraft. As you can see, everything has been added and I can set it down and it absolutely
looks just amazing. 0 once again, just
all looking great. And we can also strip it
right-click with an ax. You can see, I can strip all of that jazz and everything
is working fine. So I mean, that's pretty
much all there is to it, to add custom would
Minecraft, right? Once again, of course,
all of the code at the JSON file are available to you in the GitHub repository or an individual just as well. But this is going to be it
for this lecture right here. I hope you found this useful
and you learn something new. And I'll see you in
the next lecture. So, yeah.
89. (Advanced) Custom Signs: All right, welcome back
the fabric course for 118. In this lecture,
we're going to be adding a custom
sign to Minecraft. For adding a custom sign, actually made fairly easy because we are
going to be using, this is the fabric
sign example from new poll is a very useful
ball basically repository. Now I do want to make sure that you are aware of that
this is under the GPL, basically general
public license. So if you want to use the exact same code
in your own model, make sure that you
follow the license, just making sure that
this is understood. This will of course, also
be linked in the resources. And let's just continue here. So let's just
actually take a look. We're going to need two things. First of all, and that's
going to be two mixin. Interesting, isn't it? Well, I'm actually going to copy over both of those files. Those are of course, also
all available to you. Now they are actually
very, very easy. They're not that crazy. So you can see we have the
block entity type mixin, where basically it supports
our own sign as well. So it's very, it's
actually not that crazy, is basically making sure
that as long as a wall sign, assign block, or a nd, an entity sign right here,
it's going to be fine. And the sine type accessor
basically just makes it so basically that we can access
the actual sign type. Because the sign type
class right here, you can see it's protected. We can actually create
a new sign type. And with this, we
basically can't. What are we gonna do with this? Well, first of all,
we're actually going to add this to the fabric, to the actual MC course
mixins Jason, because, oh boy, if we forget that, that would be not so good. We're going to add
those right here. This is just the name 1
second of those files, very important that they match. And then we can
basically proceed. And proceed. Are we going to in the indie
block package actually, so we're going to eat the
signs in the block package. So we're going to make
a new model sign types. So they're just going to make a public static final sign type, old Sherry underscore blossom. This is going to be equal to the sine type accessor that register new
sign type accessor, a new sign type hold,
Sherry underscore, blossom. And that's all that we
need to do to create a new mod sign type
or a new sign type. And then we can proceed in
the actual more blocks class. Or we're just going to copy
over the planks right here. And then what's very important
is that both of those are actually going to be registered
without a block item. Because the interesting
thing about the signs is that we have a wall
sign and a normal sign. And those are going to be we'll have the same items
associated with it. So we're going to
have a mind block, and then we're going to
have a normal sign block. Then the same thing
goes in here. All underscore
sign, normal line. And then this is a
wall sign block, which as a second parameter, actually takes in the mod
sign types dot every blossom. And then it doesn't
take an a item group here because of
course we don't have, we don't have a block
item than this one. Same mod. Sign types are awesome and then change
this to a sidewalk. There you go. Now those are the two blocks basically registered
rectally. That's great. And then in the
more items class, we're going to have
to create a new item. So we're just going to get
to get honey bucket here. Cherry underscore
blossom underscore sign. And then same here. Very underscore blossom
underscore sign. And this is going to be
a sign item I and item. And then the first one
is going to be this. The max count is
actually going to be 16. And then we're going to
have more blocks dot sign. And the more blocks dot wall sign as the
second parameter, the ego or the third, I guess. So this is the item done in amine were almost
completely done at this point. It's actually pretty
crazy how fast this goes, but with the mixins, it's going to make our
lives just insanely easier. Like that's one of
the great things that the mixin basically
provides for us. But the thing that we
now need to add is still some block States basins. We'd still need a Hi in
block C, Jason right here. So that's going to be
the cherry blossom sign, which simply points to
the cherry blossom sign. And then we also need the
cherry blossom wall sign. We need both of those post, however, pointing to
the same block model. And then in the items we're
just going to have a, an item here which is the cherry blossom
owners could sign. And then same here as well, is going to be the
cherry blossoms. And then in the models we
actually only like I said, have one model here. And that's the normal sign model because this only
defines the particle. As you can see, that's all that it basically requires here. In the item, of course we
also only have one item. Well, we only have one item. So there's simply points
to the normal texture. That's going to be the
item textures here. I'm just going to
copy this over. Very awesome sign right there. And then how is it
displayed in 3D? Well, this is basically
an interesting thing, but we basically need to go into our Minecraft
Textures folder again. And then in the entity folder, we need to add the signs folder. And then the name of this
right here has to match the name that we're given
in the sine types class. So that's very important. This basically has
to match this one. And then this is how it's
being displayed in 3 D, right? And after having added all of that, Let's see if it works. All right, we finds us in
Minecraft and look at this. Well, it actually is
going to be a block. Well, I mean, not the
worst thing ever, but let's just see
if the sign actually works and they go, it works. That's great. Well, I'm in
a suit like this again, and then let's set it down
on the ground as well. It also works and everything
is working great. So I'm, the only
thing that we really need to fix is the
translation here. But that isn't of
course, an easy fix, just changing this to block. And then we're going to also
move it down so that we have it a little bit
more organized here. But that pretty much
sums it up, right? And after having fixed the translation here,
we're basically done. And this is how you can add
a custom sign to Minecraft. Overall, with the help
of the repository. Like I said, it's going to
be linked in the resources. It's actually fairly
straightforward, right? But that would already be it
for this lecture right here. I hope you found this useful
and learned something new. I'll see you in
the next lecture. So, yeah.
90. (Advanced) Updating Minecraft & Fabric: Or I welcome back to the
fabric course for 118. And in this lecture we're
going to be updating both Minecraft and fabric
to the new version, 1181. Right. So updating a version
usually can be, well, I'm wouldn't say
risky necessarily, but there might be a
lot of changes between versions and some
things might change. Now, luckily for us, the changes here are actually
basically not present. So there are no changes in
everything should still work in one 1800s with
the new fabric version. What we're gonna do is
we're going to open our Gradle properties file. And these are this right here, the dependencies and
the fabric properties, other things that
we're going to change. And this is exactly the
site that we want to open. I already have this open
right here and you can see making sure that we are on the correct version here, 1181. And then this is what
we want to copy over before we continue a
message from the future. As 1 1000th 2 has been
pretty much just released, I highly recommend
what you do is you keep it on 100 1800s. If you've been following
the lectures with 118, I highly recommend
you stay on one 1800s instead of updating immediately to one hundred eight
hundred and two, because one 1800s to all of
the upcoming world generation is not going to work with 172
at the end of the course, there's gonna be a section
in which we can watch if you want to go through with one 1800s to just
keep that in mind. So highly recommend,
keep at 181. And then you can update at
the very end of the course, right-click Copy then, then we basically just
want to paste it in here and you can see that not actually quite
a lot has changed. So the fabric version, we actually are on the
newest fabric version. That's great. So we
can delete this. We can see that the loader
version here is actually new, so we're going to just
replace this with it. And then both the version for the Minecraft and then the
yarn are also both changed. We're also going to
replace both of these. And then basically
just save this and then reload it
with the load Gradle changes here because
now going to rebuild the project with about 1.18.1 and the new yarn version, same with the loader. He could have probably changed the mod version here as well, but we're gonna be fine. I think that this is okay. And there you go,
build successful. Now everything here is
going to be mapped. And then what we
can do is we can, I highly recommend doing the
debug for the first time. So running this, when I actually ran it for the
first time I bought, the game, didn't
start, but as soon as I ran it for the second
time it did start. So there's probably something
in the background that has to download the first time. So if you are getting an
error for some running it, just run it again and see
if it works again because that was a very strange thing, but we're just going to see whether or not
it's going to work. But of course it's
the expected error that because we're
not logged in, Minecraft has already started
on a different screen. So there you go. One hundred eight hundred one beautiful, absolutely great. And there you go. We're in
game, basically it works. Let's just go into
the world just to make sure that everything
works between versions. Usually if it's
the same version, so if it's just the last
digital changes sort of speak, the changes will probably
not affect too much. Sometimes there are
things that are deprecated from one fabric
version to the next. That might be the case. I will try to basically keep everything as
up-to-date as I can. So basically, I'm going to add a lecture somewhere
where it's like, hey, this has changed. You got to do it like this now. But overall, you can see I
can still right-click here. They're still, I'm still
getting the speed here. So overall, usually everything here still works great, right? And that's actually how
easy it is to update. So let's just for
completion sake here, Let's do something like Let's do at this point we're at like version like 0.1.5 or
something like that. I think I feel like. And
then we're going to put this to 118 of the archive base name. We're not going to change
because that of course, is still fabric course 118
and that's gonna be fine. But now we're on micro
version 1800s and the newest yarn version
of lower version as well. And that's actually how easiest to update fabric that has already for this
lecture right here. I hope you found this useful and you learned
something new. I'll see you in
the next lecture.
91. (World Gen) Custom Trees: Or I will come back to the
fabric course for 118. And in this lecture,
we're going to be adding a tree to
Minecraft, right? So adding a tree involves also adding the
leaves and a sapling. And this will also
involve adding the bear's bones of
role generation because the actual spawning of
the tree is somehow sort of like a little bit intermingled with the
world generation. But for the time
being, first of all, we're going to go to the mailbox
class and we're going to create the leaves
and the saplings. We're going to copy over
the planks right here of the cherry blossom
planks and we're going to say leafs here, then leaves right here. And maybe elifs block. And this is going to
copy the oak leaves. Then the same thing
here, cherry blossom sampling and then
sapling here as well. And this is a new
tumbling block. And then we're going
to have the same thing we have previously had. The axis here is protected. Therefore, we're
going to need to make a mod that building block class. We're just going to extend
the sapling block class over, over this create
constructor matching super. And we're just going
to make this public. And instead of the
sibling block where you use the mod sublingual, now there are actually two parameters that
we're going to need. You can see we need
a sibling generator. So this is something
that we're going to create inside of a new package. So MC course,
right-click new package. Old world is going to be
creating the world package. And then a new
package cool feature. And inside of there we're
going to make a new package called tree and
industry package. We're going to create a
new Java class called the Cherry Blossom
tackling generator. We're going to need to make basically new ones for each different tree
that we want to add. This is equal to the
sapling, sapling generator. And this basically
just implements one method and that is the
get three feature method. For the time being, we're
going to keep this null. We will add the configured
feature here in just a moment. Then here we're just gonna say a new very blossom
doubling generator. And that's basically all
that we need to do here. But both of those are done. Let's actually immediately add them to the proper
render layer here, because then we don't have
to think about that anymore. So the leaves and the
sampling as well. And then also here making sure that this copies the
sapling by the way, that's also important day ago. And then we're immediately
going to add all of the JSON files because
then they are done. And then we can
basically continue on with the code after that. They are both all basically
just normal JSON files. You can see just the leaves
here and the sapling here, or the block States Jason Lange. Translation, I mean,
at this point, would be fairly
self-explanatory. Here they go the leaves and sapling than with
the block model files. The only interesting thing
here is that the sampling has a cross parent and a
cross texture here, but the leaves are a
normal block all around. This is the only
interesting thing here. And then there's another
interesting thing in the item texture or the sapling. And that is that the
sapling actually has a normal texture
as you can see. So it actually points to
a block texture here, because sapling that is
displayed in the world, in the cross pattern is the
same as it is in, as an item. Basically, that's what
that is the case. Then we can just add the sapling and the leafs textures as well. There you go. And then everything here
has been added pretty much so that we don't need
to worry about that anymore. And now we basically
only need to add the and figured feature right here that
spawns with the tree, for example, when
we bone meal it. So this is the first part
and then the next lecture, we're going to see how to spawn the tree it as world generation. As part of the world
generation, though, we're going to create in
the features package, right-click new Java class. And this is the mode
configured features class. And for this we're actually
going to need a few things. Number 1, go, we're
going to need, I'm going to copy
over those methods. All of the code is of
course available to you in the GitHub repository
or an individual just, you can see that I've registered configured features
method right here. This is something
we're going to call at the very top of the
initialized method, actually Fairly
drained, but this is actually where we
need to call it a weak need to call
it at the very top. Otherwise the order of
initialization doesn't quite work. And then we also have
this register method, which you can see it's
religious registered, a Configure feature under
the name that is given here. And that's pretty much
all there is to it. And we're going to need this because I'm actually
going to copy over the cherry blossom
configured feature. And I will explain as
we basically go along, what you will see is that we're basically registering
it with the name cherry blossom and it is a
feature tree configure. So this is the idea. If we middle mouse button
click on the tree, you can see this is a tree
feature or just a feature. And then as soon as
you call configured, it turns into a
configured feature. And we're passing in a, b. Feature conflict builder,
which then needs some things so we can middle mouse click on this
as well and you can see, oh, this is a trunk
provider, a trunk placer, foliage provider, a fully to place her and then
a minimum size. So the general idea here is that we have a
block say provider. This, the first one is, provides what the
log is going to be. So this is going to be
whatever the trunk is. Then we have a different we can make different trunk places. So I can middle mouse
button click on this and press Control H over the placer. And you can see there's different
types of trunk placers. And yes, you can also
make your own, right? They are, a lot of Java
knowledge is probably required because making them
it's actually quite hard. Then the third parameter is the leaves that
you want to have. And then the blob all, each place, or in this case, is the way that the
leaves are displayed. Once again, you can
go in here and take a look at the foliage
placers Control H. And you can see
basically that there are a bunch of options
there as well. So once again, I just highly recommend playing around
with this a little bit. And then the two layers feature, we can go back again. This was the minimum size, so I'm still not a 100 percent
sure what exactly this is. What I believe the general
idea is that this is how much space has to
be around the tree. If I'm not mistaken, this
is something, but the, overall the world generation, there are so many moving
parts that it is crazy. And then also it changed
from 1 16th, 170 to 180. Now, it all changes
fairly regularly. Usually, though. Sometimes it is hard to keep up. But this is, I
believe, what this is. And we need to return this in the sapling
generator right here. So we need to say mod configured features that
cherry blossom tree. Then we will return this.
Everything should be fine. So then, now in theory, as soon as we put the sapling
down and we bone meal ID, or the time passes, it's going to grow into a tree. So this is basically
the first part of this. So let's just see if it works or if I'm says back in
Minecraft as you can see, the sapling and the leaves
have been added in. Do they not look great for now, let's set down the sapling and less bone millet and
let's see if we can get a tree and there it is a
tree mighty big and strong. So that's really cool. And let's also just try and just set some of them down here. And let's see if they
can actually grow. When I turn on the IM rule, random tics speed and dislike increase it by
craziness. Let's see. There they go. Leave this one on actually spawn
because it's too close. It we actually have to let us away a little bit and then it's going to spawn
probably as well. They you go there, it is totally fine. So everything working
totally great, just like you would
expect, right? And once again, to recap for every new tree
that you want to have, you will have to need a
new configured feature of bitter conflict, as well as a custom
sapling generator and then a custom sapling. And that's basically the
three things that you're going to need in
order to basically facilitate a tree growing from a sapling either when he
bone meal at or over time. Why? But that would be it for
this lecture right here. I hope you found this useful
and he learns that the new, if you did, I would very much appreciate a review from you. Otherwise, I will see you in the next lecture, though. Yeah.
92. (World Gen) Tree Generation: All right, welcome back to
the fabric course for 118. And in this lecture
we're going to be taking a look at how you can add a stem trees, the
world generation. But we've made the
custom tray last time and now we're going to add it to the world generation. And specifically, we'll
also see how you can very easily filter in
what biome this goes to. So what we're gonna
do is we're going to need a few more
classes for this. The first one is in
the features class, Right-click new Java
class called the model placed features is
very important. This is probably going to
be the main class today. And this is going to be very interesting because this has a two different methods
that we're going to need. Once again, I will
copy them over. The court is available
to you, of course, in the GitHub repository or
an individual just this, the method register
place feature and the registry key method. Well, both of those are
very important here. And the one of them basically, this gets the registry key for
a specific place features. So this is sort of what
we're going to need to refer to when we
actually want to spawn it. And this, this
actually registers the place feature and the actual registry
key I will also copy over, actually
fairly straightforward. You can see it's just
a registry key of a registry key of place feature what the
cherry blossom placed key. And this is equal to
the registry key. And then the name here, basically the same name as the placed feature
will get as well. So that's very important. But before we can make the
placed feature for the tree, we actually have to get another configured
feature in here, right? So now there's something
very interesting. So to basically see the vanilla code for
the features and stuff, we can go to the features class. And now what you might
have is the blue line here and basically nothing
else in here. To fix this, we can go to the terminal and
we can put in dot, dot slash Gradle,
w, Jan sources. And then just run this through and then let this run through. And then after it has
been done, hopefully, the sources will basically
generate for us the way. There's another trick that
we can use basically to actually see the real sources,
basically for Minecraft. Right there we go. 58 seconds. Build successful,
That's very good. If you get a build
failed and it says, Hey, I like this one. Look at this. You're not using the
correct version. What you can do is you
can add the Java home to the radial properties where you have to change your Java
home environment variable, either of those would work. But for the time
being, this is fine. So now we can do is we
can middle mouse button, click on Feature and you will see this still
doesn't work well, I can go to choose sources. And then I'll say, I'm going
to use the map sources. I say yes and see all of a
sudden everything is in here. And now we can actually see what the actual source
code looks like. And for this one, for example, that doesn't really
interest us too much. But if I middle mouse
back, click on it again, you can see everywhere
where this has been used. And you can see
that it is used in the tree configured
features classes like, oh, that's very
interesting, isn't it? It's like, Yeah, it's very interesting to, let's
see, for example, the AUC configure feature is a configured featured
on register with the tree configure feature with basically the features of
OK. You can see that here. Basically it's just a
already done builder. You can see tree
conflict builder. And then literally all that
we've done as well, right? We've made a lock
stateProvider of the log. We made a trunk placer
and all of that jazz. So all of this is
done here as well. But now this actual
tree feature, config configured
feature is used again. So if I middle mouse button,
click on this again, you can see this is used in the tree place features, right? And if I go in here and
see that this is now a placed feature
object and this one, as the width would
survive filter on it. But now it gets even crazier and please bear with
me for the time being. You can see that this place
feature is then used in the vegetation
configured features with some other random stuff. So this is like insane, right? So that you can see this
is the line, so line 66. And see this is the
dark forest vegetation, which once again is a configured feature of
random feature Conflict. This one is used in
a place feature. Again, though we're
basically going from configured feature
to place feature to configure feature
to place feature. That seems crazy like
way to go about this. What I do highly recommend is going through all of the
feature classes here. Basically, there is a crap
ton of stuff in here. It's actually insane. There's so many things in here. I just highly recommend
going through the, basically the tree
place features all over the place features are
insanely interesting. And basically to see, well, how does vanilla do it? How does vanilla spawn stuff? And we're gonna do
a similar thing. Let's say, Well,
the similar thing we're gonna do is
we're going to go into our mode configured features
class again. So right here. And we're immediately
basically going to take this configured feature and making another configure
feature out of it. Now I'm going to copy
this over as well. This is the one with the random feature
config in this case. And you can see this basically takes the feature
random selector, mix a new random configured
random feature conflict, then either takes the
cherry blossom tree with would survive
filter of the cherry, sapling or the same thing. So basically, this is a little
bit of a convoluted way. There probably is a better way to do this, but for
the time being, this is the best way
that I've found it basically that it could work
and that it should work. And this actually totally
fine and we'll work now. The reason why we need the
configured feature right here is because we
want this filter. Now the issue is
that this filter, if I middle mouse
button click on this, you can see that this
returns a place feature. And the issue is once I
have a place feature, I can't do any other
placements on it. So I can only ever do one
particular placement here. And that's it. Now, there's probably,
like I said, another way to do this That's going to be hashed
out and little bit amine 1.18 is very new and the world generation
is completely redone. So maybe there's going to be an update to this at some point. But for the time being, this absolutely works by the
way, there's no worry. So we're going to use this now and make a place
feature out of it. So in the marketplace features, last but not least, I'm going
to copy this over as well. This is the cherry
blossom placed. And you can see that I'm taking the Cherry Blossom Tree Random, which is exactly
this one right here. And I'm going to use this with the placement of vegetal
placed features modifiers, which I have, which I
can basically go into. So you can see this is basically a particular list of
already built modifiers. And then I'm going to say, Hey, take the count extra modifiers. What is this? Well,
what this should do is it should spawn one
tree per trunk. It has a 10 percent chance
to respond to extra. Believe that that's sort
of the general idea you're in might even
spawn a little bit more. But overall this is
the general idea. So if you want, for example, a tree that is super rare, but you can do is you
can just say no count 0. And then like a, like a 0.1% chance that one extra
one sponsor for example, or but for our purposes here, we of course
want to see it. We want to see the
actual tree on. So let's do it like this. This basically determines the, how this, how the
tree actually spawns. What is very important
is that this key here and this key
years of those books, book, those two names
have to be the same. That's very important. And then what we're
gonna do is we're going to need two new classes. I actually, that is
in the world-class. First of all, in
the work package, right-click new
package called Jen. And then inside of there we're going to have two new classes, the mod three generation class and then also the
mod world gen class. So in the model tree
generator class, we're going to add a
public static void cool, generate a tree. Res actually does. Maybe we want to
create multiple ones. And here, willing WHO called
the mole iam modifications that add feature selectors. And then here we can basically
select different biomes. We can say, Hey, just
take all biomes, top, take all of the
ones in the overwork. We can even go by tag here. So you can see that
there's a lot of different ways that
we could use this. We're gonna, we're gonna do the categories and we're
going to say category dot planes so that we basically only what the
spawn in planes by ohms. And then the
generation step here, we're going to say
generation step, and this is the
vegetal decoration. I will show this in a moment. Then the marketplace
features that key. So we want the key
here to be passed in. And then this will generate
our last feature in the all biomes that have the category planes in the
generation step vegetal. So actually let's go into this. You can see that there are
different generation steps. And it's very important to
eat this order basically. So once we, for example, an underground ores,
you can see those come before the
vegetal decoration. Therefore, we will have to
add the oars before it. So this is very important and
you will also always have to be basically do the
correct thing here. But usually it is
very clear what the actual generation step
is in the modern world gen, now, there's going to be
a simple method as well. That's going to be the
public static void. We're just going to call this
degenerate mode world gen, stuff that radius
or coolest name, but it will suffice definitely. And then this is going to call
the model tree generation that generated trees. And then this one right
here will just be called at the very bottom of the
initialized method. Though, modern world gen, generate modern world again, and that is it. So let's recap one more time. Let's close everything
that we have and let's reopen the ones
that we've changed. So we had a new
configured feature that we have to add to basically make sure that the cherry
blossom tree only spawns where a sapling is valid. This is why this is so
important right here. That is done, then we can
make a feature out of it, which is basically going
to filter a little bit even more with some placement. The specific placement
that we've chosen was the count extra,
highly recommend. For example, going
in here you can see placement modifiers for middle mouse
button click on this, and I believe I can
click on this again. Then you can see, for example, where all of those
features have been used. So there are, for example, some already
prepared once you're in the place features
class, which you can use. So there's a lot
of stuff in there. I believe that those are also used with Control H Surely there you can see there's some square placement features,
random offset. There's a lot of stuff in here. I just once again can highly recommend playing
around with it. Be open to
experimentation for it. Especially when it
comes to world gen. It is very complicated. And therefore, if you have something in mind that you
want exactly how you want it, who, you're going to have to try out a bunch of
stuff with that. But this place feature
then basically has the same key here as the key. So this key has the same name as the place
feature and this has to match. And then we can call it in the model tree generation
with this bio modifications, this is a something that
fabric gifts to us now this is an experimental feature may be removed or changed
without further notice. That's very important
for the time being. It still works. We can still
use it if it ever changes. I will of course, make and updated lecture
somewhere so that you know how you can basically
do it without this class. But for the time being, we're going to use
it because it is very easy to use and
it works perfectly. And then basically
that is just caught in the modern world generation
or more world gen, class. And that the standard is called
in the, on a literalism. So that's pretty much all
there is to it for now. Let's see if it works, right? Don't forget to create a
new world for this as well. Because of course we mess
with the rural generation where every time you do that, I highly recommend
making new world just to be sure that
everything spawns correctly. So let's see, or we find
ourselves in Minecraft. So let's just locate by
on planes right here. And let's see if the cherry
blossom trees spawn there. And let's see, there they are like it's not
a big biome here, but they are spawning. And this is just great. So as you can see, responding, that's sort of the
general a deer a year as to how much they are small if the
biomes a little bit bigger, you can of course see it
little bit like more clearly. But for the time being,
this is totally great. And like I always say, when it comes to the numbers, you will have to tweak the
numbers one way or the other. So that is one important
part of it anyway. So that's something you definitely have to
keep in mind, right? But everything works
and this is pretty much the first lecture for the World War generation
section done. I hope you found this useful
and learned something new. I'll see you in
the next lecture. Oh, yeah.
93. (World Gen) Flower Generation: All right, welcome back to
the fabric course for 118. In this lecture, we're going to be taking
a look at how you can basically add flour
generation to your MOD. Now, once again, a lot of
stuff will be copied over, but actually this time it's
not going to be that much. The core is, of course,
for you available in the GitHub repository or an
individual just as well. Now, the general idea
here is that when it comes to the generating
of the flowers, one of the thing that
people might ask is, well, how did you
figure this out? It actually is not that crazy. It's pretty much the same
thing that we've done before. Middle mouse button
click on the feature class and then you have the, for example, the
flower feature, right? And then I can middle mouse
button click on this and can see where it has been used. So for example, it has been
used in the flower default. Then what I do is I
literally copy over the flower default
here you can see I just select the entire line, press Control C, Control V, and then just take a look
at everything that I need. And then you can see that, hey, this takes a dandy lion
and I'm like, okay, so I can basically replace
this with my own flower, stuff like that and
so on and so forth. And this is pretty much
how you do it, right? You just continuously tribe and then just with
that you basically, well, you reverse engineer it and then you
know how it works. First of all, we're
going to copy over the configured feature here, and we will see that one
of the thing here is red, and that is exactly the Create Random patch feature
conflict is, I believe it is either in here or actually in the
vegetal decoration, I think that is used here. This is not the
one that we want. We want to take a look at. This one, I believe. Nope, not the case.
So you can see that there's a lot of different
ones here actually. And actually the one that
we want is the following. I'm actually going
to copy it over. This is this one right here. So is the random patch
feature conflict from a block sit provider and a number of tries here that this basically just calls
this method right here. So no worries there. And the general idea here
is that this now fulfills basically everything in this creates the random
patch feature conflict. We can actually take a
look at this as well. But this is not really going to be that interesting to us, is usually those like
feature conflict classes are well, kinda
complicated sometimes. I mean, all of this is
fairly complicated, as you will probably
have guessed and realize at this point. But overall this is the
configured feature. And now when we think back, okay, we have a
configured feature, but what we also need is we also need a placed feature
that is exactly right. So in our model placed
features class, now, I'm going to
copy this over. Now, this one is actually fairly straightforward
because you can see this the pink rose
placed and this one's going to be some
registers, a place feature. We're going to take the
configured feature from our mode configured
features class when, say with a particular placement. And in this case
we're going to add the rarity filter placement of four and a square placement, just a normal modifier
here with also the height map and then the
bio placement modifier. So this is pretty crazy, like where does this come from? Well, once again,
it plays features of some of the actual flowers. If we just take a look at this right vegetal configure feature. We're just going to take those and then we
can, for example, see the vegetation, vegetation
place features here. Our warm, that is line 73. And we can just see a rarity
here, square as well. It also takes the
motion block height map and the biome
placement modifier. So that's basically where
all of those come from. I just basically took
all of this from vanilla and it
works beautifully. So that's pretty much
the general idea. Now what we are
also going to need is a new registry key for it. So this is going to be the pink rose underscore police
underscore key. This will have the same
name as this once again, because those will
have to match. And then that is
pretty much all that we need to do now we of course
need to still spawn this. But for that we need
in the gen package in New Mode, lower generation bus. And I'm actually just going
to copy over the method here. It's nothing too crazy. Oh, look at this model
placed features, they go and then everything
year should be fine. So once again, those
are only going to spawn in the planes just so that we have it basically
in the same biome. And then this will just have
to be cooled right here. So this can either be
called above or below it. That does matter because both of them are
vegetal decoration. Everything here is
called an engineering, has been added properly. Let's see if it works. Once again, don't forget to
create a new world as we have once more mess with
the world generation. So let's see what we can see. And as luck would have it, we are already next to a
planes and there they are, the pink roses morning
in small patches here. And you can see
there's another patch. And then there's like quite
a big patch right here. So that's pretty cool. And you can see, of
course, once again, messing with the numbers
is the main thing that you will have to do
to get your generation. Just write if you wanted
a little bit differently. Of course, no worries at all. You can always try that out. But for the time being, this is actually great and
they all spawn, well, that's pretty
freaking cool, right? But that will already be it
for this lecture right here. I hope you've found this useful
and ignorance of the new. Once again, all
of the code is of course available to you in the GitHub repository or an
individual just as well. And I'll see you in
the next lecture. So, yeah.
94. (World Gen) Ore Generation: All right, welcome back to
the fabric course for 118. In this lecture,
we're going to be doing the thing you've
all been waiting for. Let's see how to add
or generation to Minecraft when it comes to
the generation usually, or generation is pretty much the one thing where
everyone's like, Oh my God, I need to know
how or generation works. This is the most
important thing ever. They want their
sport in the world. And that's exactly what
we're gonna do right now. But once again, hurry
figure this out. We'll middle mouse button
click on the feature. And what you will find is
that right here or this, or yes, indeed it
is a or feature. And if I just click on this, you can see there are
some configured features. So for example, there
are some diamonds, small diamond, large
diamond buried. But let's just
take a look at the diamond small
configured feature. You can see that this has a or feature Conflict Diamond ors. So what is this? Is it a list of all
future conflict, our target, we're
actually going to have to make this
ourselves as well. But no worries. This is no like this is
actually not that hard. Now I will once again
copy everything over, but everything
here is of course, also available to you in the GitHub repository or an
individual just as well. And for a, or, like I said, we need a list of these target here as well
as a configured feature. Now that pretty much
is all that we need. And you can see that
preening the target here, there are basically
two targets rate. So if I just basically
make this a little bit different so that it reads a
little bit different here. So there you go. Now you can clearly
see both targets and both basically blocks that
are associated with it. A target has a rule tests
that it follows, right? So the rule test you can see right here basically
just checks, Hey, does this match this
particular block here? So in this case we're
actually saying, Hey, everything that can basically
replaced with a stone, the stone ors, and
then there's also deep slate or replaceable. So that's the general idea here. Because of course, our
normal or can replace, or should be able to
replace normal stone and then deep sleep or should be
able to replace deep slate. Now this is not only storing, this can, for example, also spawn in direct
and stuff like that. And the same with deep sleep. There's like other stuff, other types of blocks
that are can also spawn in the deep state and
therefore this is needed. Now, the size here is going to be very
interesting because the size, if we actually go in here, you can see that it only
says size and the size there means that this should be
the average size of a vein. So this should be the
vein size actually. And then how it spawns
in the actual world, you will be able to configure with the
placed feature again, that we actually need a very interesting
thing and that is a new class and the
features packaged. So this is the mode or eaters and we'll just
copy over two methods. Now those methods come from
the or feature itself. So from the vanilla or features, I just basically took them and made them public here
so that we can have access to them so that
we can very easily API over the place feature here, which is the oracle
complains as you can see, because the oracle come or with a specific placement and then
the modifiers with count. So the count at the
various you're basically says how many veins
should spawn per trunk. This is at least my current
understanding of it, really, that the count modifier is how many veins spawn per trunk. And then we have a height range placement modifier of trapezoid. So you might have seen this picture of how
the ores now spawn. And there's different types
of features basically, or different types of
modifiers have they spawn? There is the trapezoid, there's uniform and you can even make custom height providers. We can see there's uniform
trapezoid constant, very biased, weighted,
biased towards them. So that is very interesting. So there's different
height providers that you can basically
put in there. If for example, you're like, no, I want this to spawn like very, very boring, very biased to bottom height
provider can be made. You can see you can create
those very easily actually. So there once again, experiment,
experiment, experiment, be open to experimentation, especially with this visually
playing around with this. This is one example of
how to do it, right? We're gonna basically
going to say, Hey, this can spawn anywhere from
negative 80 to plus 80. This is just basically for testing purposes,
for the time being. If I wanted to really
make this recall from our probably even use
the very biased like towards the bottom eight placement modifier
because I feel like that's that would be
the coolers and would probably decrease
the count as well. But we just want to show that
it basically works here. And then the key, once again is very easy, but it's just the recalc, underscore or unscrew place key. Then same thing here. This has to be the
same name as this one, of course once again, plays feature same with
the registry key. And then we just need a
new model origin here. So mod or generation also
quickly copy this over. It pretty much looks exactly
the same as the other ones. This is just demoed
placed features they ago. And then this pretty much is
found in all the over world. So this is another
one and this is in the underground ors
generation step. What's very important
is that this is called before the
vegetal decoration. So MAR or generation generate doors. That's
very important. Otherwise it will
not properly work. But that is once again
actually all that we need. So we just need one
configure feature that actually takes in
a list of targets, which is very important
because you of course want both the
store and the deep state or just small size being
the size of the veins, basically the vein size here. And then place feature. We can say how many veins
per transcripts born, and then in what type of
way they should spawn. But in this case trapezoid
and then a Y offset. So basically say, Hey, from what Y level to what
level should they spawn? That's the general idea. Once again, I highly recommend just playing around with it. You can middle
mouse button click and see what you can change. Different HIE
providers, all of that. I highly recommend. Just
play around with that. If you have different values or different functionality
where different way you want your
horse to spawn. But for the time being,
let's see if it works. And of course, as
so often because we've messed with the
world generation. Let's create a new world, or a pharmacist in Minecraft
in there actually is a very good command
that we can use, which basically
just fills all of the things below here with air. And we can basically then, I'll take a look at all of this. So let's see if something that we want
has spawned in here. And for this one, it doesn't actually
look like it. Well, then let's go
into not survival, but it actually into
the dictator mode. And let's just go through and see if we can find that the, OR right in here, we have it. So some of it spawned. You can see here some more. That's actually old men,
even bigger vein right here. As you can see, it
spawned perfectly fine. And there's probably even
more of it all around us. There it is there some,
some more of it even. So, that's actually
how pretty cool it is. And this is, of
course, deep sleep. Now it also spawns
and stone of course. So look at this
there, for example, we immediately found it. So that's pretty much
how easy this, right? I think I stress this
enough that you should just experiment with this a
little bit and try it out. So I will not repeat myself, but I will say that this is it for this lecture right here. I hope you found this useful
and year-old's of the new. And I'll see you in
the next lecture. So, yeah.
95. How to make a JAR File out of your Mod: All right, welcome back
the fabric course for 118. In this short lecture, we are going to be seen how you can make a JAR file
out of your model. And the way that you do this is you open the terminal and you put in dot slash Gradle w built. Now you're basically just
let this run through. This should not take very long. It'll be round about 10
seconds. There you go. Five seconds actually,
maybe a little bit longer if your
PC is a bit slower, but no worries at all. If you get an error here that maybe you're not using the
correct version of Java. You can specify the
Java home variable right here so that it
takes the correct JDK. Apart from that,
you will now find your JAR file inside
of your folders. So in the Build
folder, actually, we're just going to
right-click on this open-end Explorer right here. We're going to
build folder libs, and then this one right here. So the one with the shortest
name is your JAR file. And you can now add
this and try and we'll play with this added to
a server, stuff like that. That all just works basically like any other JAR file
you might download, for example, from workers forage or something
like that, right? But that is it for this
lecture right here. And that is also it
for the, let's say, planned content for the first content
batch of this course. Now there will be more
topics added in the future. So after basically this
lecture is going to be a section called some additional topics or
something like that, where additional topics in
the future will be added. So maybe if you're watching this course just
after it came out, that maybe does not
gonna be anything there. But in the future, something
might be out of there. That's pretty frequent, cool. So hopefully some
more advanced topics are going to be
covered there as well. As, well as maybe some not so advanced topics
that might still be useful and that might have been asked for
quite a lot, right? But that would be it for
this lecture right here. I hope you found this useful
and ignorance of the new. I'll see you hopefully
in the next lecture. So, yeah.
96. (Additional Topics) Update Fabric (1.18.1): All right, welcome back to
the fabric course for 118. And in this lecture, we're gonna be updating our
fabric to the newest version. For me at least. I mean, I guess it's
probably going to be a little bit of a newer
version even for you. But for this, of
course, we're gonna go to the Gradle properties file and then we can
navigate to this right here. So two fabric EMC Net Versions, HTML and I've already
got this open. So these are the new versions
here of the yarn mappings, the loader and the fabric version for we continue
a message from the future as 118 to two has been pretty
much just released. I highly recommend
what you do is you keep it on one hundred,
eight hundred and one. If you've been following
the lectures with 118, I highly recommend you stay on one 1800s instead of
updating immediately to 172 because one 1800s and all of the upcoming world generation is not going to work with 1800s. At the end of the course, there's gonna be a section
where we can watch if you want to go through with one 1800s to just
keep that in mind. So highly recommend,
keep at 181. And then you can update at
the very end of the course, we're gonna do is I'm
actually going to put this on the other
monitor and I'm just going to copy it
over just like that. And then we have the
other three right here. So those are those
three they ago and then we're just
going to move them over. And that is pretty much it. And then we'll just click the little elephant here
is that does not appear. You can always open
up the Gradle tab and then click this button as well. And then as it's built, once again, it might
take a little while. It might take a minute or two, or it might also only
take like thirty-seconds, depends on your speed on
the internet connection, whether or not you've updated in the past, stuff like that. But once that is
basically run through, we're just gonna
basically patiently wait until this one
through and then we're going to see whether or
not any errors might occur. All right, so you can see
for me it took 50 seconds, so not too long,
actually totally fine. And overall so at
the moment I'm not getting any errors or
what we can do is we can just start the
run client task and let's just see whether or not some errors
might occur there. Of course, once again,
might be some red here, some different warnings, at least, that should
be totally fine as long as the actual clients
starts, we're gonna be fine. This era, of course,
like always, it's just a normal
error that we've seen basically every time
we started the client. So no worries there at all. And there you go. So the window is actually already loaded. And let's see. There we are. So everything working totally fine and that's actually
how easy it is to update. Now if of course previously seen an update already, however, I wanted to do it one more time basically before we're
going into the wall, the additional topics that
we're going to discuss in the, in the upcoming lectures. So those are gonna be
really interesting, some really advanced stuff. But I'm sure that we
will manage to get through it and it's gonna be
really freaking interesting. But that is already at for
this lecture right here. I hope you found this useful and you'll
learn something new. I'll see you in
the next lecture.
97. (Additional Topics) XP Drops for Blocks: All right, welcome back to
the fabric course for 118. And in this lecture, we're gonna be taking a
look how you can add experienced drops
to your blocks. Now, this is something that puzzles of few
people in the past, but it actually is fairly straightforward once
you know where to look. And that is basically
we're going to press the Shift key twice and
then we're going to take a look at the
oral block class where I'm going to make sure
that include non projects. And then we're gonna choose
this one right here. And then actually let's do the, let's actually go into
the terminal here. And let's say Gradle w sources just in case after the updates. Sometimes you need to when the, when a lot of stuff updates, you need to actually do the
gen sources right here. And let's just let this run
through and then we can see what the actual class
has to offer for us. There you go. Took about a minute
and then it was done. And now what we can
do is in theory, we can search for it again,
making sure once again, we'd select this and then here
we still get the blue bar, but now we can go choose
sources right here. Who's the mapped
sources say, okay, and then after it reloads, then we should get
the proper class. Usually, the difference
is not stork, but it can sometimes
be a difference. Making sure that we have the proper sources here instead of just the
decompile ones. Now, the orange block
class right here gives us the ability to also pass
in a uniform in provider, which is the experience
that drops when actually, while destroying this block. That's actually all
that we need to do. So in our mode blocks
class, Let's for example, take the oracle outcome
or the case of the more, we probably wouldn't want
extra experience to drop. But we're just gonna do it here because it makes sense to
do this as an example, are usually of course, because our ori calcium or
block drops Rory calcium, usually you wouldn't want
to add the experience here. But just for an example, we're gonna do this after
the fabric block settings. We're just going to add
another parameter here and that's gonna be the uniform
in provider dot create. We're just gonna say something
like a three to seven. Let's see what we can actually also take a look at in
the or block right here, we take a look at where
this has been used. So middle mouse button click
on this and for example, seeing the Emerald or
just as an example, we're going to see the provider. Here's exactly 37. That's
roughly the size that you want. This I believe, should be all of the different or blocks
where this has been used. But of course you
can change this. Maybe you have an order
that's incredibly rare and maybe you want
this to be way higher, but of course also be the case. That's actually all
that you need to have your blocks drop
experience as well. So for completion sake, let's see if it works or if
Francis back in Minecraft. So let's just mine a little
bit of this and there you go. See it drops experience as well. And like I said, you can just change
the integers they are, and then basically
try and dilute into how many experience
you want it dropped. And we can just see, I can continue here and h is
continuous working. That's actually how
easy it is to add some customer experience drops yours. That has already at, for
this lecture right here. I hope you found this useful
and you'll learn something new and I'll see you
in the next lecture.
98. (Additional Topics) Adding Transparent Blocks: Or I welcome back to the
fabric course for 118. And in this lecture
we're gonna be adding a custom transparent
block to Minecraft. This actually once again, one of those things
that's actually fairly straightforward once
you know what to do, of course, that's
usually the trick of it. But let's just go
in and let's just copy over the cherry
blossom leaves right here. And this is gonna be the
winter underscore window, even though winter is slowly
but surely fading away. But that is of course fine. There's, of course, it's
gonna come back some time. Winter is coming. Of course. We're gonna make this a new glass block they ago
and this is going to just copy over the
block glass right here. That is pretty much
all that we need. Now let's actually also
add was non opaque. That's actually very
important and let's add some strength here as well. Why not some custom strength? And that's gonna be fine. And for the block, actually
that's all we need. Now the reason we need
the glass block class is if we go into it, middlemost point, click on it, and then middle mouse
button clicking on the abstract class block, you can see that it
has first of all, the camera collision
shape empty. Then we have the ambient
occlusion light level. It's needed so that
light gets through. And then we also have
the translucent method, basically returning true here. This is why we use the glass
block, just makes sense. Now what we also
actually needs to do in order for the
winter window to be properly added in the
MC course client class, we're gonna copy over
the sampling here. I'm not going to make
this the winter window, and we're going to make this
render layer translucent. So get translucent. Very important that
we add this as well. And then the actual
transparency is done. Now of course, we
still need to add the normal JSON files that we're gonna copy those
over everything here, of course, available to you
in the GitHub repository, an individual just as well. The sea, the block
States race is completely just a
normal everyday, actually kind of boring. Block says JSON file. And then let's also copy over
the translation right here. This is nothing,
nothing too crazy. Nothing that should alarm you
in any way, shape, or form. It's just normal
stuff like we've seen a pretty much
plenty of times already. Same with the block
model JSON file. You can see completely
normal what militarism file and
we're going to go 33. Yes, we're gonna go
through with a three also completely normal
item modal JSON file. And then let's actually also get the texture you're over and that would pretty much be
it. That's all that we need. So two very important things, making it a new class
block non opaque. And then also making
sure that this is called your get the translucent
render layer. And after having
added all of that, Let's see if it works or
if answers in Minecraft z, the winter window has been successfully added to the game. So let's just set it down and
you can see, there you go. We can look through it and
it looks pretty amazing. So working pretty much
exactly like normal glass, like you would expect it to. And we're going to have one more thing and we're going to take a look
at the texts from one more time to basically
show you one other thing that's very important for
custom transparent blocks. We've opened the winter
window PNG right here. And once, of course, very
important here is that those pixels right here
are of course transparent. They have an Alpha value associated with it
that's less than one. That's very important
that the alpha value here for some of the pixels is
of course, less than one. Otherwise it's not going
to show transparent. So that's pretty much all
there is to it as well. You can do this in GIMP, in paint on net or
two great programs. I personally use Photoshop, but those two also would work. But whatever the case may be, this is actually already it
for this lecture right here. I hope you found this useful and you learned something new. I'll see you in
the next lecture.
99. (Additional Topics) Add Animated Items: All right, welcome back to
the fabric course for 118. In this lecture,
we're gonna be adding a custom animated
item to Minecraft. Now, adding an animated item is actually a fairly
straightforward process. Now this is gonna be
a texture that is going to be animated
and changing over time. For, for this, of course, we're
going to need a new item. So let's go into our
more items class unless just upper copy
over the bowl item, actually, that's gonna
be probably easiest. And among our call
this the magic underscore recalc
come underscore dust. And then same here. Magic underscore or a
calcium underscore dust. Now this is going to
be a normal item. Curious, isn't it? Yes, the actual item
itself is very, very straightforward to be done. The interesting
thing is actually going to be the
texture itself as well as the associated
MAC metafile. Interesting, what does
that, what we're gonna see. But first of all, let's add the translation right
here so that we have it. And then we're going to
also add the model file. Now the model file,
it might say, Well, the model file has to be like crazy complicated, doesn't it? It's probably going to be
really freaking awesome. And no, it's actually
just a normal model file, as you can clearly see, that
just points to a texture. And the texture is the thing that is going
to be the interesting, well, interesting
part of all of this. So we're going to
copy this over, including the MC Mehta file. Now this is of course
all available to you in the GitHub repository in
individual just as well. And you can see
right here, this is the actual dust itself. And you can see that these
are multiple textures. And these are the
frames that are referenced in the MC metafile. You can see 012345, it's pretty much 012345. They are going, they're going to be basically animated
in a French term of 16. I highly recommend changing this and playing around
with this a little bit, be open to experimentation here. Interpolation simply means that it sort of fades in and out from one frame to the other instead of changing discreetly. That's the general idea of
interpolation in this case, and that is the idea here. So this is actually
all there is to it. Now it's very important
that the MC metafile has the same name as the, as the texture
including the dot PNG. This is incredibly important. Please make sure that this
is written correctly. Once again, one of those
things where it's best to double-check or triple
check the spelling. And for some
examples, for blocks. Example, you can go to the external libraries down here to net microbes
project maps, so on and so forth. And we're gonna go into
the assets folder, Minecraft textures block. And we're gonna take a
look at the magma block because that one
also is animated. You can see the magma texture actually is free,
different textures. And here is the MAC metafile. Once again, pretty much
almost exactly the same as with the actual metafile
that we have here. You can see it's just a
different frame time for the magma and that is pretty much all there is
to are highly recommend, like I said, play around
with this a little bit. Try it out and see what you
can basically come up with. But otherwise,
let's actually see if the animated texture
works properly. Or a Minecraft. As you can see, the magic
dust has been added successfully and you can see that it looks
fricking, amazing. It generates or rather
animates automatically. You can see that it just, it looks really cool for has a, you know, like a
sparkling effect to it. And like I said, this is completely customizable. You can just change
the MC metafile, play around with this
a little bit and then you can just with that, just with basic stuff like that, you can already add some
pretty cool frequent things into your model. That has already for
this lecture right here. I hope you found this useful
and you'll learn something new and I'll see you
in the next lecture.
100. (Additional Topics) Custom Menu Screen: All right, welcome back to
the fabric course for 118. In this lecture,
we're gonna be making a custom menu screen. Now this is going to be
very interesting indeed, because a custom menu
screen is something that's just so very interesting
thing to add to your MOD. Now, one of the
thing that I want to mention immediately here is that when we're making the
menu screen in this lecture, we're going to make it so
that it always displays. And then in the next
lecture where we're going to talk about configs, we're gonna make it so
that you can figure out whether or not the
thing displays. That is very important
that you add that. Because otherwise
your MOD will never be added to any mod pack ever. You have to make
this configurable. But that's something that we're gonna see in the next lecture. In this one, we're gonna make the wall custom title screen. Now, what's going to be really
interesting is that I've seen a lot of ways that this
has been done previously, but basically always using
the title screen class. So this is gonna be
the title screen. There you go under this
one right here and that microbe client GUI screen. And it was very
strange because they always basically just
made the entire title. Screen maker made a
mixin and just changed. I mean, a lot of stuff in here. And I was like, I can't imagine that that's gonna
be the only way to do it. And in fact, actually it is
not the only way to do it. I have found a much, much easier and better way. So we still going
to need one mixin, but it's gonna be very simple. So first of all, we're
gonna make a new class mimics and packaged
quality screen mixing. Go and it's going to
look kind of like this. I'm going to copy it over. I'm going to say, Oh my God, that's way too much exactly. It's almost nothing. You're going to make
this an interface. This is going to be
mixing the screen class. And it just has going to have an accessor here or
the drawables list. That's all that we're
gonna need here. That's literally
all that we need. Then of course, for the mixing, we also need to add this are
mixed in right here now, very important, this
is under the client. That's very important because this is only going to
affect the client. That's why we have to
have this right here. We can also see this in
the screen environment, value, environment
type here is client. This only has happened
in the client. Therefore, we need
to put the mixing in the client, in the mixing JSON. After we've done
this, we're now log. Okay, how are we
going to proceed now? We're gonna make a
new title screen. Let's just going to be
in the util package. Right-click new Java
class called the, I'm gonna call this the
kelp and title idle screen. There you go. This is going to extend
the title screen class. You can see we actually don't
have to hover over this and we don't have to
do anything here. But what I'm going
to do is I'm going to copy over the
contents of this. Once again, all of this
is available to you in the GitHub repository and
individual just as well. I'm going to explain what
the FREC is. Hubbard here. We can see this splash. This is the actual
identifier that points to my image that I wanted to
replace the normal image width. And then we also have the Minecraft title
screens texture. This is just the
Minecraft that's written basically
on the top, middle, top of the actual title screen because we had to
actually add this. Again. The way that this works is
we call this render method. The first thing
that it does is it renders the normal title screen. Then as you can see,
I've separated this into four different
methods here. Then we're drawing our
custom title screen. Then over that
we're going to draw the Microsoft logo with I'm going to draw the
copyright notices, and then we're going to draw the title screen and buttons. I was very important is
that definitely always keep the copyright notices in
there and not 100% sure. But I think that if
you don't have them, that you might be committing
copyrights fraud or some something like that.
So keep them in there. Just keep it like this. This is pretty much
exactly the same code that is also in
the title screen. Most of this stuff was taken
from the title screen. The actual logo here completely
from the title screen. The screen buttons taken from the title screen and then the
draw custom title screen. This one right here
is a little bit of a I wouldn't necessarily
say maximum customer stuff, but most of this as customers, you can see that
most of the stuff is very similar to this as well. We're just basically drawing
a different texture here. And that is pretty much
all that we're doing. Now. What are we going to do
with this title screen? Well, we're gonna make a
new event interesting. In RV event package, we're going to right-click new Java class and this is gonna be the replace title screen event. Let's just what
I'm gonna call it. This will implements the screen
Events dot before in it, and we need to take
this one right here. This event is core before a particular event
is initialized. We're then going
to implement the before init method right here. And then I will copy
over the contents, which are also gonna be
very straightforward. But what we're just
going to say is hey, if the screen that is
currently being initialized is a title screen and it
is not our title screen. We're just going to set that
screen toward title screen. That's overdoing
here easily enough. That's literally overdoing. And now we just need to
basically make this register, this actual event here. And this is gonna be done
in the client class. So MC course client,
very important. And then here we're just
gonna say screen events before in it this time of
the event factory here. And then we're just
gonna say a register, a new replace event, replace title screen event. That is it. Now the title screen will be replaced with this
texture right here. We have course, I still
have to add that texture. Otherwise we're just going to
get black and pink texture, which is not what we
want at this gonna go into GUI and then
under background, so new directory, their
background they ago. And then we'll copy this over. This is available
to you as well. However, please
note that there is a copyright notice
associated with this. Once again, can be taken
here from the credits file. You can see some by your knee. So this is once again the same
Creative Commons license. And then you just have to link the Fiverr page right there. It'll keep that in mind as
well if you want to use it. I highly recommend not using it because it doesn't
make any sense because when you will see
the actual texture here, I just don't, you
don't need to use it. Well, whatever the case may
be, this is all that we need. So now let's see if
it works or it's starting to load here and we should immediately,
of course, see it. And there we are. The custom title screen are working exactly how you
would expect it to. The buttons still work. I can I mean, that's like a very bad example,
but there you go. So I can basically click on everything and
everything still works. And we have Milo
microbe character here holding a sign
tutorials by column and row. Here on the left we
have a little bit of a spoiler right here. So who knows what
this combined mean? Who knows? But overall, I really like it is really cool and
everything's to work. And so you can even go onto
the copyright right here. You can still click on this and everything is still
working great. That's actually how
easy it is to add a custom title screen
to my craft, right? And like I said, highly
recommend checking out the next lecture as well, where we're going to add a
conflict to this as well. Because if you don't
have the conflict, then you have to make
this configurable. I will just say this,
but for the time being, this is it for this
lecture right here. I hope you found this useful and you learned something new. I'll see you in
the next lecture.
101. (Additional Topics) Add Simple & Basic Configs: All right, welcome back to
the fabric course for 118. And in this lecture,
we're gonna be adding a simple conflict to Minecraft.
So what does this mean? How do conflicts work? Well, first of all,
we're gonna be using a already made class. And that is right
here from the fabric, simple lips right here. This is from a magistrate Vmax. And be wary or be sure that
this is under a copyright. And so this is gonna
be the MIT license just so that you're
aware of this. So making sure that you
know that that is the case. The simple conflict
here is actually, I mean, it's fairly
straightforward. It's not actually
too complicated, but we're going to use this. And this is of course all
available to you as well in the GitHub repository in
individual just as well. And I'll actually copy
over all three classes that are made in the MC course packet right-click new package called config. Then inside of
there, I'm going to copy over the three classes. Like I said, they
are all available to you as well for download. But let's see. There you go. There they are. We have the simple
conflict class, which is generally just
a normal Java class. Inside of here,
nothing in here is basically for either
Minecraft or fabric. This is all normal Java code. Here I had, I did one tiny
modification right here, is that it recognizes
a common after a value that is all I
basically added here as well. Let's just, because my, I found it a little bit nicer because of the
way that I set it up so that we have this
conflict provider right here. We can see that this is just
a default configuration. Now what does this do? Really is just a list of pairs. So we're gonna have
a key-value pair for a conflict to
be fairly sensible, where there's a string
that is gonna be the key, then some type of value. We don't know what value
because we can basically save stuff in different
values and that is in the mod conflicts
class is basically all well done here we have this register conflicts method, which we're gonna call in just a moment. But what does this do? Well, it makes a new
conflict provider. It then creates the conflicts. This is the actual
creating of the conflicts. You can see we're just adding key-value pairs to this modern conflict
provider right here. The idea is that
this is the key. So you can see I've just
had some examples here. T-test value, we have
another test value. Another test value is
a string in double, or have those comments
here just so that it's a little easier
for the player or the actual user to
change this conflict so that they know what type
they want to change this to. You can also add some
other stuff to it as well. Like possible things
you can put in here, something like that
would also be the case. And you can see that have the replacement title
screen e-value here, which is the most important one, and which is the one that we're going to
basically take a look at in just a moment
for the time being, we're going to go here and at the very top of
the uninitialized, we want to say mod conflicts,
not registered conflicts. That is pretty much all
that we need to do here. So like I said, of course
all the code is available. Now on this, the very
important thing is that you can't use your configured
values here everywhere. And that's something that
is very important here. Because some, this, basically what we're
gonna do is we're just gonna run a client
for just a moment. And I'm going to explain why there could be some issues here. So we have two different
threads, right? So there's the server thread and the client for this is of
course also why we have the MC cores mod right here and the MC
course client class. Because this is only the client, this is, this is for both. This should be four common. Basically. Our config right now is gonna be interesting
because on the, if we're on the server is
actually going to be loaded in. And then if we're on the client, it's also gonna be loaded in. So now I have my microphone, it has started and
then I can go quit. And now I should be able to find my conflict under the
R1 folder in conflicts. And there you go, MC course
conflict or properties. And you can see there they are. So you have the actual key here and then whatever
this value is, and then you can also
see the default value as well as the comment that
I've basically added here. That's the general idea, and this is how it is displayed. Now once again, the
interesting thing is here that this file actually
is going to be the same for the server
and the client. Now if we, for example, were to change something in the whatever in the more items, for example, and say there's
a different max count here. That's gonna be a mismatch between the server
and the client. Be very wary of where
you're using this. I found that conflicts in fabric are way harder to properly do. Then in Forge, I don't
know that there's no real good solution
that I've found. All of the Config APIs are all incredibly convoluted
and not very easy to follow. I'm not a 100% sure. This simple conflict
here is gonna be enough for definitely some or
some clients stuff, 100% for the server stuff. Well, we'll see. And you could also separate
this out to make a, these three classes basically, or rather these two
classes make this a mod. Client conflicts only
call this on the client, then it should not
even be a crater on the server because of course the replace tiled screen
in this moment, in this instance here, actually something that only happens in the actual, the
actual client. But nonetheless, it
should be totally fine. So we're gonna go into the
replace title screen event. And then here we're gonna
say is we're gonna say mod, mod client, no more conflicts. They go more conflicts
that replace title screen. And we're just
going to add an end and that is going to be it. It basically you're
just going to check whether or not this is true. And if we were, for example, to change this to
false right here, and then start again. After this has been
basically created once, then it should now read
the actual value in. And it's gonna say, hey,
replace title screen is false and then not
replace the title screen. But like I said, there are some still some hurdles
on the conflict front. So this is definitely
not the best, the best solution at the moment. There you go. It works. This is the best solution at
the moment, however, it's not the best solution
probably for ever. I have yet to find a very good implementation
of any thing that is a good conflict API for fabric, but
it is what it is. But nonetheless, we
have now at least added as the conflict
year for the screen, which is basically the
most important thing here. You have something
for conflict as well, so that there's at least they tended to step into
the right direction. The fabric MC wiki, by the way, has a list of a few
different conflicts. Like I said, I have not
found any of the others to be well that interesting
or that well-done. At least I didn't really, I spent a little bit of
time with each of them. And the simple
conflict really is easily used for while the
use case that we have. I will link this as
well so that you can basically take a look at some
of the other ones as well. But for the time being, I think we're gonna be fine. That is already at for
this lecture right here. I hope you found
this useful and New, and I'll see you in
the next lecture.
102. (Additional Topics) Add Custom Effects: All right, welcome back to
the fabric course for 118. In this lecture,
we're gonna be adding a custom effect to Minecraft. This is a very
interesting thing because the actual effect comes
from another student that had actually
imported this effect in their mob but had an issue. And I was able to fix it. And I was like, That's
a really cool effect. I want to basically show
how this works and this is actually way more straightforward
than you might think. In our MC course package. We're gonna right-click
new package in effect. And then instead of there, we're gonna make two new classes. One of them is gonna be
the Mode Effects class. Then the other one is going
to be the freeze effect. The effect how
it's gonna work is basically it's going to freeze an entity or that they
can't move anymore. You know, a little
bit of I wouldn't necessarily say any issues here, but it's gonna be an
interesting thing to see because there's some
sort of interesting, let's say, ways that this works, but we're going to just
see how this works. I'm gonna copy over the
contents of the actual class, extends the status affect
class you can see. And then basically just, they'll have a normal
constructor here. We're going to overwrite the
apply update effect method. So this is gonna be
the ticking method that is going to basically get hold every tick that an entity has this status
effect applied to it. And then we also very
importantly have to override the can apply update effect method and return
a true right here so that this method is even coat because
if this is false, then this isn't even coat. You can see we're
basically just taking the actual entities current coordinates and
then setting them, letting the actual entity
back to those coordinates. There might be some issues with this, especially
with flying. However, for the actual player, this method called
is very important. And for any the else, so anything that has an entity that is going
around in the world, then the set velocity is important because this
basically makes it so that the animals or a zombie or whatever might not be
able to move anymore. So both of those are important, and that is pretty much
all that you need to do here in the Mode Effects class. We're once again going to just copy this over
because why not? This is not actually that much. And also of course, everything
available to you in the past or an
individual just as well. You can see basically
nothing too crazy. We have the status effect than we're registering
it right here. And we're actually
registering it inside of the register effects coal, which is of course something
that we need to call instead of the MC course Ahmad
class right here, we're just gonna go
over bottom here. We're gonna say more effects,
not register effects. There you go. And that is all that we
need to do now we need to still add one
more thing and that is going to be in the assets
MC course Textures folder. You want to make a new directory called mob underscore effect. Effect. There you go, Effect.
And then we want to add the freeze PNG to it is going to be the actual PNG or the actual image that is displayed when you
have this effect. That is actually
all there is to it. It's really not
that complicated, especially the status
effect in and of itself. The category here should be
fairly self-explanatory. This is just the
color you can see, this is just the
actual color of this, of this status effect
that is going to be used, I believe in oceans
and Persians, we're basically going to
see next lecture as well. For the time being,
we're just going to have this effect without portion. And after having added all that, Let's see if it works or if
it was back in Minecraft. So let's just add
and see if I can give myself the effect here. So this will be player
there and you can see MC course freeze
effect is there. So let's just give it
to me and you can see, I can't move some trying
to press the keys, ie, it doesn't work, right? And you can see we don't have a actual translation at the moment, but
that's gonna be fine. And you can see I can't, I can't even move the mouse around. I can still hit blocks
if I'm like happy. But you can see that
this is like very much, I'm basically frozen. There's probably something
that you can also do so that you don't get that shake when you're
trying to move the mouse here. But overall, it works. And then as soon as the effect
wears off, there you go. Now can move out again and
everything is working fine. So that's really freaking cool. Like I said, all of the rest will be added in
the next lecture, including a portion and all of the translation is going
to be there as well. But that will be it for
this lecture right here. I hope you found this useful
and millions on the New, and I'll see you in
the next lecture.
103. (Additional Topics) Add Custom Potions: All right, welcome back
the fabric course for 118. In this lecture,
we're gonna be adding custom potions to Minecraft. Now, custom portions
are very interesting, and this is of course
going to piggyback off of the frieze effective we've
added in the last lecture. What we're gonna do
is we're gonna make a new package right here, and we're gonna call
this the potion package. There you go. Then instead of there,
we're gonna make a new Java class called the mod oceans. They ago. Once again, I will actually
copy over the contents here. But before we can copy
over the contents, what we wanna do is
actually we want to copy over this right here. If we want to get the frieze of portion and then register
potion method or this is of course available to you in the GitHub repository and individual interests as
well. So no worries. Then I'm going to actually add the modified register
potions method right here, because we're gonna
be able to add the Register potion
recipes in just a moment because for the
recipes that we added, we actually need
a mixed in here, but no worries at all. It's actually also not
going to be complicated. But this register potions
method will call right here. So under the motor effects, more potion, start register
potion. So there you go. That should be that. Now this is actually
important that we assign this field inside of
the register potions method. I'm not 100% sure. It just is a little
bit of a quirk here, but I've found that this works. And if, if we
immediately assign it here when we initialize the
field and it doesn't work. But whatever the case may be, we now need a mixing. So if we actually take a look at the brewing recipe
registry here right now, they are in a net
microbes recipe. This is a great class
that registers all of the different
recipes for potions. And you might be
like, That's great, but sadly, the register potion
recipe method is private. That's kind of an
issue here of course, because that means that
we can't just add it. If this was public, it
will be way easier. But luckily, we can
just use a mixed. And for this, we're gonna
make a new Java class, and this is gonna be
the brewing recipe. You registry mixin. There you go. Then this is going to be, I'll actually copied over and this is once again very straightforward and of course all
available to you. Gonna change this
to an interface. This is of course going to mix the brewing recipe
registry class. Then we're going
to basically have this static method called just invoke register portion recipe, making sure that this name
right here is the same as, let me go back in here
as this name right here. So this name has to match
this name in the Volcker one. And then we're just adding
this assert because this shouldn't
actually ever be cold. If the mixed and works properly, then this method should
be called a notch, whatever is written in here, That's just another thing. And then we also have to add it in the EMT
course, mixed race. And very important,
you want to add this, but let's just add this
right here under the mixin. So that's very
important under mixing, not Client right here, making sure that this
is written correctly. So we can just
double-check copying this, hopping this and everything
written correctly. That's great. Then what we wanna do
is we want to go to the MOD portions
class one more time. And we're just going to
make a private debt tick. Nope, There you go. Static void. We're going to call this the
register potion recipes. And then inside of here what we're gonna do is
we're gonna call the brewing recipe
registry mixing, invoke register portion recipe. And then I'm just gonna say
we're gonna use the portions. Awkward, awkward. They ago. And then I want the mod items
start or calcium ingot, we have to be added
and then we're gonna get the more potion start raised portion
right here as the result. And that is pretty
much all that we need now this one needs
to be cold right here. So we're gonna call this at
the very bottom right here. After all of the
Persians have been registered for our
custom portions, then we will register the
portion recipes as well. And that's going to
register it by the way, for all of the three different
portion times no potion. Potion, as well as the
lingering portion. That is pretty much
all that we need here. And then we still
need the translation, which is very important. And we're going to add
the translation as well. But the translation
is very interesting because the items here, so the portions are actually under the Minecraft namespace. Not a 100% sure why
that's the case. I think that, I mean, It's obviously the case because when we
register a potion, the actual portion
item is going to be registered under Minecraft. It just is what it
is, but that's fine. And then we also need
one for the effect here. I'm just going to add that. We're just going
to add that at the very bottom right here. So effect MC course freeze, and that is just free. So those are the four translations
that we need as well. And that is actually all
that we needed to add, the portion including
the potion recipe. So I guess let's see if it works or fossils
back in Minecraft. So let's just try and
see whether or not I can craft my custom portion. So if I put the
oracle coming it in, we're already starting to
get some progress here. That's very good
already, of course, because that means that it is at least
working the recipe. Now, hopefully
we're also getting the correct actual
portions here as well because otherwise
sometimes you get the uncomfortable potion
if something went wrong, but we did not freeze potion, splash portion of freeze and
the lingering ocean as well. But for now we can
actually go and see as well how it works for moms. Let's just kill the sheep year. And let's actually
see what we can see. If I add some sheep here that's actually
out a few of them. But if I just broke this down, you can see now
they're all frozen. And what I can actually
do is you can see that if I hit him, That's actually really
gonna be interesting because they're actually
going to float in the air as well as the Y is of course also a frozen there. Let's actually see,
let's do the following. Let's actually yet another
freeze portion right here. Let's get some zombies in. And let's see. I'm going to switch back to survivals that they're going to follow me and then freeze them. And then you could see
all of them are frozen. Very, very funny,
But actually works. And then sometimes
they're unfrozen again. Go back here, there you go. And that is actually
how easy it is. And as you can see,
all of this stuff has been added correctly, the portions have been added, everything working as well. So let's just go back here and see all of the portions and
the potion recipes as well. So that is pretty freaking cool. That would already be it for
this lecture right here. I hope you found this useful and you learned something new. I'll see you in
the next lecture.
104. (Additional Topics) Add Custom Entities with Geckolib: All right, welcome back to
the fabric course for 118. And in this lecture
we're gonna be adding a custom entity to Minecraft. The long awaited lecture
on how you can add a custom mob or custom entity to Minecraft
is finally here. And overall, it's gonna be
fairly straightforward. I think all things considered, there are a lot of steps
that we have to go through, but each of the
different steps is actually not that difficult
in and of themselves. Now the first thing
I want to say is that all of the entities
that we're going to make here are going to
be gecko lip entities. So we're not gonna do
any vanilla entities. We're immediately
going to start with the actual gecko lip entities. And I will actually
link something here. So that's gonna
be the gecko lip, basically the GitHub
repository right here. So gecko lip you can see is an animation library
or microbe maths. And at the moment, basically what
we're gonna do with this is we're gonna use this to actually implement
the actual entities. And this will also
allow us to just get a little bit of a nicer
way of animating them. So I highly recommend
also doing this. I mean also the lecture here
and the upcoming lectures on the entities are always going to require the gecko lip library
there no going around this. And also this is
not a that thing. Some people are like, Oh,
I don't want other people to also have to download
another March, stuff like that. Don't worry about this at all. I highly recommend being open to this because
for the user, usually a lot of stuff
happens in mod packs anyway. And then something
like the gecko lip is probably in there one
way or the other. Whatever the case may be, you can see fabric use. We have some different things
that we need to copy over. What I will do is I
actually have this on my other monitor
already here up for me. What I'm gonna do is
I'm going to copy stuff over so you can see we need to first of all add a maven URL
here in the repositories. So this is gonna be this one that's always going
to be the same. And then we can actually
take a look at this. So this is going
to be 32 that are actually the same version
that I have here as well. And that's gonna be
under dependencies. So we're going to
put this in here. Most implementations software burning gecko lib, equilibrium, dashed file, fabric dash
118, and then 3032. And that is actually all
of the stuff that we need. You can see this is for
forged, so we don't need this. And then there's some
initialization stuff here, basically what we're
gonna be fine with that. So let's actually go back
here and let's reload this. So we're gonna reload
this once again, right, to take my take a
couple of minutes, maybe, something like that. It might also just
take 20 seconds. Of course depends a lot on
your internet connection and also on your wall
on just in general, the speed of your PC
while they go 13 seconds. That's kinda nice. So let's actually take a
look at what we can now see. There's quite a few
things that we need to add in our MC course package. Right-click new package called entities or entity
actually, let's do that. There you go. And then
instead of there we're gonna make a new package
called Custom. And then first of all, in the entity package, we're going to right-click
new Java class called the mod entities. There you go. And the more entities class is actually going to be
filled in just a moment. We first of all need
the actual entities. So in our custom package, right-click new Java class, and this is gonna be
the raccoon entity. There you go. And then we have this done. Now I will be copying over a fairly sensible
amount of stuff here, which is gonna be,
you're gonna say, okay, that's quite a bit of stuff
here. Don't worry about it. The general idea here
is that while there is a quite a few things
that I want to basically copy over
and I will copy over. First of all, of course, all of this is available to you in the GitHub repository in the
individual just as well. So I highly recommend
you're gonna have to check this out one
way or the other. And then also there is
a lot of stuff I will try and go and explain
a best I can do. First of all, this
is going to extend the animal entity right here. And then it's also going to
implement the AI animatable. You can see this is from Ecolab. We're going to hover over
this and implement methods. And then we're gonna say,
okay, then after this is done, you see the Create trial method is that for the animal entity, we're gonna keep this
null for the time being. We're actually not
going to take a look at the spawning of tribal
entities just now. In the coming lectures
we're gonna see maybe there's gonna be another
lecture on that in the future. But for the time being,
nothing as planned. Whatever the case may
be within have also the register controllers and
the animation factory here. Those are from the eye
animatable interface. And then we hover
over this again. Basically then create
constructor matching super. And there you go. Now let's make this constructor immediately just public
so that we have this. And then we're gonna
do is I'm going to add the animation factor here. So we're going to animate
at the animation factory, you can see fairly
straightforward new private information factory, factory, new animation factory. And then passing in this, then we're just going to
return this right here. We're not going to add
animations in this. Lecture actually, whatever, setting it up here is
no worries at all. So that's gonna be totally fine. Then there is a two other
things that we definitely meet. So the first thing that we actually need is we want to say this dot ignore camera
for Ostrom equals true. I'm honestly not 100%
sure what this does. I just know that
we should call it. So that's the general idea. Sometimes that is the
case in entities, also quite the complex
topic, so no worries there. But whatever the case may be, that's the easiest thing. Then we want to add
some attributes. We're going to copy over
the set attributes method. You can see that here, we're basically building
some attributes. You can see it max, health, damage speed, and
stuff like that. So we're basically setting this up in this particular entity, those numbers, of course, you can change them
however you want, but they have to be there. That's very important. And then we also
need some goals. This is the AI of
your overall mark. Basically. Now I have two things
here that are basically, I can already Delete. We're going to need
those in a little bit. Let's basically in future
lectures when we are making this raccoon
entity, also T-Mobile. That's something for
the future lectures. As I said, we can see there are some different goals here and they have
different priorities. The lower the priority number, the higher the actual
goal is in its priority. Priority 0 would be the
first thing that happens. And then to if there's a
conflict between the basically, if two goals could be
executed than the one with the lower priority
and executed in the face because that's
just how it works. And that is actually all of the different things
we need to add. There isn't anything
else that we need to add in this entity itself. All of the rest comes, well, I mean a little bit
later when we are going to start with
the table entity. So in the future lectures, the recording entity is done. So let's go into the
mod entities class. And once again, I will
actually copy it over, but no worries at all. Because once again, this
is all available to you and we're gonna go through this so we
can see that we go, am I gonna make a
new entity type of our customer
record entity here? And then we're just
going to call register, registry, that register
new entity type. We're gonna say this
is called raccoon. And then we're going to call the fabric entity type of Builder, going to create a
new entity type. I'm going to say
this is a creature sworn group are of course, different types of
bridges, as you can see. You can also see where
it says like peaceful, yes, And then that's
gonna be fine. Then making a new raccoon
entity makes sure that you're, that you made your
instructor Republic. Otherwise you're gonna get
an error here, of course. And the dimensions here
are the dimensions for the hip box of that entity. And then we're just
gonna call the building right there and
that's gonna be it. That is, however, of course not everything because nothing
can be this simple. In the entity package,
we're gonna right-click new package called client. And inside of here we're gonna make the model and the renderer. Those are gonna be two classes, so it's gonna be
the raccoon model. And we're also going
to make the raccoon. If you go Java class raccoon
renderer, there you go. Those are the two classes
that we're gonna need, once again, copying
over some stuff here. So I'm going to do
the model first. Right there. This is going to actually
extends the animated GO model. You can see off type
raccoon entity. There you go. And then if I hover over this, I can actually see three methods that we need to implement. These are the three
get modal location, get modeled like
texture location and get animated by location. And once again, like I said, I will copy over the abundancy
are but nothing too crazy. We're just creating
new identifiers under our model ID and then
putting in the different, well here it's the
texture location, animation location, and
the model location. We're going to add
those in just a moment. First of all, we
have to basically finish the code or I want
to finish the code and then we're going to also
switch over to block bench to actually see our
custom raccoon model. And let's first of all go
here to the actual renderer. So we're gonna say
this is extends the geo entity renderer
of type raccoon entity. And they go. And then we're
going to hover over this quick constructor
matching super. And then we have to take
away the first model. The second parameter
here actually, because here we want to pass
in a new raccoon model. That's what we want. And then just to be sure, we're also going to overwrite the get texture location method. I'm just going to
basically hobby that over. So you can see this points
to the same texture. This one points to. That should be pretty
much all that we need. And that's actually
those two classes done. Now we need to still combine the Renderer with the entities. So how do we do that? Well, we're going to go into our MC course, client method. And then at the very bottom
where we're gonna say, we're gonna say the entity, render a registry,
this one right here, register mode entities,
that raccoon. Then we're gonna say the
record renderer colon, colon knew we should get no errors if everything
has been set up properly. So the actual entities, the class CRF and
set up properly, the extensive been
set up properly, then we should not get no error. And now the thing
actually works. But now of course we
still need an entity. Where do we get an entity from? Well, the entity you
get from a block bench. Now we've seen this pretty
much previously already, but we're going to
go into it again. And here you can
see the raccoon. Doesn't it just look
freaking amazing? I do, I do really like it, but this is done by Euro or so this is going to of course, make the creditors file. That's gonna be a
link there as well. But I really like it. You can see that
basically this is a, this is a gecko lip model. What you're going to need
actually is under file plugins. No, that's not required, right? We're going to do plugins. This is the gecko
lip animations util. You need this plugin here. Otherwise it's
not going to work. And then you can make,
if you make a new, you can make a gecko
lip animated model. So this is a gecko lip
animate the model. And what is so
special about this? Well, you have this
animated tab right here, and you can see there are
different animations for it. But these animations in
this case are already done, but no worries of course at all. We're gonna see them in a
later lecture when we're actually going through the
animations for the time being, what we only want is we
basically only wanted to export the gecko model is this does not appear
to you by the way, go to convert, convert project, and then makes sure that you choose the gecko
live animated model. If this appears in this, then you should be able
to properly do that. So I can save, I can just
say export glycolytic model. And then we're going to
basically export it. Now actually going to
copy it over as well. So we're gonna go back here. So the model is a geo file, geo dot JSON, and that has to go under your assets folder. And then we're going to make
a new folder right here, directory GO, and then
it goes in there. So we're just going
to copy this over. There you go. And you can see this is the
geometry of the raccoon. So sometimes I actually had a typo in there, but
no worries at all. This should still work
because the thing that actually looks for,
it's this name here. And as long as that name works with the name
given right here, you can see GO raccoon
dog geode adjacent. This is what, this one points
to the middle location. We still need the
texture location that is gonna be under
textures, of course. Then under a new
folder called entity. That instead of there
we're gonna make a new folder called raccoon. Then this is going to
be the raccoon dot PNG. So we're going to copy
this over as well. There you go. And now everything is set up. The animation duration we can just ignore for the time being. Like I said, we're going to
take this one step at a time, and this is pretty much
all that we needed to do to add the actual raccoon. Of course, like I said, inside of block bench, there's gonna be a lot of stuff
that you have to do here. This block bench file will
also be available to you. So no worries there. You can basically take
this and try it out and then see what you
can use with this. Otherwise, it's just very important to that we're
basically going to use the gecko live from
this point onwards. And overall of the other things should pretty much be done here, we have selected the in this river registered the
raccoon and the renderer. And just to sort of go over
it for a custom entity, what are you going to
need is you're going to need the entity class. You don't need a
renderer and a model. Now this is actually the same if you are not using Ecolab. However, the extending here, of course it's gonna be
different because this is gonna be an animated GO
model here for gecko lip. And it's not gonna be that for a normal or vanilla
type of entity, right? So there's one more thing
that we need to do and that is setting over
the attributes. Now we're gonna do that in
our registries, right here, the mode registries,
we're just going to make a new class private static void. And this is going to be
the register attributes, but this is going to be a
cooling the fabric entity, let's actually call it a fabric default attribute registry. They ago that register mod
entities, that raccoon. And then we're just going to
call the raccoon entity data set attributes they ago. And that should
be that the error here should be or the
warning here should be fine. And then we're of course going
to call this right here, register attributes they a goal. And then one more thing that is, of course, well quite important. All things considered is
going to be the spawn eggs. So we're gonna need a
spawn egg for the raccoon. Let's go into our
mode items class and let's add that as well. We're just going
to copy this over. This is gonna be the raccoon underscore spawn underscore egg. Now this is going to be called the raccoon underscore
spawn underscore egg. This is going to be a
new item right here. The first parameter of which is going to be
the entity types of mod entities that raccoon and among gonna have
a primary colors. So I'm actually
going to copy those over because those
are basically just, those are the colors of the actual sperm and egg basically. And I have settled up already so that we don't need to
actually add this again. Now what we do need to do, and this is very strange, but I mean, it is what it is. We actually need to
add a spawn AG Jason files while in the item
model adjacent file. So in the models item
folder and copy this over. Now this is going to be
very, very straightforward. You can see it just has the parent of item
template spawn egg, and then they respond
at gets colored in. There's also add the translation because then we have
this done as well. This is an item here. Let's put it right
here. There you go. So the raccoon has spawned
egg now also successfully added as well and it should
immediately while just work. I mean, that's that's pretty much how easy that should be. And now I'm fairly certain that everything here
has been added. We can see there are
quite a few steps here. However, once you
go through them once and then again and again, this pretty much to be fairly
sensible on the goals here. I want to say that there
are a lot of goals. So if we middle mouse button
click on the goal here, you can see the goal class. And if I press click on this
and then press Control H, you can see all of the
different goals that are in vanilla and I can
even expand them. There's even more goals here. You can either, you can
take a look at those. You can either even
make your own goals. In theory, this is
very complicated. We're not going to go
into this anytime soon. The goals are very, very complicated
and the best ways to take a look at
this as definitely first of all, the vanilla goals. And then secondly, you can always take a look at some
GitHub repositories of other mods where there might be some entities with interesting
goals that you've seen. And you can then take a look
at how they are done and learn from that the goals
are very quite complicated. It's AI, it is what it is. But for the time being,
this is all that we need. So I guess let's see if
it works or if answers back in microphysics see the raccoon spawning
has been added. So now let's see if
we can spawn it. And there it is, the raccoon actually
spawns and there they go, walking around, of
course, in this moment, not really animated at all. And they also have
quite a few of them. But if they actually
survived like two hits, three hits with
another light source. So that's pretty crazy
because they help, of course, has been
set quite high. But this is something that
you can always change. This is something that's always be open to experimentation here, but you can see the
actual animal spawns. So that is a really
freaking cool. And well, I mean, let's see where the future of
leads with them. And let's actually
take another look at the entity class because there are some more
things that we can add, which might be
interesting to you, where we find ourselves back in the entity class and
just so that you've seen it because this is probably going to be something that
people are going to ask. Because, I mean, of
course you can always go into the animal
class right here and take a look at
all of those methods that you might be
able to override. Same by the way, with the passive entity and the path aware entity
and so on and so forth. We can see the
entities are going all the way back to
the living entity, which basically all
of the rest here are basically descended
from in the hierarchy. A highly recommend also
checking those out. There's so much to be gained in looking at the vanilla entities. You can always find interesting
things the way they work. But one thing that
might be asked as well, how do I add custom
sounds to my entity? And for that we have four different methods right here where I'm gonna copy
over the ambient sound, the hertz sound to the deaf
sound and the step sound. Those four methods, you can
just return a sound event. This of course then includes the custom sound
events that we've seen in previous lectures already. So this would also then work. So highly recommend, you can basically do that and then it's going to play those sounds
under specific circumstances. I definitely wanted
to show this as well. This might be something that's
very interesting to you. Otherwise, all of the
rest really highly recommend taking a look at
some of the vanilla examples. And then also basically, well, taking a look at how we can do this in the
upcoming lectures. Because like I said,
we're gonna do a few different lectures on, well, how different, how
the actual entities work. So we're going to basically
set up the actual animations. Next time. We're going to take
a look at some of the variance and then
some other stuff as well, which is really interesting. So I recommend checking
those out as well. But for the time being, this is gonna be it for this
lecture right here. I hope you found this
useful and you'll learn something new if you did, I would very much appreciate
a review from you. Otherwise, I will see
you in the next lecture.
105. (Additional Topics) Add Entities Animations with Geckolib & BlockBench: Or I welcome back to the
fabric course for 118. In this lecture,
we're gonna be adding custom animations to
our custom entity. For that. First of
all, we're gonna go back into broke bench. And like of course, in the last lecture, we've actually added
the raccoon entity. This block bench model is
available to you for download. And when you have this, then what's very
important is that this is a gecko lip model here. If this is not quite
correctly formatted, you can convert the project into a gecko lip animated model. And then you should have
this Animate tab right here. And the Animate tab, you can see if you've ever
worked with something like anything that is an editing program
where you have certain, certain keys, your keyframes
that you can set by. This is also animation
in, for example, unity, something like that is
basically the same here. And what we can do is we can click on the island animation. And for example, I can click
on the tail and you can see I've set something
in the rotation here. What I can do is I can
just play the animation. You can see that
over the head and the body are slowly
going up and down. And the tail here is just wiggling back and
forth a little bit. What you can see if I click on this keyframe that we can even put in certain methods
function calls right here, you can see Query
anime time math sin, this is just the
sine wave that we're then putting in the actual
animation time into. And that basically just, well does this in the y-axis. So it's going to rotate
this in the y-axis. That's the general idea here. You can put in many
different things in here. You can also, of course,
putting the keyframes manually. So you can do a keyframe,
do something about it, and then advanced the time, make another keyframe,
advanced the time make another keyframe
and so on and so forth. And of course you can do that manually over what
I did like I said, here in the body. I did the sinewave in the head. I also did a sine
wave up and down. And then for the tail, I did a sine wave as well. So you can see this one is sine wave and then
position here is also in a sine wave
just a little bit of a different or
different values here, that it looks a
little bit different, but overall, it
looks really nice. So it's just a very simple one, but it is enough to
give an impression of some life that they are instead
of just having a static. And we can also take a look
at the walk animation. You can see there you
go, the walk animation. And then we can also take a look at the sitting animation of that one is actually a
completely static in this case, would also be
something added there. But for the time
being, I'm actually quite happy with what this is. It's also just an example
here In no worries there. What do we do with this? With all of these animations? So how do we save
those animations while we go to animation? And then we go to
save all animations. First of all, then you can see where I want to save this in the age Tracer file raccoon
animation, that trace. So I'm gonna save this. And then we can basically use that JSON file for
our, our project. We're going to go
back to a fabric. And if we remember
this in the model, we have to specify the
location for the animations. This is going to go
once again, assets MC course folder right here. And then right here
we're gonna make a new directory
called animations. And then inside of there, we're gonna put the
raccoon animation, that adjacent file,
the caveat is in here. And then I just have to quickly change the name CR2 raccoon. This is something that
should be fixed for you. It's just there was a
typo in there before, and then we should be iron. Now we have those
animations that we are basically
made right here. Now, how are we
going to use them? How are they able to be used? Well, they are able to be
used in the entity class. So we remember that we've added the register controllers
and the factory right here. And now we have to add
two more things in there. So first of all, we're
going to add the predicate. The predicate is a method, so I'm gonna just
going to add this at the very bottom here. We're just going to do
something like animation. This is gonna be the
animations where you can see this is the name
of the animation that is going to basically
use this name right here, has to match these names, right? So you can see this
is the sitting animation which
we're not going to use in this tutorial orange
rather than this lecture. We're going to use this
in the later lecture. And then this animation
of the walking animation here is actually something
that we use here. And then the idle
animation right here, those names have to
match very important. And then the question is,
when is this happening? Well, you can see the
walk animation is happening when event
that is moving, you can actually take a
look at the animation event and see some examples here. Usually there aren't
that many examples. Some other stuff we'll see, especially with
the setting event. We'll see in a little bit how we can, in a future lecture, how we can basically
implement that when we have the sitting
animation as well. But for the time being, we want this and then what
we want to add it to the registered controllers
event is following. Once again, of course all of
this is available to you in the GitHub repository and
individual just as well. Let's actually take this one. So this is animation data
at animation controller. We're gonna make a new
Animation Controller just with an animation controller here. And then we're just
going to pass into this dot-product kit or
this colon colon product. And this product
here is asked in, and now these
animations should be, well, basically, basically
functional already. That's actually all
that we need for those particular
animations here, because we've already
set everything up with the model right here. This is points to the
actual JSON file. We've updated it and exported it all from the
block bench right here. Worse, if you want to have
some crazy cool animations, There's always, there's a lot
that you can do about it. But like I said, overall, it's just a matter
of trying it out. Being open to experimentation one more time right here, right? I mean, we're not gonna go
through every single thing and you're just going
to also have to try some things out on your own. But overall, this is
pretty much how you do it. Yes. Let's see if it works. Or what we found was back in Minecraft. And as you can see, the actual animations have been added successfully to the game. So you can see that you know, the walking animation as well. So both of those
work by the way, the sounds also work from last
lecture that we can hear. Those also work. Let's actually get the deaf
sound I think was from a pig. Let's hear that as well. Yeah. That's a kind of
weird, but okay. And then the actual ambient sounds or from the
dolphin, I mean, it doesn't quite fit,
but it's kind of funny that actually works. But most importantly, the animations work,
as you can see, that that's really cool and was fairly easy to implement
all things considered, I can tell you what
definitely easier to implement some of those
custom animations. In this case, rather than doing them with the
vanilla model stuff, that is way harder, I can tell you that, but
pretty cool. Nonetheless. That is already at for
this lecture right here. I hope you found this useful and you'll learn something new. And I'll see you in
the next lecture.
106. (Additional Topics) Add Entity Variants: Or I welcome back to the
fabric course for 118. And in this lecture
we're gonna be adding custom mob, variance
to Minecraft. So what this means is basically, you've probably all
seen the horse entity, the horse mob in Minecraft, and it can have different, different colors or
different codes. And this is exactly what we're
gonna do for the raccoon. Now this is surprisingly a very straightforward
thing to do. Now there's quite
a few places where we actually need to
add some things. But mainly of course
in the entity class and also in the renderer, if I'm not mistaken, yes, it's in the renderer and
in the model actually, there's quite a few places where we need to change some things, but no worries there. It's actually once you sort of understand what
we're doing here, it's actually fairly
straightforward. But the first thing
that we're gonna do is in the entity package, we're gonna right-click new
package called a variance. Then instead of there, we're
gonna make a new Java class. We're going to select enum, and this is going to be
the raccoon a variant. Now I will copy over
the contents of this. However, there are going
to basically be the same every time you
make a new variant. This is how it looks like. The only things you need
to change is basically the actual references here
to the name of this class. Otherwise, it's fine. And then here, just like any other enum that
we've seen previously, you just list all of
the different while enums here and then
just recall them. I mean, here this
is like probably like green and this ID that's probably a little
more sensible here in this case, whatever
the case may be. So we're going to have
a default invariant, a dark variant and
a red variant. Now, how do we choose these? How do we know what is
going to happen here? Well, what's going
to happen is in the raccoon renderer
class right here, we're going to add a map. Once again, I will
actually copy this over. However, it's very
straightforward once you actually see how it looks like and then
it looks maybe a little crazy and
at the first sign, but then you're gonna be like, Okay, that's actually
not too crazy. The only thing
we're doing here is we're saying location bivariant, a new map from Raccoon
variant to identifier. Which just means that if the, if we're passing
into this variant, the default raccoon
varied right here. We're just going to
point to this texture. If it's the dark variant, we're going to point to this texture. If it's the red variant, we're going to point
to this texture. That's literally
all there is to it. If you have multiple ones, you just add more here, mapped output and then with a new variant and
so on and so forth. That's it. The actual texture
location here and now it has to be changed. So we have to say location
bivariant dot get. Now the question is, well, how do we get the variance? Well, we have to somehow get
the variant into the entity. This is what we're
gonna do next. We're going to leave this
area here for the time being, and we're going to change
some stuff in the entity. This is a little
more complicated, let's say, where there's
more parts to this. However, I'm once again, I'm actually sure
that will be fine. I will be copying over all of the different methods now this is gonna be
quite a few of them, but let's bear with me and
let's go through this. I will then explain all of the different methods that we're gonna have one error here, that is the data arrows. So we actually need
something that is called a tract data of type integer. And I'm going to actually add
this to the very top here, because usually I do like the actual practice
data here to be at the top and then
no more errors in the entity class
should be present. And then we'll actually go
through and explain what the FREC is going on right
here. But what do we have? We have first of all, this data tracker, this
is interesting, right? So the track data here
you can see is a, well, it's a way of storing data in an entity that is tracked through both the
client and the server. That's of course very important
that those are the same. And we can see for
an example here, if I click on the animal entity press
Control H and for example, will go into the
OR space entity. We can see there are some
practice data things in here. You can see there
are some flags. There is the data
of the owner UUID. And I think that we
can even go further in the maybe in
the horse entity. There you go. We have an armor boneless
ID variant here as well. And this is pretty much
exactly the same world works. So this is pretty much
where I've gotten how this works from
the horse entity. So once again, it's just goes
to show you one more time. It's all in the vanilla
classes as well. You can take a look at
them and you can just find almost anything
in there as well. They are the West tool and the best resource that
you have at hand. Now what else do we have in the class where we
use this, right? So we're going to use this. You can see first of all here
in the init data tracker, this is incredibly important. You need to add this
year, otherwise it's not going to work. We need to initialize this data. The tracking of this
actual type of data. And then we can see we
have a set variant method that is actually only used in this particular class and it's used only in
the initialized method. Whereas the initialized
method, well, this is called when one of those entities spawns and
especially when it's bonds, for example, through a spawning. What it's supposed
to respond egg, what we of course want is we
want a random variant here. We're gonna set that variant and then we're gonna be fine. Lets us what happens here. Then we also have a right and
a read method for NVT data. This should be fairly
self-explanatory. We're just saving
the variant right here and then we're
reading it out right here. Pretty much everything
you need to know, sending it once again, also
fairly self-explanatory. This is the only thing
that's kind of weird here with this end. And in the 255, this is just something
that is needed. I'm not gonna go into
too much detail. It's just some Java shenanigans
basically with the ID. Because in the variant
right here you can see it's sort of
saved in this manner. So we're just going to basically keep it like that and
be fine with this. And we're just gonna say,
okay, it is what it is. This is how it needs to be done, but it all works fine. That's pretty much it. Those
are the different methods. And now of course what we
can do here is we can say entity and the T.
There you go, Right? Entity dot get covariant. And then there you go. And then we need to
do the same thing in the model right here, where we of course
also have the texture. But we can literally take
the same thing, this one. And we just have
to say right here then the raccoon renderer, This is what we want to take
that location bivariant, but get entity, get variance. And that is it. Now of course, we still
need the texture, so let's not forget to copy
over both of the textures. Otherwise that
would be definitely a little bit of an oversight. So let's go raccoon,
there you go. And then we have raccoon dark and the red raccoon as well. There you go. And that should pretty
much be all that we need. Let's just make sure that all of this is also written correctly. Raccoon dark should be fine, red raccoons also be fine. This should work. This should work and to be functional, so
that's pretty good. And that's actually how easy
it is to add some variance. Now, once again, of course, there are a lot of
different tiny things. Let's say the map here
shouldn't be too crazy. This shouldn't be too crazy. This shouldn't be too crazy. Same with the actual entity. The amount of methods
is not actually that much when you
think about it, is not that many methods. It's just a lot to wrap your head around
when you think about it. This data, data ID
tie variant, okay, There's a little
weird, but overall, it shouldn't be
anything too crazy. You know, at this point, I
hope that most of you have sufficient Java knowledge
for you to just breeze through this
and understand it from a Java perspective. And once again, of
course, like I said, the vanilla classes offer all
of the different examples. There are amazing and actually really good and you can work through them as well. But for the time being,
because we've added everything, Let's
see if it works. Or fat cells back in Minecraft. So let's spawn some
raccoons, and there you go. We already have all of
the other variance here, spawning happily. Here from the spawn egg, you can see it, everything works perfectly fine. And that's just, that's just
freaking amazing, isn't it? So in this case, of course, the variant really
is a little bit of a different wall texture
in terms of coloration. But I mean, that's still really freaking cool,
really freaking awesome. And I mean, it's just
working very, very well. And I mean, it's overall, I think and I hope that
you agree with this is actually fairly
straightforward and not too difficult to do. So That's really
freaking cool, right? Like always, of course all of the code is available to you in the GitHub repository in
individual just as well. But otherwise this would be it for this lecture right here. I hope you've found this useful and you'll
learn something new. And I'll see you in
the next lecture.
107. (Additional Topics) Add Tameable Entities: Or I welcome back to the
fabric course for 118. In this lecture,
we're gonna be adding the capability functionality
to our raccoon entity. And for that, what we're gonna
do is first and foremost, we're gonna change
the actual superclass here to attainable, attainable entity. Attainable entity. And then we just
need to copy this over to right here
to the entity type. And then we're going to
do the same thing to the attributes right here. And what we're gonna do then is we're once again going to add a few things now I'm
going to copy them over one more time,
but no worries. All of this is
available to you in the GitHub repository in
individual just as well. And we should get no
errors in theory. This will include, once again, at some tract a data right here, this type, this time
of type of Boolean. As you can see, a Boolean. This is the sitting Boolean. This is very important
because this is going to save the whether
or not this raccoon, this entity is sitting. Now there is already a setting. Let's say, what would you say a sitting variable
in the table entity, I believe this should be
here, right there you go. Private boolean sitting. However, this right here is I
believe only on the server. Which means that this kind of an interesting
thing because this is only on the server if we
now also add the following, a animation for sitting
into this one right here. So we're going to
add this as well. You can see if this is sitting, so this is my custom
Boolean right here, which actually takes the
data tracker sitting. If this is old, it doesn't work because
this right here, the everything gecko
lab does pretty much is only on the client. The animations will
happen on the client. Therefore, the sitting variable
has to be somehow tract. This is why we need to add
a custom sitting variable. This is why this one
exists right here. And this is why this one exists. And this actually calls
these set sitting. This one is actually
called the super method right here that
sets this to equal to it, but we cannot use it. The normal method is
sitting in that case, because that just doesn't work. Also a very important thing. Please note this
we have to add are sitting variable to the
data tracker right here. This is incredibly important. Please do not forget
this, otherwise, your game will crash when
you go into our world. That is very important right now on to probably the
big method here, and that is the
Interact mobile method. So we can see we have a set, set a is sitting method. The scoreboard is needed
for the actual team. So this is just so that
the actual thing of the entities central team
and then can be leached. We're just going to put
this to false because it has been a little bit of
an issue with gecko live and basically putting
the lead onto entities that
doesn't quite work. Whatever the case may be though, they interact mob method. What is this? Well, this is of course code
when you right-click a mob. Now, when we
right-click this mob, what we want to do, of course, is we want to attainment. Possibly. What I have here, for example, is the item for taming. I've just made a little
bit of a variable here. I've just set this to an apple. So if you want to change this, you can just change it here. And then we can see, well, if the item is actually the item for tamed that
we're right-clicking with. And it is, the actual
entity is not tamed yet, then what we're gonna
do as long as we're on the actual server. So this is happens
on the server. Then what we're gonna
do is basically Hey, just set the owner to the player that is
right-clicked it. We're gonna do some basic
recalculating stuff. We're going to send the entity
status here and then we'll immediately setting
it to setting the, after we've actually
tamed an entity, we're going to set it to sit. Interesting. Now if it already is tamed, were on the server
and the main hand is right then and
we right-click it, then we're going to just
toggle this setting. It's very important that we
have this hand here in as well because this is real issue. This is cold for both hands. So this is why maybe if
you don't have this, then it's actually
not going to work. I've seen that error or
mistake a few times before. Now, if we were to
run this like this, we would actually
have a little bit of issue and that is that the actual entity does not sit. Now, why
is that the case? Well, because we
actually have to add two more goals right here. And that is going
to be number one, the set goal with priority one, it is incredibly important
that this goal is above all of the
other wonder goals. And they look around
goals and all of that. Because as you can see,
where it's important that they sit goal is higher
than the wonder goal. Otherwise, what
will happen is that the raccoon will sit down and
then it's going to wonder, and then it's going to sit
down again and then it's going to wonder, and
this can sit down again. This is why the priority
here has to be, well, I mean lower in that
case, but a higher right? So it just has to be a lower
number here in this case. And then the truck
owner attack or a goal. It's just I don't even think that we necessarily
need this because I actually don't think that the
raccoon would even attack a attack someone that
detects the owner. But I'm actually
not sure about that because some of this has been taken from
the wolf as well. We can of course also
take a look at this. Just search for
wolf with entity. There you go. And then we can basically take
a look at all of the goals here you can see it's
actually quite extensive, like a lot of different things. Mainly attacker will
fall owner goal. And you can see once
again, the set goal is at the very top here. Priority two, very, very
important that this is the case. Otherwise, you might run into some issues. So
keep that in mind. This is incredibly important. Now, apart from that, the ability is actually
done like this. Is it taxable entity and then
having the possibility to tame it with exactly the
sitting variable here as well. Now the sitting variable,
if you have something that you don't actually
want it to sit, totally fine, then you
don't need to add this. You don't need to
add the sitting one. You don't need to add
this basically only need the interaction mob method. That is pretty much
all there is to it. But for now I would say actually because we've added everything
for completion sake, let's see if it works or if
council's back in Minecraft. One most important thing
here is also to say, by the way, when you're
using this in fabric, basically, every time
you go into the world, you have a different player, but it's very important
or a different name. So it's very important
that when you have this, that you sometimes, it's very hard to
sometimes test this. What are the case may be? Let's actually try
right-clicking. And there you go,
best friends forever. Now as you can see,
it's sitting right. So it's sitting usually what
I do is just encase it in a few blocks right here just
to make sure it says really, it doesn't say sitting
that's the actual entity. Stay there, but it looks
really good, right? I can also just move
away a little bit. It should stay there.
And once again, I can right-click it and
now it's no longer sitting. Now the animation has changed, and now it should also start moving either on its own or I, I didn't actually
put in a hollow, follow the owner goal, so it should just
do it on its own. There you go. Now it's zooming across at an I can just
right-click again and then it's sitting again and it should be
working totally fine. But that's actually
how easy it is to add the team ability as well. So that's really freaking cool. You can see that's
how easy it can be. And I mean, it's, you know, it's just
really freaking cool. I mean, that's with the customer animations
as well, right? You can make a custom
sitting animation. You can do all sorts of stuff. I mean, that's just amazing. That is already it for
this lecture right here. I hope you found this useful and you'll learn something new. And I'll see you in
the next lecture.
108. (Additional Topics) Add Rideable Entities: All right, welcome back to
the fabric course for 118. In this lecture,
we're gonna be adding a entity that is both
table and a writable. This is a very interesting
thing because of course, it's very similar to
the horse once again. But in this case, we actually
want a writable entity. And there's I would
say like, you know, a couple of things that you basically need to keep in mind. And for this, we're gonna
basically make tiger. Now this is really cool as well. So let's just start and how
would we go about this? Well, first of all,
of course we would go about and make it the tiger entity
class right here. Then I will actually,
once again, of course, like so often be copying
over a bunch of stuff here. Now for the actual tiger, I will be copying over pretty
much the entire class. Now, important is that, of course everything here
available like always in the GitHub repository in
individual adjust as well. Because this is also quite
a bit so bear with me here as I basically copy over everything including
the extending stuff. So we're going to see
you can see 270 lines and then I believe I need to have a closing bracket there. There you go. And now everything
should be working here, so we should get no errors. Now the first thing that there
is actually the type ID, actually we don't need that
actually that's a very interesting was probably
just still in there. But no worries there. We have the rest here. Pretty much sensible
table entity. We've seen this before. Attributes the product gets for the different animations
should be fairly sensible. The goals here register this, or this is pretty much,
you know, understandable. The T-Mobile is a
little bit different, mainly the Interact
mob method right here. So here for example, the T-Mobile item is
the term, of course, for the tiger doesn't
really make a lot of sense, but it's just an example
here, of course. You can see that
this entire thing here is a little bit
differently setup. So you can see that if
a player is sneaking, then we can actually
make it sit. And if the actual player is not sneaking, then
we start writing. You can see later
start writing this. So that's very interesting. So that's something to
keep in mind as well, that there's basically a little
bit of a difference here. When we sneak them, we make it able to be able to
sit the entity. And then if we just right-click, then if it's tamed, then
we start writing it. And also you can see that
we have this right here. So we have the possibility of actually having it randomly
assigned to the owners. So there's what we say, there's a twenty-five
percent chance, I believe, of actually getting
tamed here in this case. And then these
entities, statuses, this would be spawning
the hearts and this would spend small and I don't
want to be your friend. Basically. Different particles here. Once again, the sitting here, both with the SETT setting
and as well with the sitting detract
variable right here. This is also the same word changes the health right there, the actual team and
this, and then the init. And then here comes
the rideable part. The rideable part, pretty
much all of this has been taken from the
horse space entity as well as the horse entity. That is pretty much
all there is to it. I can once again just tell
you that you might be like, How did you figure this out? Like literally, I just took
a look at the horsepower, the horse base entity, the horse entity copied
over everything. I copied over the method
by method until it worked. That's pretty much
all there is to it and then changed
a little bit, I believe in the travel method, there were a few things
with the jumping speed, which I actually
have not in here. So the tiger entity
you actually can't jump is just one example here. Once again, highly recommended. Just check out the horse space entity and the horse entity if you want some more
basically functionality here. And then we just have
two interesting methods, which is the update
passenger for dismount and the locates saved
this mounting position, which are really
just used to, Hey, where can the player now
go after disk mounting? That's all there is to it. So those look very complicated,
completely copied over. We don't need to go
into them too much because the name pretty
much already says what it does and we don't
need to understand every single little
detail in the most, let's say the most, the highest resolution possible. That's not necessarily the thing that you always want to have. It's like okay, locate saved, dismantling position,
you know what this does? It's like, okay, it just
locates a position in the world where we can spawn the player after this mounting from
this writeable entity. That's all there is to it. Usually that should
be pretty much fine. And overall, like I said, you can always take a look at some other mounts right here. So if I press Control H right here you can see
horsepower entity, a horse entity,
highly recommend. Take a look at this. I mean, everything is in here. I don't know what
else to tell you. Basically, at this point,
the actual vanilla stuff is. It's very prevalent and just a very good thing to
basically take a look at. Now let's add the renderer
and the model as well. So there's gonna be
the tiger model. Of course also the
tiger renderer. Go. And once again, stuff
here will be copied over, but it is fairly
straightforward. All things considered,
you can see just an animated video model of tiger entity and
then just pointing to with the three methods
here one more time. Let's actually add this
as well. There you go. And then for the
renderer, I mean, that's gonna be even
funnier. Basically. This is even less,
as you can see. It's just once again
the context here, the actual location
for the texture. And that is pretty much it. This time we won't have any
different variants here. But of course this is something that you could add as well. We use seen it, how it works with the raccoons,
so no worries there. Then we're going to make a
new entity type right here. Once again, pretty much the
same thing as the raccoon, just tiger any tier
targeted here. In this case, I'm actually
having it a creature as well, just making it a different
name here of course. And then just having a little bit of a different
dimension here as well. And that is pretty
much all authors put. Now this is actually
almost all that we need to do now
in the client here. Let's just duplicate this
Control D and then say tiger. And then here this is gonna
be the tiger or renderer. That would pretty much be what? I mean, this is pretty
much all there is to it. Now we need to also
add the JSON files. We have, of course, the actual tiger model as well. So it's gonna be right here. We have this tiger
model as well, which is of course
available to you once again with some of the different
animations right here. So this is all available
to you as well, including the JSON files. We're going to just get the
tiger animation over here. Go. And then we also need the drill, of course, and then the texture. Last but moment, Let's
get the geo here. There you go. Then the texture should
be under entity, and then a new
directory called tiger. And then inside of there, we're going to add
the tiger PNG. Interestingly enough, that is actually all there is to it. Now of course, once again, a lot here was copied over. All of this is
available on GitHub repository and just as well, usually a lot of the stuff, most of this is fairly straightforward, all
things considered. I think that most
of this is the same as the raccoon with a
capability especially. And then also when it comes
to the right ability, like I said, vanilla classes, that's the best thing
you can take a look at. Now let's not forget to also add the registries right here. So this is gonna be the
attributes right here. So that's good to Tiger. And then this is going
to be the tiger entity. They ago. And that should pretty much be all that we need for
the tiger entity. So like I said, I mean, I don't know how often
I have to say it, but the vanilla stuff is all
there for you to look at. If it's kind of
hard to understand. Once again, you just need a little bit
more Java and glitch, the job introduction, trying out some stuff and be open
to experimentation. Just try it out. See how far
you can get without just, you know, just trying out stuff. I mean, at the end of the day
you always have control Z. You can always just go back. If you have a GitHub
repository setup, makes sure that you and
push your changes often, you can always revert then if something completely breaks, that is also something to
basically keep in mind. But for the time being, this is actually all that we need. So I guess let's see if it works or where we find
ourselves back in Minecraft. So there was, of course,
one thing that I actually forgot
and that is adding the actual spawn, the spawn egg. But no worries, we can just some of the tiger like this they ago and then let's
see, so it works. The animations also
work immediately. Let's see, right-click. I
actually got very lucky here. Now I can right-click
it and they go, now I'm writing on it
and it's very fast. Now, what's very
important here is that I actually can't go up the
stairs as you can see, because the issue
there is that the, I can't actually
jump with the Tiger. This is what I
said, where this is the way that it's set
up at the moment. And then if I just shift right shift or
Kraut, and it works. And then if I can basically
shift right-click, then it no longer sits. And now it should also just move about how it normally does. Let's see, let me just wait for a second and it's
probably going to go, I think that the tail actually
wiggles a little bit. It's a very strange
one. But there you go. Now it starts walking. And they ago, there's a little bit of a weirdness
of course going on. And like always write
with the entities. I mean, it's just
also about refining. The actual speed here that you go with is it might
be a little bit too high. I think that that's something
that you could also change. But overall, it's pretty cool and that's actually
how easy it is to add a writable entity to Minecraft writing just
for completion sake, let's actually also add the
other spawn EKG right here, because that just makes a
lot of sense. There you go. The most important
thing are the, the two colors here. Otherwise it's gonna be the
tiger, tiger spawn egg. And of course here as well, the tiger spawn eg
of tiger, they ago. And then we just
need the JSON file, but we can just copy over the other JSON file
Because of course, like I said this
morning, Jason Hall is like the easiest thing ever. It's just gonna be the
high gross Baunach. And we can actually
keep this as it is. We just need the translation. The tiger spawning, then here as well, the tiger spawning. But now we have everything
here setup as well. But that's gonna
be totally fine. But yeah, that's pretty
much all there is to it. Like I said, any modifications, you are free to do any
modifications here, just try out a bunch of stuff. The movement speed,
as you can see here, is quite advanced here. So it's when it's tamed, actually have quite a
high movement speed. You can also take
a look at some of the other goals as well. Once again, everything
here is available to you in the GitHub repository in individual just as
well copies of over, try out a bunch of stuff, look
at some vanilla examples, and then I'm sure
that you will get to hopefully the
entity of your dreams. I can also of course,
always recommend some of the GitHub repositories
of other popular modes where you can also take a
look at their code and that is also always very,
very valuable. Usually now, you will need
quite a bit of Java knowledge, at least intermediate
to advanced. Otherwise, sometimes you will
not get through it because other people might have
different ways of, let's say, coding and programming in Java, then you do so
sometimes you will need to get used to reading
other people's code. It is different than reading
your own definitely. But I mean, whatever
the case may be, this is it for this
lecture right here. And this also
concludes the sort of entity excursion that we
did here for the lectures. But still I hope you found this useful and you
learned something new. If you did, I would very much appreciate a review from you. Otherwise, I will see
you in the next lecture.
109. (Additional Topics) Adding Entity World Generation: All right, welcome back to
the fabric course for 118. And in this lecture
we're gonna be looking at entity world generation. What does that mean? Well,
basically we want to add our custom entities to the world generation
so that they spawn in particular biomes. Now this is incredibly easy
to do, like genuinely. In our gen package, we're just going to
make a new Java class with the mod entities form. Right here we're going to make a public static void
called add entities phone. The more I'm gonna do is
I'm actually going to copy over the two things
that we need, but it is incredibly
easy because you can see really freaking easy by
modifications that adds phone. Let me just once again it needs some biome selectors here. In this case, we're
just going to get the raccoons to spawn in the plains biome and the tigers to spawn in the jungle
biome. Anything else here? The spawn group
just has to match the actual group of
the entity here, the weight determines
how often they spawn. If you increase this, they're going to
spawn more often. But do be aware that other
mobs then spawn less. And Min group size,
max group size should be fairly
self-explanatory. Now, where do we call this? Well, in our modern
world and Jen, math class here in the generate
mode world gen method, we're just gonna say more
entities on Add, entity, spawn. That's it. We're done. That's literally all
that we need to do. Now, the actual the
actual entities will be added to the
game into the palms. I mean, let's just
see if it works. I actually went to
a planes by him to find some raccoons here, as you can see,
because they were a little bit easier to find as the tigers in the
jungle actually were. Well, I mean, very sparse. It might be because of the big the trees and the density of the trees where it's like
hard for them to spawn. But regardless, we're
actually going to take a look at one more thing in the code. It just now though that's which also is kind of
important or IDE. So one more thing that we
basically want to add for both the raccoon and the tiger
or the spawn restrictions. Though I can actually
show you those. Let's actually add this
to the tiger as well. There you go. The general idea is why would we
want to add those? Well, if we actually take a look at these
respond restrictions here, you can see there
are some locations that we basically wanted to say, Hey, where can those animals
or those entities are spawn. And you can see that most of them only can
spot on the ground, which is actually
kind of important. So if you were to, for example, add a, let's say a custom
zombie to the game. And you wouldn't add this
spawn restriction right here. It could also spawned in
the air and then just fall down who's deaf and
then that would be it. So it's actually kind of
important to add this. You can see this is
actually the animal is valid natural spawn. There are however, also
different ones that you'd see. Husk entity called entity, hostile entity can
spawn and dark. So there's a quite a few things here are highly
recommend checking out the spawn restriction
class right here in a net microphone entity or some more
information on that. But otherwise, that is
pretty much all that you need for the
entities spawn here. Like I said, the
weight sometimes is a little bit wonky, got to. Basically, depending
on biome here, you might want to make this
quite high or quite low. Just play around with
the numbers like always. But otherwise this would be it for this lecture right here. I hope you found this useful
and rulers of the new. I'll see you in the
next lecture. Yeah.
110. (Additional Topics) Add Custom Trades to Villagers: All right, welcome back to
the fabric course for 118. In this lecture,
we're gonna be adding custom trades to villagers. Now, this is once again one of those very interesting
things that is actually way easier
than you might expect. So please note, we're not
going to add custom villagers. This is not this lecture. This might happen in the future, however, no promises
at the moment, because that is
definitely a little more complicated than what
we're gonna do now. We're basically
just going to add custom trades to already
existing village of professions. And for that we're going to
go into our util package, modern registries and
write it down here we're going to make a private
void, a static void. Actually they use static void. This is the register
customer trades method. You will actually
be amazed at how easy this entire method looks. I will once again, of
course copied over, but all of this is
available to you in the past or an
individual just as well. And that is it. Those are two different
trade offers that are added. Let's actually immediately
call this right here before we forget it. And then let's go through
what is happening here. We have this straight
offer helper where we are registering
a villager offers. You can see register
villager offers. And then you can see with
select a profession. So you can see these are
the professionals that you have in just in vanilla. And we're going to
choose the farmer here. You choose the level at which the particular
things that you're about to add basically
should be just blade in. So this is level one. So the normal farmer at
level one has this attitude. It, you can see that there's
a factories and then you have this curly brackets here. You can add multiple trade-offs
or serious, you can see, I can also add someone
else like a turnip seeds. All of sudden, you know,
maybe those for like six or 24 or
something like that. And you could add multiple
ones for the same level. If you want another
level, you just have to add up this entire book again. But overall, this should be
fairly self-explanatory. The first item stack here is
just what you need to pay. So you don't have to
necessarily put in emeralds, you could put in anything else. The second one here is basically
what you get out of it. I believe in the trade
off or you can also add, if you add three different
items texts here you can see, then you actually
have two items that you need to pay with
that also works as well. This is of course something that is implemented in, for example, within channeling
stuff where you give in a sort, for example, and then I don't know,
like 60 miles or I'm ready to emeralds and then you
get an enchanted sword. That also works. So you can add a
third item stack and then that would also work. The next uses is just
how often you can use this basically doable, the merchant experience should be fairly
self-explanatory. That's how much experience
the merchant gets when you actually
trade this offer. Or some examples I believe
you can take a look at, yeah, You can take a look at
the actual offers here. So the experience
right here, Let's see. So this is the actual
suspicious stew factory. That's something different. Let's see, maybe we can
find someone else here. I'm not 100% sure where the actual normal
trade offers are, whether or not they are, they
are others in this create right here, this experience. Let's see. There you go,
okay, There they are. It can see there is
some of the experience. There you go. They're actually in the trade
offers class this year. And they actually use
this by one for emerald. And you can see here
experience to two. So that's actually a
quite a low experience. River have one experience, five experienced
and experience with 6120 might be actually
a little bit too high, but you can just play around
with this of course as well. Price multiplier is just the
multiplication of the price. And that's pretty
much all there is to the normal items
tax here you can supply the count and that's pretty much all there is to it. Here we have one
for the tools myth, where it's six emeralds
for the oracle come Paxil. In level three. That's
literally all that there's two are highly recommend just playing
around with this, like always be open
to experimentation. Take a look at both the
trade offer in the trade offers classes to see
some vanilla examples. And for completion sake,
let us see if it works. Or influencers back in
Minecraft and I've already prepared some villager
trading booths, let say no, but here you can see the farmer already has
the turnips right here, so we can just trade with him. And you can see, there you go. That's really freaking cool. And then here Let's just trade
for some tools right here. And let's also get
some colon there. And let's just see that
we can trade with him until he reaches a level three. Basically they go
get some bells here, get a little bit
of this one going. Maybe a little bit
of iron as well. Level them up as well. Go a little bit of this, get some more of this. That's a little bit
more coal and then we should be able to get
them to level three. There it is, there the
oracle compact soil is, well, there you go. That's really freaking cool,
really freaking awesome. And well, that's
actually how easy it is, as you can see too. Well, basically add some
custom traits to villagers. That has already for
this lecture right here. I hope you found this useful and you'll learn something new. And I'll see you in
the next lecture.
111. (1.18.2) Fabric Update to 1.18.2: All right, welcome back to
the fabric course for 118. And in this lecture
we're gonna be updating our MOD or a project
to 118 to do that. Or of course, we're
going to need to change stuff in the Gradle
property file. We're not actually going to check this particular website. What we're going to check
is actually the fabric net develop website because this also has the latest
stuff right here. Just copy this over and
basically just paste it in here. And then I'm just
going to make it so that everything is
formatted correctly. But no worries there. They ago. So we're just going
to change all of this up. And then one more thing
that we want to change, of course, first of all,
hit the mod version. Let's introduce some terms like 19 or maybe even
all Let's do 21. Yeah, That's amazing. Then also in the
built or Gradle file, we want to change the Looom
version from ten to 11. And after having changed this, what we can do is we can
load the Gradle changes. Now this should be pretty
much everything that we need. Just let this run
through like always, be patient until this is done. And there we go, 22 seconds. It might take a little
longer for you, depending on your
internet connection and stuff like that. What we also want to do
just in case is updated to the newest version
here for gecko lip. So this is right here, 035 just in case because even though the other
versions should work, I just feel a little
bit better if we have the newest version as well. But you can actually do
that before you reload the changes and then you can reload all of them
at the same time. So let's just let this
run through again. And then there you go. Actually only seven seconds. That's even better,
but that should be pretty much all
we need to do here. Now however, we're going
to run into some issues. Namely what changed is world
generation and the tags. So if we go into the
mortar tax class, you can see all sorts of red, but no worries, we're
going to fix that. So what changed is that we no longer have the
TAC identified. This is now called the Tab key. So I'm just going to put in
tacky and we're going to press Alt and Enter
to change it. And what we basically
want to do is change all tag identified
to this tack he, so what I'm gonna
do is I'm gonna elected press Control R, and then we're gonna replace
all of them with TAC keys. Let's also get rid
of the imports right here, because we no
longer need them. Because this right here now
is gonna be actually tag E dot o f. And then we need to pass in the first parameter, the registry data
block underscore key. And we got to do this for
this run right here as well. We're gonna do the same thing. And then down here
we're going to just copy it over for the moment. And then we're gonna change
this to, of course be. And then we're gonna change
this to the item key. They ago, Same here, item keep. And then we should be fine. That should be pretty much
all that we need to do here. We now of course, also
need to change this in the custom dowsing rod
item class right here. So there's a couple of
ways that we can do this. There is one, there's
one way that is very complicated and only
requires us to change this. And then there's a little bit
of a more complicated way where we actually use
the block state here. And I'm going to do
the block state way because I think
that that's better. So we can just do say
block dot is in and then mod attacks dot blocks that dowsing rod or
detectable blocks. Of course, the issue here
is that we're actually passing in the actual
block and the block state, which of course is
not quite right. So what we need to do
is, we're gonna do, is we're going to
duplicate this by pressing Control D. And this is now
gonna be the state below. And we're gonna change this from a block, the block state. And then just not calling
the get block right here. You can see now we
have the state, we can now do is instead
of cooling all of this, we can use the state
to get the blocks. So we can say that
we can say state below that get blocked
for getting the block. And then here we have
the state below and then passing into the block state
instead of just the block. That is pretty much
all of this stuff that we need to change right here. And this will now still detect all of the
things for the tags. The Paxil item should just work. We don't actually need to
do anything here because it's actually
expecting a tag key. As you can see there you go. Also very important because I've just seen as the sources. What we're gonna do is once
again go to the terminal, put in dot slash, Gradle w, Jen sources and let
this run through as well. Might take a minute or two
to generate those sources. Once again, depending
on your PC and also depending on your
internet connection. Or just be patient and wait until you get a build
successful here. There you go to
exactly one minute. And now we should
be able to do is when we get the blue
line right here, we can go to choose
sources and choose the merged name source
right here, say Okay. And then after this is reloaded, it should now show us the proper class with the
proper sources there. But that's also one
thing that we should do. And now the real
doozy is gonna be the world generation because that has changed
quite significantly. Well, what has changed
is the syntax really? What we're gonna do is
we're gonna just go into the mode configured features class and you can see a
lot of red right here. Of course, all of the changes, all of the stuff is
available to you in the GitHub repository, in the individual,
uh, just as well. I highly recommend
checking that out because there's a lot of
stuff that has changed. And we're gonna go through the basics of how I can
basically change this. So first of all, we now have a registry entry right here instead of just
a configured feature. And what we're gonna do is this is now going to be instead of calling the configured right here on this tree feature, what we do is we
want to delete the configured and the dot, replace it with a comma and then delete the parentheses here. Then instead of using
the register method, we're gonna use the
following method. We're going to use the
configured features. This one on configured
features that register method. Get rid of all of this and now everything's still working. So as you saw, we have to change this to the registry entry into the feature dot trich dot configured to just
the feature tree. And then basically passing in
the rest just as normally. Now instead of going from configured feature to configure
feature to place feature, we now actually have to put in a place feature in-between. Now what I will do
is I will just copy over the place feature and
the configured feature. Now I will do this and keep the already existing
stuff right here. You can see this is very similar to what we've
already heard, half. So you can see this is the
random future conflict. This is the same thing. And then here are
the woods survived. Now is just the actual
check right here. So the woods survive now happens in this place
feature right here. And you can see that the rest is pretty
much exactly the same. It's a little bit different, but overall it's not that crazy. I highly recommend once again, just like in the
normal world gen, lectures that we did, just check out the, for example, the random selector or the
brief feature right here, middle mouse button
click on this minimalist one, click on here. And you can basically see all of the stuff
that they're doing. You can see it's swamp
old for example. You can see the place
feature of the swamp, OK, and so on and so forth. Just like we've went through in the original world gen lectures. I highly recommend doing that. When it comes to the pink rose, I'm going to do the same thing. So I'm just going
to copy that over and see that we're using
the Configure feature, that register method now
and then once again, passing in the flower here, random patch feature
conflict is pretty much the same thing
because we're using the same thing down here. What we actually
can do is delete both of those methods
because we're no longer going to use them. And see we are using the configured feature
register method and the create patch right here. We're just gonna
do that in line, so that's gonna be fine as well. Then the actual list here of
the auras can stay the same. And then this one is
the easiest to change. What we do is once again, get rid of the
configured here and the closing and
opening parenthesis. We want to change this to a
registry entry right here, they ago and then this
one is actually of configured features
that register they ago. And now there's one more
thing that we need to do and that is take this or future conflict and change the first a question mark to
that or feature conflict. Now this class has actually done the problems we're gonna
fix in just a moment. Those are of course issues with replaced features and stuff like that and also with the tree. So if we go into the
sapling generator and C, This is also no
longer valid rhetoric here is just to delete
the actual method, hover over this
Implement Methods, then everything here
is written correctly. And then we can just
say mod configured features that the cherry
blossom tree. There you go. And then immediately
should work. No more modifications
are required. Let's move on to the
MOD or features. Now, you see a lot of red here. This is just because of the
actual class has moved. So what we want to do is
just import them again. So click on them Alt and
Enter to import this. You can see there you go
on placement modifier, My dad as well. There you go. That should be pretty much
all we need to do here. Now the rest is in the
marketplace features. So the first thing that's
really cool is that we no longer need
the registry keys. So that's gonna be just
get that out of here. We also no longer
need these methods. We can do is we're
gonna just going to use the placed feature data register method that we've actually
already used right here, please feature dot register, so I'm just gonna copy
that over to the new list, right here, right here, and
right here, and then here. Once again, we don't want to call the placement
on the actual, on the actual
configured feature. What we want to do is we want to pass in the
configured features. So this should be a
comma and then this should be the spawn. And then let's get rid of this and this, and
this is not a, a place feature about
a registry entry, once again, of a place feature and then it should
work totally fine. So you can see they ago
working totally fine. Let's just add the
registry entry here for both of them as well. And then once again
changing it to leading the width placement
and the dot as well. There you go. We need to import those. They're just changed. There you go. Already working. And then same here with placement
is gonna be deleted, replaced with a
comma right here. And then this is also just
going to be re-import it. And then all other inputs
that are no longer valid, we're just going to get rid of. And they ago, that
is literally at, that is pretty much all of the
things that we need to do. It is almost pretty crazy, but It's not that much when
you really think about it. Like looking at everything here is, it's fairly straightforward. All things considered. A few more things
in the generation, but that is actually
also fairly trivial. So it's just the how you write
it basically that changed the underlying functionality
stays pretty much the same in the generation classes
we put in the key here. What we can do now
is we can just take the flower generation. So we want this one, dot, dot, dot, and then that's it. So we just want to replace
this with the dot, get all of the
different things here. So this is gonna be the Oracle
complaints dot, dot get. And then same with a tree here. This is the cherry blossom
placed, but get ky.gov. And that is it that should pretty much everything
that we need to change. That might be like a couple
of other things somewhere. But I believe that this is it. What's really funny
as well is that the tags and the world is
like the big things that change would also change for whatever freaking
reason is the actual. Whereas in the util
at the title screen, I don't know why,
but the title screen doesn't work anymore properly. This is I'm actually, I mean, I wouldn't say furious, but I'm a little angry about it because I had this sort of almost completely
custom class that I took a little bit from forage
and remade it a little bit, and then it worked totally fine. And now for whatever reason they changed to change the
title screen again, and I don't know why, but it is what it is. Sometimes those
things happen though. We've just got to
deal with that and you're going to see more. I mean, in just a moment
when we actually do this on, let me actually
check the conflict. And we turned this off. Yes,
we do have turned this off, so let's just turn this on
so that we can actually see what the difference
is for the title screen. You're going to see that
currently doesn't really work. So this is also one of
the other reasons why something like a conflict for the title screen actually
kind of important. Let's actually
start this and see if we're getting any errors. I'm not a 100% sure we
shouldn't get anything. It might be like
one or two things that were maybe an
import is missing, but it does look, kind of
looks good at the moment. So let's just see, let it just run through
this, of course, our normal arrow that we always get when we
start Minecraft. And I believe that
it should be fine. It starting on the
other monitor. Let's just get it over here. And then we also,
you can see that the issue here, of course, is there's no splash title right here and then
that also in the left, bottom left, the actual version and stuff is also missing. I don't know why
that is the case. They changed it somehow in
the backend on their code. But whatever the case may
be, it is 1, 1000th 2. And what we can do is we
can just create a new world and let's just make a new
world and let's actually, everything should still
be working totally fine. So this goes from the entities all the way
to the block entities, all the way to the
no spawning of trees and everything in-between
should still work totally fine. So that's really cool
and let's check it out. The spawn pretty
much doing exactly. I mean, that's great. That's also a really
interesting spot right here. But yeah, the trees
are still mourning, the actual flowers are
still spawning as well. That's gonna be really cool. And let's just take a look at all of our course
stuff right here. So let's just get this over
and see the tiger still working as the raccoons still
working variance as well. So everything is still
completely fine. And let's actually also
test the dowsing records. That was something that changed. And we're gonna see once we find something they
ago found iron ore, so everything completely
fine, still working. Don't no worries there. Yeah, that's pretty
much how easy it is to upgrade from 1820s. There are quite a few things that you have to keep in mind, but overall it's not
that bad, right? So obviously, all of the additional topics that will come after this are all
going to be for 182, highly recommend of course
now updating to this, you should probably be
through at this point. And then we can continue with some additional
topics in 118 to, but that would be it for
this lecture right here. I hope you found this useful and you'll learn something new. And I'll see you in
the next lecture.
112. (1.18.2) Custom Structures (Tutorial Example Repo): Or I welcome back to the
fabric horse for 118. In this lecture,
we're gonna be adding custom structures to Minecraft. Now the way that this
is going to work is this lecture and the
following two lectures are going to be on structures. Now in this first lecture, I highly recommend that you
go through with me through this lecture because after we've basically implemented
structures once, adding more structures to
it is incredibly easy. You just have to copy over some JSON files and basically
build your structure, save it, and then that's it. It's very, very straightforward. But this lecture, as you will probably be able to
tell, is quite long. And the reason for this is
because we're going to go through this
repository right here. This is the structured
tutorial mod repository by a telepathic grunt. It is probably the
number one resource for custom structures. It is incredibly great
at, is really good. It has a lot of different
comments in every file. And it's just, it makes this
very, very straightforward. Now 1, 1000th 2 actually
introduces a way of making structures that requires
literally no code at all. Now that is really
freaking awesome, but we'll also see one particular structure that actually will exist with code. And we're going to
basically go through this. So I will explain how I go through this
particular repository. We're gonna go through
it in its entirety. We're gonna implement both of the structures that are
basically given to us here. And the way that we
go through this as we go on the source
folder right here, we're going to open the code and the resources separately. So first of all, we
want to basically look at all of the different
classes that we have. We're gonna see there
is one mixed in class, there is one structure class, there was the St. structures
and the main class. So we have four
different classes. And you can see overall
they are quite long, but you can see also there is a lot of different
comments here. Highly recommend
in your own time. Go through the comments, see what each part means, because some things are
very straightforward, others are not that
straightforward. I just highly recommend this. So you can see overall the nasdaq crazy when
you think about it. But basically, this
is where we start. So we're starting with the code. First of all, this is gonna be the structure feature accessor. I'm just going to copy this
over and we're going to start immediately right here
in the mixing package. Now, you can of course also
get all of the code and the JSON files in the GitHub repository of the course and the
risks as well. But I highly recommend
stepping through this once, basically working through with the actual tutorial code
of telepathic grunts, tutorial GitHub
repository I highly recommended or whatever the case may be in the mixed and package, we're gonna make a
V structure feature excess or with tuesday ago. And we should be able to
just paste this in and then import all of the important
things right here. The generation step as well. There you go. And that should be that now of course going to the MC course mixin Jason and adding this as a mixed
in here as well. That should be pretty much
what we need to do here. And then we're going
to switch back to the tutorial GitHub
here we're gonna, we're gonna close the
tab and then we're going to move on
to the next one. This is gonna be
the sky structures. I'm just going to
copy everything including the imports here. And this is going to go
into the world package, into a new package
called ruptures. And then instead of there,
we're going to make a new class called the modulus. This is the sky structures. There you go. And
then we're going to paste this in the go. We need to change it this
year to MC core smart, a logger, and then this
is not run-down house, but this is the sky fracture. And then up here, we just
need to change is this one. And then no more errors
should be present here. So everything should be working. Overall as you can see, while it looks like a lot, they are actually just a lot
of different common sphere. And everything is basically explained in those comments
I highly recommend, like I said, going through
this in your own time. You can see, for
example, this one right here determines Y position. This is placed stuff like that. I highly recommend
looking at this and just making sure that you understand
a little bit of this. You don't have to
understand everything here, especially if you just want, let's say, a normal
structure to spawn, then this is going
to be totally fine. If you want something
more extensive like a custom stronghold. I mean, at that point
it's gonna be very, very hard to actually do that. That's going to require
a lot more work. This is very much just for some, let's say basic to
intermediate structures. We now have these guys
structures class. So let's just close
this as well. And then we can see we need to have this st structures here. Now I'm going to rename this to mod structures because that's
the nomenclature I go with. And we're just gonna go with modal structures. There you go. And I'm just going
to paste this in, change this back to mod ruptures and you shouldn't that we
actually write this correctly. There you go. Importing the structure feature here, retro future accessor. This is gonna be MSC
course mod that model ID. Then this is the generation
step once again as they ago. And then you can see once again that is all
that there is to it. We now just need to call this method right here
in our MC course, more class and the
constructor right here. So modal structures don't register a structure
features and that's it. And then there's also the
last thing right here. You can see, there
you go, Nicole, this, and that is it done and done. Now, all of the code
actually is already created. And now the rest happens in the Resources folder and
namely in the data folder. Here, there is a lot
of stuff in here. We're going to find actually is just a lot of stuff you
can see, first of all, a tag. I'm going to explain
that in just a moment. And then we have
the data folder for this tutorial here you can
see we have structures, we have some more tags and
then also the world again. This tag is actually something we're going
to ignore a little bit. But this is the on
ocean explorer maps. This is something
that you can add. You can see microbe has some configured
structure feature tags that can add certain behavior. And in this case,
you can actually add the structure to
the cartographers, villagers, Ocean
map, monument maps. And basically this is what
this a particular tag does. You don't have to add this. I'm not going to add
it. This is just add an extra feature that
might be really cool. So that is something that we can basically also
pretty much ignore. We're going to also close
this and now we only have the data folder for
the structure tutorial. This is of course the model ID. So for us this would be
the data MC course folder. And you can see that there
are some folders in here. So let's open the first two because this one is actually
gonna be more extensive. So the structures fold on, just has the NVT data for
the extra structures. So the idea is that you
build structures in the world and then you
can use certain blocks. Those are called the
structural block to save that particular
building in NVT data. And we're gonna
see how to do that actually in this
lecture as well, because we need to change
some of this stuff in these NVT files as well. And then we're also
gonna see this in the next lecture and the lecture after that with a single
piece custom structure. And then also we're going to see the jigsaw structures as well in the last lecture of this sort of three lecture series
for structures. But for the time being,
we're just going to take these structures I
highly recommend, once again, going through
this tutorial ones, don't change too much. Make sure that this all works. If you have done all of this
and everything here works, you get the run-down house,
you got the sky fan. Adding a new structure is a
thing of five minutes max. It's very, very straightforward. And then of course you
still had to build it. But the actual code or the JSON files changing it
there is very straightforward. So get this to run once with
a structured tutorial mod. Then you can add
your own structures really highly recommended. It's just the best way to do it. We basically want to download
all of these in VT files. Now, I've actually already
done so what you can do is you can just open it and then download here and they are gone. Then you have this NVT file. You can see actually four I've downloaded a few times already. So you can see that
is pretty much there. So just download all four of them and you can of course also get them in the GitHub
repository as well that I have. What we're gonna do is
we're gonna go into the Data folder MC course, and we're going to
make a new directory called structures. And then inside of there,
we're going to need the following NVT files. All four of those. There you go. So we're going to need
the run-down house, left, right side, right side, Golden, and the sky fans. So those four we need in
these structures folder, data folder in your
model ID here. And that would be fine. So after we've done that, we can close this as well. And then you could see we
have the tags right here. So this is gonna be under
your data for once again, tags Belgian biomes
hold has structure. These tags are very interesting because
they will actually determine in what biomes your custom structure
can spawn in. Very straightforward to
understand what this does and what we're gonna do is we're just going to
open both of them. And I'm just going
to first of all create the actual
structure right here. So in the tags older right, under your model ID,
we're gonna make a new directory
called World Jen. And then inside of
there we want to make a new directory called a biome. And then inside of there, we're gonna make a new directory called has underscore structure, making sure that we
write this correctly. And then inside of here, we need two new files. So I'm going to do actually is because those are
very long names. I'm going to actually copy
this name right here. And I'm just going to
right-click new file, paste that name
in. There you go. And then I'm going to go back, paste in the contents of
this point here again, and we're going to take a
look at that in a moment. We're actually also going to
make the other file as well. So this is the adjacent
only house biomes. So this G Jason only house that we're going to spawn one
structure that we've made, the sky structure we've
made the code for, and the house is going
to spawn completely only with JSON files is
really freaking awesome. And I'm actually, I'm
actually very much, I'm surprised at how easy it actually is when
you get to see, especially in the next lectures, after we've gone
through this, once, you're gonna see
how easy it is to add multiple new structures, It's really straightforward once you go through this, once, I cannot recommend this enough, while it is a little
bit of time to set it up and to go through
and explain everything. It's gonna be very,
very worthwhile, right? So then we have the sky biomes. Biomes for the sky fan, you can see mountains is
ocean and it's deep oceans. You can see those are
tags as you can see. And then we also add this to the swamp or the only house you can see we're adding it to all of the stuff that it's a tiger, jungle, forest and
then also deserts, plains and some other
biomes as well. So here you can just
use the biomes. In specify in a word a biomes, your custom structure
is going to spawn in. So that's really cool. So we can close this, Let's
close all of that. There you go. And then we
can proceed once again. We can close this, close
this, and close this. And now we're back here that we've done the structures and we've done the tag has structures and now
going on to the world. And so I can actually open this in this tab and you can see there are four more
different directories here. And we can basically
open or four of them. And you're going to
see, Let's actually open the first three because this is gonna be a special one. And you can see the
first one just has once again to JSON files in it. This is reconfigured
structure features. So what I'm gonna do is
I'm going to copy the name here just so that I don't
miss type anything. And this goes, and this
is incredibly important. Please note here. Now this goes into
the world gen folder, not this world gen folder. In your data MC course
or your MOD ID photo, you have to create a
new world gen folder. Look at this. Look. This world gen folder is
different from this one. This right here is instead
of the tax folder, you can see, there you go. If I open this, you can see
those are different folders. This is incredibly important. Please don't make
the mistake to put everything in your tax folder. So please be aware of this. This is a different folder. I'm gonna keep this open
and you can see MC cores, rural Jen, you go there, everything goes in
and we're gonna have a new directory right here, which is going to be
called configured underscore structure
underscore feature. Let's actually create the
rest of the ones as well. The other one is the
processor underscore list. And then we're gonna drag
this into the same folder holding control to
duplicate this. And this is the structure
underscore set. And then the last
one is gonna be the template underscore
pool. There you go. Those are the four
different directories or folders that we need in the worlds and
follow once again, making sure that this is
in the correct folder, data MC cores world. Jen, this is not the tags
worlds and full of very, very important that you have this inner correct order right? After you've made sure that
this is the correct folder, you're going to go here
and we're going to open up both of
these rays and file. So once again, I'm just going
to copy the name here first consist just makes
it a little bit easier for me so that I
won't have to type this out. So what we're gonna
right-click new file, of course they ago, and then we're gonna
get the contents here. So let's just copy this
over. There you go. And then we're gonna go
in here. There it is. We're gonna change this
stuff in just a moment. Let's actually create the
other adjacent file as well as the adjacent
only house once again. And we're going
to go right-click new file, paste only house. And then we're going to go, and then we're gonna go
here. There you go. Once again, the contents of which it over N,
there we have it. But first of all, you can
ignore the arrows right here for the actual comments. Those are gonna be fine,
so no worries there. And now you can see that
this particular JSON file is basically the
structure feature or the feature that
we're going to add, the configuration of it.
What does that mean? Well, first of all, you can
see this actually goes back and points to your tag that
we've created right here. So you can see this
is the structure. Has structure, yes. And then code structure
sky fan of biomes, which is exactly this
Jason of Alright, here we need to change this
model ID to our model. Very important. We also want to change it
this smart ID to our mod ID. And just to make absolutely
sure that everything works, we want to also
change this model ID. So everywhere where it says the structure tutorial modality, we basically want to
change to our model ID. Now this should be
fairly self-explanatory. Like I said, this points to this particular
JSON firewall here, the biome tag,
which is basically responsible for telling, okay, this particular
structure feature or this particular
structure can only spawned in the biomes
that are inside of this tag should be
fairly self-explanatory. Nothing crazy going
on it right in there. They start pool is something we're going to add
in just a moment. This is going to be added into
the template pool folder. And we're gonna see
that in just a moment. This is basically the deep, one of the central pieces
of the generating of this. And then we can see we also have some spawn overrides here, where some Volcker's and
phantoms might spawn right here. So you can see this
is what mops can spawn overtime in
this structure. So this is something
that you can also play around with highly
advise that as well. Apart from that, the adjacent
only house is very similar. You can see the base structure here is actually
completely different. This is actually
a village or not 100% sure where
this makes sense. You can see this basically
does some extra terrain check. So I think that this
just means that this basically spawns
similar to a village. So it's going to check for a flat ground, stuff like that. And it's going to do
some things like that. I am not a 100% sure, but that seems to be the case. Now once again, the
structure tutorial, changing this to our model ID. Once again MC course, MC course. And this is the run-down
house sort pool. And this once again points
to the adjacent only biomes. So this file right here, to be fairly self-explanatory,
the adult noise, you can see there
is a great comment here what this basically does if true land around it will be around the bottom
of the structure. So this is just going to change the actual structure of the land around his
actual structure. And then once it
can span overrides, we can also add
some creatures hear sounds from parents might
spawn in here as well. So there you go. Now they
configured structure feature is done and then we
can move on so we can. Those, this one, this
one and this one. And then we can see
the processor list. Now this is a special Jason file which is actually not required. This is something custom. This is the randomized stone
break and is really awesome. And I'm going to explain
what this does as well. We're going to create
this in our process, our list older right
here and my stone brick. And then let's go back
to here and let's just get all of this
craziness in here. And this basically does is
in the general gist here is c process list will
run a processor for every block placed I
edit the NVT file. When we create our
custom structures. This is of course all saved
in the NBA in an MVT file. And then basically for
every block that is placed to this processor
runs through it. And you can see,
this is really cool. You can basically specify
certain rules here. And the rule here is
that, for example, if we find a stone brick, then it has a 50% chance of being replaced with an
infested stone brick. This is really awesome
and this is really cool. You can see here, some
stone bricks might also be replaced with emerald
or some cobalt. Deep slate might be replaced with a deep
state restaurant war. This is really cool and
this might just be, you can basically add
some more variability to your custom
structures with this, with these rules here. So I'm not 100% sure of all
of the rules that exists. This is of course just one example where
you can basically change one block to
eight another block. But it is really cool
and this might just be a very cool thing to basically add to some
of your structures. But once again, this
is not necessary. This is completely optional. So you're going to see
that this is going to be used in the sky
structure right here, but not in the house. The house is actually
not going to use this. So that's what I'm saying. This doesn't have to be added, but it is still nice. And I highly recommend
for the purposes of this lecture and the
structured tutorial, I highly recommend
adding this as well. All right, so we can
close this as well. And then we are in the
world trans structure set. But once again, we
can open up both of those Jason files and I'm
gonna do the same thing. I'm going to copy
the name over here, and we're going to do a
new file. There you go. Then once again, we're
gonna go here and just get the contents of which you can
see actually not that long. And once again, we're
going to actually create a both of the files
first and then we're gonna go through the contents and what those actually mean. They are not that crazy. Overall, each
individual part here is not that complicated,
all things considered. It's just that sometimes it might be a little bit daunting
because there are so much, but when you
actually look at it, the individual parts
or not that crazy. So first of all, of course, once again, the structure here, this not 100% sure, but I believe this points to the configured structure
feature right here. So this one, we can
just change this to MC course and then it's going to point to this JSON
file right here. And then the placement
is very important. The placement here,
you basically want to make sure that
your salt right here you can see make us
unique and makes sure that it doesn't match
any other sets salt. Now the reason for this
is because otherwise the actual structures would be placed at the same location, which of course is
something that you definitely don't want to do, because that would
be just very weird. Sometimes it's still
happens that they are going to intersect, but that is just the randomness. It shouldn't usually happen, especially if you make
the separation here. So the spacing, this is
the average distance apart and this is the
minimum distance apart. And then of course, this must be always smaller than this.
It makes sense, right? If the average distance is smaller than the
minimum distance doesn't make any sense at all. So there you go, just make sure. And I believe that this would definitely be debugged values because 166 you're going to see once we actually
go into the world, that this is
incredibly not rare. This is incredibly
common in this mix, our, our different
structures insanely common. So keep that in mind, but I recommend keeping those
numbers for the time being. Same here with the
Jason only house. We're going to change it, this
one right here, MC course. Then we can also see
this one's again points to this
structure right here. Now, what you will find is
that this is of course a list. So in theory, we could add
another structure right here. So you can, even in theory, at the structure Skype and wherever you can assigned
the different rates here. We can see in this
comment that it basically tries and picks
one of those structure. If two or more
structures analysts can spawn in a biome in a spot, a random one will be chosen
based on the weights. This is the general idea here. So you can also make
a list of a lot of structures and
basically have one of them spawn in a
particular place. So that also would work. So this is the structure
set basically pointing back to the configured
structure feature, the concern, the structure feature here, of course, pointing to
the tax right here, and then also pointing
to the template pool, which is the last thing
that we now need to add. So we're gonna go back to the GitHub repository
right here, and we're going to close
all of this and then open the template pool
because this is like I said, a little
more complicated. I'm going to get the sky fan and then also the
run-down house. So we're gonna
make it like this. We're going to get
the sky fan first. Actually, that's gonna
be a little bit easier. So this is just
the sky underscore fan base and file
inside of here. So we're gonna make a
new file. There you go. And then once again, copying
over the contents of this also not that
long as you can see, this, in this case, what
we want to do change this one right here are
the actual more ID. I don't think this is
entirely necessary. You can also see this actually points to the side
pool right here. It doesn't really make any sense because this shouldn't
be the case. This should actually
be its own name. So this should be Skype. And I believe that
this is actually not that important to
the actual name here. And then you can see this one of course as well, MC course. And you can see this one as you can see the final path here, resources data
structure to roll with. This would be MC course
structures run on house left note this points to the
sky and swore fan and VT. So this name right here has
to be the same name as this. So the location right here
points to the MDT file in the structures folder inside of your MC course folder in this case, because
we've done this. Now you can see
that we also have the processors
randomized stone, brick. There's also needs to
change to MC course, right? So same here, MC course. This then looks for the processor list,
randomized stone brick, and then we'll
randomize a stone brick for each of the different, is basically going to go
through exactly this rule that I've shown you a couple of
minutes ago, basically. Yeah, and that is pretty
much the sky fan done. What we now want to
do is also the side and the stored pool for
the run-down house. So we're gonna make a new
folder in here called Run underscore down
underscore house. And then inside of there, we're going to make
two JSON files stored Fool and site pools or right-click new file stored
underscore pool dot json. And then we also want the side
underscore pool dot Jason. And let's copy
over the contents. This is the storage pool. Let's just copy this over the goal and then
let's last but not least copy over the side fool and then we have
everything copied over. Then we basically need, That's the one to start pool. And first of all, once again, the new list to MC course, changing this to MC course. And that is all that we need. So you can see run-down house
left for this once again, this one right here,
this NVT to File. And then here we
have the site pool. This is gonna be
very interesting. This is needed for the jigsaw
block and the jigsaw stuff. So we're going to see basically what this means and what
this does in just a moment. We're just going to change
all of the locations here. Go MC course. And the general idea
here is that you have a, you have the storage pool, which is gonna be the
left side of the house. And then you have
a jigsaw block in both sides of the house and the left and the
right side of the house. And they are connected
with each other. And then it basically calls the site pool and then spawns either the
right side House, normal or gold. That's
the general idea. But we're gonna see that in a little bit more detail in
the jigsaw lecture as well, where we actually make a new custom structure
completely crust custom with our own custom
jigsaw blocks and stuff like that as well. So no worries there. We're gonna go into
a little bit more detail in that in the future. But now actually everything here has been added and should work. If that one thing that
it should not work is actually the left
and the right side has inside of those MVT
files in the jigsaw block, there is a wrong model
ID associated with it. So the model ID is
still the structure underscore tutorial and we
actually need to change this. Now what should spawn already is our sky fan and the
left side of the house. So what we're gonna do is
we're gonna make a new world. And we're going to do
what we're gonna do is actually go into Minecraft,
make a new world. And then when I see that
the sky fan actually owned, and then also the
run-down house though. Let's just see if it works. Very important to note,
you will get at this world's using
experimental settings. After you have added
your custom structures, it just is what it is. You can't get rid
of this easily. There's, I think there's a mod that you might be able to add or basically to get
this as a mixed in, but you're just gonna
have to deal with this. Just click Proceed and
lets the world generate. And if you join an
already existing world is gonna say something like, Oh, it's using
experimental settings. Just say, Yeah, I
know what I'm doing. Enter the world and you're
gonna be totally fine. No worries that they are at all. All right, so we find
ourselves in Minecraft and usually the structures
should be fairly prevalent. There we go. Actually, there is 1.5 of the house
already existing. So let's just go down
here and you can see it's only half
a house, right? So the actual jigsaw block
is placed right here. And then there should
be another side of the house which we're going
to fix in just a moment. But you can also see some
very nice and cool examples of some more stuff right here. Basically TreasureChest how you can add some include as well. So I highly recommend
checking this out as well. And then let's
actually also go slash locate the MC course code
only structures Chi Fan. And then we should also be
able to find that this, Let's say my two phi up. Now there it is. Okay, we can see that you go and we should
also be able to see stone breaks and then some
of them are infested stone bricks and rather than have
been replaced with emeralds. And then here are some of
this has been replaced with the different ORS. Really cool everything working exactly how you
would expect it to. And now we need
to fix the house. So how do we fix the house? Well, what we need to do is we need to get a certain block and that is going to be
the, this block right here. So let's just give us the, this is the structural block. There you go. We're
gonna do is we're just gonna set it down and
then right-click this. And what we need to do is we need to get the structure name. There is an MSC course colon, and this is run underscore
down underscore house, underscore left underscore side. I think that that
is it. Let's load and then you would go
actually loaded it. Let's go, let's select this control a
control C to copy it, and then click load again
to load the structure in. And you can see this
structure loads in width a rock right here. This is the drink so block. And you can see this takes the structure
underscore tutorial, a run-down house beside pool. That is why it doesn't
work and we actually want to do the same thing right here. Let's just go a little
bit further away. And then let's right-click,
copy this and paste this in. And then we're gonna
do a right side, right here, right side, load. It should also load.
Let's get out of this. There you go, load this
in. And then let's do the same thing one more
time with the golden sides. So this is going to be a
right, I'll underscore golden. So those are all of our
different NVT files. Let's load that in as well. There you go. And now we have all of
those different blocks. As you can see, we're gonna
start with the left house. So what we need is needed change this of
course to MC course. So MC course, now it's going to look at our site
pool JSON file. Then what we're gonna do
here is the right side. We don't necessarily
need to change this, but I'd like to change this as well. This is the target name. I'm going to select this again, control a, control C to copy it. And then we're gonna say done. Now this name right
here, the target name has to match the
name right here. So if I right-click this one, you can see this has
a particular name and those have to match done. That's actually double
check this. Yeah. This is Steve. I knew that I had a w in there because I sort of moving
a little bit too early. And there we go, this
one as well done. Now what we want to
do is we want to save those MVT data again. How do we do this? Well, once again, in
our structure block, we're going to go
to the safe mode, and we're just going
to save this under the same name, safe. There you go, done. And then the same here, go to Save mode safe. And then going here
to safe mode safe. So if this was a little quick, Don't worry, like I said, next lecture and especially
the lecture after that, we're going to discuss
the jigsaw blocks in little bit more
detail when it actually building a
own custom structure and how you can
easily save that. So if this was a little, I'm not 100% sure
everything works. You are, don't worry about it. We're going to see that
in just a little bit in the next lectures as well. But now those
different structures have been saved and now the
only thing we need to do is exchange the NVT data we already have with our
just saved in VT data. So let's just switch to intelligence and
see how this works. All right, so we
find a suspect in the intelligence and we want to go to the run
folder to your safes. And then you want to go into
the world that you've just created where you actually
have those structures. There should be a
generated folder right here with exactly this NVT data. But this is exactly
what we wanted. We're just gonna take this
and we're just going to move it all the way to the
structures right here. And we'll say override
all. And that is it. Now, the run-down
house will work properly because
now it's basically going to look for
the proper site pool because we had to specify that in the left house and it's also going to work with
the proper right side. So that should be pretty
much all that we need to do. So let's create a new world and let's see if the house
now spawns correctly. All right, we found in Minecraft and you can
see, there you go. There's actually two
of them. As I said, they are very, very common. So you definitely want
to change the numbers if we want to make them
a little bit more rare. But as you can see, there it is. And let's see,
I've gotten lucky. There you go, 50% chance of
getting the gold one here. Now the right side
spawns as well. And we can actually see,
Let's just go in here and see whether or not
this is the other ones. So they could see that there
are different variants. There you go. This is the
one that without the gold. So this is really awesome and really cool and all things
considered not that crazy. Once again, it's
all about getting it to roll ones because I promise you next lecture when we actually make
our own structure, you're gonna be
amazed at how easy it is to add this once
you've gone through this, understand all of
the different pieces of it and how you can basically then change it to whatever you
want your structure to be. So that is how easy it can be. Once again, to quickly summarize what the freak has been
going on here, right? This was quite a bit. We basically have a storage pool that starts to generate
your structure. This looks at an MDT file in your structures
folder right here, and then generates that
particular MVT file. Now how does it know
where to generate this? Well, it's going to use
this tag right here. So in this instance,
for example, the adjacent only house
biomes tag and says, Okay, if we're in any of these different biomes than this structure might
be able to spawn. This is specified
in the configured structure feature right here, where we basically pointed to exactly this biome and
also the star pool that is basically used for the configuration of this
particular structure. The structure set then also
has the possibility of basically choosing between
different structures at the same location. Also makes sure that the structures don't intersect
each other by adding a salt right here and
adding the average and the minimum distance apart in chunks for that
particular structure. In the case of a run-down house, we also have a site pool, which then also specifies two different NVT files actually that might be able
to generate at that particular location
using jigsaw blocks. Now, all of this we're
gonna see in the next and the lecture after that as well, where we're going
to actually create our own custom structure. We're gonna save
the structure in an MVT file. We're
going to export it. We're going to add it to
our structures folder. And then we're gonna copy
over the JSON files that are responsible for responding
that actual structure. And you're gonna be able to see that we only need to change very few things to make
the structure spawn then. So even though this
lecture is quite long and quite extensive and has
a lot of content in it. You're going to see that once
you've gone through this, understand what is happening. Then adding new structures is a very trivial thing
to do entirely, right? So this was a credit,
the crazy lecture, I will agree with
113. (1.18.2) Custom Structures (Single Piece): All right, welcome back to
the fabric course for 118. And in this lecture
we're gonna be making a custom structure. We find ourselves already in Minecraft and I've already created a custom
structure right here. So you can either download
the NVT file for this. However, I actually
recommend what you do is you actually create
your own custom structure. It doesn't have to be big, it doesn't have to
be complicated. It definitely has to be
below 48 by 48 by 48. I'd say you can just
pause the video, create your own structure,
and then we will continue. Hopefully you have built
a structure that is, it has, it can be similar
to this or whatever. But basically we now want
the actual structure block. So if you don't
have this, you can just give this to yourself. Just give your own player here, the structure block,
this one right here. You can see, there you go. This is the structure block. And what we wanna
do is we want to place this pretty much outside
of the entire structure. So we want to place
it right here so that everything inside
of it is going to, Well, basically it saved them later and then we want
the other one right here. So we want those in these
two corners and then the other two blocks should go into the
other two corners. But they basically form a, form a cube around this. In this case, just going
to put this right here. There you go. Then
we're gonna start here. The structure name should
be MC course colon, and I'm going to call this
the carpet underscore house. And I'm going to copy this name. So once you can control
a to select everything, control C to paste it. And then we're switching to
corner mode and say Done, I'm going to go
here, paste it in control V corner mode done. Over here, they sit
in hormones done. And then our last
one right here, we actually want to
go to Safe Mode, paste this in and say detect, and then it should detect
the entire structure so you can see and make
sure that everything that you want is inside of the actual lines right here
and everything looks great. Now what we can do
is we can say safe. Now the file, the NVT file
actually has been saved. That's actually how
easy this for a while, a single piece structure
to be saved in this case, of course, building it. That's of course a
whole other thing. When it comes to
the jigsaw blocks, That's something we're gonna
see in the next lecture. But for now we're going to
switch back to IntelliJ. And we're gonna
take a look at what we can basically
see it right there. So in intelligence, we're gonna go into the
R1 folder, saves. This was in the structures world I believe generated there is the cabin house
and we're just going to copy this over control C. And then I'm gonna paste
it in into my structures. Follow right here.
Hothouse NVT they ago, this is now my accustom. How's that I've built? And now of course we need to add some stuff that
we've done before. So now what we're gonna
do is we're just going to open the origin folder with all of the different Jason
final CR, same with the tax. And now basically the
idea is that once you've gone through
this is why I said in the last lecture, once you've been
through it, once, adding new structures
is incredibly easy. Because what we're
gonna do is we're gonna take the JSON only house. You're going to make this
adjacent only structure. In this case, we're just
going to take each of these files and
just duplicate it. So we're going to drag
it into the same folder that it's in bile
holding control. So that's going to duplicate it. We're going to call this
company underscore house. And I'm going to select
all of the name here, control C to copy it because
we're gonna use this a couple of times in with
the other JSON files. And these biomes are
actually totally fun, so we're gonna keep those. This is of course once again
just the JSON file that specifies in what biomes our custom structure
can spawn in. And he configured
structure feature. We're going to copy
this over as well. And then once again, just copy and paste in the name here. Here we want to change this name to cover underscore
house, store pool. We're going to create
that in just a moment. And then this one is of course, the half structures
carbon house Jason, that it points to right here. So maybe what we
actually don't want, we don't want any monsters here. So let's just do this one. We're just going to have a creature spawned,
maybe a parrot. That should be fine overall, the rest here is fine. We don't need any processor
list in this case, I don't want anything to
be replaced randomly. You could, of course,
still do this. We've seen this,
the last lecture, the process list was pretty
cool, but we don't want this. And then we have a
structured set once again also cover
underscore house. Here it points to the
carbon underscore house and very important, this is incredibly
important to make the placement here
in the Salt unique. It has to be unique. And then we're also
going to change the spacing a little bit. We're not going to go too
crazy year once again, 166 are still very, very small. This should definitely
be higher when you're actually implementing
something into the game. And of course, you
saw sort of how the general distance was for the previous
structure as well. In other last thing we need
is the template pools. We're gonna get the entire
run-down house folder here. We're going to rename
this to cope and house. And then I'm going to open both the site pool
and the store pool. They start pool here, disciple, we can actually delete,
that's actually even better. So we're just gonna
do yes, delete it. And then the storage pool here, making sure that we have this start pool
house right here. And then here we're
just going to say instead of the
run-down house left, this is of course,
pointing to the NVT file. We're gonna point it to
the common house NVT file. That is it. Now you're gonna
say it can't be everything. This is actually
everything we need. 1234 JSON files and our NVT file files and
total one of them, depending on how
complicated your built is, might take quite a long time to actually save the NVT file, but that is pretty much
all that you need to do. Now of course, you can still also change a few
things round here, right in those Jason files, configure a few different
elements there. But overall, this is
pretty much all you need. So for completion sake, what we're gonna do is we're
gonna make a new world, go in and see if we can
find our carbon house. They're very interestingly
enough right here, I actually have a
arrow right here.
114. (1.18.2) Custom Structures (Jigsaw Structures): All right, welcome back to the fabric course for 100
thousand seen in this lecture, we're gonna be creating
a jigsaw structure. You can see I've already
prepared this lex actually those two
blocks right here. And let's actually create
this from the ground up. So I've already built the
structure right here. And what we're gonna do
is we're gonna save 1.5. So pretty much with the, with the separation here. Once NVT file and then the other part
in another NVT file. And then what I'm gonna
do is I'm going to do a three different variance. One with iron right here, one with emeralds and
one width diamonds. In the world, this
storage platform can spawn with Oracle
come on the one side, and then the other side is going to be determined randomly. So first of all, what we're gonna do is we
need the structural blocks. So once again, we're gonna
do is we're just going to give ourselves this block. So we're just gonna say Give and then search for the
structure block right here. We're also going to need
is the jigsaw block. So let's just give this to a selves immediately
so that we have it. And then what we're gonna
do is we're going to, first of all, get the
main structure in here. This course should
be right here. I think that, that
should be fine. And then what we need is, of
course at the top as well, let's make sure that
we are high enough up. That should be fine. And then one more or
they ago, that is okay. And then over here, you need to be below one. So right there. And then once again, but went up all the way
through the same height. I believe that should be fine. Now this was of course
right here, there you go. This should be okay. But we're gonna see
in just a second, then we're gonna go in here, go to corner mode, and this is going to
be MC course colon. Let's call this the storage
underscore platform. There you go. And I'm going to, It's like
all of it with Control a, Control C to copy it, done. And we're gonna go
with this one or remote control V
to paste the name in control V to paste the Neyman and of course also
changed the corner mode. Very important. And
then right here, we're gonna go to Safe Mode, paste the name in, and then
we're gonna say detect. And there we go. So we have the entire
structure in here, so that is exactly right. Now what we also want to set
down is the jigsaw block. Now, how do jigsaw blocks work? Well, the general idea is that the way that the arrow points. So basically we want two arrows always pointing to each other. So what we're gonna
do is we're going to find the middle right here. Let's just get this one. And then the arrow points
in this direction. And then we also want
the other jigsaw block to point in the same direction. So you see that they form, they form this sort of line and the arrows point to each other. This is how the other one
is going to be placed. This is why I've already built it right next to each other. Let's quickly just
do this one right. There you go. You can see that this one is inside of the first
structure, right? So this one is inside
of this structure and the other one is going to be inside of the second structure, which we're gonna
do in a minute. What this does is this one
right here has a name defined. So this is just going to be MC course colon side underscore
platform for example. Let's select this and copy
this name right here. This is the only thing
that we need to do on the secondary jigsaw block. On the primary jigsaw block, we want to put this under the target name and
then the target pool. And this is incredibly
important and we want to do MC course. And then this is
going to be these, let's say storage underscore platform slash site
underscore pool. So this right here, it points to the adjacent file inside of our data folders. If I just quickly open it up, You're so you can see this
for the run-down house, this side pool right here. That is this. Of course we haven't created
the storage platform yet, but that is the idea. So we have this side
pool JSON file, which defines different variants of this particular, of
this particular site. And actually put the irony here, but that's going to be fine. I'm just going to have
the iron spawn and then this is gonna be
the side platform. I mean, it doesn't really
matter which way you do it. And yeah, so basically
the site platform, this name and this
name has to match. That's the one thing. And
then for the main ones, so this is the primary one. This is the structure
that's going to spawn when you use
the structure, the storage platform,
this one right here, that is gonna be the primary one where we have this side pool. So this is the JSON file. This is just the name of
the other jigsaw born. And then also what
we can define here is what the jigsaw
block turns into. We're just going to delete them and let them turn into air. But you could in theory
also change this. What we're gonna do is
we're also going to get the second one here just
so that we have it. So this would be right here. This is should be I think no, I think this should be fine. Then we should ever have
everything in there. And then over here, also going to put the structure
block down right here. And then the other
structure block to be writing your I think
that should be it. And this is now going to be the we're gonna call this not
the site plan form of this is going to be the Oracle income underscore storage
underscore platform. Go, I'm going to select it, press control C to copy it, Warner mode, control V to paste. They didn't corner mode.
And then over here as well, they sit in mode and then this one is of course going
to be saved mode again, they sit in, say detect, and we should have
this in their day ago. Now we have the oral
calcium storage platform, which also includes this
jigsaw block right here. Which is very important
in that case. So what we're gonna do
is we're gonna take the storage platform
would have saved this. We're gonna take the Oracle
platform, save this, and then multiple do is I
will change this up to be a different type of order and we're going to save a different
example of this as well. Alright, so I've changed it
all to emeralds in this case I'm gonna do is now we're going to change the name right here. We're just going
to change the name to Emerald storage platform. I'm going to select it all. Press control C to copy it. And we're gonna change
all names here. This is very important. So once again,
there's control a2 collected or control V
to paste the new name. And that should be pretty
self-explanatory here. I'm gonna do the same
here and then we're going to detect it one more time. And you're gonna
see, there you go. This is the emerald storage
platform in this case, make sure also when you select when you put on a
new blocks that you are, aren't outside of
the boundaries here. And then we're going to
save this one as well. Now we have two
different variants. Just for the sake of argument, we're going to make
another variant. Let's also make the
diamond variant. Let's just do that quickly. I felt it with a diamond. So once again, let's
change the names here. So this is gonna be the
diamond storage platform. Once again, Control
a to select it, Control C to copy it over. And then we're gonna
do the same thing for all different
corners right here. There you go. And then this one as well. There you go. And then let's go here once again to detecting it. And we have detected
as successfully, and now we can save it as well. There you go. And now we have saved three different variants
of this part of the platform and basically
one main platform right here. Those are basically connected through this jigsaw
block right here. But this is the, the
whole idea here. Let's switch to until a DJ and see what we can see at firstly, of course we need to
get the NVT data for this one is going to enter
the R1 folder in the safes. In the same way, you basically save this and this is gonna be
all four of them. We're going to need
those storage platform and the three
different ones there. Let's copy them over to our structures, follow right here. And then what we're
gonna do is once again, we're just going to copy over the counter house JSON files. And you're gonna see
that once again, even with the jigsaw blocks, it is not that crazy. We're gonna copy over this
one that is going to be the storage underscore platform. This is gonna be the name of the general structure itself and the moon will do once
you can configure it. Structure feature,
also storage platform, but we just need
to change the name right here to storage platform. And the name of the
biomes here was just this JSON file right
here, platform as well. The same list thing in
the structure, set. The structure quenching back to the configured
structure feature. And then this one
is just going to be something like that. So once again, a salt
and the spacing, I mean, we can pretty much just keep it as it is, just going
to change a little bit. There you go. And
then it is off to the template house,
the template pools. So we're going to actually
use the run-down house here. I want to change this
to STORD platform and we have the
two Jason fancier, the site pool and
the store pool. Let's start with
historic pool here, changing this to our
storage platform, star pool number one, and then this one to
the storage platform. This is going to be the main quote unquote in
VT file that it points to. So this is going to point to
this NVT file right here. And then the side pool
is gonna be interesting. This is gonna be, of
course, once again, changing the name
here and the wound is instead of pointing to
run-down house right side, we actually wanted
to point to the, for example, diamond
underscore storage platform. Yes. And then we also
want is the other two we're going to delete
this one right here. We're just going to also delete the comments for the
sake of argument. I'm going to do this and
then just copy this twice. And we can change the
weight here as well. So let's say, for
example, we have a thirty-three percent chance of spawning either of
them, let's just say. And then this one is not
going to be the time at one, but the Orange County item underscore storage platform
and then this is going to be the Emerald emerald
storage spot platform. Once again, these locations
here points to the NVT files. And it's going to take
one of those NVT files and going to generate that
with different weights here. If we have the
weights of all three, then it's pretty much
gonna be one over three. And we could also say,
well maybe you know what, Actually this is
twice as likely. This is maybe a five-year. So then this is going to
come up 50% of the time. This is going to come
up 20% of the time. In this 10% of the time, it's just the weights
basically on how it's spawns. And that is literally
all you need to do. We're already done
with setting this up. Once again, when we have the JSON files already prepared
once copying them over, you are done like it's it's
very, very straightforward. And yes, of course, if
you have crazier ideas, if you have even like
extended a multiple, multiple jigsaw blocks
and stuff like that, then of course it's going to get more and more complicated. But let's say great start. And I highly recommend being
open to experimentation, especially and just
trying out stuff and seeing what you can
basically come up with. So for the last time
for the structures, let's go into Minecraft, create a new world
and let's see if our new storage
platform spots or a fantasy Minecraft and I
already spy something here, and this is probably the
worst case scenario. You can see that only half of the sport, that's
very interesting. So there's probably going to be a typo in there somewhere, which is very strange, but we're going to
see wait a second. Let's just the issue
is very funny because I just changed the names of
the run-down house once. So you can see in
the run-down house, I changed the actual things
to the storage platform. And the storage platform has this things in the
run-down house. So that's not quite what
I had in mind here. Let's just do it like this. Let's just do copy this over. And then we're gonna do is this one is just going to be deleted. So we're going to get
the name off of this, is this name back
to run-down house. And then this one is going to be the storage underscore plant. But now this should
be working fine. So let's see. This is the storage
platform start pool storage platform side
for now, we should be fine. So the issue here was
that I accidentally changed the run-down
house JSON files instead of the storage platform. Jason files can happen anytime, so no worries there. But he actually saw that sometimes you can't
really find it. So you'd then have to
go through sentence. You see you can actually find
something in the terminal. Wasn't anything here. It was just a arrow right here in the files, but
no worries at all. So now let's
actually take a look at whether or not it's
spawns correctly. All right, If
answers in Microsoft once again and let's see, I don't even know if this
spawns in this actual biome. So let's just located the MC course
storage platform and let's see if this works.
N is there we go. It finally works. So you can see no
worries at all. It can always happen that
there's a typo somewhere. But overall, you saw that it
wasn't anything crazy year. It was very, very
straightforward to fix. Let's just see if I can't
fly around and actually find another one of
those storage platforms, maybe with something
else then already calcium does look like
it's also a calculus. Actually. And it is indeed, let us just tp to somewhere
very, very distant. Let's just go like,
I don't know, 20 K. And let's see if I can
locate another one. Let's just locate his
sword platform and see if this one has something different
than what we calculate. Of course not, because
that would be too easy. Let's see P1 last time and let's actually see maybe we
can find something. Let's go to negative 20, K to K, That's okay. And then let's do locate MC course towards
platform One more time. Let's see if this
is going to work. I think we're actually below it. There it is. And we actually found
some difference. So here we can see the one
with the emeralds as well. So everything working totally like you would expect it to. And really freaking awesome. So everything working
great and yeah, that's pretty much
how easy it is for some jigsaw structures to
be added to Minecraft. But that would pretty much be it for this lecture right here. I hope you found this useful and you'll learn something new. All of the JSON files in
the NVT fonts are of course also available for download
you in the GitHub repository, an individual just as well. But otherwise I will see
you in the next lecture.
115. (1.18.2) Custom 3D Armor Models: All right, welcome back to
the fabric course for 118. And in this lecture
we're gonna be adding a custom 3D armor
model to Minecraft. We're going to turn
our Oracle come armor into a custom
3D armor model. And for this, we're once again going to use a block bench. As you can see, I've
already prepared the oracle come
armor right here. But this is actually
fairly straightforward. So we're going to use
echo lip one more time. And the way that this
works is if you make a new geckos live
animated model here, we can just make a
test armor here. Then what you can do
is you can go under File gecko lip model settings. You can just turn this to
armor and then it's going to generate the Minecraft
player right here. You can see you
don't touch this. So basically these different blocks should not be touched. Then everything else
you want to add under the armor head, armor body and so
on and so forth. Do for example, you can
click this Add Cube and then you can start to add your
custom armor right here, Z, just size it up. And however, you were basically
like your armor to look. You can duplicate it,
Control D. There you go. And then you can just add stuff to it and you can of
course make it as, as custom as you would like. Now what I found is that making the armor is
actually quite hard. Like making it look
good is not that easy. So this is, it isn't actually
doesn't look that good, especially when you
actually take, for example, the arm here for the sake of argument, we can
rotate it around. You can actually see if I
rotate it a little bit, that it actually missing
here and stuff like that. So it's not, it's not that interesting,
it's not that crazy. It's just an example
of one piece of armor. And what you could do here
is also the following. When you've created everything, what you can do is let's just delete this texture
for the moment. And then you might have
something like this. What you can do is you
can press Control a, and then this is going
to select every piece of what different thing
that you have in here. And we can then do is you can make a new texture out of this. So we're just going to keep this texture and then you can see it basically replaces
everything on this texture. Now if you save this texture, I'm gonna just gonna do this. You have already prepared
some stuff here. Worse than what I can do
is I will be able to, well, this is how it
looks like, right? When I just open it, you can
see it basically gives you a thesis of the armor where you actually
want to draw this. So what we can do
is just add this in here right to the texture.
We're just going to open it. What you can do then
is we can go in here and then just
change some stuff. For example, right here,
I believe that it should be like the back of the head
or something like that. We can just draw all over
this and then save it. And if I go into block bench
again, right-click refresh, then you can see now
this has changed and at the back of the
head, you'd see there, and I'll have this color, coloring it and making the
texture quite difficult, like it's not actually
that easy to do. You can also click on
the individual phases and you can see where this is. So you can see the bar at the top of the head
is actually this. Then I can say, Okay,
this one right here, I believe, or not mistaken. So I can say, oh, make this blue and
then save it again. Once again, go in here, refresh. And you can see now at the
top of the head is blue. So this is definitely a thing that is going
to take quite awhile. I just want to show you how
you can basically added. So I have already
prepared the texture. Let's just take the oracle
outcome texture right here. And then also what I did is
I added this black right here because what
I wanted to do is on the head and stuff, I wanted to move those to the bottom so that it's
a little bit easier to basically see the
distinction between my actual armor and the player. So I can do this one
right here as well. There you go. And then the other leg as well. So basically all of
the Do not touch once. I just moved to the black
piece of armor right here, just so that I can
basically have a less contrast there
so that I can see, okay, whereas this,
what am I doing here? This block pinch
model will of course also be available for download. And what you then do is you
can just go to File Export, Export, gecko lip model. This is going to be a geo
model once not once again, I already have this, of course, so we're just going
to replace this. And what you can do
then is go into fabric right here and then
continue in an intelligent, let's continue and
actually add this. What are we going to
need? What we're going to need three different things. One of them is a custom items. So in the custom item package, we're gonna make the
account come armor item. And this is going to do this. We're going to extend
the mod armor item, actually that it has
the same functionality. We're going to create a
constructor matching super. And then we're also gonna do, which is very important
is that there was actually an issue in the oriC outcome armor item or in the more
armor item rather. In this has armor
method right here, normally gonna do
is I actually have the correct method right here. You can see we
basically just checking for we cast this
to the armor item, whether or not it actually
is a armor item here, The reason for doing
this is otherwise, when you have an electron and the rest of
the armors filled, and one of them is
the more armor item, then the game is actually
going to crash because you can't cast the electron
to an armour items. So keep that in
mind, but that is pretty much all we
need to do here. And then for the
calcium armor item, what we actually want
is a few things. So we actually wanted to add the implements I
animatable as well. Hover over this Implement
Methods is going to implement the register controllers method as well as the GET
factory method. But you can also do is
you can press shift twice and look at the put the
potato armor item right here. This is an example. So
this is also great. You can basically in theory
just copy everything over. So the potato, potato
armor item pretty much is the example given
from gecko lip here. So you can also take
a look at that. We're just gonna
continue through. So we of course need for the I animate all the
animation factory. This is something
that we've seen with the custom entities as well. We're going to basically
return the factory right here. And then for the predicate, what we're gonna do is pretty much what you could
in theory do, like I said, literally just
take this entire method here, the predicate, because that's the thing
that we're going to need. And we can just take it
over and copy it over because it pretty much is
going to be always the same. The only thing that we're gonna change, the animation here is just going to be
called idle in this case. And then down here, we actually want this to be a
little bit different. So there's not, I'm registries. This is gonna be mod
items, start booths, and then we're just
gonna go through more and more items,
starts leggings. We're going to go
for the more items starts just played and
then last but not least, the more items start
helmets they ago. And that should pretty much
be all that we need here. Then of course, the
predicate to be fairly self-explanatory here
we're gonna use this in the register method right here. Okay, let's just
rename this to data. There you go. That should be it. All of
the code is of course also available to you in
the GitHub repository, an individual just as well, but that should pretty much
be everything that we need. You also have some nice
comments right here, which is really useful. That's also pretty cool, right after having added
as this armor item, we now need to change all
four pieces of armor to this, or it can become armor item That's actually very
necessary here. And then we can use this in
the model and the renderer. So these will go into my entity client package right here under a new
package called armor. You could also move them anywhere in the item,
client, whatever. So they don't have to go here, but I'm just going
to put them there. And there's going to be the
Oracle come arm or model. And the other one is going to be the Oracle outcome armor
render, Are they ago? The modal is going to extend the animated real model of
type or a calcium armor item. And then we're just
going to hover over this, implement the methods. So those are gonna
be the three methods that return identifier's. Now I've already prepared this. I'm just going to
copy this over, but should be fairly
self-explanatory. This points to the
model JSON file that we've exported from block bench. This is just our texture file
and this is the animations. And I prepared the animations. It's just almost a
blank Jason file. Not quite, but it's
fairly self-explanatory. So let's just add
the JSON files here. The animation is of
course also available. And this I pretty much just used for all of the
different textures, for all of the different armor. If you don't have any specific animations associated with it. And you can just pretty much do this animation which
has nothing in it. And then what we're gonna
do is we're gonna take the armor GO and also get
this in here they ago. Of course, actual
model in this case. And then the texture you can see this should go
under textures, model armor or calcium
Armor Texture. So there's gonna be a
new folder right here, models and then new
directory called armor. And then let's get the
texture over as well. This is gonna be
this one right here. There you go. Just for testing
purposes, of course, or income Armor Texture.
That is correct. There you go. So
that should be fine. And then the model is done. We can then proceed to add
stuff to the Renderer. Renderer is going to extend the geo armor renderer once again of type already
count them armor item. We're just going to
hover over this and create constructor
matching super. And we actually don't want
anything to go in here and here we want the new
Oracle Cloud Armor model. This is fairly self-explanatory. And then what we're gonna
do is we want to set this, so we want to set the head bone, party bone and so on and
so forth to the names. And those names are going
to be the names right here. We can see this is the
armor head right here. We're setting the head
bone to armor head. This has to be the case. We can also take a
look at once again, the potato armor renderer. I believe if I actually
take a look at this, the renderer right here, see
they also do the same thing. This is just, you just
have to set this. And it was very
interesting and I don't know why that is the case, but you have to set
the left leg bone to the armor right leg the right
leg bone to the armor left. Like I don't know why
that is the case. At least this is
what I found works. I don't know why it
switched around here. I can't tell you why, but
it's just what I found. It's a very easy fixed.
So this is not a typo, this is actually how
you need to do it, at least it was for me. And after you have added this now we can actually use this in our MC course client class. So there's gonna be right here. We want to do is, we want to do, of course, in the
uninitialized client method, we want to say GU
armor renderer.org, register armor render us with a new or the
calcium armor renderer. And then we want
to pass in all of our items that we have. Once again, we want to pass on the boots and then mode items. Not. This is gonna be the leggings. And then we have mod
items, start split. Nope, That definitely not. There's cherry blossom
sign and then we have the more items, that element. There you go. And that should be fine. No errors. Should be president right here. And I believe all
things considered, this should pretty much be
everything that we need. There's one more thing
that I just want to add, just so we have it in here. Let's just add it as well. We can call gecko
LEP dot initialize. I'm not a 100% sure whether
or not this is necessary. However, it's insanely
just a good idea to add this just so that we have it in our own
initialized method. I'm not a 100% sure I tested it. Whether or not it basically
breaks the mod, it doesn't, if you don't add it,
just being sure, let's add this as well. And otherwise, I think this should pretty much be
everything that we need. I mean, if something
does not work, then of course
going to be able to immediately see this
in game as well. Let's just enter Minecraft
and see if it works. Councils in Minecraft. And let's just get the armor right here and
let's see if it works. And indeed it does. And of course we still get our customer armor
effect right here. And it looks freaking amazing. The thing also works, like I said, making the armor
look really, really cool. That is a very hard
thing like adding the ARMA as you've seen, right? It's just a couple of classes that changes things
around a little bit. And then you have the armor, the exporting it, the JSON
files and stuff like that. It's fairly
straightforward, but then making it look really
cool, having a cool, a cool texture, a cool model that is
definitely very hard, but I mean, that
is how easy it is to add the armor to
Minecraft, right? That concludes this
lecture right here. I hope you found this useful and you'll learn something new. And I'll see you in
the next lecture. Yeah.
116. (1.18.2) Custom Villagers: Or I welcome back to the
fabric horse for 118. And in this lecture
we're gonna be adding a custom villager to Minecraft. Yes, this is now going
to be a custom villager. Instead of just
adding some trades to already existing villagers, we're going to add a
customer villager, but this is actually way
more straightforward than I thought in the
MC course package. We're gonna make a new
package called villager. Instead of there,
we're gonna make a new Java class called
the mode villagers. Now this is going to contain
both the point of interest as well as the professional or the content of this class
I will be copying over, but I will explain
everything as we go along. And also of course, everything
is available to you in the GitHub past or
individual just as well. You can see if you
have a point of interests and a
villager professional, those are of course
related with each other. A point of interest
is where a villager gets their profession
from the professional. Then of course it's
just the professional. So let's first of
all take a look at the actual point of interest. You can see what we're
doing here is basically registering a point
of interest type right under the model ID. And our name should be
fairly self-explanatory. And you can see what we're
doing here is we're calling this accessor because otherwise we have to call this
interface, this mixing. Otherwise it's not
going to work. But the general idea is that
we're basically creating a point of interest with the
name that we're given here. And then a block of
a certain state. Though the idea is that if a block that we're
putting in here, when we call this
register point method, then the oracle come
blaster and all of its different states
are basically going to be registered
as a point of interest. That is the blastopore,
that is the idea. And after we've
registered the point, we then register the profession. And you can see here
once again with a name given and then
the age-specific point of interest type
that we're passing into the blast report right here and within creating the
actual profession. So this is the name, this
is the point of interest type each two immutable
sets right here. We can actually do is
we can middle mouse, click on the
professional side here, and we should be
able to see this. So this is the gatherer items and the secondary job sites. I've just put them to basically just empty
immutable Sets because that's going to be
easier for the time being. You can always take a
look at both the village or profession and
other being used. So we can actually take a
look at this one right here. I think the register method, for example, the
farmer right here. You can see it has weed, weed seeds, beetroot
seats excellent, can actually pick up. And then also there
is a farmland as a work site, so to speak. But we're just gonna
keep it like this. I don't want this to
be too complicated. You always have
available to you all of the vanilla classes to take
a look at how those work. And that should pretty much be hopefully what you're
going to need. So then this setup boys
method right here, we actually need to call
the setup for every point. So if you have another point, just add this as well. Add your poll here and then
it's going to be fine. And this needs to be cold inside of your MC course
on initialized, let's just call it right here. This is going to be
the MOD villagers that setup boys they ago, and that should be pretty much all of the
code that we need. Now we're actually going
to do two more things. So one more thing in the code, or we're gonna do is
we're actually going to add or at least one
or two different, different trades
because the traits we're actually going
to add in the same way that we added those traits with something like
duplicates this. And then instead of choosing
village or professions, we're gonna choose motor
villagers, not a blast master. And then just add one here. And let's just say something
like it, like nine emeralds. And then we're just going
to add a second one. Maybe for the account can
pick axe. There you go. And then just add a third one, which is going to be level two. And that's gonna be
maybe the shovel or a different amount
of air you go, this is going to be
five, that, that's fine. So this is how you then add the different
trade offers as well. There might be a different
way to do it right here, but I found this to be
absolutely, totally fine. There's also works and then there's one
thing that is very strange and that is going to be the texture or the textures. Let's just go to the
external libraries all the way down to right here, the project merged name
and so on and so forth to the Assets folder,
Minecraft textures. This should be under
entity from not mistaken an entity and then all the way down to a villager here, and then the professions. So we have the professions right here and the
villager right here. So we're actually going to
need the villager as well as our custom profession. Now I've just taken the armor
professional right here, the image and just made it
blue because I'm making a custom villager outfit
is actually very, very, I mean, it's
not that easy, right? So it's like, it's,
it's quite a lot. So what we're gonna
do is we're going to go and copy this over. So the structure is
going to be under the EMC course namespace. So this is gonna be,
it's gonna be under assets MC coarse textures. We already have the
entity right here, and then we need the
villager right here. A villager go and
then we're going to need the profession as well. I'll actually copy it over
right here so you can see we have the
profession right here, the blast master as
well as the villager. I don't know why we
need the village or at least in my testing, I needed the villager, a PNG. I don't know why that is the
case, but it is what it is. And then the blast
mass right here, we have, as you can see, just made it blue basically, because I'm making a completely custom look for a villager. Actually quite hard.
So it's similar to the custom 3D armor. So yeah, that's
pretty much a thing. And then the last
thing we're gonna need is the translation for the name of the profession. And that is going
to go into the ENR screw us adjacent file. And this is gonna
be the following. So we're gonna go right here. And it's gonna be entity micro
village or a blast master. And there you go. Blast
master is gonna be what it says when we actually open the inventory to trade
with the villager. And that's gonna
be pretty much it. Now those are the steps. Once again, of course,
everything available to you in the GitHub posture in
individual just as well. And that is pretty much all you need for a custom villager. So let's just see if it works or if finds us in Minecraft. So let's respond a villager
and set down the blaster. And there you go, It works totally fine. We now have a blast
master that trades exactly the traits that
we've basically given here. So let's just get some
emeralds and let's just get them up to the
next level right here. Let's just see,
once the level up on stuff literal levels
up we're gonna see on, and there we go. And now, as you can see it, now we can get the
shovel as well for these level two. And
it's also an apprentice. That's really freaking awesome. And actually how
easy it is to add a custom villager to Minecraft. And then that would
pretty much be it for this lecture right here. I hope you found this useful and you'll learn something new. Like always, all of the code is available in the
GitHub repository, an individual just as well. And I'll see you in
the next lecture.
117. (1.18.2) Baby Entities: Welcome back to the
fabric horse for 118. And in this lecture
we're going to be adding a custom baby entities
to our tiger. Now this is actually way easier than I
thought I'll father, this was way more complicated, but it actually isn't
the only needs to change stuff in the entity as
well as in the renderer. And we're gonna start
in the entity itself, what we're actually getting
into a couple of things. The first thing is going to
be the animal meat goals. What we're gonna do is
we're just going to duplicate the track
or goal right here. And we're going
to call this the, this is the animal
mate goal right here with this and then
also passing in one. D is gonna be the trans here and priority three
should be fine. Usually that's gonna be okay. This is very
important that we add this and then we
also wanted to add the reading item
method right here. And then here we can
basically filter whether or not a
certain item that we right-click this entity
with is going to make it so that we get the breeding
sorted, so to speak. And for our case,
we're going to use items dark beef in this case, if we right-click
the tiger with beef, then it basically gets
into meeting mode. That's the general
idea you have. And then of course,
the last thing here is the create child. But this is going to require
us to do mod entities, not tiger dot create and then passing in the
world parameter here, and that is it. Now in theory, the babies
would already spawned. However, they would be the
same size as the tiger, which is of course
quite not quite what you had in mind, I think. And for that, we're going to go into the renderer and
we're going to just override the get
render type efforts. So this is gonna be
this one right here. And what we wanna do is we
just want to keep this alone. We're just going to
modify this a little bit there it goes to read
it a little bit better. We just want to do
is an if statement for animatable dot is baby, and then do something else. We're gonna do something else. What we wanna do
is we just wanted to take the stack and scale it. So this is gonna be the
scale of the animal. 111 is of course going to be the same scale as it was before. And then in the baby, if
we just pass this in here, we want to, for example, make this kernel 0.4 so that
we're gonna make the baby about 40% the size
of the normal adult. And that is it. This is all that we need. Once again, very easily
doable, changeable. You can just change out this one right here
for a different item. If you don't want beef, if
you want something else, there are a couple of things
that you might want to do. You can think about, but if you right-click the tiger with a, with the beef, you
might want to make another check and your
Interact mob method right here that you
don't start writing it. And then also may be
that you can't write a baby because at the moment we can actually write a baby. Those should be things that
are fairly self-explanatory. At this point, I am
actually very confident that you should be able to
do this on your own easily. But whatever the case may be, this is the child. So let's just see if
we've added children to Minecraft or fossils
in Minecraft. So let's just get to tigers and let's get
some beef in here. And let's just see,
right-click, Right-click. And then let's see. I don't get any particles at the moment because I actually
turned off particles, but you can already
saw that it works. So let's video settings
under particles. Let's just get all
particles right here. Unless you see There's one
more time, There you go. We also get the particles
and there it is. Let's see, there it
is the baby animal in a smaller version
than the big ones. It actually totally fine working completely like
you would expect it to. We can also right-click
on it and then it should also spawned
a baby animal. That's also another thing that
you can do. There you go. They will actually
grow up by the way, It's just takes quite a while. I can actually show
you whether it is in the animal class. Well, but that is how
easy it is to add some baby animals to microbes. If we go down the tree here, there are ten obtain
capable entity, animal entity in the
animal entity class. Here the breeding cool down, maybe it's in,
somewhere in here. I think it might be
even further down. Maybe h there it is, in the passive entity,
negative 24 thousand. So this should be 24
thousand takes, I believe, until it creates an
adult basically. So you could in theory
also change this. Maybe I'm not sure it's file, so maybe this can't be changed, but there is basically
where it is at. And that is pretty much
also how easy it is to add some custom entities to your
entity, to your entity. And that would conclude
this lecture right here. I hope you found this useful and you'll learn something new. And I'll see you in
the next lectures.
118. (1.18.2) Custom Geodes: All right, welcome back to
the fabric course for 118. And in this lecture
we're gonna be adding a custom geode to Minecraft. So accustomed yield is actually fairly straightforward,
all things considered. So let's just see how this
works in the world package, feature package in R
configured features class, I'm going to copy over the actual geode feature
config craziness. And it will look like a lot. But don't worry,
we'll go through almost all of the lines
and see what they mean. So this is the oracle
come geode here. Let's just format is a little
bit differently maybe, so they can see
everything they ago. And the general idea
is that we have a geode feature conflict
with some layer conflicts. Here. The layer conflicts is actually the really interesting thing
because here we can define, you can see 12345
different blocks and then also a list of blocks or blocks
states in this case, but pretty much the same idea. If we go into the
G0 layer conflict, we can actually see what those different blocks states are. So we can see there's a
filling provider inner layer. There's an alternate
enlarged interlayer. There's a middle
layer an hour later and inner block it
cannot replace, and then also an invalid
blocks tag as well. So what does all of
those crazy things mean? Well, let's talk about
the inner blocks first. The inner blocks are basically, in the case of vanilla, are the budding amethyst. So if we middle mouse button, click on this and we can see the underground
configured features class right here and see the amethysts geode
clusters go in here and see air
is the first one. So this is just the
absolute inner most block. And of course usually
what you would want is your GOD to
be filled with air. That is why this is
air in this case. And the emesis block is the, let's see, this is the
inner layer providers. So this is the first
inner layer basically. And then we have a
block state provider of a alternate inner layer. Now those are the
budding amethyst. So those are the blocks where the Earth is actually
grow out of. We also have a calcite here. So this would be the
middle layer provider. And then we also have the, let me actually check this here, the smooth muscles
and that would be the outer layer provider. So we have a middle
layer and an hour later, you're going to see
in our example here, if I switch back to this, we can see that the error is the same thing that
we have deep slate as the general makeup
of the inner layer. The oracle come or is going
to be our budding amethyst, so so to speak, an outer layer of dirt. And then the complete our layer is gonna be
the Emerald block, while the recalc and
block right here, where this list is basically, this is going to be
our growing amethyst. So in the list right here
you can see these are the MFAs buds that can spawn. And in our case,
this is going to be our calcium blocks just for the sake of an
example here, right? Thickness should be
fairly self-explanatory. Just define the thickness here. A cracking config basically
determines on how big some openings might
be in this geode. And then you have some things that you can basically
change the distribution, noise multiplier and
some generation offset, highly recommend,
like as always, play around with the
numbers over here. This is like the best
thing that you can do. Also play around with
the blocks over here. You will see in just a moment
when we actually spawned this in a new world, how
this actually looks. And you will pretty much very easily understand
how this works. So no worries there. And this is basically
the general idea. Play around with this.
Now this is of course, all available to you
in a GitHub repository and individual just as
well. So no worries there. Let's proceed to the
marketplace features class. So I'm going to copy
this over as well. But this is also going
to be not too crazy. Actually do something like this. Maybe you can read this. There you go. There's the oracle come real placed and you can
see we're just making a rarity placement
here of 42 because why not? And then we need the
square placement feature, squared placement modifier off. And then we have the uniform
height from six to 50. I've just chosen those because
that's gonna be fine once, uh, once again, of course,
play around with this, right? Chose, choose different
offsets, right? You can use the fixed one
below top all of that. Just try out a bunch of
stuff here and then see what you can find with the
different values here. And to spawn this, well, it is fairly straightforward. We just want to go into
our generation here. We're just going to duplicate this one and we
want to change this to the oracle come or placed to the oracle come,
GO TO placed. Also making sure that the Configure feature
here is the geode. And then here we are
also referencing the geode and that is it That should small niche,
you're in a new world. Let's create a new world
and see if it works. Or France or in Minecraft. And there we have
one example already. So we found one, a geode
and you can see, of course, the inner most layer
basically is air here. And then you can see these
are the different layers. You can see this is deeply
the dirt over here. Then we have the budding
amethyst replacement for r ors. And then on some of
them, the Oracle can block spawn and those would be the places where the actual
clusters would spawn from. The Emerald block itself, you can see is actually
very much outside of it. So you can see that
this is actually where the geode already starts
and it is quite a lot. So you can see here
then all of this is dirt and then at some point, you basically start
finding some of the different blocks
here as well. And then at some point
after digging a lot, so you can see that
it is quite a lot. So you've actually reached
the other outside again. We can have to go this way. And then at some
point, let's see. We're gonna be able to find
the actual GO inside as well. So that is pretty much how easy it can be to add
some custom fields. Once again, playing
around with the numbers, playing around with the blocks. That's all up to
you. But overall, it is a very straightforward to actually have
it, generate it. And as always, as I've said, the code is available
on GitHub repository and individual just as well, but that would be it for
this lecture right here. I hope you found this useful and you'll learn something
new and I'll see you in the next
lecture. So, yeah.
119. (1.18.2) Block that interacts with Redstone: All right, welcome back to
the fabric course for 118. And in this lecture
we're gonna be taking a look at how you can implement Redstone
into your customer block. So what does that mean? Well, we're going to make
the oracle become a lamp, a block that instead of right-clicking it to
turn it on and off, we're going to make it work with redstone ore this, right? We have one example and that
is the redstone lamp block. Like always microbes source
code is your best friend. Let's just press
shift twice and let's search for the redstone
lamp block right here. And you can see that we have the neighbor update method as well as these scheduled
to take methods. So those are the two
methods that we need. Let's just copy
them over, select them and copy them
over control C, control V to paste it in. And then we just need
to change the lid here to collect everywhere
where it says LET, you just want to say
then same here as well, and liked as well. And then we can make this a
little bit easier to read. So instead of the Boolean value, we just wanted to like that. And then the casting here also, it doesn't have to
happen right now the question is what
is happening here? Well, the neighbors
update method is called when a neighbor of this
particular block state updates in the world
shouldn't be too crazy for the general ideas that we
want to know whether or not this particular block is on. If it is on n, it is
not receiving power, we want to turn it off
and other way round. If it's, if it's
turned off and it's receiving power than
we want to turn it on. That is the general idea. Now this is a little bit more complicated in my mind
than it has to be, but we're gonna be
fine because this is pretty much how
vanilla does it as well. And then we're scheduling a tick take basically is
then done right here. So you can see this
is called when a scheduled to tick is
well executed basically. And we're basically just
setting the state at this particular position
to the flick state cycle. What is cycle mean? Well, we're basically
just inverting whatever the actual
Boolean value is. So cycle, just cycles
through all of the values. It's very hard to
see in this case. But the general idea is just that it just cycles
through all of the different values of
this particular block state property because
it's a Boolean, there are only two possible
values that it can have. Therefore, it's just going
to turn a folds into a true and a true into a false. And that is
all that we need. So you can see the is receiving Redstone power at this
particular position, and that is all that
we need, right? So this is just a Boolean
method here that asks, Hey, is this block
receiving power? And that is all that you
need to check whether or not power is applied
to this block. And then just so that
we have it that's actually comment this out here. And let's just make
a system out print line and we're just
going to say powered by. And then we're
going to say world that and we have a few power. Well things over here you can see there's a emitting power, read some power and get
received power, get emitted. Redstone is receiving
Redstone and then strongest, we're just going to output
the strongest power. So this is going to return
an integer in this case, and it's gonna be anything from 0 to 15 because of
course, Redstone power, the max is 15 and the
lowest would be 0, which would be no power at all. This is then going to be
output in the console here inside of intelligence when we right-click
this particular block. Now that is actually
all that we need to do, most of it from vanilla. Now, as always, of course, all of the code here is
gonna be available to you in a description in the
GitHub repository and individual just as well. Now let's go into a world
and let's see if it works. All right, friends
in Minecraft again, and I've already set down the
oracle icon lab over here. So let's just take a
lever and let's see. And then we go, it turns on
and then it turns off when I, but the lever off again. And so what we can
do as well as we can with this. So there you go. And this also works. If I now right-click
this and take a look right here
in the incline, we should see power by 14. So this is of course the case because this would be 15 and then one further along with the Redstone line
here, this would be 14. If I then also turn on the lever here and I
right-click again, then you can see we're
still getting 14. Interestingly enough,
this should be 15. In my mind, that is
very interesting. Let's see if we can
do it like this. That's this work. Now
it works with 15. Alright, so the lever, it didn't actually quite work. I guess. That's very
interesting to me. Actually, I would've expected
this work, but fair enough. So this now basically is the way that this works and
this is how easy it can be to add a block that will functions with
Redstone, Minecraft. Of course, any additional
functionality that you will then want to add when
the restaurant is applied, you of course have
to either add in the block or if this
is a book entity, you can also of course
do this as well and then change it around
there as well. But that is of course,
something that you can do on your own. And I hope that you can do this and add some
functionality to it as well, but that will be it for
this lecture right here. I hope you found this useful
and you'll learn something new and I'll see you
in the next lecture. So, yeah.
120. (1.18.2) Custom Block Entity Renderer: Alright, welcome back to
the fabric course for 118. And in this lecture
we're gonna be adding a customer block entity
renderer to Minecraft. So what is a block
entity renderer? Well, basically
it is going to be a certain extra rendering that we add to a
customer block entity. And what is going to
be our block entity? Well, we're going to have a custom block model that
looks kind of like this, but it's going to be a pedestal. And then when we right-click
it with an item and the item is going to hover
over this particular pedestal. That is the general idea. Nothing too crazy,
but still pretty cool to look at this particular
block bench firewall, of course, also be
available for download. And then we can go
to File Export, Export, block item model,
the pedestal adjacent. Now I already have this, so we're going to be fine and we're going to
add this in just a little while as a
block model adjacent. But first let's start
by adding the block. So in our book, in our custom block package, right-click new Java class
called the pedestal. Look. Now I will be coming over
most of this, but no worries. All of this is
available to you in a GitHub repository in
individual just as well. Now we will get one arrow right here and a couple of
more arrows right here. But no worries, we'll
be able to fix those in just a moment once we've added the block entity class as well. Now what is happening here? Well overall, the most
important thing here is of course that is extends the
block with entity class and also that we have the get rendered type overwritten
with the model. This is extremely important. If you don't do this, then
your custom block will be invisible as actually
go to the bottom. So those are three
helper methods. We also have the
on-state replaced. This just drops basically all of the items that are
inside of the inventory. Nothing too crazy. And
then we have the unused. This method is of course called when you right-click
this particular block. And what happens here is
that if the item instead of the pedestal is empty and we actually are
holding an item, then we're just going to put this item that the
player is holding into this inventory and deleting the later item in his hand. If there actually
isn't item inside of this particular pedestal, then we're just spawning
it to the player and then we're deleting the
pedestal item right here. So that's actually
all that we're really doing in the unused method. Highly recommend checking
this out as well. It's not that complicated,
all things considered. And one of us, we
have this block. Let's actually go into the entity package and
make the custom entities. So this is gonna be the
pedestal block entity and there is something
snuck in here, and that is gonna be a typo. So there you go. Block entity. There we go. And once again, I will copy over the continents. This is actually, I
think this is actually even less than the actual block. Funnily enough. There's only 67 lines long. Not that crazy. And you can see this of course, extends the block entity and it implements the
implemented inventory that we've added in
the customer block entities lecture as well. We have the defaulted
list of items stack that's just the inventory shouldn't be anything crazy. And then we also have
a flawed right here, which is the rotation. But we need the
rotations in this case, because those need to be saved on the block entity itself. Because we can't
really save this on the block entity
renderer because they're ever only exists one
block entity renderer while the book entity itself. If we save it on this,
then it won't interfere. Because when you save it on
the block and D renderer, then what happens is that
each time you sit down a new pedestal block entity, the thing just gets
faster and faster. And that is of course not
quite something that we want. So this is why the rotation is going to be the
rotation of the item. So this is why we
save it right here. We also have a right in a read and beauty method shouldn't be anything
crazy, right? These are just for saving the inventory when we
go out of the world, right? When we save the world. And then also incredibly
important is that we want to update packet method overwritten
with the block entity, update to server to
client as to see packet and creating it
with this and then also to initial
chunk data and b t. We want this to look like this. So those two are
incredibly important. Otherwise there will be a D sync between the server
and the client. So keep that in mind that those
have to be added as well. As I've already mentioned. All of this is
available to you in the process or an
individual just as well. We can copy it over from there, right then let's go into
the block entities class and let's just copy
over the pedestal. So first of all, we're
going to copy this. So we're going to
duplicate this and make this the pedestal block entity is going to be
called the pedestal. And then we're going
to just duplicate this selected and
press Control D. This is gonna be the pedestal. This is of course equal to, first of all, the
name here, pedestal. And then here we
want to change this to a pedestal block entity. And then here we want
to use the pedestal. Now of course this
is not implemented yet, but no worries at all. We're just going to
add this as well. So the blue mode block entities, we can now go to the
pedestal rock entity. The error here should go
away and there should be no more errors present
than in the block. We can now import the
pedestal book entity class and are all errors here
should also go away. And it's great. And then to get
rid of this error, we just have to register
the actual block. So we're just gonna
do that as well. Let's just copy over
the winter window. That is going to be fine. And this is gonna be
the pedestal horse, Same with the name
here at assault. And this is going to
be the pedestal block. Now we're not going
to copy glass. Let's actually do
of material stone. I think that that makes the
most sense, non opaque. We actually don't need that. Strength three, that's
going to be fine. And then of course,
in our item group, in our custom item group here. And that should be fine. Now this arrow
should also go away, and now all of the
errors are gone. Now we still need
the custom renderer. So the entity package, we're going to right-click
new package called client. And then inside of
there we're gonna make a new class called the pedestal Volokh entity renderer. You go and this is actually
fairly straightforward, but this is going to implements the block entity Renderer, renderer right here of type. Pedestal block entity will hover over this
Implement Methods. This is the render
method right here, and that is pretty much
all that we need to do. Do. So then we can do a public pedestal
block entity renderer. Instead of here, we want
to call the book entity render our factory dot context, context and the goal. So we just want the default
constructor basically in here with this
particular parameter and the render method as well, the contents of the
random method I will actually copy over. You can see we're basically getting the item
render over here, and then we're also
getting the item stack. Now the thing that we're
doing with the matrices here, the matrix stack
basically is we are, this all just determines
the translation. So where our particular
item stack is, scale determines how big it is, and then multiply here, just rotates the
actual item erupt. That's what these
three colds do than the item renderer Render
item just renders the item. Then we have to pop this
particular matrix stack, and then we're adding the
rotation to it as well. So that is pretty much all
that we're doing here. So pretty cool, All
things considered. And I highly
recommend just taking a look at this and I'm
trying to understand it. It shouldn't be that crazy. But I will also say rendering
is definitely not my forte. I especially like it. It's, it can be pretty crazy, but all things considered,
it should be fine, right? One tiny thing,
Let's actually do call the non opaque over here. Just so that we have this. It does make sense, I
believe because the, because it is smaller
than a block. So let's just call this. And then how do we register this particular block
entity renderer? Well, this block is your Hendra is actually registered fairly straightforwardly
in the MC course client class once again, of course, now this will
require the following. We want to call it book
entity renderer registry. This one right here,
not registered. More block entities, dot
pedestal and then the pedestal rock entity
Renoir colon, colon new. We also want to call
the block render layer map dot instance that put block or
blocks dot pedestal. And then set the renderer layer to get cut out that you got. And that should actually be all of the things
that we need. Now we of course also
need the adjacent files, but those should be fairly
self-explanatory, right? So those shouldn't be too crazy. But once again, in
the block state is Jason in the block
States folder, right, Let's start by adding
the block status JSON file for the
actual pedestal. They go, this is just a normal
Bloc states Jason file. Nothing crazy going on here has also added
the translation. We have a block though
is this name pedestal. So we're just going to add this. At this point, this should
be pretty much routine, shouldn't be anything
crazy over here. Now, this is going to
be the exported file, so there's gonna be pedestal
adjacent over here. And here. Of course we once again
need to change this to Minecraft colon block
slash smooth stone. Because otherwise it's not
going to find a smooth stone. So that is one of the thing
that you need to change from the exported json file and
then the item JSON file also. Pretty much the same
thing that we've seen plenty of times before. This refers back
to the block model JSON file and then no
texture is needed. So those are actually all
of the things that we need. Lock states, translation, block, an item model, JSON file, and that should be it. So this should be all
that we need for. Now. Let's go into the
game and see if it works. Alright, so we find ourselves in Minecraft and as you can see, the pedestal has been added. So let's set it down
and let's try to right-click with the
raw error calcium. And there you go.
It is sat down. And we can also add
some more over here. And you can see
basically they are all only thing up and down
and registering here. So I can right-click and
get them out of it again. And I can right-click
and put them in. And you can see I'm always losing one or calcium basically. And then I can also get it out. So exactly how we would
expect it to work. It actually does work, and that's pretty cool. And this is one example of a customer block
entity renderer. But as I've said, the
code is all available in the GitHub repository in
individual just as well. But that would be it for
this lecture right here. I hope you found this useful
and you'll learn something new and I'll see you
in the next lecture. So, yeah.
121. (1.18.2) Loot Chests in custom Structures: All right, welcome back the
fabric course for one ATP. In this lecture, we're gonna
be seeing how you can add custom loot chests to
your custom structures. So this is something
that actually some people struggled with, even though the custom structure
from telepathic ground right here had this pretty
well explained over here. But some people still
needed a certain examples, so we're going to apply
them with that example. Let's just see what
we have to do. That what we have
to do is we can spawn a chest right here. And again it's born it with
this particular command. So set block at the
position we're standing, a Minecraft chest, they ignore. So it's going to face the same direction
we're looking into. And then the loot
table we're going to set to chest simple bungees. So we're just going to do this. And you can see now
the trust has spawned. Now, if I open it, right, and then we're to go
in and save this. So if they live, this
one is the Davidson. If I've ordered now
save this structure, then every structure would have this particular
contents of this chest. That is one of the issues
that some people have faced because what you need to do is when you actually spawn it. So let's just split it again, right here with once again, the loot table, simple dungeon. You can also add your
own Lu tables and you can also do different
route tables here, but be sure to basically have a table that is
specifically for chess. And then once you've
shown the chest, do not open the chest. You can open the chest because as soon as
you open the chest, you solidify whatever
is inside of it. You want this to be not
opened after you swallow it, and then you want to save
your custom structure. But now we're going to
save the structure. And now we can
replace the NVT data that we have already have. And then this chest in particular
is going to always have different load in it when the structure is
spawns in the world. Now let's go to intelligent and change up the MPT file, right? So the NVT file is of course
once again under the safe. Now this should be
the, another day, another structure, if
I recall correctly, There you go, the count mouse. Let's copy this over. Let's go to the Data folder, MC course structures, and
let's paste it in here, account mhos MVT, we're
going to override it. That's fine. And now this
is all that we need to do. Now let's make a new world
and see if it works. Alright, so we find ourselves
in Minecraft again. So let's just fly
to the first count, my house right here
that has spawned and I believe there's another
one in this direction. Well, first of all, we will find the chest inside of here. And if I right-click it, you can see this is the particular load. So we have iron horse armor
and three rotten flesh. So let's just save that in
our brain and let's see. Okay, So there was a horse
armor and three rotten flesh, and let's see if we
can find another one. Another count my
house, whether or not this is also the case. Alright, then we finally go, I finally found another
account mouse would actually quite difficult
to find those. Remember, there was three, rotten flesh and a horse armor, and we can see this is
completely different. We now have music disk. We still have a horse
armor but no rotten flesh. But you can see every
single structure has different loop
inside of them. So that is pretty much
how easy it is to add some custom loot chest, your custom structures, right? But that would already be it
for this lecture right here. I hope you found this useful
and you'll learn something new and I'll see you all
in the next lecture. So, yeah.
122. (1.18.2) UPDATE TO 1.19: All right, welcome back to
the fabric course for 118. And in this lecture
we're gonna be updating our project to 119. Now, this is
actually going to be a fairly straightforward
process, all things considered. Luckily, the changes
between 11819 and fabric aren't that crazy. So let's just begin. First of all, we're
going to start with the fabric mod adjacent file, where we have to change
these depends or here. Now we want to change those two. Fabric loader being 14.6. I want to change the
Minecraft version to be the squiggly line
here, tilda 1.19. Of course, that should be fine. In our MC course
mixing Tracer file, we want to change
the Java, java 17, and then we can continue
to the build Gradle file, where first of all,
we want to change the fabric Looom
version here to 12. And then we of course,
also wanted to change the gecko lip
implementation over here. The equilibrium force
has to be updated. So this would be
fabric one at 22.1. And then in the greater
properties file, this is actually
where we have to change most of these things. We want to change the
micro version to 1 ninth, yarn mappings or 119, build one fabric loader. The lower version here is 14.6. We can then of course
it's also change our own mod version here. And then this is
going to be 55.11.19. And that should
pretty much be all of the things that we
need to change over here. And then we can load
the Gradle changes. Now once again, this might take anywhere from a few seconds
to maybe even two minutes, three minutes, depending on
how fast your computer is, depending on how fast your
Internet connection is, all of that craziness. Let's just let this run
through and be patient. And then we'll see once this has gotten as a
build successful, alright, here we are 32 seconds. If you then go, for example, into your main mod
class and some of the classes are marked red rates on what
initializer could, for example, be
Margaret, don't worry, just wait a second
until everything has built and then it should
fix itself in theory. So this is pretty much
all that we need to do. Now, of course, come
the code changes, which are, I wouldn't say
numerous necessarily, but there are quite
a few of them. So let's first of all start at the very top of our classes. So the first one where we need
to change some things is, I believe in it's not
the pedestal class, it should be the speedy block. Now interestingly enough, the thing that we actually
need to change here is the text over here. So the literal texts class
does no longer exist, but luckily, it is very
easy to change this. We just need to call
text dot literal. And that is pretty much all that we need to
do once again here, text dot literal, and now we have an error in the imports. You fix this, we can just
press control alt and O. And that should
fix that as well. Now you can see that
the Random display is also not working. Now why could that be?
Well, the reason is that the random class
has changed as well. We're currently using
Java util random. Let's just delete this import. And if we then import
the random class again, you can see it actually wants
to import net Minecraft, beautiful math random, random. We actually have a
new random class. This now of course has some different functionality to it. So we actually have to do
the following in the double. So here in our next double, we're just not going to pass
in anything in this case. And this should also
be ins that case. There you go. That should be okay. So if you have a method
where random is a parameter, that is probably the reason
why it's not working. If it's still using the Java util class of random,
it's a little, it's not the best naming
convention here at naming it the same as the Java util one, but that's
going to be okay. But that is the random
class there and that is the speedy block and
that should be fine. Now, one of the big
changes is going to be in our high-end stuff. So this one should
actually be fine. More block entities
should be fine. You can of course go
through it. Here. We just have a text. Once again, this
is gonna be texts that literal and then Alt, Control and O, and then no
more errors should be present. So that's all great. You can see most
of this stuff is actually going to be
pretty much fine. The more blocks class is
also correct. That's great. Science also good. So the blocks are all done. Some changes have
happened in the commands. We're going to see
this in a moment. De-register method actually has also changed, but that's fine. We're just going to
change the texts that literal for the time being. And then once again
Control Alt O. And then for this at home
command, the same thing. We're going to say, text literal day ago and then
Control Alt O again. And there we go. The commands are changed
for the time being. And what's very
important here also is that everything
of course is once again available to you in
the description below in the GitHub repository and
individual just as well. Now the mod conflicts
should not change because those are
all basically new. Select custom classes
more or less the effects, they don't change
the Enchantments, they don't change the entities. So something's changed
in gecko lip and that is the names of these
particular methods. So what we can do is we
can just do the following. We can just select
this. So I'm just going to copy the name over here. I'm going to go to my account little package of press Control, Shift R and paste this in. And I want to change
this in all of the wells everywhere
we're basically comes up and this name here
changes to model resource. In short, we write
this correctly there you will get
more resource. We're just going to replace all. And then this is
going to be fixed in all of our custom model classes. How do I know that
this is the change? Well, if we just
middle mouse button, click on the animated GO
modal mass over here, we can basically see the
different things are, this is actually in
the model provider. I believe they go model
resources, texture resources. And the other one is
the animation resorts. So that's pretty much
what it changes too. So once again, we're
gonna do the same thing, Control Shift R on
the calendar package. Now we're going to change
the texture location to texture resource. This is all fine. But let's just
replace all the ego. That's gonna be okay. And then the animation file
location also the same thing. Going to replace this with the animation resource
lays it, replaced it. Now no more errors should be present in any of
our model files. This is also fine and you can
see this also all changed, but also all still working. So kind of exactly how you would want it to the
actual entities. There are no changes
to the entities. There is a change here. What is this? This is the end, be controlled by writers. So let's actually take
a look at what this is. Well, I'm not a 100%
sure why the writable here does no longer have the
can be controlled by writer. But honestly, let's
just remove the add override and let's just
hope that it still works. That's probably going to
be the best idea here. And then when it comes
to the rest here, everything should still
be working totally fine. So entities are also done. The events should also be fine in this
case, that's great. Fluids are also totally fine. And then we come to the item. The item is the first one. We are quite a few
changes happened, but also not that crazy. Though most of the changes
in the item happened in the data tablet and
the dowsing rod. Because once again,
we have some texts, so easily enough texts that literal right here
Control Alt O, and then the same in the dowsing rod item here we
have a translatable texts, so this is gonna be
texts translatable. And then here as well, have instead of a new
translatable texts, we have texts
translatable and then same here, texts translatable. Then here once again we have
a literal texts of texts, data literal Control, Alt O, and then no more errors
should be present. Apart from that, the rest
of the items are all fine. There might be something
in the more items class. There's nothing in
the more items class. So everything here
working as well. The mixer should be fine except for these structural
feature mixin, we can actually delete
this right here. And then also very important, delete this from the MC course
or mixed race in as well, that is no longer needed. Now the paintings have
the painting strange? Yes, the paintings
have actually changed. It's crazy, I know, but it is the case now. It's no longer called
the painting motif. It is now called the
painting, a variant. But what we can do is we
can basically just select this press Control R and then change this to painting variant and then just say Replace All, and then
it should be fine. And then here we want to
change this to a painting, a variant, and then it
should work as well. The potions have not changed, and I believe the recipes
also have not changed. So everything here is
still working. Great. Screens are fine,
sounds are fine, and then you till now in Utah there are actually who changes. One of them is the
loot table modifier. So those have changed
a little bit. So now we no longer use the loot table loading
callback event. We're now using the
loot table events data modify that register, but this is the change
we have to do here. And then the change
here is we no longer use the fabric
lewd pool builder. We're now using the pool
loot pool data builder. And then here we're using loot pool data builder and then creating a new
building right here. This is going to call
the apply method and this is going to call
it the pool method. And then we can just copy
over the first line over here and then just replace
this Diego and then same here. This is apply and then width
pool is just called Pool. Once again with functions called Apply and this one is called, well, now this should
work totally fine. Once again, the imports, we're just going to
press Control Alt O, and that should be fine. Let's continue to the
Model Registry is where we actually have a issue
with the event over here. Now the event actually, we
just can import this again, but you can see then our register methods
are no longer working. So the register method
have changed a little bit. So I'm just going to copy over the new register
method parameters. So we now have three parameters. As you can see,
the dispatcher is just now the server
command source dispatcher. So this is all that we need
to do once again, of course, this is available to you in the GitHub repository and
individual just as well. So you can basically, well, we're easily take a
look at that there. So let's just copy over the parameters one
more time over here. You go in them. We're taking this one
and just changing it. And now normal airstrip be
present, Control Alt O. And then the mod
registries are also fine. But then there are
some crazy changes in the villagers over here. Now, the change down here
is actually going to be that instead of a point
interests type accessor, we're just making a new point, new interests over here. So you can see we're
just creating this. We also no longer need to call
the setup of poise method. And then in here in the
register professions, while we wanna do is we want to actually call the register the villager profession
builder that create. That ID with a new identifier as seeing in our MC course
mod mod ID and the name. And then calling the workstation
passing in the type. We also have to change
this in a moment. And then we also want to call the bark sound sound events, that entity work
Amara, that build, posing with a
parentheses and they go and that should be pretty
much what we need to do here. For the point of interests type, we want to change this
to a registry E of type, point of interests type. There you go. And then here, instead
of passing this in, we want to see a registry key, registry key dot of
registry data point of interests to type a key
with a new identifier. Once again, of course
MC, course Mod model ID. And then the blast or point
were important to that. The blastopore here
is the same as this name right here
or the plaster point. Now we also want to say Control Alt O to get
rid of the imports. And then in our MC
course mod class, we wanted to remove the setup poise call and
that should be fine. The villagers should
now work as well. And now last but not
least, of course, World generation, what
has changed here? Well, actually not too crazy. In the sapling generator, we once again have the
different random class. So if we just remove random
import and import it again, then here everything
should work fine. So that's great.
Nothing's changed in the other feature classes. And then the changes are just in the gen class because we now have a different
way of selecting it. So the selector is actually
now have include by key all out another found in N. So there's a little
bit of a difference here, but we can just say this
and then it's, for example, say biome keys dot planes. And then here we
should be able to say include by key biome, keys dot jungle for example. So this should now work as well. The same thing
happens here, right? The planes, let's
say biome keys, planes for the
flowers over here, and then for the tree,
same thing, load here. Biome keys dot planes. And that should be fine. The origin ration didn't change and the world modern
origin as well. The same thing. Now the structures, they have changed again because of course, this is why we can't have
nice things so to speak. But that is going to be
okay, no worries there. So let's actually start with the sky structures over here. These guys structures,
I'm just going to once again copy the contents over of this and we're just going to briefly look at this. So we now have a codec. What does the codec? The simplest thing
to explain this as basically it is a way of reading a class from a JSON
file that is pretty much the easiest way to
take a look at this. Now, once again, this is
going to be available, and this was also done by
telepathic ground once again. So we can basically thank them for basically updating
this very, very fast. And I highly recommend
checking out the allopathic grunts it up, pause to once again and checking out all of
the new comments that are added there that should
probably help you as well. Now the mod structures
one looks like this. Now they actually might
be one more issue here. Now, this should be all fine. And then intimate structures, basically one of the following. So now we want a
structure type over here. Then let's add this. So we want this, this
is a register method. The register method,
it looks like this. The course MOD or this
is MC equals MOD Diego. And then just deleting all
of the inputs that are no longer working and that
should pretty much be fine. You can see the code
changes are not that crazy, but there are also Jason
changes which we can, I believe tackle already because this should be everything that we
need to change here. Yes. We can basically go into the adjacent files and take
a look at those as well. So this is going to
be the, of course, the MC course traits
and files world gen. The first thing we do is we need to rename this
particular folder configured structural feature is now just called structure. Structure. Now the contents of this have changed a little bit as well. So let's take a look at this. But first of all,
we want to remove the conflict over here so that it only has the storage
pool and the size inline. And then we also want to add the max
distance from center. So this one right here, you also want to add three more things. And that is going to be
we basically replace the add up noise with the surface
structures absolute height. We can now actually also define
inside of the JSON file, starting to height map
this one right here. Now we need to do the same thing for all of the adjacent files. And what's important is that
for the adjacent only house, we actually wanted to
change this one up here to jigsaw, that's
very important. Then remove the
conflicts once again, AMA in line this distance from center over here below the size. And now we want to add
four different things, changing the adept noise. And that is gonna be the US
expansion hack here as well. That's very important
of this is basically needed for when you use
the jigsaw right here. Same thing here. Just
changing this up. You go, don't forget to
add the comma over here. They are. There you go. Let's replace the add
up noise over here. And then of course once again, the max distance from center. And that should be fine as well. Then last but not least,
the storage platform as well or platform changing
the type to jigsaw, getting rid of the
config over here, distance from center, and then placing the ad up
noise right here. There you go. And that should pretty
much be all that we need to do in the structured
trace of us. Lead structures should
now work totally fine. And I believe looking at this, this should be all of
the like huge changes. There is one more change
which is very annoying, and that is actually with
the recent files right here. There is a change for the door. So we have a cherry blossom door over here and this
one right here. And they also changed. So both the block
States JSON file, as well as the block model JSON files for the
doors changed. We had four of them, two for
the bottom, two for the top. And now there's
actually four for each. So there's four bottom
ones and for top ones. So what we can do
is we can go to the external libraries all the way down to is
this one right here, net micro projects,
so on and so forth. Under the assets Minecraft, we can first of all go
to the block states and copy over the acacia door, in this case R1. So let's just do that. There you go. Let's go back down again and let's go to the models block. And you can see
here acacia door, all of a sudden
there's eight of them. It's actually insane. I don't know why they
changed it, but that's okay. So copy those over as well. And then we can change
them one by one. So this one here, the acacia door, basically, all we just need to do is we just need to change a microphone over here to MST
course, Replace All, and then select acacia
and change this to the cherry underscore blossom. Replace all. There you go. And then we can delete the
cherry blossom door here. Press Shift F6 once again to rename cherry blossom
underscore door. And then the block
states one is changed, but of course then come the real thing and that
is the model file. Now what we can do is
click on the blog folder, press Shift Control R, and then change not
cherry blossom, but actually acacia
to cherry blossom. You can say it replaced all. Yes, please. And then we can do
the same thing. Go to block again,
Control Shift R, and then we want to change
a Minecraft MC course. Now we have to be very
careful to not just replace all because it's going to replace the
parents as well. And we don't want that. We only want to
change the bottom and top. You can see bottom. I can replace top. Replace. Now we
have a parent no. Bottom. Yes. Up. Yes. Once again, parent no. Bottom. Yes, top. Yes. Please make sure to
do this correctly. Otherwise, you will
have an error in there or it's not going to
display properly. But please take care when
replacing it like this, up and then bottom
and top again. And then now we
only have parents, so we now are done. And now we just need to
change the names here. Once again, Shift
F6 to rename them, and then always changing the
acacia to cherry blossom. And then I believe we
should be fine over here. After we've done this. Now as you can see, there's
a little loop tedious. Hopefully, you don't have not added like 20 different doors. Otherwise. I I mean, I'm sorry. It is what it is. It's probably going to be just a very boring
afternoon for you then renaming all of this
because my God is this is this annoying,
but it is what it is. It doors have changed and
that is gonna be okay. But now we can remove the
old door Jason files. And with this, we
are finally done. For now. Let's open the game
and see if it works. Or we have another
random tick over here. This is of course once again because of the random, right, just remove the import
Alt and Enter on this, and then everything
should work fine. Let's see, and let's continue. Let's see if there's
any other arrows. There might be another
scheduled tick once again, the same error here,
no worries at all. Let's just remove this
Alton enter on the random, and then let's continue along and now I think we
should be fine. Alright, so fabric has started. So let's just go in and see
if we can create a new world. And this looks great. So if we reach this one,
that's gonna be okay. And let's just make a
new world and let's see. Alright, so here we are
in Minecraft once again. So let's first of all take a
look and there we have it. Everything is still available. So let's just take a look
at whether or not some of these things still work the
way we would expect them to. Let's get a dowsing rod. Let's get a data
tablet over here. Let's see if we can
still find some ores. And there we have it. We have found some ores and it has saved on
the data tablet. So that seems to all
be working fine. Let's spawn the entities. They also still are fine. They seem to be
responding quite well. Let's then take a look at
the recalc and blaster. That is always a thing that is a little bit of an
interesting one, right? D-block entities if
they still work. Let's get some cool. Let's get a pick ax over here. And then last but not least, let's get a worry calcium ingot and let's see if this
also still works. And indeed it does still work. I found rabbit. I think you have a little
bit of an issue over here. Alright, there you go. The Oracle can pick
x also still works. So this also works still fine. Then let's actually take
a look at if we can locate a links
biome and y-naught. And let's see if that
yields some things for us. So we should find out
that's not the right one. We want to go with the
spectator more. There you go. We can find some of
the trees over here. And maybe we can also
find some of our flowers. And indeed we can,
there we have it. So just a few of our
flowers, interestingly, interesting resist of
this as a venture model. Eventual more. There you go. And then we have pink roses. So everything here
seems to still be working pretty much exactly
how you'd expect it to. Let's actually also locate a structure just so
that we have this. So this should be MC course. Let's see, counting
house and there is a count Mao's available
and there we have it. So everything's still
working totally fine even with our
custom loop in here, which is exactly what
you want to see. So yeah, that's
pretty much how easy it can be to update
fabric to 119. Alright, and this pretty
much concludes the course. Thank you so much for watching. I hope you found this useful and you'll learn
something new if you did, would very much appreciate
a review from you. Otherwise, I hope I'll see you in possible future lectures now, there's nothing currently
planned anymore, but who knows, there might be one or two extra things
that might come up. Otherwise, I hope to see
you in anywhere else, maybe in future courses as well. So, yeah.