WEBVTT

1
00:00:00.080 --> 00:00:03.000
<v Speaker 1>Have you ever been deep in Minecraft, maybe building something

2
00:00:03.000 --> 00:00:06.960
<v Speaker 1>amazing and just thought, man, I wish this worked differently.

3
00:00:07.240 --> 00:00:11.960
<v Speaker 2>Oh, definitely, like wanting a custom command, or maybe changing

4
00:00:12.000 --> 00:00:12.960
<v Speaker 2>how blocks.

5
00:00:12.599 --> 00:00:15.279
<v Speaker 1>Behave exactly Like, would it be cool to type one

6
00:00:15.320 --> 00:00:17.440
<v Speaker 1>thing and have I don't know, a whole army pop up,

7
00:00:18.000 --> 00:00:20.239
<v Speaker 1>or maybe make every block you touch turn to gold.

8
00:00:20.440 --> 00:00:23.320
<v Speaker 2>Yeah. Taking that world you know so well and then

9
00:00:23.359 --> 00:00:27.839
<v Speaker 2>getting the power to actually tweak the rules with code. Well,

10
00:00:28.280 --> 00:00:29.760
<v Speaker 2>it's literally a game changer.

11
00:00:29.760 --> 00:00:32.240
<v Speaker 1>It really is. And that's that's pretty much what this

12
00:00:32.280 --> 00:00:34.600
<v Speaker 1>deep dive is all about. Today. We've been looking at

13
00:00:34.600 --> 00:00:39.200
<v Speaker 1>this beginner's guide that focuses specifically on using Java programming

14
00:00:39.439 --> 00:00:41.359
<v Speaker 1>to make those custom Minecraft mods.

15
00:00:41.799 --> 00:00:44.679
<v Speaker 2>Yeah, think of this as a bit of a shortcut.

16
00:00:45.000 --> 00:00:47.880
<v Speaker 2>We're aiming to unpack the core bits of Java you

17
00:00:47.920 --> 00:00:51.000
<v Speaker 2>really need and show how they plug directly into making

18
00:00:51.039 --> 00:00:53.240
<v Speaker 2>your own mods, you know, going from just playing the

19
00:00:53.240 --> 00:00:54.600
<v Speaker 2>game to actually shaping it.

20
00:00:54.679 --> 00:00:57.840
<v Speaker 1>Okay, so let's start right at the beginning. Why Java?

21
00:00:58.200 --> 00:00:59.880
<v Speaker 1>Why is that the language for Minecraft?

22
00:01:00.799 --> 00:01:03.439
<v Speaker 2>Well, the source material is pretty clear on this. Minecraft

23
00:01:03.439 --> 00:01:06.280
<v Speaker 2>itself is built using Java, so it just makes sense.

24
00:01:06.319 --> 00:01:09.239
<v Speaker 2>It's the native tongue, if you will. And importantly, the

25
00:01:09.239 --> 00:01:13.280
<v Speaker 2>guide really emphasizes that it's not some super scary, impossible

26
00:01:13.359 --> 00:01:16.560
<v Speaker 2>language to pick up, especially just for modding basics.

27
00:01:16.799 --> 00:01:19.719
<v Speaker 1>That's encouraging. So what tools do you actually need to

28
00:01:19.760 --> 00:01:20.239
<v Speaker 1>get going?

29
00:01:20.519 --> 00:01:25.200
<v Speaker 2>It's surprisingly accessible really. First you need the Java development kit,

30
00:01:25.319 --> 00:01:27.439
<v Speaker 2>the cord Java stuff itself, it's free.

31
00:01:27.719 --> 00:01:28.040
<v Speaker 1>Okay.

32
00:01:28.159 --> 00:01:30.159
<v Speaker 2>Then you need a place to write the code. The

33
00:01:30.159 --> 00:01:33.159
<v Speaker 2>guide recommends net beans. That beans right, Yeah, it's an

34
00:01:33.200 --> 00:01:37.480
<v Speaker 2>ID and integrated development environment, basically a smart text editor

35
00:01:37.519 --> 00:01:38.959
<v Speaker 2>for code. Also free.

36
00:01:39.200 --> 00:01:42.400
<v Speaker 1>So Java net beans. Huh what else do you need?

37
00:01:42.400 --> 00:01:43.519
<v Speaker 1>The game? Ah?

38
00:01:43.640 --> 00:01:48.000
<v Speaker 2>Yes, you definitely need the actual Minecraft game client, specifically,

39
00:01:48.040 --> 00:01:51.000
<v Speaker 2>the guide mentions the Windows or mac os versions. That's

40
00:01:51.040 --> 00:01:54.000
<v Speaker 2>the paid part around twenty seven dollars currently.

41
00:01:53.640 --> 00:01:55.799
<v Speaker 1>And that's where you'll actually see your mod in action.

42
00:01:56.000 --> 00:01:57.959
<v Speaker 2>Well, you need one more piece for testing, according to

43
00:01:57.959 --> 00:02:00.760
<v Speaker 2>the guide, a Minecraft server you set up, usually on

44
00:02:00.799 --> 00:02:03.799
<v Speaker 2>your own machine, to start your own little test world exactly.

45
00:02:03.920 --> 00:02:06.959
<v Speaker 2>Your mod runs on the server, and then you connect

46
00:02:07.000 --> 00:02:10.039
<v Speaker 2>to that server with your regular Minecraft game client using

47
00:02:10.080 --> 00:02:14.360
<v Speaker 2>the multiplayer option. That whole setup is your development and

48
00:02:14.439 --> 00:02:15.400
<v Speaker 2>testing playground.

49
00:02:15.520 --> 00:02:19.039
<v Speaker 1>Okay, setup complete, Now let's crack open NetBeans. You've got

50
00:02:19.039 --> 00:02:21.680
<v Speaker 1>this software. Yeah, where do you even click? First.

51
00:02:22.000 --> 00:02:25.479
<v Speaker 2>Right, So in NetBeans, you typically start by creating a

52
00:02:25.520 --> 00:02:26.879
<v Speaker 2>new project.

53
00:02:27.039 --> 00:02:29.919
<v Speaker 1>A project like a folder for the mod pretty much.

54
00:02:30.000 --> 00:02:32.520
<v Speaker 2>Yeah, it holds all the files related to that specific

55
00:02:32.560 --> 00:02:35.960
<v Speaker 2>mod you're building. And inside that project, you create a

56
00:02:36.000 --> 00:02:37.840
<v Speaker 2>new Java class file, and the.

57
00:02:37.840 --> 00:02:39.759
<v Speaker 1>Class file is where the actual instructions go.

58
00:02:39.879 --> 00:02:42.280
<v Speaker 2>It's it. It's like a blueprint. You write your Java code,

59
00:02:42.280 --> 00:02:44.319
<v Speaker 2>your instructions inside that class file.

60
00:02:44.400 --> 00:02:48.439
<v Speaker 1>Now, for the program to actually well run, it needs

61
00:02:48.479 --> 00:02:51.800
<v Speaker 1>a specific starting point, doesn't it like computers start here exactly?

62
00:02:52.039 --> 00:02:55.319
<v Speaker 2>Every standalone Java program that you can just run needs

63
00:02:55.319 --> 00:02:58.400
<v Speaker 2>a special method called main. Okay, that's the entry point.

64
00:02:58.400 --> 00:03:00.680
<v Speaker 2>When you hit run, the java is looks for that

65
00:03:00.759 --> 00:03:03.800
<v Speaker 2>main method first and starts executing the code inside it.

66
00:03:03.879 --> 00:03:06.479
<v Speaker 1>The guide had that classic first example, right. The im

67
00:03:06.520 --> 00:03:07.319
<v Speaker 1>spartakan is one.

68
00:03:07.680 --> 00:03:11.680
<v Speaker 2>Yeah, you type one line of code inside Maine something

69
00:03:11.800 --> 00:03:16.520
<v Speaker 2>like system out dot printle nimspartacus. You run it in

70
00:03:16.639 --> 00:03:17.680
<v Speaker 2>net Beans.

71
00:03:17.599 --> 00:03:20.000
<v Speaker 1>And bam, it appears in the output window.

72
00:03:20.159 --> 00:03:23.319
<v Speaker 2>Yep, your first little piece of running code. It's a

