Edible Weapons Minecraft Mod

A mod for minecraft 1.17 that adds procedually generated food based weapons to the game.

Finding a Box to Think Outside of.

I wanted to create a mod for minecraft that would have a simple premise so that I could focus on learning the Forge 1.17 mdk without becoming overwhelmed.

As such, the edible weapons mod was born! The idea was simple enough as it made use of mechanics and items that were already in the game, but gave me plenty of room to expirement and let my imagination run wild!

Thats a lot of Weapons...

I started out first, by identifying which foods I wanted to base my weapons off of. To begin, I chose Wheat, Potatos, Carrots, and Beetroots all of which can be obtained from the overworld. Afterwords, I had some fun choosing the different weapons I wanted to try and implement. In the end I came up with:

an image displaying a matrix of each of the different food and weapon combinations. The left axis reads from top to bottom: 'Dagger, Rapier, Spear, Long Sword, Mace, Morningstar, Staff'. The top axis displays icons of various foods in the following order: 'Beetroot, Carrot, Potato, Wheat'

Creating each individual icon for each weapon by hand would be painfully slow. Since this project didn't have a strict deadline, I decided to create an algorithm using Java to procedurally generate the weapons for me! This way, I would only need to provide the color palette, weapon type, and food type to generate each weapon automatically.

Becoming a Blacksmith with Java.

Since I didn't want to add additional overhead to the mod, I branched out my icon and weapon generation into a seperate project. This way, I could generate the icons before hand, and then add the generated images and stats to the mod when I was ready.

Once I had my seperate procedural pixel art project set up, broke my problem down into smaller steps.

What is a Weapon Anyways?

I needed to figure out the general constraints each weapon would follow. I identified several components that may or may not be shared by multiple weapons. For instance, a staff is made of a singlular component. This component is a straight cylinder with a consistent diamter (for my purposes). A sword on the other hand, is comprised of a grip, guard, and blade. To keep things clean and reusable, I could consider a staff to be entirely comprised of a grip.

I would need to break down the recipe for each weapon component, and then define each weapon by mixing and matching them. I came up with the following components and weapons:

ComponentDescription
BladeA diagonal metallic component with variable thickness.
SpikeA squarish spikey weapon component for blunt weapons.
Mace HeadA squarish less spikey component specific to the mace.
GuardA component branches off in a perpendicular line on either side of the weapon.
GripA plain diagonal weapon component, with an optional decoration at the start
OutlineA simple outline of the weapon, used to give the weapon more substance.
WeaponComponents
DaggerGrip, Guard, Blade
Long SwordGrip, Guard, Blade
MaceGrip, Mace Head
MorningstarGrip, Spike
RapierGrip, Guard, Blade
SpearGrip, Guard (Used as the base of the spear tip, in this case), Spike
StaffGrip

Coloring by Component

Once I had a recipe for cooking up each weapon shape, I moved onto color. I would need to create some sort of color palette based off of the original material. I decided to get a bit creative to solve this step.

First, I decided to use some random garish colors to represent each color of the future palette when generating each component. Each weapon would come out looking like a clown weapon, but I could then apply the actual color in a later step.

To generate the palettes for each material, I picked a base color from each food icon. From that color, I would generate some sort of pleasing color palette. I programatically created this palette by shifting the hue saturation and lightness of the base color at each step of the palette.

Then I would replace the clown colors in the originally produced icon, with the palette colors.

Somehow the hours spent on this process, wasn't enough for me. Its a good thing I chose a project which was so simple on paper, because I ended up creating my own shader. The shader would diagonally apply a gradient to the weapon icon, giving it a bit of depth.

Putting the Pieces Together

With the pieces in place, I could now generate each weapon icon! Hooray! Using my new weapon icon generation utilities, I created the weapon icons for each weapon as a part of building the mod.

If you want a peek at my creativity (and madness), check out both repositories here:

Reflecting Years Later

I'm writing this in 2024, and I'm still proud of this project. There are definitely a few things in my code that I cringe at slightly, but I learned an incredible amount of things by creating this mod. Who knew colors were so complicated? I certainly didn't. But I do now. Thanks 2019 Cassie.

Role

Full Stack Developer

Goal

Create a mod for minecraft that allows food items to be crafted into weapons. Use procedural generation to create the weapon icons and stats.

Tools

Java, Minecraft Forge