CS 1 (Fall 2024) Final: Building a Minecraft Plugin

You’ll get to show off your new skills in Java by programming a Minecraft plugin.

Introduction

In CS1, you’ve learned to read, modify, and write code to build programs. For your final, we are not trying to test you on the concepts in the class.

Instead, we intend for this to be a cumulative demonstration of the skills you do have. Therefore, so you can see your program work in a real setting, we want you to modify the game of Minecraft using the plugin interface.

A Very Small Primer on Minecraft

Before we begin writing code, it helps to see how various things interact with each other in minecraft. Specifically, during this project, we will use the following Minecraft “features”/”concepts”:

Writing the Plugins

Typically, when you play minecraft, if you “drop an item”, it becomes available for other players to use…but not on the Caltech servers! We have installed (and given you the source code to!) a plugin which immediately removes an item from play as soon as a player drops it. Take a look at the IDidntNeedThatAnywayMod.java file which is a complete definition of a Minecraft Plugin (which we’ll colloquially call a “Mod” (and yes, we know this is technically incorrect).

Our mod uses the concept of an “event listener” where Minecraft tells us when an event occurs so we can respond to it. The astute student will recall that we used many of these in the Critters environment in project06 (e.g., when critters were done mating). This is exactly the same thing! Just in a bigger world!

Your first task is to fix our mod so it does something less…stupid.

Now, we’re ready to accomplish our real goal. Minecraft doesn’t have enough turtle ponds. Or Turtles. The final (heh, get it?) goal of CS 1 is to make a mod that will spawn turtles into minecraft if the player constructs a pond.

Our definition of a “turtle pond” is any pattern of 8 stone blocks in a square with a water block in the middle. The construction order matters, though.
First, the player must construct the border of the pond (where else would the water go?), and then empty a bucket of water into the hole in the center. Then, as if magic, your mod will make a turtle appear out of thin air!

The good news is that this mod is actually just a slightly more complicated version of the one you just wrote with a couple exceptions: 1) Instead of listening for an item to be dropped, we want to listen for a bucket to be emptied. 2) Instead of always doing something when the listener happens, we only want to conditionally do it when the block we’ve emptied into is surrounded by stone. 3) Before spawning the new item, we want to delete the pond.

We’ve scoped out an approach for you in TurtlePondMod.java, and we strongly recommend you fill in the methods from top to bottom, as per the rest of this guide.

The trickiest part of the remainder of this project is how to “get” one type of thing from another type of thing. We’ve encapsulated the relevant methods and their arguments into the following diagram. This diagram is the most important part of this guide:

flow