73
00:03:23.319 --> 00:03:25.520
<v Speaker 2>good feeling, But coding.

74
00:03:25.240 --> 00:03:29.520
<v Speaker 1>Isn't always smooth sailing. What about mistakes? Typos?

75
00:03:29.719 --> 00:03:33.560
<v Speaker 2>Ah? Yes, errors. The guide jumps right into that. It's

76
00:03:33.599 --> 00:03:36.439
<v Speaker 2>just good. It shows how NetBeans helps you out immediately

77
00:03:37.240 --> 00:03:40.199
<v Speaker 2>how so well, say you forget a semicolon at the

78
00:03:40.240 --> 00:03:42.360
<v Speaker 2>end of a line, which is easy to do. Net

79
00:03:42.360 --> 00:03:44.639
<v Speaker 2>Beans will often put a little red squiggle under it

80
00:03:45.039 --> 00:03:46.159
<v Speaker 2>or show an error.

81
00:03:46.159 --> 00:03:47.840
<v Speaker 1>Icon like spell check for code.

82
00:03:48.000 --> 00:03:50.680
<v Speaker 2>Kind of yeah, it gives you instant feedback telling you, hey,

83
00:03:50.719 --> 00:03:53.400
<v Speaker 2>something's not quite right here. It really helps catch simple

84
00:03:53.439 --> 00:03:54.240
<v Speaker 2>mistakes early.

85
00:03:54.560 --> 00:03:58.039
<v Speaker 1>That sounds super useful for beginners. The guide also mentioned

86
00:03:58.080 --> 00:04:00.560
<v Speaker 1>comments lines that aren't actually right.

87
00:04:00.840 --> 00:04:03.800
<v Speaker 2>Comments you start them with for a single line, or

88
00:04:04.000 --> 00:04:05.639
<v Speaker 2>wrap a block with an NM, and.

89
00:04:05.599 --> 00:04:07.120
<v Speaker 1>The computer just ignores them.

90
00:04:07.000 --> 00:04:10.039
<v Speaker 2>Completely ignores them when running the program. But they're absolutely

91
00:04:10.199 --> 00:04:13.400
<v Speaker 2>vital for humans for understanding what you wrote later exactly,

92
00:04:13.520 --> 00:04:16.240
<v Speaker 2>or for someone else reading your code. They're like little

93
00:04:16.279 --> 00:04:19.519
<v Speaker 2>notes explaining why you did something or what a particular

94
00:04:19.560 --> 00:04:23.279
<v Speaker 2>section of code is trying to achieve. Essential for anything complex.

95
00:04:23.519 --> 00:04:27.199
<v Speaker 1>Okay, so we can run a basic instruction, but mods

96
00:04:27.279 --> 00:04:32.600
<v Speaker 1>need to remember things right, like a player's name or coordinates,

97
00:04:33.240 --> 00:04:36.600
<v Speaker 1>or maybe how much health a mob has. How does

98
00:04:36.680 --> 00:04:37.600
<v Speaker 1>Java handle that?

99
00:04:37.600 --> 00:04:40.000
<v Speaker 2>That's where variables come in. You can think of variables

100
00:04:40.000 --> 00:04:43.600
<v Speaker 2>as named containers, like little labeled boxes in the computer's memory.

101
00:04:43.680 --> 00:04:46.560
<v Speaker 1>Boxes to store information precisely.

102
00:04:46.040 --> 00:04:48.519
<v Speaker 2>You put pieces of data into these boxes so you

103
00:04:48.519 --> 00:04:49.920
<v Speaker 2>can use them later in your mod.

104
00:04:50.160 --> 00:04:52.439
<v Speaker 1>And these boxes hold different kinds of information.

105
00:04:52.600 --> 00:04:56.480
<v Speaker 2>Yes, very important variables have types for Minecraft moding. The

106
00:04:56.560 --> 00:04:58.839
<v Speaker 2>guide highlights a few key ones. You'll use a lot

107
00:04:59.199 --> 00:05:01.639
<v Speaker 2>like well, is a big one. That's for whole numbers,

108
00:05:01.800 --> 00:05:04.560
<v Speaker 2>think coordinates xyz or counting items.

109
00:05:04.319 --> 00:05:06.399
<v Speaker 1>Stuff like that. Okay, in for whole numbers.

110
00:05:06.439 --> 00:05:10.160
<v Speaker 2>Then there's string note the capital s. That's for storing text,

111
00:05:10.399 --> 00:05:12.800
<v Speaker 2>player names, messages you want to show in chat command

112
00:05:12.879 --> 00:05:14.720
<v Speaker 2>words like stone or diamond.

113
00:05:14.879 --> 00:05:18.240
<v Speaker 1>So inf counts string for text. Makes sense.

114
00:05:18.360 --> 00:05:21.079
<v Speaker 2>The guide also mentions float and double for numbers with

115
00:05:21.160 --> 00:05:24.360
<v Speaker 2>decimal points maybe for precise positions or something, and char

116
00:05:24.480 --> 00:05:27.759
<v Speaker 2>for just a single character. But honestly, int and string

117
00:05:27.839 --> 00:05:30.560
<v Speaker 2>will get you very far when you're starting out with mods.

118
00:05:30.920 --> 00:05:34.439
<v Speaker 1>How do you like create one of these variable boxes?

119
00:05:34.480 --> 00:05:36.639
<v Speaker 2>You declare it. You see the type, then the name

120
00:05:36.680 --> 00:05:39.399
<v Speaker 2>you want to give it. So int player score creates

121
00:05:39.399 --> 00:05:40.920
<v Speaker 2>an integer variable named.

122
00:05:40.800 --> 00:05:42.920
<v Speaker 1>Player score, and putting a value in it.

123
00:05:42.800 --> 00:05:45.439
<v Speaker 2>You use the equal sign. That's the assignment operator. So

124
00:05:45.519 --> 00:05:48.639
<v Speaker 2>player score equals one hundred, puts the value one hundred

125
00:05:48.639 --> 00:05:49.360
<v Speaker 2>into that box.

126
00:05:49.480 --> 00:05:51.519
<v Speaker 1>The guide also showed some shortcuts, didn't.

127
00:05:51.279 --> 00:05:54.920
<v Speaker 2>It, Like plus Yeah, player score plus ten is shorthand

128
00:05:54.920 --> 00:05:57.800
<v Speaker 2>for player score player score plus ten and plus plus

129
00:05:57.800 --> 00:06:00.240
<v Speaker 2>act like player score plus plus ac just adds one

130
00:06:00.600 --> 00:06:02.000
<v Speaker 2>very common, saves a bit of typing.

131
00:06:02.120 --> 00:06:04.800
<v Speaker 1>Are the rules for naming these variables A few simple ones.

132
00:06:05.040 --> 00:06:07.639
<v Speaker 2>They are case sensitive, so player score is different from

133
00:06:07.639 --> 00:06:11.319
<v Speaker 2>player score. Okay, no spaces or punctuation usually allowed in

134
00:06:11.360 --> 00:06:15.800
<v Speaker 2>the name, and you can't use java's reserve words words

135
00:06:15.879 --> 00:06:20.120
<v Speaker 2>like public class INNT if those already have special meanings.

136
00:06:20.279 --> 00:06:23.879
<v Speaker 1>Got it. So variables hold the data, What about doing

137
00:06:23.920 --> 00:06:24.959
<v Speaker 1>things with that data?

138
00:06:25.560 --> 00:06:29.279
<v Speaker 2>Calculations, right, That's where expressions and operators come in. You

139
00:06:29.399 --> 00:06:34.240
<v Speaker 2>use operators like plus for addition, for subtraction, for a multiplication.

140
00:06:33.720 --> 00:06:35.439
<v Speaker 1>For division, just like basic math.

141
00:06:35.519 --> 00:06:38.360
<v Speaker 2>Pretty much in total score at score one plus score

142
00:06:38.399 --> 00:06:42.759
<v Speaker 2>two adds two scores together. The guide mentions operator precedence

143
00:06:42.839 --> 00:06:47.439
<v Speaker 2>like multiplication happens before addition, and this exactly. But you

144
00:06:47.439 --> 00:06:50.040
<v Speaker 2>can always use parentheses to control the order, just like

145
00:06:50.079 --> 00:06:52.600
<v Speaker 2>in math class to make sure things calculate the way

