Latest / CyberSecurity Summary / Absolute Beginner's Guide to Minecraft Mods Programming
Transcript
- 0:00Speaker 1: Have you ever been deep in Minecraft, maybe building something
- 0:03Speaker 1: amazing and just thought, man, I wish this worked differently.
- 0:07Speaker 2: Oh, definitely, like wanting a custom command, or maybe changing
- 0:12Speaker 2: how blocks.
- 0:12Speaker 1: Behave exactly Like, would it be cool to type one
- 0:15Speaker 1: thing and have I don't know, a whole army pop up,
- 0:18Speaker 1: or maybe make every block you touch turn to gold.
- 0:20Speaker 2: Yeah. Taking that world you know so well and then
- 0:23Speaker 2: getting the power to actually tweak the rules with code. Well,
- 0:28Speaker 2: it's literally a game changer.
- 0:29Speaker 1: It really is. And that's that's pretty much what this
- 0:32Speaker 1: deep dive is all about. Today. We've been looking at
- 0:34Speaker 1: this beginner's guide that focuses specifically on using Java programming
- 0:39Speaker 1: to make those custom Minecraft mods.
- 0:41Speaker 2: Yeah, think of this as a bit of a shortcut.
- 0:45Speaker 2: We're aiming to unpack the core bits of Java you
- 0:47Speaker 2: really need and show how they plug directly into making
- 0:51Speaker 2: your own mods, you know, going from just playing the
- 0:53Speaker 2: game to actually shaping it.
- 0:54Speaker 1: Okay, so let's start right at the beginning. Why Java?
- 0:58Speaker 1: Why is that the language for Minecraft?
- 1:00Speaker 2: Well, the source material is pretty clear on this. Minecraft
- 1:03Speaker 2: itself is built using Java, so it just makes sense.
- 1:06Speaker 2: It's the native tongue, if you will. And importantly, the
- 1:09Speaker 2: guide really emphasizes that it's not some super scary, impossible
- 1:13Speaker 2: language to pick up, especially just for modding basics.
- 1:16Speaker 1: That's encouraging. So what tools do you actually need to
- 1:19Speaker 1: get going?
- 1:20Speaker 2: It's surprisingly accessible really. First you need the Java development kit,
- 1:25Speaker 2: the cord Java stuff itself, it's free.
- 1:27Speaker 1: Okay.
- 1:28Speaker 2: Then you need a place to write the code. The
- 1:30Speaker 2: guide recommends net beans. That beans right, Yeah, it's an
- 1:33Speaker 2: ID and integrated development environment, basically a smart text editor
- 1:37Speaker 2: for code. Also free.
- 1:39Speaker 1: So Java net beans. Huh what else do you need?
- 1:42Speaker 1: The game? Ah?
- 1:43Speaker 2: Yes, you definitely need the actual Minecraft game client, specifically,
- 1:48Speaker 2: the guide mentions the Windows or mac os versions. That's
- 1:51Speaker 2: the paid part around twenty seven dollars currently.
- 1:53Speaker 1: And that's where you'll actually see your mod in action.
- 1:56Speaker 2: Well, you need one more piece for testing, according to
- 1:57Speaker 2: the guide, a Minecraft server you set up, usually on
- 2:00Speaker 2: your own machine, to start your own little test world exactly.
- 2:03Speaker 2: Your mod runs on the server, and then you connect
- 2:07Speaker 2: to that server with your regular Minecraft game client using
- 2:10Speaker 2: the multiplayer option. That whole setup is your development and
- 2:14Speaker 2: testing playground.
- 2:15Speaker 1: Okay, setup complete, Now let's crack open NetBeans. You've got
- 2:19Speaker 1: this software. Yeah, where do you even click? First.
- 2:22Speaker 2: Right, So in NetBeans, you typically start by creating a
- 2:25Speaker 2: new project.
- 2:27Speaker 1: A project like a folder for the mod pretty much.
- 2:30Speaker 2: Yeah, it holds all the files related to that specific
- 2:32Speaker 2: mod you're building. And inside that project, you create a
- 2:36Speaker 2: new Java class file, and the.
- 2:37Speaker 1: Class file is where the actual instructions go.
- 2:39Speaker 2: It's it. It's like a blueprint. You write your Java code,
- 2:42Speaker 2: your instructions inside that class file.
- 2:44Speaker 1: Now, for the program to actually well run, it needs
- 2:48Speaker 1: a specific starting point, doesn't it like computers start here exactly?
- 2:52Speaker 2: Every standalone Java program that you can just run needs
- 2:55Speaker 2: a special method called main. Okay, that's the entry point.
- 2:58Speaker 2: When you hit run, the java is looks for that
- 3:00Speaker 2: main method first and starts executing the code inside it.
- 3:03Speaker 1: The guide had that classic first example, right. The im
- 3:06Speaker 1: spartakan is one.
- 3:07Speaker 2: Yeah, you type one line of code inside Maine something
- 3:11Speaker 2: like system out dot printle nimspartacus. You run it in
- 3:16Speaker 2: net Beans.
- 3:17Speaker 1: And bam, it appears in the output window.
- 3:20Speaker 2: Yep, your first little piece of running code. It's a
- 3:23Speaker 2: good feeling, But coding.
- 3:25Speaker 1: Isn't always smooth sailing. What about mistakes? Typos?
- 3:29Speaker 2: Ah? Yes, errors. The guide jumps right into that. It's
- 3:33Speaker 2: just good. It shows how NetBeans helps you out immediately
- 3:37Speaker 2: how so well, say you forget a semicolon at the
- 3:40Speaker 2: end of a line, which is easy to do. Net
- 3:42Speaker 2: Beans will often put a little red squiggle under it
- 3:45Speaker 2: or show an error.
- 3:46Speaker 1: Icon like spell check for code.
- 3:48Speaker 2: Kind of yeah, it gives you instant feedback telling you, hey,
- 3:50Speaker 2: something's not quite right here. It really helps catch simple
- 3:53Speaker 2: mistakes early.
- 3:54Speaker 1: That sounds super useful for beginners. The guide also mentioned
- 3:58Speaker 1: comments lines that aren't actually right.
- 4:00Speaker 2: Comments you start them with for a single line, or
- 4:04Speaker 2: wrap a block with an NM, and.
- 4:05Speaker 1: The computer just ignores them.
- 4:07Speaker 2: Completely ignores them when running the program. But they're absolutely
- 4:10Speaker 2: vital for humans for understanding what you wrote later exactly,
- 4:13Speaker 2: or for someone else reading your code. They're like little
- 4:16Speaker 2: notes explaining why you did something or what a particular
- 4:19Speaker 2: section of code is trying to achieve. Essential for anything complex.
- 4:23Speaker 1: Okay, so we can run a basic instruction, but mods
- 4:27Speaker 1: need to remember things right, like a player's name or coordinates,
- 4:33Speaker 1: or maybe how much health a mob has. How does
- 4:36Speaker 1: Java handle that?
- 4:37Speaker 2: That's where variables come in. You can think of variables
- 4:40Speaker 2: as named containers, like little labeled boxes in the computer's memory.
- 4:43Speaker 1: Boxes to store information precisely.
- 4:46Speaker 2: You put pieces of data into these boxes so you
- 4:48Speaker 2: can use them later in your mod.
- 4:50Speaker 1: And these boxes hold different kinds of information.
- 4:52Speaker 2: Yes, very important variables have types for Minecraft moding. The
- 4:56Speaker 2: guide highlights a few key ones. You'll use a lot
- 4:59Speaker 2: like well, is a big one. That's for whole numbers,
- 5:01Speaker 2: think coordinates xyz or counting items.
- 5:04Speaker 1: Stuff like that. Okay, in for whole numbers.
- 5:06Speaker 2: Then there's string note the capital s. That's for storing text,
- 5:10Speaker 2: player names, messages you want to show in chat command
- 5:12Speaker 2: words like stone or diamond.
- 5:14Speaker 1: So inf counts string for text. Makes sense.
- 5:18Speaker 2: The guide also mentions float and double for numbers with
- 5:21Speaker 2: decimal points maybe for precise positions or something, and char
- 5:24Speaker 2: for just a single character. But honestly, int and string
- 5:27Speaker 2: will get you very far when you're starting out with mods.
- 5:30Speaker 1: How do you like create one of these variable boxes?
- 5:34Speaker 2: You declare it. You see the type, then the name
- 5:36Speaker 2: you want to give it. So int player score creates
- 5:39Speaker 2: an integer variable named.
- 5:40Speaker 1: Player score, and putting a value in it.
- 5:42Speaker 2: You use the equal sign. That's the assignment operator. So
- 5:45Speaker 2: player score equals one hundred, puts the value one hundred
- 5:48Speaker 2: into that box.
- 5:49Speaker 1: The guide also showed some shortcuts, didn't.
- 5:51Speaker 2: It, Like plus Yeah, player score plus ten is shorthand
- 5:54Speaker 2: for player score player score plus ten and plus plus
- 5:57Speaker 2: act like player score plus plus ac just adds one
- 6:00Speaker 2: very common, saves a bit of typing.
- 6:02Speaker 1: Are the rules for naming these variables A few simple ones.
- 6:05Speaker 2: They are case sensitive, so player score is different from
- 6:07Speaker 2: player score. Okay, no spaces or punctuation usually allowed in
- 6:11Speaker 2: the name, and you can't use java's reserve words words
- 6:15Speaker 2: like public class INNT if those already have special meanings.
- 6:20Speaker 1: Got it. So variables hold the data, What about doing
- 6:23Speaker 1: things with that data?
- 6:25Speaker 2: Calculations, right, That's where expressions and operators come in. You
- 6:29Speaker 2: use operators like plus for addition, for subtraction, for a multiplication.
- 6:33Speaker 1: For division, just like basic math.
- 6:35Speaker 2: Pretty much in total score at score one plus score
- 6:38Speaker 2: two adds two scores together. The guide mentions operator precedence
- 6:42Speaker 2: like multiplication happens before addition, and this exactly. But you
- 6:47Speaker 2: can always use parentheses to control the order, just like
- 6:50Speaker 2: in math class to make sure things calculate the way
- 6:52Speaker 2: you intend.
- 6:53Speaker 1: And once you've done a calculation, or you just want
- 6:55Speaker 1: to display some text, how do you show that to
- 6:57Speaker 1: the user or maybe in the serverlog.
- 7:00Speaker 2: The most fundamental way in Java is using system dot
- 7:03Speaker 2: out dot print allen.
- 7:05Speaker 1: System dot out dot print allen. Bit of a.
- 7:07Speaker 2: Mouthful, it is, but you get used to it. Whatever
- 7:09Speaker 2: you put inside the parentheses gets printed out, usually to
- 7:12Speaker 2: the NetBeans output window or the Micraft server console. When
- 7:15Speaker 2: you're moddling like.
- 7:16Speaker 1: That example, alphae has been killed by a magma cube.
- 7:18Speaker 2: Huh huh, yeah, that memorable one, that exact text would appear.
- 7:22Speaker 2: There's also system dot out dot print, which does the
- 7:25Speaker 2: same thing, but doesn't automatically start a new line afterwards.
- 7:28Speaker 1: Okay, so we can store info, do math, print stuff out.
- 7:31Speaker 1: But real programs need to make decisions, don't they Like
- 7:35Speaker 1: if the player does X, then do HY or repeat tasks.
- 7:40Speaker 2: Absolutely, that's control flow. You need ways to control which
- 7:42Speaker 2: lines of code execute and when. Conditional statements and loops
- 7:46Speaker 2: are the pills for that.
- 7:47Speaker 1: Conditionals first making choices.
- 7:50Speaker 2: The simplest is the if statement. You give it a
- 7:52Speaker 2: condition something that's either true or false. If it's true,
- 7:54Speaker 2: the code inside the if block runs. If not, it's skipped.
- 7:57Speaker 1: So if player has enough gold, then run the code
- 8:01Speaker 1: to give them the item exactly.
- 8:02Speaker 2: Then you've got if else. This gives you two paths.
- 8:04Speaker 2: If the condition is true, do the if part. If
- 8:07Speaker 2: it falls else, do the else part. Plan A, plan B.
- 8:10Speaker 2: The guide also mentioned the switch statement. That's useful when
- 8:13Speaker 2: you have one value and you want to do different
- 8:15Speaker 2: things based on several possible specific values. It could have
- 8:18Speaker 2: like checking an item type and doing something different for
- 8:21Speaker 2: a sword, an ax, or a pick axe.
- 8:23Speaker 1: Okay, decisions covered. What about doing things repeatedly?
- 8:27Speaker 2: Loops essential for so many modding tasks. Imagine placing blocks
- 8:33Speaker 2: in a line or checking every slot in a chest.
- 8:36Speaker 2: You need loops.
- 8:37Speaker 1: The fore loop is one, right, Yeah.
- 8:38Speaker 2: The fore loop is often used when you know roughly
- 8:41Speaker 2: how many times you need to repeat something. You typically
- 8:44Speaker 2: set up a counter, tell it when to stop and
- 8:46Speaker 2: how to increment.
- 8:47Speaker 1: Like for I from zero to nine place.
- 8:49Speaker 2: A block perfect example. Then there's the wil loop. It's different.
- 8:52Speaker 2: It keeps looping as long as a condition stays true.
- 8:56Speaker 1: More like while the button is held down, keep doing
- 8:58Speaker 1: this exactly.
- 9:00Speaker 2: The condition is checked before each loop iteration. The guide
- 9:03Speaker 2: also mentions do while, which is similar, but the check
- 9:06Speaker 2: happens after the code runs, so it always runs at least.
- 9:08Speaker 1: Once, and sometimes you need to stop a loop early.
- 9:11Speaker 2: Yeah, the break statement lets you jump out of a
- 9:13Speaker 2: loop immediately. If you're searching through a list and find
- 9:16Speaker 2: the item you need on the third try, you can
- 9:18Speaker 2: just break out instead of checking the other one hundred items.
- 9:21Speaker 1: So if else switch for a while. Those are the
- 9:25Speaker 1: core control tools.
- 9:26Speaker 2: There really are. Mastering those lets you build the actual
- 9:29Speaker 2: logic into your mod.
- 9:31Speaker 1: Now, we talked about variables for single pieces of info,
- 9:35Speaker 1: but what if you have like a whole bunch of things,
- 9:37Speaker 1: say all the players online or a list of block
- 9:40Speaker 1: coordinates for a structure, Making a separate variable for each
- 9:44Speaker 1: seems inefficient, Totally inefficient.
- 9:47Speaker 2: That's where arrays save the day. An array is a
- 9:49Speaker 2: special kind of variable that holds a collection of items
- 9:52Speaker 2: a list, basically kind of but with a key restriction.
- 9:55Speaker 2: All items in a single array must be the same type.
- 9:57Speaker 2: So you can have an array of vents or an
- 9:59Speaker 2: array of string, but not a mix in one standard array.
- 10:02Speaker 1: So an inter ray could hold all the y coordinates
- 10:04Speaker 1: for a tower exactly.
- 10:05Speaker 2: You create an array and specify its size upfront, like
- 10:09Speaker 2: in chords equals new Inn fifty, it creates an array
- 10:11Speaker 2: that can hold exactly fifty integers fixed size. Huh yep.
- 10:15Speaker 2: That's a key characteristic of basic arrays. Each slot in
- 10:18Speaker 2: the array is called an element, and you access them
- 10:21Speaker 2: using an index.
- 10:21Speaker 1: Number, and the index starts at zero.
- 10:24Speaker 2: Always zero in Java. So the first element is an
- 10:27Speaker 2: index zero, the second at index one up to index
- 10:30Speaker 2: forty nine. In our fifty element array that.
- 10:32Speaker 1: Reindeer names example in the guide really drove that fixedisz
- 10:36Speaker 1: point home made an array for eight reindeers.
- 10:38Speaker 2: And then poor Rudolph couldn't fit because the array was
- 10:41Speaker 2: full there was no index eight.
- 10:43Speaker 1: Right. How do you know how big an array is
- 10:44Speaker 1: once you have it.
- 10:45Speaker 2: Arrays have a handy length property, so ycords dot length
- 10:49Speaker 2: would give you fifty.
- 10:50Speaker 1: And what happens if you mess up and try to
- 10:52Speaker 1: access say index fifty in that fifty element array.
- 10:55Speaker 2: Boom, Well not quite boom, but your program will likely
- 10:59Speaker 2: stop and throw an array index out of bounds.
- 11:01Speaker 1: Exception an exception like an error.
- 11:03Speaker 2: Yeah it's job as a way of saying you tried
- 11:05Speaker 2: to access a part of the array that doesn't exist.
- 11:08Speaker 2: The guide points out the specific exception usually means there's
- 11:11Speaker 2: a flaw in your.
- 11:12Speaker 1: Code logic something you need to fix. In the code itself,
- 11:15Speaker 1: not just handle during runtime.
- 11:17Speaker 2: Generally, yes, you should fix your loop or your index
- 11:19Speaker 2: calculations so it doesn't try to go out of bounds.
- 11:22Speaker 2: Arrays are fundamental, but the guide also briefly mentions other
- 11:26Speaker 2: collection types, things like a ray list. It's more flexible,
- 11:29Speaker 2: like a list that can grow or shrink as needed,
- 11:32Speaker 2: much more convenient than fixed size arrays sometimes, and hash map,
- 11:36Speaker 2: which is great for storing key value pair.
- 11:39Speaker 1: KEYWTE like looking up a word in a dictionary.
- 11:41Speaker 2: Exactly, you store something using a unique key like a
- 11:45Speaker 2: player's name, a string and associate it with a value
- 11:48Speaker 2: like their score an end. Then you can quickly retrieve
- 11:51Speaker 2: the value just by knowing the key. Very useful structure.
- 11:54Speaker 1: Okay, arrays and collections for handling groups of data. Now
- 11:57Speaker 1: let's just step back a bit. The guide talks about
- 11:59Speaker 1: a really big concept, object oriented programming.
- 12:02Speaker 2: Op ah yes, oh ohp. It's a whole way of
- 12:06Speaker 2: thinking about structuring your programs, and it's fundamental to Java
- 12:10Speaker 2: and by extension, to Minecraft modding with things like spigot.
- 12:14Speaker 1: So what does object oriented actually mean in this context?
- 12:17Speaker 2: It means you design your program around objects. Think of
- 12:20Speaker 2: objects as representations of well things. They could be real
- 12:24Speaker 2: world things like a player, a wolf, a block, or
- 12:28Speaker 2: more abstract things like a game rule or a server event.
- 12:30Speaker 1: And what makes something an object? In code?
- 12:33Speaker 2: Two main things to find an object. First, it has
- 12:35Speaker 2: data associated with it, attributes or properties think variables, but
- 12:39Speaker 2: belonging to that object. Second, it has behavior things that
- 12:43Speaker 2: can do. These are called methods.
- 12:45Speaker 1: Okay, So back to that zombie idea earlier.
- 12:47Speaker 2: Perfect a zombie object would have attributes like health, maybe
- 12:51Speaker 2: an int, location, maybe a location object is baby, a
- 12:54Speaker 2: true false, a boolean that's the data right, and its behavior.
- 12:58Speaker 2: It's methods would be things like attack player, target, move
- 13:02Speaker 2: towards location, destination, take damage into mounts.
- 13:05Speaker 1: So an object bundles is data and its actions.
- 13:08Speaker 2: Together exactly the guide use a virus example, I think
- 13:11Speaker 2: with attributes like identify an author, same principle, and a
- 13:14Speaker 2: key part of OKP is controlling access to that data.
- 13:17Speaker 1: The public and private stuff.
- 13:19Speaker 2: Yes, you can mark attributes and methods as public meaning
- 13:23Speaker 2: any part of your code can access them directly, or
- 13:26Speaker 2: private meaning only the code inside that same object's class
- 13:30Speaker 2: can access them.
- 13:31Speaker 1: Why make things private?
- 13:32Speaker 2: It's about encapsulation, protecting the object's internal state. Usually you
- 13:37Speaker 2: keep the data health, etc. Private and provide public methods
- 13:41Speaker 2: get health, set health to interact with it in a
- 13:45Speaker 2: controlled way. It makes your code more robust and easier
- 13:48Speaker 2: to manage.
- 13:49Speaker 1: And methods can give back results you.
- 13:50Speaker 2: Said yep using the return keyword. A method like get
- 13:54Speaker 2: health would return the current value of the private health variable.
- 13:57Speaker 2: A method that just performs an action like attack might
- 14:01Speaker 2: not return anything. Its return type would be void.
- 14:03Speaker 1: Okay, Then there were static methods. Those felt a bit different.
- 14:07Speaker 2: They are a bit different. Remember, the class is the blueprint,
- 14:09Speaker 2: and objects are the things made from the blueprint. Right,
- 14:11Speaker 2: Normal methods belong to the objects. Static methods belong to
- 14:15Speaker 2: the class itself, the blueprint. You don't need a specific
- 14:18Speaker 2: object instance to use them.
- 14:20Speaker 1: Like that integer dot parsing example, converting text to a.
- 14:23Speaker 2: Number exactly, you don't need an integer object. You just
- 14:27Speaker 2: call the method directly on the integer class integer parcent one,
- 14:31Speaker 2: two three. They're often used for utility functions that don't
- 14:34Speaker 2: depend on the state of a particular object.
- 14:36Speaker 1: And making a new object, like a new zombie in
- 14:39Speaker 1: the game that uses the new keyword.
- 14:41Speaker 2: Correct zombie, My zombie equals new zombie When you use
- 14:46Speaker 2: new a special method called a constructor gets called.
- 14:50Speaker 1: Automatically a constructor.
- 14:52Speaker 2: Yeah, it's a method with the same name as the
- 14:54Speaker 2: class zombie, and its job is to initialize the new object,
- 14:58Speaker 2: set up its initial state, give its attributes starting values.
- 15:01Speaker 1: Cool. The guide also covered inheritance using extends.
- 15:05Speaker 2: That sounds important, Oh, it's huge In Java and Minecraft.
- 15:08Speaker 2: Inheritance is how you create classes that are based on
- 15:10Speaker 2: other classes. You make a new class, the subclass or
- 15:13Speaker 2: child that automatically gets all the non private attributes and
- 15:16Speaker 2: methods from an existing class.
- 15:18Speaker 1: The superclass reparent like a family tree for code.
- 15:20Speaker 2: Kind of. So in Minecraft you might have a monster
- 15:23Speaker 2: class that extends living entity, which extends entity. This means
- 15:27Speaker 2: your monster automatically knows how to do everything an entity
- 15:30Speaker 2: can like exist in the world at a location, and
- 15:33Speaker 2: everything a living entity can like have health, take damage,
- 15:36Speaker 2: plus any specific monster things you add, so you.
- 15:38Speaker 1: Don't have to rewrite all that basic entity stuff every
- 15:41Speaker 1: time exactly.
- 15:42Speaker 2: It promotes code reuse and creates a logical hierarchy. Java
- 15:45Speaker 2: itself has a base object class that everything ultimately inherits from.
- 15:49Speaker 1: Okay, that op structure makes sense, but what happens when
- 15:53Speaker 1: things just go wrong while the program is running, not
- 15:56Speaker 1: a typo that net Beans catches, but like unexpect.
- 16:00Speaker 2: Situations right run time problems, that's where exceptions come in.
- 16:03Speaker 2: The guide described them as exceptional circumstances. The program hits
- 16:08Speaker 2: a situation it wasn't necessarily designed to handle smoothly at
- 16:11Speaker 2: that exact point, like.
- 16:12Speaker 1: The user typing text when you expected a number.
- 16:15Speaker 2: That's the classic example the new calculator, and the guide
- 16:17Speaker 2: showed this perfectly. If your code tries to use integer
- 16:21Speaker 2: dot parsin on the text hello, that's going to cause
- 16:24Speaker 2: a problem. It would crash unless you handle the exception.
- 16:29Speaker 2: Java lets you anticipate these problems using a tricatch block.
- 16:33Speaker 1: How does that work?
- 16:33Speaker 2: You put the code that might cause an exception, the
- 16:37Speaker 2: risky code like integer dot parse end user input inside
- 16:41Speaker 2: a tryblock. Immediately after it, you put a catch block.
- 16:44Speaker 2: The catch block specifies the type of exception it's designed
- 16:47Speaker 2: to handle, like number format exception.
- 16:49Speaker 1: So if that specific error happens inside.
- 16:52Speaker 2: Try, the program immediately jumps to the catch block for
- 16:55Speaker 2: number format exception and runs the code inside that block
- 16:58Speaker 2: instead of crashing. Do you Calculator example, use this to
- 17:01Speaker 2: print a nice message like, Hey, that wasn't a number
- 17:04Speaker 2: instead of just dying, that's much better. Yeah.
- 17:07Speaker 1: The guide also mentioned other exceptions like that array index
- 17:10Speaker 1: out of bounds exception again and null pointer exception.
- 17:13Speaker 2: Yeah. Null pointer exception happens when you try to use
- 17:15Speaker 2: a variable that hasn't been initialized to point to an
- 17:18Speaker 2: actual objecto null pointing to nothing.
- 17:21Speaker 1: And the guide said you shouldn't always try to catch those.
- 17:23Speaker 2: It made the point that exceptions like array index outbounds
- 17:26Speaker 2: or null pointer often signal a fundamental logic error in
- 17:30Speaker 2: your code. While you could technically catch them, it's usually
- 17:34Speaker 2: better practice to fix the underlying code flaw that's causing them,
- 17:38Speaker 2: rather than trying to patch over it with a catch block.
- 17:41Speaker 2: Prevent the error rather than just reacting to it.
- 17:43Speaker 1: Got it, fix the bug. Okay, we've chewed through a
- 17:46Speaker 1: lot of core Java there. The guide also glanced at
- 17:49Speaker 1: a couple of slightly more advanced topics.
- 17:51Speaker 2: Just briefly. One was threads. Threads are a way to
- 17:55Speaker 2: make your program do multiple things seemingly at the same time,
- 17:58Speaker 2: like multitasking. Much The prime Finder example showed this one
- 18:02Speaker 2: part of the code. One thread could be doing heavy
- 18:05Speaker 2: calculations while another thread updates the user interface or progress bar,
- 18:09Speaker 2: keeping things responsive.
- 18:11Speaker 1: Useful for long tasks in a mod maybe could be.
- 18:14Speaker 2: And the other thing was file io input output, reading
- 18:17Speaker 2: and writing files exactly using Java's built in libraries to
- 18:21Speaker 2: read data from files like loading mod settings, or write
- 18:25Speaker 2: data to files like saving player progress or configuration. The
- 18:28Speaker 2: configurat example showed writing simple key value pairs like username
- 18:33Speaker 2: max to a dot properties file. It involves concepts like
- 18:36Speaker 2: data streams and remembering to close the file connection when
- 18:39Speaker 2: you're done.
- 18:40Speaker 1: Okay, wow, that's a lot of Java. Now the payoff.
- 18:45Speaker 1: How does all this variables, loops, objects, exceptions actually let
- 18:49Speaker 1: you make a Minecraft mod using something like spiggot, which
- 18:53Speaker 1: the guide mentioned right.
- 18:54Speaker 2: This is where it connects. Spigot is a popular modified
- 18:57Speaker 2: Minecraft server software that provides an API, a set of
- 18:59Speaker 2: two tools and interfaces for mod developers. Your mod is
- 19:03Speaker 2: essentially a Java program that plugs into spigot.
- 19:05Speaker 1: So how does a basic mod look?
- 19:07Speaker 2: Your main mod class will typically extend a class provided
- 19:10Speaker 2: by Spigot, usually Java plug in. This hooks your code
- 19:13Speaker 2: into the server's life cycle.
- 19:14Speaker 1: And making it do something when a player types a
- 19:16Speaker 1: command like petwolf.
- 19:18Speaker 2: That's a core feature you override a specific method in
- 19:21Speaker 2: your main class called on command.
- 19:22Speaker 1: Override, meaning you provide your own version exactly.
- 19:25Speaker 2: Spigott calls your on command method. Whenever a player uses
- 19:30Speaker 2: a command associated with your mod. Spigott gives your method
- 19:33Speaker 2: information like who sent the command, what the command was,
- 19:36Speaker 2: and any arguments typed after it.
- 19:39Speaker 1: So insight on command, you'd check if the command was.
- 19:41Speaker 2: Petwolf yep, and the guide stressed. You should also check
- 19:44Speaker 2: if the sender was actually a player, because sometimes bands
- 19:47Speaker 2: might come from the server console itself, which can't own
- 19:50Speaker 2: a wolf.
- 19:51Speaker 1: Good point, and the petwolf example used that on a
- 19:54Speaker 1: command to what spawn a wolf?
- 19:56Speaker 2: Yeah, it's code running inside on command would use Pigott's
- 19:59Speaker 2: a p I calls to get the player's location, spawn
- 20:02Speaker 2: a wolf entity there, set its color to pink, and
- 20:05Speaker 2: then set the player who typed the command as the
- 20:07Speaker 2: wolf's owner.
- 20:08Speaker 1: Cool. But how does Spigotto that petwolf belongs to your
- 20:11Speaker 1: mod in the first place?
- 20:12Speaker 2: Ah configuration, you need a special file called plug in
- 20:16Speaker 2: dot eml. It's a simple text file you bundle with
- 20:19Speaker 2: your mod.
- 20:20Speaker 1: What goes in it?
- 20:20Speaker 2: Basic info, your mod's name, the author, the main Java
- 20:24Speaker 2: class that Spigot should load your dot package dot main
- 20:27Speaker 2: class and crucially a commands section. There you define petwolf,
- 20:31Speaker 2: give it a description, and make some usage instructions. That
- 20:34Speaker 2: file tells spiggot, hey I exist and I handle these commands.
- 20:38Speaker 1: Okay, And what if the command has arguments like transmute
- 20:41Speaker 1: stone diamond, how do you get stone in diamond.
- 20:44Speaker 2: Those words come into your own command method as an
- 20:46Speaker 2: array of string arguments. Your code would look at that array.
- 20:50Speaker 2: Index zero zero would be stone, index one would be diamond.
- 20:53Speaker 1: And then you use those strings. Right.
- 20:56Speaker 2: The guide showed how spigot provides methods like material dot
- 20:59Speaker 2: get material. You pass it the string stone and it
- 21:02Speaker 2: gives you back the actual material object representing stone in
- 21:05Speaker 2: the game. The transmuter mod would use this to figure
- 21:08Speaker 2: out the from material and the two material based on
- 21:11Speaker 2: player input.
- 21:12Speaker 1: This leads into actually interacting with the game world, mobs
- 21:15Speaker 1: blocks the environment itself. That feels like the real heart
- 21:19Speaker 1: of modding.
- 21:19Speaker 2: It really is all those Java object concepts applied directly.
- 21:23Speaker 1: Here.
- 21:24Speaker 2: You get references to game objects, living entities, zombie player block,
- 21:29Speaker 2: and then you use their methods. So for mobs you
- 21:32Speaker 2: can use methods like world dot spawn to create new
- 21:35Speaker 2: ones or get an existing mob object and call methods
- 21:39Speaker 2: on it to change its properties, set its age, apply
- 21:41Speaker 2: potion effects. The guide mentioned making one mob ride another
- 21:44Speaker 2: using set passenger lots of possibilities.
- 21:47Speaker 1: But mods don't just react to commands. What about reacting
- 21:50Speaker 1: to things happening in the game, like a player mining
- 21:53Speaker 1: a block or a creeper exploding.
- 21:55Speaker 2: Yes, event handling this is maybe even more central than
- 21:58Speaker 2: commands For many mods. Your mod becomes an event listener
- 22:02Speaker 2: listening for it why for specific events that the Spigot
- 22:04Speaker 2: server broadcasts whenever something significant happens in the game player movement,
- 22:08Speaker 2: entity taking, damage, block breaking, inventory clicks, tons of events.
- 22:12Speaker 1: So your mod is constantly listening in the background.
- 22:15Speaker 2: Sort of. You have to register it. First. You make
- 22:18Speaker 2: your main mod class or another class implement the listener interface. Then,
- 22:22Speaker 2: when your mod starts up, usually in a method called
- 22:25Speaker 2: on able, you tell spiggott, hey start sending events to
- 22:29Speaker 2: this listener object.
- 22:30Speaker 1: Okay, registered?
- 22:31Speaker 2: Then what Then You write specific methods in your listener
- 22:34Speaker 2: class and mark them with at event handler. Each method
- 22:37Speaker 2: takes a specific event type as a parameter, like player
- 22:41Speaker 2: move event or entity damage.
- 22:42Speaker 1: Event, and that method automatically runs when that event hass exactly.
- 22:46Speaker 2: Spiggott sees the event, finds all registered listeners with handlers
- 22:50Speaker 2: for that event type, and calls their at event handler methods,
- 22:53Speaker 2: passing in the event object, which contains details about what happened.
- 22:57Speaker 1: Can you give those examples from the guide again?
- 22:59Speaker 2: The stone right stone Walker would have an ad event
- 23:02Speaker 2: handler method that takes a player move event. Inside that method,
- 23:06Speaker 2: it gets the location the player moved from and uses
- 23:08Speaker 2: Spiggott's API to change the block at that location, maybe
- 23:11Speaker 2: to stone or gold or whatever.
- 23:13Speaker 1: It's the Pathway and health checker.
- 23:16Speaker 2: That would listen for entity damage event. It's handler runs,
- 23:20Speaker 2: gets the entity that was damaged, maybe, calculates its remaining
- 23:23Speaker 2: health percentage, and then uses methods like set custom name
- 23:26Speaker 2: on the entity object to display that health maybe using
- 23:29Speaker 2: Spiggot's check color codes to make it red or green like.
- 23:32Speaker 1: A dynamic health bar above their head.
- 23:34Speaker 2: Precisely. And the Zeus mod that's out of fun. Yeah,
- 23:38Speaker 2: that one listens for entity target event. When a mob
- 23:41Speaker 2: targets a player, the handler runs, gets the mob's location
- 23:44Speaker 2: and calls World dot strike lightning at that spot.
- 23:47Speaker 1: Bam. Wow. So events let you react to almost anything
- 23:51Speaker 1: pretty much.
- 23:52Speaker 2: It's how you make mods that feel deeply integrated with
- 23:54Speaker 2: the gameplay, not just triggered by commands. You combine listening
- 23:58Speaker 2: for the event with using the Java objects player, block, entity, world,
- 24:02Speaker 2: and Spigot methods strike, lightning, set type, set custom name
- 24:05Speaker 2: to make changes.
- 24:07Speaker 1: Speaking of changing things, let's focus on blocks for a second. Yeah,
- 24:10Speaker 1: how do you pinpoint and manipulate specific blocks in the world.
- 24:14Speaker 2: You use a combination of classes. Spigot provides World represents
- 24:18Speaker 2: the dimension overworld nether end location holds specific xyz coordinates
- 24:24Speaker 2: within that world. Block represents the actual block at a
- 24:27Speaker 2: given location, and material defines the type of block like
- 24:31Speaker 2: material dot stone, material dot diamond or so.
- 24:34Speaker 1: How do you change a block?
- 24:35Speaker 2: Typically you get the world object, then use a location
- 24:39Speaker 2: object which might come from an event, or you calculate
- 24:41Speaker 2: it to get the specific block object using a method
- 24:44Speaker 2: like world dot get block at location. Once you have
- 24:48Speaker 2: the block object, you can call methods on it like
- 24:50Speaker 2: get type to see what it is, or set type,
- 24:52Speaker 2: material dot goldiebelot to change it.
- 24:54Speaker 1: The guide mentioned big Dig in Tree Chopper is more
- 24:56Speaker 1: complex examples.
- 24:58Speaker 2: Yeah, they illustrate going beyond single Big dig would involve
- 25:01Speaker 2: some math to figure out all the locations within a
- 25:03Speaker 2: certain radius of the player than looping through those locations
- 25:06Speaker 2: to change each block and.
- 25:08Speaker 1: Tree chopper sounds like it needs to find all the logs.
- 25:11Speaker 2: Right, that's more complex. You might detect when a log
- 25:15Speaker 2: block is broken than have code that searches upwards and
- 25:18Speaker 2: maybe outwards for connected log blocks, potentially using loops or
- 25:22Speaker 2: even more advanced techniques like recursion, where a method calls
- 25:26Speaker 2: itself to explore the tree structure. These show how you
- 25:29Speaker 2: build on the basics to tackle bigger problems. Managing potentially
- 25:33Speaker 2: lots of blocks and locations.
- 25:35Speaker 1: With all this power to change the world, literally digging
- 25:39Speaker 1: holes and chopping trees with code. Managing the actual Minecraft
- 25:43Speaker 1: world files seems important. Any tips from the guide on
- 25:46Speaker 1: that definitely.
- 25:47Speaker 2: It strongly recommends making regular backups of your world folders.
- 25:51Speaker 1: Just copy the folder.
- 25:52Speaker 2: Pretty much find your server directory and inside there will
- 25:55Speaker 2: be folders named after your world, usually World, nether and
- 25:58Speaker 2: world themed. To do this when the server is not
- 26:01Speaker 2: running to avoid corrupted files, just copy those folders somewhere safe.
- 26:05Speaker 1: Good advice. How do you know the world name?
- 26:07Speaker 2: If it's not just world, You can usually find the
- 26:10Speaker 2: name listed in the server dot properties file in your
- 26:12Speaker 2: server directory and.
- 26:14Speaker 1: The world seed that unique generation number.
- 26:17Speaker 2: Yeah, the guide mentions you can easily get that in
- 26:19Speaker 2: game using the command seed. Good to note down if
- 26:22Speaker 2: you ever want to recreate the exact same terrain later.
- 26:24Speaker 1: Okay, so, looking back, we've covered quite a bit of ground,
- 26:29Speaker 1: from the absolute basics of Java.
- 26:31Speaker 2: Syntax variables, if statements, loots.
- 26:34Speaker 1: To organizing code with objects, in handling.
- 26:36Speaker 2: Errors, inheritance exceptions, trycatch, and.
- 26:40Speaker 1: Then seeing how all those pieces come together using this
- 26:42Speaker 1: Spigott api to actually make things happen in Minecraft.
- 26:46Speaker 2: Yeah, writing command handlers, listening for game events, spawning mobs,
- 26:50Speaker 2: changing blocks. It all uses those core Java concepts and.
- 26:54Speaker 1: It's worth stressing. Like the guide implies, these skills aren't
- 26:58Speaker 1: just for Minecraft modding.
- 26:59Speaker 2: Absolutely understanding variables, control flow, object oriented programming, event handling,
- 27:04Speaker 2: these are foundational concepts used across vast areas of software development.
- 27:08Speaker 2: Learning Java from modding gives you a really solid base.
- 27:11Speaker 1: And for folks who want to dive deeper, the guide
- 27:13Speaker 1: mentioned to resource.
- 27:15Speaker 2: Yeah www dot javamincraft dot com sounds like a place
- 27:19Speaker 2: to find the source code for examples, ask question and
- 27:22Speaker 2: connect with other people learning the stuff. Community is always
- 27:25Speaker 2: helpful when learning to code.
- 27:27Speaker 1: So really taking these first steps into programming through something
- 27:31Speaker 1: familiar like Minecraft, it fundamentally changes your relationship with the game,
- 27:35Speaker 1: doesn't it.
- 27:36Speaker 2: It really does. You're not just playing by the rules anymore.
- 27:39Speaker 1: You're starting to understand how to write the rules.
- 27:40Speaker 2: You've got the potential power to reshape that world, So
- 27:45Speaker 2: the question really becomes what will you create