Karen Craig

Create a Minecraft mod with 100 mansions divided into 4 phases of 25 mansions each: Phase 1 – Dirt Mansions: 25 dirt mansions that progressively grow bigger from Mansion 1 to Mansion 25; Phase 2 – Gold Mansions: 25 gold mansions that progressively grow bigger; Phase 3 – Diamond Mansions: 25 diamond mansions that progressively grow bigger; and Phase 4 – Netherite Mansions: 25 netherite mansions that progressively grow bigger, with Mansion 100 being the biggest and most powerful mansion of them all also each one has their own gun space with guns hanged on the wall

Kodari AI
KodariOct 10 at 7:36 am 2
MansionArsenal
A Fabric mod generating 100 progressively larger mansions across four phases: 25 dirt, 25 gold, 25 diamond, and 25 netherite structures. Each mansion contains a dedicated gun room with weapons displayed on wall-mounted racks. Mansion size scales incrementally from Mansion 1 to Mansion 100, with the final netherite mansion being the largest and most powerful. The mod uses world generation to place these structures, with each phase introducing a new material tier and increasing architectural complexity. Gun racks feature randomized weapon selections, creating unique armories per mansion.
  1. Create the Fabric 26.3 mod scaffold and a command that builds any of the 100 phase-themed mansions, including a decorative gun room.- Add the Fabric 26.3 build scaffold and mod entrypoint.

  • Register /mansion <phase 1–4> <number 1–25> to build a progressively larger themed mansion.

  • Give each mansion a separate armory with crossbows displayed in wall frames; Mansion 100 is the largest, with six stories.

Created the Fabric 26.3 mod and registered /mansion <phase> <number> to build one mansion at a time near the player.

  • Phase 1 builds dirt mansions; Phase 2 gold; Phase 3 diamond; Phase 4 netherite. Mansion size increases across all 100, and Mansion 100 is the largest at six stories.

  • Each mansion has an armory with crossbows displayed in wall frames.

  • In survival, run /mansion 1 1 through /mansion 4 25; /mansion 4 25 builds Mansion 100.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
5 189
src/main/java/com/kodari/phasemansions/PhaseMansionsMod.java
package com.kodari.phasemansions;

import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.decoration.ItemFrame;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;

public final class PhaseMansionsMod implements ModInitializer {
    private static final Block[] PHASE_MATERIALS = {
        Blocks.DIRT,
        Blocks.GOLD_BLOCK,
        Blocks.DIAMOND_BLOCK,
        Blocks.NETHERITE_BLOCK
    };

    @Override
    public void onInitialize() {
        CommandRegistrationCallback.EVENT.register((dispatcher, buildContext, selection) -> dispatcher.register(
            Commands.literal("mansion")
                .then(Commands.argument("phase", IntegerArgumentType.integer(1, 4))
                    .then(Commands.argument("number", IntegerArgumentType.integer(1, 25))
                        .executes(context -> buildMansion(
                            context.getSource(),
                            IntegerArgumentType.getInteger(context, "phase"),
                            IntegerArgumentType.getInteger(context, "number")
                        ))))
        ));
    }

    private static int buildMansion(CommandSourceStack source, int phase, int number) throws CommandSyntaxException {
        var player = source.getPlayerOrException();
        int mansionIndex = (phase - 1) * 25 + number;
        int width = 12 + mansionIndex;
        int depth = width - 2;
        int stories = 1 + (mansionIndex - 1) / 17;
        BlockState material = PHASE_MATERIALS[phase - 1].defaultBlockState();
        BlockPos origin = player.blockPosition().offset(-width / 2, 0, 6);

        buildStructure(source.getLevel(), origin, width, depth, stories, material);
        source.sendSuccess(
            () -> Component.literal("Built Phase " + phase + " Mansion " + number + " (" + width + "×" + depth + ", " + stories + " stories) with its own armory."),
            false
        );
        return 1;
    }

    private static void buildStructure(ServerLevel level, BlockPos origin, int width, int depth, int stories, BlockState material) {
        for (int story = 0; story < stories; story++) {
            int floorY = story * 6;
            for (int x = 0; x < width; x++) {
                for (int z = 0; z < depth; z++) {
                    place(level, origin, x, floorY, z, material);
                }
            }

            for (int y = floorY + 1; y <= floorY + 4; y++) {
                for (int x = 0; x < width; x++) {
                    placeWall(level, origin, x, y, 0, x, 0, y, width, depth, story, material);
                    placeWall(level, origin, x, y, depth - 1, x, depth - 1, y, width, depth, story, material);
                }
                for (int z = 1; z < depth - 1; z++) {
                    placeWall(level, origin, 0, y, z, 0, z, y, width, depth, story, material);
                    placeWall(level, origin, width - 1, y, z, width - 1, z, y, width, depth, story, material);
                }
            }

            for (int x = 0; x < width; x++) {
                for (int z = 0; z < depth; z++) {
                    BlockState ceiling = x % 8 == 3 && z % 8 == 3
                        ? Blocks.GLOWSTONE.defaultBlockState()
                        : material;
                    place(level, origin, x, floorY + 5, z, ceiling);
                }
            }

            if (story == 0) {
                buildArmory(level, origin, width, depth, material);
            }
        }

    }

    private static void placeWall(ServerLevel level, BlockPos origin, int x, int y, int z, int wallX, int wallZ, int worldY, int width, int depth, int story, BlockState material) {
        boolean entrance = story == 0 && wallZ == 0 && wallX >= width / 2 && wallX <= width / 2 + 1 && worldY <= 2;
        if (entrance) {
            return;
        }

        boolean windowHeight = worldY == story * 6 + 2 || worldY == story * 6 + 3;
        boolean frontWindow = wallZ == 0 && wallX > 1 && wallX < width - 2 && (wallX % 12 == 5 || wallX % 12 == 6);
        boolean sideWindow = (wallX == 0 || wallX == width - 1) && wallZ > 1 && wallZ < depth - 2 && (wallZ % 12 == 5 || wallZ % 12 == 6);
        BlockState state = windowHeight && (frontWindow || sideWindow)
            ? Blocks.GLASS.defaultBlockState()
            : material;
        place(level, origin, x, y, z, state);
    }

    private static void buildArmory(ServerLevel level, BlockPos origin, int width, int depth, BlockState material) {
        int armoryPartition = depth - Math.max(4, depth / 4) - 1;
        int doorway = width / 2;

        for (int x = 1; x < width - 1; x++) {
            for (int y = 1; y <= 4; y++) {
                if ((x == doorway || x == doorway + 1) && y <= 2) {
                    continue;
                }
                place(level, origin, x, y, armoryPartition, material);
            }
        }

        for (int x = 2; x < width - 2; x += 5) {
            addWallGun(level, origin, x, 2, depth - 2);
            addWallGun(level, origin, x, 4, depth - 2);
        }
    }

    private static void addWallGun(ServerLevel level, BlockPos origin, int x, int y, int z) {
        BlockPos framePosition = origin.offset(x, y, z);
        ItemFrame frame = new ItemFrame(level, framePosition, Direction.NORTH);
        frame.setItem(new ItemStack(Items.CROSSBOW));
        level.addFreshEntity(frame);
    }

    private static void place(ServerLevel level, BlockPos origin, int x, int y, int z, BlockState state) {
        level.setBlock(origin.offset(x, y, z), state, Block.UPDATE_ALL, 512);
    }
}