146
00:06:52.600 --> 00:06:53.160
<v Speaker 2>you intend.

147
00:06:53.439 --> 00:06:55.720
<v Speaker 1>And once you've done a calculation, or you just want

148
00:06:55.759 --> 00:06:57.800
<v Speaker 1>to display some text, how do you show that to

149
00:06:57.839 --> 00:06:59.879
<v Speaker 1>the user or maybe in the serverlog.

150
00:07:00.079 --> 00:07:03.439
<v Speaker 2>The most fundamental way in Java is using system dot

151
00:07:03.480 --> 00:07:04.920
<v Speaker 2>out dot print allen.

152
00:07:05.120 --> 00:07:07.279
<v Speaker 1>System dot out dot print allen. Bit of a.

153
00:07:07.199 --> 00:07:09.519
<v Speaker 2>Mouthful, it is, but you get used to it. Whatever

154
00:07:09.560 --> 00:07:12.279
<v Speaker 2>you put inside the parentheses gets printed out, usually to

155
00:07:12.319 --> 00:07:15.079
<v Speaker 2>the NetBeans output window or the Micraft server console. When

156
00:07:15.079 --> 00:07:16.079
<v Speaker 2>you're moddling like.

157
00:07:16.079 --> 00:07:18.759
<v Speaker 1>That example, alphae has been killed by a magma cube.

158
00:07:18.839 --> 00:07:22.399
<v Speaker 2>Huh huh, yeah, that memorable one, that exact text would appear.

159
00:07:22.680 --> 00:07:25.519
<v Speaker 2>There's also system dot out dot print, which does the

160
00:07:25.519 --> 00:07:28.279
<v Speaker 2>same thing, but doesn't automatically start a new line afterwards.

161
00:07:28.360 --> 00:07:30.839
<v Speaker 1>Okay, so we can store info, do math, print stuff out.

162
00:07:31.759 --> 00:07:35.199
<v Speaker 1>But real programs need to make decisions, don't they Like

163
00:07:35.560 --> 00:07:39.839
<v Speaker 1>if the player does X, then do HY or repeat tasks.

164
00:07:40.000 --> 00:07:42.720
<v Speaker 2>Absolutely, that's control flow. You need ways to control which

165
00:07:42.759 --> 00:07:46.079
<v Speaker 2>lines of code execute and when. Conditional statements and loops

166
00:07:46.120 --> 00:07:47.000
<v Speaker 2>are the pills for that.

167
00:07:47.319 --> 00:07:49.720
<v Speaker 1>Conditionals first making choices.

168
00:07:50.000 --> 00:07:52.120
<v Speaker 2>The simplest is the if statement. You give it a

169
00:07:52.120 --> 00:07:54.759
<v Speaker 2>condition something that's either true or false. If it's true,

170
00:07:54.759 --> 00:07:57.759
<v Speaker 2>the code inside the if block runs. If not, it's skipped.

171
00:07:57.879 --> 00:08:00.959
<v Speaker 1>So if player has enough gold, then run the code

172
00:08:01.000 --> 00:08:02.399
<v Speaker 1>to give them the item exactly.

173
00:08:02.399 --> 00:08:04.879
<v Speaker 2>Then you've got if else. This gives you two paths.

174
00:08:04.920 --> 00:08:07.160
<v Speaker 2>If the condition is true, do the if part. If

175
00:08:07.199 --> 00:08:09.560
<v Speaker 2>it falls else, do the else part. Plan A, plan B.

176
00:08:10.160 --> 00:08:13.079
<v Speaker 2>The guide also mentioned the switch statement. That's useful when

177
00:08:13.120 --> 00:08:15.120
<v Speaker 2>you have one value and you want to do different

178
00:08:15.160 --> 00:08:18.319
<v Speaker 2>things based on several possible specific values. It could have

179
00:08:18.839 --> 00:08:21.439
<v Speaker 2>like checking an item type and doing something different for

180
00:08:21.480 --> 00:08:23.439
<v Speaker 2>a sword, an ax, or a pick axe.

181
00:08:23.480 --> 00:08:27.319
<v Speaker 1>Okay, decisions covered. What about doing things repeatedly?

182
00:08:27.519 --> 00:08:33.240
<v Speaker 2>Loops essential for so many modding tasks. Imagine placing blocks

183
00:08:33.279 --> 00:08:36.279
<v Speaker 2>in a line or checking every slot in a chest.

184
00:08:36.440 --> 00:08:37.240
<v Speaker 2>You need loops.

185
00:08:37.440 --> 00:08:38.840
<v Speaker 1>The fore loop is one, right, Yeah.

186
00:08:38.879 --> 00:08:41.440
<v Speaker 2>The fore loop is often used when you know roughly

187
00:08:41.559 --> 00:08:44.200
<v Speaker 2>how many times you need to repeat something. You typically

188
00:08:44.240 --> 00:08:46.399
<v Speaker 2>set up a counter, tell it when to stop and

189
00:08:46.440 --> 00:08:47.720
<v Speaker 2>how to increment.

190
00:08:47.600 --> 00:08:50.039
<v Speaker 1>Like for I from zero to nine place.

191
00:08:49.799 --> 00:08:52.879
<v Speaker 2>A block perfect example. Then there's the wil loop. It's different.

192
00:08:52.919 --> 00:08:56.159
<v Speaker 2>It keeps looping as long as a condition stays true.

193
00:08:56.080 --> 00:08:58.759
<v Speaker 1>More like while the button is held down, keep doing

194
00:08:58.799 --> 00:08:59.720
<v Speaker 1>this exactly.

195
00:09:00.080 --> 00:09:02.960
<v Speaker 2>The condition is checked before each loop iteration. The guide

196
00:09:03.000 --> 00:09:06.080
<v Speaker 2>also mentions do while, which is similar, but the check

197
00:09:06.120 --> 00:09:09.200
<v Speaker 2>happens after the code runs, so it always runs at least.

198
00:09:08.960 --> 00:09:11.039
<v Speaker 1>Once, and sometimes you need to stop a loop early.

199
00:09:11.399 --> 00:09:13.639
<v Speaker 2>Yeah, the break statement lets you jump out of a

200
00:09:13.679 --> 00:09:16.399
<v Speaker 2>loop immediately. If you're searching through a list and find

201
00:09:16.399 --> 00:09:18.360
<v Speaker 2>the item you need on the third try, you can

202
00:09:18.440 --> 00:09:21.039
<v Speaker 2>just break out instead of checking the other one hundred items.

203
00:09:21.440 --> 00:09:25.679
<v Speaker 1>So if else switch for a while. Those are the

204
00:09:25.679 --> 00:09:26.960
<v Speaker 1>core control tools.

205
00:09:26.679 --> 00:09:29.840
<v Speaker 2>There really are. Mastering those lets you build the actual

206
00:09:29.919 --> 00:09:31.200
<v Speaker 2>logic into your mod.

207
00:09:31.519 --> 00:09:35.360
<v Speaker 1>Now, we talked about variables for single pieces of info,

208
00:09:35.759 --> 00:09:37.679
<v Speaker 1>but what if you have like a whole bunch of things,

209
00:09:37.759 --> 00:09:40.840
<v Speaker 1>say all the players online or a list of block

210
00:09:40.919 --> 00:09:44.320
<v Speaker 1>coordinates for a structure, Making a separate variable for each

211
00:09:44.440 --> 00:09:46.919
<v Speaker 1>seems inefficient, Totally inefficient.

212
00:09:47.120 --> 00:09:49.799
<v Speaker 2>That's where arrays save the day. An array is a

213
00:09:49.840 --> 00:09:52.159
<v Speaker 2>special kind of variable that holds a collection of items

214
00:09:52.200 --> 00:09:54.720
<v Speaker 2>a list, basically kind of but with a key restriction.

215
00:09:55.039 --> 00:09:57.399
<v Speaker 2>All items in a single array must be the same type.

216
00:09:57.440 --> 00:09:59.159
<v Speaker 2>So you can have an array of vents or an

217
00:09:59.240 --> 00:10:02.519
<v Speaker 2>array of string, but not a mix in one standard array.

218
00:10:02.639 --> 00:10:04.639
<v Speaker 1>So an inter ray could hold all the y coordinates

219
00:10:04.639 --> 00:10:05.799
<v Speaker 1>for a tower exactly.

