Write a mod
Project setup
- Create a new Java project in your IDE
- Add Maven to your project
- Set up
pom.xml
- Paste following code into dependencies:
<dependency> <groupId>com.google.code.findbugs</groupId> <artifactId>annotations</artifactId> <version>3.0.1u2</version> </dependency> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>31.1-jre</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>[2.14.0-rc1,)</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.13.2</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>2.13.4</version> </dependency> <dependency> <groupId>com.github.Fylipp</groupId> <artifactId>easy-events</artifactId> <version>v1.1.0</version> </dependency>
- Place content at specific directories:
textures/
- texturessound/
- sounds
- Place translations in a known directory (used in step 7)
- Create several classes:
- A class which implements
AddonCentral
, a class which defines mods - A class with items/blocks (this is a separate class to ensure that items are created at the right time)
- A class with recipes (this is a separate class to ensure that recipes are created after items)
- A class which implements
- Fill in the methods:
- (constructor) - instantiate mod
info()
- return an instance ofModMetadata
with mod name, release date, description and namefirstOpen()
- load your translations withGlobalSettings.injectResources()
makeContent()
- place your call to init function of your items classintegrationModules()
- place your call to init function of your recipes class, and any mod integration
- Create blocks and items.
- If you want to create a block entity, implement any of these:
BlockEntityDataless
- when your block does not store any extra information beyond its typeBlockEntityData
- if your block stores data and can’t be rotatedBlockEntityChirotable
- if your block can be rotated and flippedSkeletalBlockEntityRotary
- if your block can rotate, but not flip
- If you want to create an item entity, implement
ItemEntity
if you want an immutable item, orItemEntityMutable
, if your item would be mutable. - If your item or block is an entity, declare an appriopriate entity type in your content class
- If your item entity is immutable, declare
hash0()
andequal0()
for equal items to collate. - If you want captions (titles and descriptions) to be translated, instead of a literal string, use a translation key. Translation keys begin with ‘#’ and are followed by a key in your translation file.
- Create additional classes if needed
- If you want to create a block entity, implement any of these:
- Create recipes
- If your recipe outputs an item entity, declare a raw item with
ItemRaw.make()
instead of an item entity as the recipe output. - Do not consume item entities within recipes
- If your recipe outputs an item entity, declare a raw item with
- Test your mod. If you find bugs, debug them and apply fixes
- Publish your mod to GitHub. (See here)
- Write about your mod at the game discussions under ‘Show and tell’