Durga Mainali

Create a mod where the player is the leader of an army called Null, 100% inspired by Unstable SMP

Kodari AI
KodariOct 22 at 11:48 am 5
NullArmyCommand
A Minecraft Fabric mod where the player leads an army called Null, inspired by Unstable SMP. Recruit NPC soldiers that follow commands, build military bases, and engage in tactical battles. Features include army management UI, soldier AI with formation movement, base building mechanics, and resource gathering for army upkeep. Soldiers level up through combat and can be assigned specialized roles like scouts, defenders, and siege units. The mod adds a command center structure that serves as the army's headquarters, allowing players to issue global orders, manage supply lines, and defend against enemy raids. Includes custom armor and weapons themed around the Null army aesthetic.

Plan:

  • Add a craftable Null Recruit Seal that summons a tamed, black-collared wolf companion and is consumed on use.

  • Register the item in a creative tab and add its survival crafting recipe, name, and texture.

Created Null Army for Fabric 26.3. Craft a Null Recruit Seal from 1 bone, 1 echo shard, and 2 amethyst shards; using it consumes the seal and summons a persistent, tamed wolf named Null Recruit. The seal is in the Tools & Utilities creative tab and has its own texture.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
10 178
src/main/java/com/nullarmy/NullArmyMod.java
package com.nullarmy;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.creativetab.v1.CreativeModeTabEvents;
import net.minecraft.core.Registry;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.Identifier;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.EntitySpawnReason;
import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.entity.animal.wolf.Wolf;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.Level;

public class NullArmyMod implements ModInitializer {
	public static final String MOD_ID = "nullarmy";
	private static final Identifier NULL_RECRUIT_SEAL_ID = Identifier.fromNamespaceAndPath(MOD_ID, "null_recruit_seal");
	private static final ResourceKey<CreativeModeTab> TOOLS_AND_UTILITIES = ResourceKey.create(
			Registries.CREATIVE_MODE_TAB,
			Identifier.fromNamespaceAndPath("minecraft", "tools_and_utilities")
	);
	public static final Item NULL_RECRUIT_SEAL = Registry.register(
			BuiltInRegistries.ITEM,
			NULL_RECRUIT_SEAL_ID,
			new NullRecruitSealItem(new Item.Properties().setId(ResourceKey.create(Registries.ITEM, NULL_RECRUIT_SEAL_ID)))
	);

	@Override
	public void onInitialize() {
		CreativeModeTabEvents.modifyOutputEvent(TOOLS_AND_UTILITIES).register(output -> output.prepend(NULL_RECRUIT_SEAL));
	}

	private static final class NullRecruitSealItem extends Item {
		private NullRecruitSealItem(final Item.Properties properties) {
			super(properties);
		}

		@Override
		public InteractionResult use(final Level level, final Player player, final InteractionHand hand) {
			if (!level.isClientSide() && level instanceof ServerLevel serverLevel) {
				Wolf recruit = EntityTypes.WOLF.create(level, EntitySpawnReason.TRIGGERED);
				if (recruit != null) {
					recruit.setPos(player.getX() + 1.0, player.getY(), player.getZ());
					recruit.tame(player);
					recruit.setCustomName(Component.literal("Null Recruit"));
					recruit.setPersistenceRequired();

					if (serverLevel.addFreshEntity(recruit)) {
						player.getItemInHand(hand).consume(1, player);
						recruit.playSound(SoundEvents.ENDERMAN_TELEPORT, 0.8F, 1.2F);
						serverLevel.sendParticles(
								ParticleTypes.PORTAL,
								recruit.getX(),
								recruit.getY() + 0.8,
								recruit.getZ(),
								18,
								0.35,
								0.5,
								0.35,
								0.02
						);
					}
				}
			}

			return InteractionResult.SUCCESS;
		}
	}
}