220
00:10:05.879 --> 00:10:09.000
<v Speaker 2>You create an array and specify its size upfront, like

221
00:10:09.080 --> 00:10:11.639
<v Speaker 2>in chords equals new Inn fifty, it creates an array

222
00:10:11.639 --> 00:10:15.039
<v Speaker 2>that can hold exactly fifty integers fixed size. Huh yep.

223
00:10:15.279 --> 00:10:18.519
<v Speaker 2>That's a key characteristic of basic arrays. Each slot in

224
00:10:18.559 --> 00:10:21.039
<v Speaker 2>the array is called an element, and you access them

225
00:10:21.120 --> 00:10:22.080
<v Speaker 2>using an index.

226
00:10:21.840 --> 00:10:24.600
<v Speaker 1>Number, and the index starts at zero.

227
00:10:24.720 --> 00:10:27.200
<v Speaker 2>Always zero in Java. So the first element is an

228
00:10:27.240 --> 00:10:30.279
<v Speaker 2>index zero, the second at index one up to index

229
00:10:30.360 --> 00:10:33.039
<v Speaker 2>forty nine. In our fifty element array that.

230
00:10:32.919 --> 00:10:36.399
<v Speaker 1>Reindeer names example in the guide really drove that fixedisz

231
00:10:36.480 --> 00:10:39.399
<v Speaker 1>point home made an array for eight reindeers.

232
00:10:38.919 --> 00:10:41.639
<v Speaker 2>And then poor Rudolph couldn't fit because the array was

233
00:10:41.639 --> 00:10:42.960
<v Speaker 2>full there was no index eight.

234
00:10:43.080 --> 00:10:44.840
<v Speaker 1>Right. How do you know how big an array is

235
00:10:44.879 --> 00:10:45.519
<v Speaker 1>once you have it.

236
00:10:45.799 --> 00:10:49.039
<v Speaker 2>Arrays have a handy length property, so ycords dot length

237
00:10:49.039 --> 00:10:50.120
<v Speaker 2>would give you fifty.

238
00:10:50.360 --> 00:10:52.279
<v Speaker 1>And what happens if you mess up and try to

239
00:10:52.320 --> 00:10:55.799
<v Speaker 1>access say index fifty in that fifty element array.

240
00:10:55.919 --> 00:10:59.200
<v Speaker 2>Boom, Well not quite boom, but your program will likely

241
00:10:59.240 --> 00:11:01.120
<v Speaker 2>stop and throw an array index out of bounds.

242
00:11:01.159 --> 00:11:03.559
<v Speaker 1>Exception an exception like an error.

243
00:11:03.399 --> 00:11:05.360
<v Speaker 2>Yeah it's job as a way of saying you tried

244
00:11:05.360 --> 00:11:07.480
<v Speaker 2>to access a part of the array that doesn't exist.

245
00:11:08.120 --> 00:11:11.279
<v Speaker 2>The guide points out the specific exception usually means there's

246
00:11:11.320 --> 00:11:12.360
<v Speaker 2>a flaw in your.

247
00:11:12.279 --> 00:11:15.080
<v Speaker 1>Code logic something you need to fix. In the code itself,

248
00:11:15.240 --> 00:11:16.679
<v Speaker 1>not just handle during runtime.

249
00:11:17.039 --> 00:11:19.879
<v Speaker 2>Generally, yes, you should fix your loop or your index

250
00:11:19.919 --> 00:11:22.120
<v Speaker 2>calculations so it doesn't try to go out of bounds.

251
00:11:22.919 --> 00:11:26.039
<v Speaker 2>Arrays are fundamental, but the guide also briefly mentions other

252
00:11:26.080 --> 00:11:29.480
<v Speaker 2>collection types, things like a ray list. It's more flexible,

253
00:11:29.519 --> 00:11:31.519
<v Speaker 2>like a list that can grow or shrink as needed,

254
00:11:32.000 --> 00:11:36.320
<v Speaker 2>much more convenient than fixed size arrays sometimes, and hash map,

255
00:11:36.559 --> 00:11:39.279
<v Speaker 2>which is great for storing key value pair.

256
00:11:39.320 --> 00:11:41.120
<v Speaker 1>KEYWTE like looking up a word in a dictionary.

257
00:11:41.240 --> 00:11:45.080
<v Speaker 2>Exactly, you store something using a unique key like a

258
00:11:45.120 --> 00:11:48.279
<v Speaker 2>player's name, a string and associate it with a value

259
00:11:48.440 --> 00:11:51.120
<v Speaker 2>like their score an end. Then you can quickly retrieve

260
00:11:51.120 --> 00:11:54.200
<v Speaker 2>the value just by knowing the key. Very useful structure.

261
00:11:54.279 --> 00:11:57.120
<v Speaker 1>Okay, arrays and collections for handling groups of data. Now

262
00:11:57.360 --> 00:11:59.600
<v Speaker 1>let's just step back a bit. The guide talks about

263
00:11:59.600 --> 00:12:03.200
<v Speaker 1>a really big concept, object oriented programming.

264
00:12:02.960 --> 00:12:06.480
<v Speaker 2>Op ah yes, oh ohp. It's a whole way of

265
00:12:06.480 --> 00:12:09.919
<v Speaker 2>thinking about structuring your programs, and it's fundamental to Java

266
00:12:10.159 --> 00:12:13.799
<v Speaker 2>and by extension, to Minecraft modding with things like spigot.

267
00:12:14.120 --> 00:12:17.360
<v Speaker 1>So what does object oriented actually mean in this context?

268
00:12:17.519 --> 00:12:20.440
<v Speaker 2>It means you design your program around objects. Think of

269
00:12:20.519 --> 00:12:24.639
<v Speaker 2>objects as representations of well things. They could be real

270
00:12:24.679 --> 00:12:27.960
<v Speaker 2>world things like a player, a wolf, a block, or

271
00:12:28.000 --> 00:12:30.679
<v Speaker 2>more abstract things like a game rule or a server event.

272
00:12:30.799 --> 00:12:32.960
<v Speaker 1>And what makes something an object? In code?

273
00:12:33.159 --> 00:12:35.840
<v Speaker 2>Two main things to find an object. First, it has

274
00:12:35.960 --> 00:12:39.879
<v Speaker 2>data associated with it, attributes or properties think variables, but

275
00:12:39.960 --> 00:12:43.480
<v Speaker 2>belonging to that object. Second, it has behavior things that

276
00:12:43.559 --> 00:12:45.279
<v Speaker 2>can do. These are called methods.

277
00:12:45.559 --> 00:12:47.679
<v Speaker 1>Okay, So back to that zombie idea earlier.

278
00:12:47.720 --> 00:12:51.039
<v Speaker 2>Perfect a zombie object would have attributes like health, maybe

279
00:12:51.120 --> 00:12:54.320
<v Speaker 2>an int, location, maybe a location object is baby, a

280
00:12:54.320 --> 00:12:58.519
<v Speaker 2>true false, a boolean that's the data right, and its behavior.

281
00:12:58.639 --> 00:13:02.000
<v Speaker 2>It's methods would be things like attack player, target, move

282
00:13:02.120 --> 00:13:05.679
<v Speaker 2>towards location, destination, take damage into mounts.

283
00:13:05.679 --> 00:13:08.759
<v Speaker 1>So an object bundles is data and its actions.

284
00:13:08.360 --> 00:13:11.639
<v Speaker 2>Together exactly the guide use a virus example, I think

285
00:13:11.639 --> 00:13:14.639
<v Speaker 2>with attributes like identify an author, same principle, and a

286
00:13:14.720 --> 00:13:17.559
<v Speaker 2>key part of OKP is controlling access to that data.

287
00:13:17.600 --> 00:13:18.840
<v Speaker 1>The public and private stuff.

288
00:13:19.039 --> 00:13:23.120
<v Speaker 2>Yes, you can mark attributes and methods as public meaning

289
00:13:23.200 --> 00:13:26.000
<v Speaker 2>any part of your code can access them directly, or

290
00:13:26.080 --> 00:13:30.080
<v Speaker 2>private meaning only the code inside that same object's class

291
00:13:30.080 --> 00:13:31.000
<v Speaker 2>can access them.

292
00:13:31.039 --> 00:13:32.320
<v Speaker 1>Why make things private?

293
00:13:32.679 --> 00:13:37.519
<v Speaker 2>It's about encapsulation, protecting the object's internal state. Usually you

294
00:13:37.639 --> 00:13:41.679
<v Speaker 2>keep the data health, etc. Private and provide public methods

295
00:13:41.919 --> 00:13:45.080
<v Speaker 2>get health, set health to interact with it in a

296
00:13:45.120 --> 00:13:48.320
<v Speaker 2>controlled way. It makes your code more robust and easier

297
00:13:48.360 --> 00:13:49.440
<v Speaker 2>to manage.

298
00:13:49.039 --> 00:13:50.840
<v Speaker 1>And methods can give back results you.

299
00:13:50.799 --> 00:13:54.039
<v Speaker 2>Said yep using the return keyword. A method like get

300
00:13:54.039 --> 00:13:57.519
<v Speaker 2>health would return the current value of the private health variable.

301
00:13:57.679 --> 00:14:01.120
<v Speaker 2>A method that just performs an action like attack might

302
00:14:01.159 --> 00:14:03.519
<v Speaker 2>not return anything. Its return type would be void.

303
00:14:03.639 --> 00:14:07.240
<v Speaker 1>Okay, Then there were static methods. Those felt a bit different.

304
00:14:07.360 --> 00:14:09.600
<v Speaker 2>They are a bit different. Remember, the class is the blueprint,

305
00:14:09.600 --> 00:14:11.759
<v Speaker 2>and objects are the things made from the blueprint. Right,

306
00:14:11.879 --> 00:14:15.440
<v Speaker 2>Normal methods belong to the objects. Static methods belong to

307
00:14:15.480 --> 00:14:18.440
<v Speaker 2>the class itself, the blueprint. You don't need a specific

308
00:14:18.480 --> 00:14:20.120
<v Speaker 2>object instance to use them.

309
00:14:20.320 --> 00:14:23.679
<v Speaker 1>Like that integer dot parsing example, converting text to a.

310
00:14:23.720 --> 00:14:27.080
<v Speaker 2>Number exactly, you don't need an integer object. You just

311
00:14:27.120 --> 00:14:31.159
<v Speaker 2>call the method directly on the integer class integer parcent one,

312
00:14:31.200 --> 00:14:34.519
<v Speaker 2>two three. They're often used for utility functions that don't

313
00:14:34.519 --> 00:14:37.000
<v Speaker 2>depend on the state of a particular object.

314
00:14:36.679 --> 00:14:39.120
<v Speaker 1>And making a new object, like a new zombie in

315
00:14:39.159 --> 00:14:41.639
<v Speaker 1>the game that uses the new keyword.

316
00:14:41.320 --> 00:14:46.600
<v Speaker 2>Correct zombie, My zombie equals new zombie When you use

317
00:14:46.679 --> 00:14:50.399
<v Speaker 2>new a special method called a constructor gets called.

318
00:14:50.200 --> 00:14:52.159
<v Speaker 1>Automatically a constructor.

319
00:14:52.559 --> 00:14:54.399
<v Speaker 2>Yeah, it's a method with the same name as the

320
00:14:54.440 --> 00:14:58.039
<v Speaker 2>class zombie, and its job is to initialize the new object,

321
00:14:58.120 --> 00:15:01.519
<v Speaker 2>set up its initial state, give its attributes starting values.

322
00:15:01.799 --> 00:15:05.279
<v Speaker 1>Cool. The guide also covered inheritance using extends.

323
00:15:05.279 --> 00:15:08.279
<v Speaker 2>That sounds important, Oh, it's huge In Java and Minecraft.

324
00:15:08.480 --> 00:15:10.840
<v Speaker 2>Inheritance is how you create classes that are based on

325
00:15:10.919 --> 00:15:13.320
<v Speaker 2>other classes. You make a new class, the subclass or

326
00:15:13.399 --> 00:15:16.559
<v Speaker 2>child that automatically gets all the non private attributes and

327
00:15:16.600 --> 00:15:18.000
<v Speaker 2>methods from an existing class.

328
00:15:18.320 --> 00:15:21.200
<v Speaker 1>The superclass reparent like a family tree for code.

329
00:15:20.960 --> 00:15:23.039
<v Speaker 2>Kind of. So in Minecraft you might have a monster

330
00:15:23.080 --> 00:15:27.279
<v Speaker 2>class that extends living entity, which extends entity. This means

331
00:15:27.320 --> 00:15:30.279
<v Speaker 2>your monster automatically knows how to do everything an entity

332
00:15:30.360 --> 00:15:33.000
<v Speaker 2>can like exist in the world at a location, and

333
00:15:33.080 --> 00:15:36.360
<v Speaker 2>everything a living entity can like have health, take damage,

334
00:15:36.519 --> 00:15:38.919
<v Speaker 2>plus any specific monster things you add, so you.

335
00:15:38.840 --> 00:15:41.200
<v Speaker 1>Don't have to rewrite all that basic entity stuff every

336
00:15:41.200 --> 00:15:42.080
<v Speaker 1>time exactly.

337
00:15:42.159 --> 00:15:45.799
<v Speaker 2>It promotes code reuse and creates a logical hierarchy. Java

338
00:15:45.879 --> 00:15:49.399
<v Speaker 2>itself has a base object class that everything ultimately inherits from.

339
00:15:49.519 --> 00:15:53.120
<v Speaker 1>Okay, that op structure makes sense, but what happens when

340
00:15:53.120 --> 00:15:56.080
<v Speaker 1>things just go wrong while the program is running, not

341
00:15:56.159 --> 00:16:00.399
<v Speaker 1>a typo that net Beans catches, but like unexpect.

342
00:16:00.240 --> 00:16:03.320
<v Speaker 2>Situations right run time problems, that's where exceptions come in.

343
00:16:03.759 --> 00:16:08.200
<v Speaker 2>The guide described them as exceptional circumstances. The program hits

344
00:16:08.200 --> 00:16:11.720
<v Speaker 2>a situation it wasn't necessarily designed to handle smoothly at

345
00:16:11.720 --> 00:16:13.039
<v Speaker 2>that exact point, like.

346
00:16:12.960 --> 00:16:15.159
<v Speaker 1>The user typing text when you expected a number.

347
00:16:15.320 --> 00:16:17.919
<v Speaker 2>That's the classic example the new calculator, and the guide

348
00:16:17.960 --> 00:16:21.159
<v Speaker 2>showed this perfectly. If your code tries to use integer

349
00:16:21.360 --> 00:16:24.720
<v Speaker 2>dot parsin on the text hello, that's going to cause

350
00:16:24.720 --> 00:16:28.720
<v Speaker 2>a problem. It would crash unless you handle the exception.

351
00:16:29.360 --> 00:16:32.759
<v Speaker 2>Java lets you anticipate these problems using a tricatch block.

352
00:16:33.080 --> 00:16:33.759
<v Speaker 1>How does that work?

353
00:16:33.919 --> 00:16:37.039
<v Speaker 2>You put the code that might cause an exception, the

354
00:16:37.159 --> 00:16:41.320
<v Speaker 2>risky code like integer dot parse end user input inside

355
00:16:41.360 --> 00:16:44.480
<v Speaker 2>a tryblock. Immediately after it, you put a catch block.

356
00:16:44.600 --> 00:16:47.440
<v Speaker 2>The catch block specifies the type of exception it's designed

357
00:16:47.440 --> 00:16:49.440
<v Speaker 2>to handle, like number format exception.

358
00:16:49.639 --> 00:16:52.399
<v Speaker 1>So if that specific error happens inside.

359
00:16:52.039 --> 00:16:55.399
<v Speaker 2>Try, the program immediately jumps to the catch block for

360
00:16:55.480 --> 00:16:58.519
<v Speaker 2>number format exception and runs the code inside that block

361
00:16:58.600 --> 00:17:01.879
<v Speaker 2>instead of crashing. Do you Calculator example, use this to

362
00:17:01.919 --> 00:17:04.559
<v Speaker 2>print a nice message like, Hey, that wasn't a number

363
00:17:04.759 --> 00:17:07.400
<v Speaker 2>instead of just dying, that's much better. Yeah.

364
00:17:07.599 --> 00:17:10.599
<v Speaker 1>The guide also mentioned other exceptions like that array index

365
00:17:10.640 --> 00:17:13.519
<v Speaker 1>out of bounds exception again and null pointer exception.

366
00:17:13.720 --> 00:17:15.839
<v Speaker 2>Yeah. Null pointer exception happens when you try to use

367
00:17:15.880 --> 00:17:18.440
<v Speaker 2>a variable that hasn't been initialized to point to an

368
00:17:18.440 --> 00:17:21.720
<v Speaker 2>actual objecto null pointing to nothing.

369
00:17:21.440 --> 00:17:23.359
<v Speaker 1>And the guide said you shouldn't always try to catch those.

370
00:17:23.599 --> 00:17:26.599
<v Speaker 2>It made the point that exceptions like array index outbounds

371
00:17:26.680 --> 00:17:30.400
<v Speaker 2>or null pointer often signal a fundamental logic error in

372
00:17:30.440 --> 00:17:34.160
<v Speaker 2>your code. While you could technically catch them, it's usually

373
00:17:34.200 --> 00:17:37.799
<v Speaker 2>better practice to fix the underlying code flaw that's causing them,

374
00:17:38.200 --> 00:17:40.480
<v Speaker 2>rather than trying to patch over it with a catch block.

375
00:17:41.039 --> 00:17:43.480
<v Speaker 2>Prevent the error rather than just reacting to it.

376
00:17:43.680 --> 00:17:46.559
<v Speaker 1>Got it, fix the bug. Okay, we've chewed through a

377
00:17:46.559 --> 00:17:49.759
<v Speaker 1>lot of core Java there. The guide also glanced at

378
00:17:49.759 --> 00:17:52.160
<v Speaker 1>a couple of slightly more advanced topics.

379
00:17:51.960 --> 00:17:55.200
<v Speaker 2>Just briefly. One was threads. Threads are a way to

380
00:17:55.240 --> 00:17:58.119
<v Speaker 2>make your program do multiple things seemingly at the same time,

381
00:17:58.480 --> 00:18:02.759
<v Speaker 2>like multitasking. Much The prime Finder example showed this one

382
00:18:02.799 --> 00:18:05.119
<v Speaker 2>part of the code. One thread could be doing heavy

383
00:18:05.160 --> 00:18:09.440
<v Speaker 2>calculations while another thread updates the user interface or progress bar,

384
00:18:09.640 --> 00:18:11.599
<v Speaker 2>keeping things responsive.

385
00:18:11.319 --> 00:18:13.920
<v Speaker 1>Useful for long tasks in a mod maybe could be.

386
00:18:14.319 --> 00:18:17.519
<v Speaker 2>And the other thing was file io input output, reading

387
00:18:17.559 --> 00:18:21.400
<v Speaker 2>and writing files exactly using Java's built in libraries to

388
00:18:21.480 --> 00:18:25.079
<v Speaker 2>read data from files like loading mod settings, or write

389
00:18:25.160 --> 00:18:28.920
<v Speaker 2>data to files like saving player progress or configuration. The

390
00:18:28.960 --> 00:18:32.960
<v Speaker 2>configurat example showed writing simple key value pairs like username

391
00:18:33.000 --> 00:18:36.119
<v Speaker 2>max to a dot properties file. It involves concepts like

392
00:18:36.200 --> 00:18:39.599
<v Speaker 2>data streams and remembering to close the file connection when

393
00:18:39.640 --> 00:18:40.119
<v Speaker 2>you're done.

394
00:18:40.200 --> 00:18:44.920
<v Speaker 1>Okay, wow, that's a lot of Java. Now the payoff.

395
00:18:45.559 --> 00:18:49.839
<v Speaker 1>How does all this variables, loops, objects, exceptions actually let

396
00:18:49.880 --> 00:18:53.279
<v Speaker 1>you make a Minecraft mod using something like spiggot, which

397
00:18:53.319 --> 00:18:54.480
<v Speaker 1>the guide mentioned right.

398
00:18:54.559 --> 00:18:57.160
<v Speaker 2>This is where it connects. Spigot is a popular modified

399
00:18:57.200 --> 00:18:59.839
<v Speaker 2>Minecraft server software that provides an API, a set of

400
00:18:59.839 --> 00:19:03.000
<v Speaker 2>two tools and interfaces for mod developers. Your mod is

401
00:19:03.079 --> 00:19:05.640
<v Speaker 2>essentially a Java program that plugs into spigot.

402
00:19:05.920 --> 00:19:07.359
<v Speaker 1>So how does a basic mod look?

403
00:19:07.519 --> 00:19:10.119
<v Speaker 2>Your main mod class will typically extend a class provided

404
00:19:10.119 --> 00:19:12.960
<v Speaker 2>by Spigot, usually Java plug in. This hooks your code

405
00:19:13.039 --> 00:19:14.720
<v Speaker 2>into the server's life cycle.

406
00:19:14.480 --> 00:19:16.480
<v Speaker 1>And making it do something when a player types a

407
00:19:16.519 --> 00:19:17.880
<v Speaker 1>command like petwolf.

408
00:19:18.039 --> 00:19:20.960
<v Speaker 2>That's a core feature you override a specific method in

409
00:19:21.000 --> 00:19:23.079
<v Speaker 2>your main class called on command.

410
00:19:22.720 --> 00:19:25.599
<v Speaker 1>Override, meaning you provide your own version exactly.

411
00:19:25.799 --> 00:19:30.079
<v Speaker 2>Spigott calls your on command method. Whenever a player uses

412
00:19:30.119 --> 00:19:33.039
<v Speaker 2>a command associated with your mod. Spigott gives your method

413
00:19:33.039 --> 00:19:36.240
<v Speaker 2>information like who sent the command, what the command was,

414
00:19:36.799 --> 00:19:38.920
<v Speaker 2>and any arguments typed after it.

415
00:19:39.000 --> 00:19:41.519
<v Speaker 1>So insight on command, you'd check if the command was.

416
00:19:41.519 --> 00:19:44.279
<v Speaker 2>Petwolf yep, and the guide stressed. You should also check

417
00:19:44.319 --> 00:19:47.759
<v Speaker 2>if the sender was actually a player, because sometimes bands

418
00:19:47.799 --> 00:19:50.720
<v Speaker 2>might come from the server console itself, which can't own

419
00:19:50.759 --> 00:19:51.160
<v Speaker 2>a wolf.

420
00:19:51.400 --> 00:19:54.319
<v Speaker 1>Good point, and the petwolf example used that on a

421
00:19:54.319 --> 00:19:56.720
<v Speaker 1>command to what spawn a wolf?

422
00:19:56.839 --> 00:19:59.880
<v Speaker 2>Yeah, it's code running inside on command would use Pigott's

423
00:19:59.880 --> 00:20:02.680
<v Speaker 2>a p I calls to get the player's location, spawn

424
00:20:02.720 --> 00:20:05.599
<v Speaker 2>a wolf entity there, set its color to pink, and

425
00:20:05.640 --> 00:20:07.440
<v Speaker 2>then set the player who typed the command as the

426
00:20:07.480 --> 00:20:08.240
<v Speaker 2>wolf's owner.

427
00:20:08.759 --> 00:20:11.880
<v Speaker 1>Cool. But how does Spigotto that petwolf belongs to your

428
00:20:11.880 --> 00:20:12.839
<v Speaker 1>mod in the first place?

429
00:20:12.920 --> 00:20:16.720
<v Speaker 2>Ah configuration, you need a special file called plug in

430
00:20:16.799 --> 00:20:19.599
<v Speaker 2>dot eml. It's a simple text file you bundle with

431
00:20:19.640 --> 00:20:20.039
<v Speaker 2>your mod.

432
00:20:20.119 --> 00:20:20.759
<v Speaker 1>What goes in it?

433
00:20:20.920 --> 00:20:24.359
<v Speaker 2>Basic info, your mod's name, the author, the main Java

434
00:20:24.359 --> 00:20:27.400
<v Speaker 2>class that Spigot should load your dot package dot main

435
00:20:27.480 --> 00:20:31.720
<v Speaker 2>class and crucially a commands section. There you define petwolf,

436
00:20:31.759 --> 00:20:34.440
<v Speaker 2>give it a description, and make some usage instructions. That

437
00:20:34.559 --> 00:20:38.440
<v Speaker 2>file tells spiggot, hey I exist and I handle these commands.

438
00:20:38.480 --> 00:20:41.799
<v Speaker 1>Okay, And what if the command has arguments like transmute

439
00:20:41.799 --> 00:20:44.279
<v Speaker 1>stone diamond, how do you get stone in diamond.

440
00:20:44.599 --> 00:20:46.839
<v Speaker 2>Those words come into your own command method as an

441
00:20:46.920 --> 00:20:50.200
<v Speaker 2>array of string arguments. Your code would look at that array.

442
00:20:50.319 --> 00:20:54.200
<v Speaker 2>Index zero zero would be stone, index one would be diamond.

443
00:20:53.880 --> 00:20:55.839
<v Speaker 1>And then you use those strings. Right.

444
00:20:56.119 --> 00:20:59.440
<v Speaker 2>The guide showed how spigot provides methods like material dot

445
00:20:59.480 --> 00:21:02.680
<v Speaker 2>get material. You pass it the string stone and it

446
00:21:02.680 --> 00:21:05.559
<v Speaker 2>gives you back the actual material object representing stone in

447
00:21:05.599 --> 00:21:08.640
<v Speaker 2>the game. The transmuter mod would use this to figure

448
00:21:08.680 --> 00:21:10.960
<v Speaker 2>out the from material and the two material based on

449
00:21:11.039 --> 00:21:11.759
<v Speaker 2>player input.

450
00:21:12.039 --> 00:21:15.119
<v Speaker 1>This leads into actually interacting with the game world, mobs

451
00:21:15.240 --> 00:21:19.079
<v Speaker 1>blocks the environment itself. That feels like the real heart

452
00:21:19.119 --> 00:21:19.599
<v Speaker 1>of modding.

453
00:21:19.799 --> 00:21:23.559
<v Speaker 2>It really is all those Java object concepts applied directly.

454
00:21:23.599 --> 00:21:23.839
<v Speaker 1>Here.

455
00:21:24.440 --> 00:21:29.079
<v Speaker 2>You get references to game objects, living entities, zombie player block,

456
00:21:29.559 --> 00:21:32.559
<v Speaker 2>and then you use their methods. So for mobs you

457
00:21:32.559 --> 00:21:35.160
<v Speaker 2>can use methods like world dot spawn to create new

458
00:21:35.200 --> 00:21:39.039
<v Speaker 2>ones or get an existing mob object and call methods

459
00:21:39.039 --> 00:21:41.680
<v Speaker 2>on it to change its properties, set its age, apply

460
00:21:41.759 --> 00:21:44.799
<v Speaker 2>potion effects. The guide mentioned making one mob ride another

461
00:21:44.920 --> 00:21:47.319
<v Speaker 2>using set passenger lots of possibilities.

462
00:21:47.359 --> 00:21:50.440
<v Speaker 1>But mods don't just react to commands. What about reacting

463
00:21:50.480 --> 00:21:53.119
<v Speaker 1>to things happening in the game, like a player mining

464
00:21:53.119 --> 00:21:55.319
<v Speaker 1>a block or a creeper exploding.

465
00:21:55.480 --> 00:21:58.640
<v Speaker 2>Yes, event handling this is maybe even more central than

466
00:21:58.640 --> 00:22:02.079
<v Speaker 2>commands For many mods. Your mod becomes an event listener

467
00:22:02.160 --> 00:22:04.599
<v Speaker 2>listening for it why for specific events that the Spigot

468
00:22:04.599 --> 00:22:08.440
<v Speaker 2>server broadcasts whenever something significant happens in the game player movement,

469
00:22:08.640 --> 00:22:12.720
<v Speaker 2>entity taking, damage, block breaking, inventory clicks, tons of events.

470
00:22:12.920 --> 00:22:15.279
<v Speaker 1>So your mod is constantly listening in the background.

471
00:22:15.559 --> 00:22:18.119
<v Speaker 2>Sort of. You have to register it. First. You make

472
00:22:18.160 --> 00:22:22.480
<v Speaker 2>your main mod class or another class implement the listener interface. Then,

473
00:22:22.759 --> 00:22:25.079
<v Speaker 2>when your mod starts up, usually in a method called

474
00:22:25.079 --> 00:22:29.079
<v Speaker 2>on able, you tell spiggott, hey start sending events to

475
00:22:29.160 --> 00:22:30.519
<v Speaker 2>this listener object.

476
00:22:30.599 --> 00:22:31.480
<v Speaker 1>Okay, registered?

477
00:22:31.880 --> 00:22:34.680
<v Speaker 2>Then what Then You write specific methods in your listener

478
00:22:34.680 --> 00:22:37.839
<v Speaker 2>class and mark them with at event handler. Each method

479
00:22:37.880 --> 00:22:40.960
<v Speaker 2>takes a specific event type as a parameter, like player

480
00:22:41.039 --> 00:22:43.200
<v Speaker 2>move event or entity damage.

481
00:22:42.839 --> 00:22:46.440
<v Speaker 1>Event, and that method automatically runs when that event hass exactly.

482
00:22:46.599 --> 00:22:50.079
<v Speaker 2>Spiggott sees the event, finds all registered listeners with handlers

483
00:22:50.079 --> 00:22:53.680
<v Speaker 2>for that event type, and calls their at event handler methods,

484
00:22:53.880 --> 00:22:57.400
<v Speaker 2>passing in the event object, which contains details about what happened.

485
00:22:57.680 --> 00:22:59.440
<v Speaker 1>Can you give those examples from the guide again?

486
00:22:59.599 --> 00:23:02.519
<v Speaker 2>The stone right stone Walker would have an ad event

487
00:23:02.599 --> 00:23:06.039
<v Speaker 2>handler method that takes a player move event. Inside that method,

488
00:23:06.119 --> 00:23:08.759
<v Speaker 2>it gets the location the player moved from and uses

489
00:23:08.759 --> 00:23:11.839
<v Speaker 2>Spiggott's API to change the block at that location, maybe

490
00:23:11.839 --> 00:23:13.559
<v Speaker 2>to stone or gold or whatever.

491
00:23:13.759 --> 00:23:16.240
<v Speaker 1>It's the Pathway and health checker.

492
00:23:16.079 --> 00:23:19.799
<v Speaker 2>That would listen for entity damage event. It's handler runs,

493
00:23:20.200 --> 00:23:23.279
<v Speaker 2>gets the entity that was damaged, maybe, calculates its remaining

494
00:23:23.319 --> 00:23:26.839
<v Speaker 2>health percentage, and then uses methods like set custom name

495
00:23:26.960 --> 00:23:29.920
<v Speaker 2>on the entity object to display that health maybe using

496
00:23:29.960 --> 00:23:32.920
<v Speaker 2>Spiggot's check color codes to make it red or green like.

497
00:23:32.920 --> 00:23:34.799
<v Speaker 1>A dynamic health bar above their head.

498
00:23:34.880 --> 00:23:38.039
<v Speaker 2>Precisely. And the Zeus mod that's out of fun. Yeah,

499
00:23:38.119 --> 00:23:41.039
<v Speaker 2>that one listens for entity target event. When a mob

500
00:23:41.079 --> 00:23:43.960
<v Speaker 2>targets a player, the handler runs, gets the mob's location

501
00:23:44.359 --> 00:23:47.119
<v Speaker 2>and calls World dot strike lightning at that spot.

502
00:23:47.440 --> 00:23:50.759
<v Speaker 1>Bam. Wow. So events let you react to almost anything

503
00:23:51.039 --> 00:23:51.640
<v Speaker 1>pretty much.

504
00:23:52.039 --> 00:23:54.599
<v Speaker 2>It's how you make mods that feel deeply integrated with

505
00:23:54.640 --> 00:23:58.279
<v Speaker 2>the gameplay, not just triggered by commands. You combine listening

506
00:23:58.359 --> 00:24:02.400
<v Speaker 2>for the event with using the Java objects player, block, entity, world,

507
00:24:02.640 --> 00:24:05.519
<v Speaker 2>and Spigot methods strike, lightning, set type, set custom name

508
00:24:05.880 --> 00:24:06.640
<v Speaker 2>to make changes.

509
00:24:07.039 --> 00:24:10.039
<v Speaker 1>Speaking of changing things, let's focus on blocks for a second. Yeah,

510
00:24:10.079 --> 00:24:13.519
<v Speaker 1>how do you pinpoint and manipulate specific blocks in the world.

511
00:24:14.039 --> 00:24:18.400
<v Speaker 2>You use a combination of classes. Spigot provides World represents

512
00:24:18.440 --> 00:24:24.920
<v Speaker 2>the dimension overworld nether end location holds specific xyz coordinates

513
00:24:24.920 --> 00:24:27.920
<v Speaker 2>within that world. Block represents the actual block at a

514
00:24:27.960 --> 00:24:31.599
<v Speaker 2>given location, and material defines the type of block like

515
00:24:31.680 --> 00:24:34.119
<v Speaker 2>material dot stone, material dot diamond or so.

516
00:24:34.160 --> 00:24:35.119
<v Speaker 1>How do you change a block?

517
00:24:35.640 --> 00:24:38.799
<v Speaker 2>Typically you get the world object, then use a location

518
00:24:39.000 --> 00:24:41.599
<v Speaker 2>object which might come from an event, or you calculate

519
00:24:41.640 --> 00:24:44.839
<v Speaker 2>it to get the specific block object using a method

520
00:24:44.960 --> 00:24:48.279
<v Speaker 2>like world dot get block at location. Once you have

521
00:24:48.279 --> 00:24:50.440
<v Speaker 2>the block object, you can call methods on it like

522
00:24:50.519 --> 00:24:52.880
<v Speaker 2>get type to see what it is, or set type,

523
00:24:52.920 --> 00:24:54.720
<v Speaker 2>material dot goldiebelot to change it.

524
00:24:54.799 --> 00:24:56.960
<v Speaker 1>The guide mentioned big Dig in Tree Chopper is more

525
00:24:56.960 --> 00:24:57.880
<v Speaker 1>complex examples.

526
00:24:58.000 --> 00:25:01.359
<v Speaker 2>Yeah, they illustrate going beyond single Big dig would involve

527
00:25:01.400 --> 00:25:03.480
<v Speaker 2>some math to figure out all the locations within a

528
00:25:03.519 --> 00:25:06.880
<v Speaker 2>certain radius of the player than looping through those locations

529
00:25:06.920 --> 00:25:08.160
<v Speaker 2>to change each block and.

530
00:25:08.200 --> 00:25:11.240
<v Speaker 1>Tree chopper sounds like it needs to find all the logs.

531
00:25:11.400 --> 00:25:15.359
<v Speaker 2>Right, that's more complex. You might detect when a log

532
00:25:15.400 --> 00:25:18.839
<v Speaker 2>block is broken than have code that searches upwards and

533
00:25:18.920 --> 00:25:22.799
<v Speaker 2>maybe outwards for connected log blocks, potentially using loops or

534
00:25:22.839 --> 00:25:26.319
<v Speaker 2>even more advanced techniques like recursion, where a method calls

535
00:25:26.359 --> 00:25:29.839
<v Speaker 2>itself to explore the tree structure. These show how you

536
00:25:29.880 --> 00:25:33.519
<v Speaker 2>build on the basics to tackle bigger problems. Managing potentially

537
00:25:33.640 --> 00:25:35.960
<v Speaker 2>lots of blocks and locations.

538
00:25:35.880 --> 00:25:39.119
<v Speaker 1>With all this power to change the world, literally digging

539
00:25:39.160 --> 00:25:43.000
<v Speaker 1>holes and chopping trees with code. Managing the actual Minecraft

540
00:25:43.039 --> 00:25:46.359
<v Speaker 1>world files seems important. Any tips from the guide on

541
00:25:46.400 --> 00:25:47.319
<v Speaker 1>that definitely.

542
00:25:47.720 --> 00:25:51.039
<v Speaker 2>It strongly recommends making regular backups of your world folders.

543
00:25:51.279 --> 00:25:52.440
<v Speaker 1>Just copy the folder.

544
00:25:52.200 --> 00:25:55.240
<v Speaker 2>Pretty much find your server directory and inside there will

545
00:25:55.279 --> 00:25:58.599
<v Speaker 2>be folders named after your world, usually World, nether and

546
00:25:58.640 --> 00:26:01.759
<v Speaker 2>world themed. To do this when the server is not

547
00:26:01.880 --> 00:26:05.519
<v Speaker 2>running to avoid corrupted files, just copy those folders somewhere safe.

548
00:26:05.559 --> 00:26:07.759
<v Speaker 1>Good advice. How do you know the world name?

549
00:26:07.839 --> 00:26:10.039
<v Speaker 2>If it's not just world, You can usually find the

550
00:26:10.160 --> 00:26:12.920
<v Speaker 2>name listed in the server dot properties file in your

551
00:26:12.960 --> 00:26:14.319
<v Speaker 2>server directory and.

552
00:26:14.240 --> 00:26:17.079
<v Speaker 1>The world seed that unique generation number.

553
00:26:17.279 --> 00:26:19.599
<v Speaker 2>Yeah, the guide mentions you can easily get that in

554
00:26:19.680 --> 00:26:22.240
<v Speaker 2>game using the command seed. Good to note down if

555
00:26:22.240 --> 00:26:24.480
<v Speaker 2>you ever want to recreate the exact same terrain later.

556
00:26:24.720 --> 00:26:28.640
<v Speaker 1>Okay, so, looking back, we've covered quite a bit of ground,

557
00:26:29.079 --> 00:26:31.319
<v Speaker 1>from the absolute basics of Java.

558
00:26:31.000 --> 00:26:34.440
<v Speaker 2>Syntax variables, if statements, loots.

559
00:26:34.160 --> 00:26:37.279
<v Speaker 1>To organizing code with objects, in handling.

560
00:26:36.960 --> 00:26:40.599
<v Speaker 2>Errors, inheritance exceptions, trycatch, and.

561
00:26:40.559 --> 00:26:42.839
<v Speaker 1>Then seeing how all those pieces come together using this

562
00:26:42.880 --> 00:26:45.880
<v Speaker 1>Spigott api to actually make things happen in Minecraft.

563
00:26:46.039 --> 00:26:50.160
<v Speaker 2>Yeah, writing command handlers, listening for game events, spawning mobs,

564
00:26:50.279 --> 00:26:54.440
<v Speaker 2>changing blocks. It all uses those core Java concepts and.

565
00:26:54.400 --> 00:26:57.960
<v Speaker 1>It's worth stressing. Like the guide implies, these skills aren't

566
00:26:58.000 --> 00:26:59.160
<v Speaker 1>just for Minecraft modding.

567
00:26:59.480 --> 00:27:04.240
<v Speaker 2>Absolutely understanding variables, control flow, object oriented programming, event handling,

568
00:27:04.319 --> 00:27:08.079
<v Speaker 2>these are foundational concepts used across vast areas of software development.

569
00:27:08.640 --> 00:27:11.720
<v Speaker 2>Learning Java from modding gives you a really solid base.

570
00:27:11.680 --> 00:27:13.799
<v Speaker 1>And for folks who want to dive deeper, the guide

571
00:27:13.839 --> 00:27:15.200
<v Speaker 1>mentioned to resource.

572
00:27:15.039 --> 00:27:18.960
<v Speaker 2>Yeah www dot javamincraft dot com sounds like a place

573
00:27:19.000 --> 00:27:22.400
<v Speaker 2>to find the source code for examples, ask question and

574
00:27:22.440 --> 00:27:25.559
<v Speaker 2>connect with other people learning the stuff. Community is always

575
00:27:25.559 --> 00:27:27.319
<v Speaker 2>helpful when learning to code.

576
00:27:27.240 --> 00:27:31.400
<v Speaker 1>So really taking these first steps into programming through something

577
00:27:31.440 --> 00:27:35.839
<v Speaker 1>familiar like Minecraft, it fundamentally changes your relationship with the game,

578
00:27:35.880 --> 00:27:36.359
<v Speaker 1>doesn't it.

579
00:27:36.359 --> 00:27:39.000
<v Speaker 2>It really does. You're not just playing by the rules anymore.

580
00:27:39.039 --> 00:27:40.799
<v Speaker 1>You're starting to understand how to write the rules.

581
00:27:40.839 --> 00:27:44.559
<v Speaker 2>You've got the potential power to reshape that world, So

582
00:27:45.000 --> 00:27:47.920
<v Speaker 2>the question really becomes what will you create
