Šimon Dumanov

so i want to create a mod named KoaCraft which adds

📎 1 file 4,124 chars
📄
pasted-code-1794765810079.txt
txt 98 lines
▶
KoaCraft — Master Feature List
1. Eucalyptus Forest
New Eucalyptus Forest biome.
Eucalyptus forests generate within 250 blocks of world spawn.
Eucalyptus trees are the dominant trees.
Eucalyptus Wood set, including logs, stripped logs, planks, stairs, slabs, doors and trapdoors.
Eucalyptus Leaves and Small Eucalyptus Leaves.
Eucalyptus Path and Leafed Eucalyptus Path.
Eucatite stone, bricks, tiles and chiseled pillar.
Eucalyptus Path naturally generates beneath trees and within 10 blocks of them.
Placing Eucalyptus Leaves above Eucalyptus Path transforms it into Leafed Eucalyptus Path.
Silk Touch collects Leafed Eucalyptus Path.
2. Koalas
Regular Koalas and Rainbow Koalas 
Adults are 1 block tall; babies are 0.5 blocks tall.
Babies use the normal Minecraft age system.
Climb eucalyptus trees, sleep in them and explore.
Forage by removing Eucalyptus Leaves and collecting Small Eucalyptus Leaves.
Both types eat normal Eucalyptus Leaves.
Rainbow Koalas can safely eat Rainbow Leaves.
Regular Koalas cannot eat Rainbow Leaves.
Tame regular koalas with Eucalyptus Leaves.
Tame Rainbow Koalas with Rainbow Leaves.
Breeding rules:
Regular + Regular = regular baby.
Rainbow + Rainbow = rainbow baby.
Regular + Rainbow = 50/50 regular or rainbow baby.
Advancement for a rainbow baby from mixed parents: REPOPULATING THE RULERS TRYBE.
Optional carrying feature: players can carry koalas, but cannot use items, mine, place blocks, sprint or interact with containers while carrying.
Koala spawn eggs with the agreed colours.
3. Rainbow Eucalyptus Tree
Rare natural world-generation feature.
Only generates in Eucalyptus Forest.
Rarity: 1 in 1,000 eligible tree-generation attempts.
Has Rainbow Leaves.
Eating Rainbow Leaves gives Poison to players.
Rainbow Koalas can eat them safely.
Bring 20 unique regular koalas to the tree.
Each koala counts only once.
Progress is saved, for example 7/20.
Completing the quest rewards a map or item leading to Rainbowroot Sanctuary.
4. Eucalyptus Village
Naturally generating villages.
Varied cozy cottages, not repetitive houses.
Eucatite Brick walls.
Stripped Eucalyptus Log corners.
Eucatite Tile foundations.
Eucalyptus Doors.
Unusual Eucalyptus Wood stairs for roofs.
Eucalyptus Trapdoor windows.
Eucalyptus Paths.
Special Eucalyptus Villagers.
Unemployed villagers and nitwits wear cowboy hats.
Employed villagers wear profession-specific clothes.
Same basic vanilla villager body, sounds and animations.
Koala Pet Shop: sells baby regular koalas and eucalyptus leaves, with a nursery.
Tour Guide: uses the village bell as a workstation, accepts emeralds and gives village tours.
Tour Guide does not reveal Rainbowroot Sanctuary.
Max-level Cartographer can sell a Sanctuary map.
5. Rainbowroot Sanctuary
Generation rarity: 1 in 5,000.
Contains the Rainbow Koala ruler.
Regular koalas are trapped inside.
Leaving them trapped causes the temple to punish the player.
Rescuing them makes them lead the player to the ruler.
Player receives an advancement.
Contains Rainbow Eucalyptus Armor, stronger than Netherite.
6. Legendary Tree Commands
/legendary_tree find — finds the Rainbow Eucalyptus Tree.
/legendary_tree find temple — finds Rainbowroot Sanctuary.
/legendary_tree find village — finds an Eucalyptus Village.
Requires cheats/permission level 2.
Displays coordinates and distance.
Coordinates are clickable.
Clicking teleports the player safely nearby, not inside the destination.
7. Extra content
Small Eucalyptus Leaves: 3 hunger points, 6 saturation.
Leaf drop chances:
No Fortune: 35%.
Fortune I: 40%.
Fortune II: 45%.
Fortune III: 50%.
Silk Touch: no Small Eucalyptus Leaf drop.
Silk Touch collects Eucalyptus Leaves blocks.
Recipes and loot tables.
Advancements.
Sounds and animations.
Optional JEI compatibility.
KoaCraft Backpack allows safe eating of Rainbow Leaves.
Custom textures bundled inside the mod.
8. Technical specifications
Setting Decision
Minecraft Java 1.21.11
Mod loader Fabric
Java 21
Mod name KoaCraft
Final format One .jar
Separate resource pack No
Kodari AI
KodariNov 15 at 6:28 pm 17
KoaCraft
Adds a Eucalyptus Forest biome near spawn with full wood sets, eucatite stone, and path blocks. Introduces tameable Koalas and Rainbow Koalas with breeding, foraging, and carrying mechanics. Features rare Rainbow Eucalyptus Trees with a 1/1000 generation chance and a 20-koala quest. Generates Eucalyptus Villages with special villagers including Koala Pet Shops and Tour Guides. Includes the rare Rainbowroot Sanctuary with a ruler, trapped koalas, and armor stronger than Netherite. Provides legendary tree commands for finding structures, advancements, custom recipes, loot tables, sounds, and a backpack item.
  1. Register the eucalyptus blocks/items, koala entity types, biome/world features, and survival loot/recipes.

  2. Implement tameable koalas, feeding/breeding rules, and the permission-gated destination-finding command.

  3. Add client rendering, generated content assets, and the mod metadata/resources.

KoaCraft’s Fabric 1.21.11 project scaffold and core content are in place, but this does not yet implement the full feature list.

Implemented: eucalyptus wood and Eucatite blocks, koala and rainbow-koala entities, taming and mixed breeding, spawn eggs, food and backpack-based poison immunity, leafed-path transformation, recipes and loot tables, a biome data file, and a permission-gated /legendary_tree command.

Still missing: natural Overworld biome placement, tree and village generation, Rainbowroot Sanctuary and its rescue quest, armor, advancement, and koala climbing/sleeping/foraging/carrying behaviors. The find command currently searches for the biome; find temple and find village report that those features aren’t generated. Koala animations, dedicated rainbow textures, and proper stair/door/slab visuals also remain unfinished.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
settings.gradle
Code
109 28,371
src/main/java/com/koacraft/KoaCraft.java
package com.koacraft;

import com.mojang.datafixers.util.Pair;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry;
import net.fabricmc.fabric.api.registry.StrippableBlockRegistry;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSetType;
import net.minecraft.block.BlockState;
import net.minecraft.block.DoorBlock;
import net.minecraft.block.PillarBlock;
import net.minecraft.block.SlabBlock;
import net.minecraft.block.StairsBlock;
import net.minecraft.block.TrapdoorBlock;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.component.type.FoodComponent;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroups;
import net.minecraft.item.SpawnEggItem;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.ClickEvent;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.biome.Biome;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.function.Function;

public class KoaCraft implements ModInitializer {
    public static final String MOD_ID = "koacraft";
    public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);

    public static final RegistryKey<Biome> EUCALYPTUS_BIOME_KEY = RegistryKey.of(
            RegistryKeys.BIOME,
            Identifier.of(MOD_ID, "koacraft/eucalyptus_forest")
    );

    public static final Block EUCALYPTUS_LOG = registerBlock("eucalyptus_log", settings -> new PillarBlock(settings.strength(2.0f)));
    public static final Block STRIPPED_EUCALYPTUS_LOG = registerBlock("stripped_eucalyptus_log", settings -> new PillarBlock(settings.strength(2.0f)));
    public static final Block EUCALYPTUS_PLANKS = registerBlock("eucalyptus_planks", settings -> new Block(settings.strength(2.0f)));
    public static final Block EUCALYPTUS_STAIRS = registerBlock("eucalyptus_stairs", settings -> new EucalyptusStairsBlock(EUCALYPTUS_PLANKS.getDefaultState(), settings.strength(2.0f)));
    public static final Block EUCALYPTUS_SLAB = registerBlock("eucalyptus_slab", settings -> new SlabBlock(settings.strength(2.0f)));
    public static final Block EUCALYPTUS_DOOR = registerBlock("eucalyptus_door", settings -> new EucalyptusDoorBlock(BlockSetType.OAK, settings.strength(2.0f)));
    public static final Block EUCALYPTUS_TRAPDOOR = registerBlock("eucalyptus_trapdoor", settings -> new EucalyptusTrapdoorBlock(BlockSetType.OAK, settings.strength(2.0f)));
    public static final Block EUCALYPTUS_LEAVES = registerBlock("eucalyptus_leaves", settings -> new EucalyptusLeavesBlock(settings.nonOpaque().strength(0.2f)));
    public static final Block EUCALYPTUS_PATH = registerBlock("eucalyptus_path", settings -> new Block(settings.strength(0.5f)));
    public static final Block LEAFED_EUCALYPTUS_PATH = registerBlock("leafed_eucalyptus_path", settings -> new Block(settings.strength(0.5f)));
    public static final Block EUCATITE = registerBlock("eucatite", settings -> new Block(settings.strength(3.0f, 6.0f).requiresTool()));
    public static final Block EUCATITE_BRICKS = registerBlock("eucatite_bricks", settings -> new Block(settings.strength(3.0f, 6.0f).requiresTool()));
    public static final Block EUCATITE_TILES = registerBlock("eucatite_tiles", settings -> new Block(settings.strength(3.0f, 6.0f).requiresTool()));
    public static final Block CHISELED_EUCATITE_PILLAR = registerBlock("chiseled_eucatite_pillar", settings -> new PillarBlock(settings.strength(3.0f, 6.0f).requiresTool()));
    public static final Block RAINBOW_LEAVES = registerBlock("rainbow_leaves", settings -> new Block(settings.nonOpaque().strength(0.2f)));

    public static final Item EUCALYPTUS_LEAF = registerItem("eucalyptus_leaf", settings -> new Item(settings.food(food(1, 0.2f))));
    public static final Item SMALL_EUCALYPTUS_LEAVES = registerItem("small_eucalyptus_leaves", settings -> new Item(settings.food(food(3, 1.0f))));
    public static final Item RAINBOW_LEAF = registerItem("rainbow_leaf", RainbowLeavesItem::new);
    public static final Item KOA_BACKPACK = registerItem("koa_backpack", settings -> new Item(settings.maxCount(1)));

    public static final EntityType<KoalaEntity> KOALA = registerKoala("koala", false);
    public static final EntityType<KoalaEntity> RAINBOW_KOALA = registerKoala("rainbow_koala", true);
    public static final Item KOALA_SPAWN_EGG = registerItem("koala_spawn_egg", settings -> new SpawnEggItem(settings.spawnEgg(KOALA)));
    public static final Item RAINBOW_KOALA_SPAWN_EGG = registerItem("rainbow_koala_spawn_egg", settings -> new SpawnEggItem(settings.spawnEgg(RAINBOW_KOALA)));

    @Override
    public void onInitialize() {
        StrippableBlockRegistry.register(EUCALYPTUS_LOG, STRIPPED_EUCALYPTUS_LOG);
        BiomeModifications.addSpawn(
                BiomeSelectors.includeByKey(EUCALYPTUS_BIOME_KEY),
                SpawnGroup.CREATURE,
                KOALA,
                10,
                1,
                3
        );
        BiomeModifications.addSpawn(
                BiomeSelectors.includeByKey(EUCALYPTUS_BIOME_KEY),
                SpawnGroup.CREATURE,
                RAINBOW_KOALA,
                1,
                1,
                2
        );
        ItemGroupEvents.MODIFY_ENTRIES_ALL.register((group, entries) -> {
            if (group == ItemGroups.getDefaultTab()) {
                entries.add(EUCALYPTUS_LOG);
                entries.add(STRIPPED_EUCALYPTUS_LOG);
                entries.add(EUCALYPTUS_PLANKS);
                entries.add(EUCALYPTUS_STAIRS);
                entries.add(EUCALYPTUS_SLAB);
                entries.add(EUCALYPTUS_DOOR);
                entries.add(EUCALYPTUS_TRAPDOOR);
                entries.add(EUCALYPTUS_LEAVES);
                entries.add(EUCALYPTUS_PATH);
                entries.add(LEAFED_EUCALYPTUS_PATH);
                entries.add(EUCATITE);
                entries.add(EUCATITE_BRICKS);
                entries.add(EUCATITE_TILES);
                entries.add(CHISELED_EUCATITE_PILLAR);
                entries.add(RAINBOW_LEAVES);
                entries.add(EUCALYPTUS_LEAF);
                entries.add(SMALL_EUCALYPTUS_LEAVES);
                entries.add(RAINBOW_LEAF);
                entries.add(KOA_BACKPACK);
                entries.add(KOALA_SPAWN_EGG);
                entries.add(RAINBOW_KOALA_SPAWN_EGG);
            }
        });
        registerCommands();
    }

    private static void registerCommands() {
        CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> dispatcher.register(
                CommandManager.literal("legendary_tree")
                        .requires(CommandManager.requirePermissionLevel(CommandManager.GAMEMASTERS_CHECK))
                        .then(CommandManager.literal("find")
                                .executes(context -> findEucalyptusBiome(context.getSource()))
                                .then(CommandManager.literal("temple").executes(context -> unavailable(context.getSource(), "Rainbowroot Sanctuary")))
                                .then(CommandManager.literal("village").executes(context -> unavailable(context.getSource(), "Eucalyptus Village"))))
        ));
    }

    private static int findEucalyptusBiome(ServerCommandSource source) throws CommandSyntaxException {
        var player = source.getPlayerOrThrow();
        ServerWorld world = source.getWorld();
        Pair<BlockPos, net.minecraft.registry.entry.RegistryEntry<Biome>> result = world.locateBiome(
                biome -> biome.matchesKey(EUCALYPTUS_BIOME_KEY),
                player.getBlockPos(),
                6400,
                32,
                64
        );
        if (result == null) {
            source.sendFeedback(() -> Text.literal("No Eucalyptus Forest was found nearby."), false);
            return 0;
        }
        BlockPos pos = result.getFirst();
        int x = pos.getX();
        int y = pos.getY();
        int z = pos.getZ();
        Text coordinates = Text.literal("[" + x + ", " + y + ", " + z + "]")
                .styled(style -> style.withClickEvent(new ClickEvent.RunCommand("/spreadplayers " + (x + 8) + " " + (z + 8) + " 0 5 false @s")));
        source.sendFeedback(() -> Text.literal("Nearest Eucalyptus Forest: ").append(coordinates), false);
        return 1;
    }

    private static int unavailable(ServerCommandSource source, String destination) {
        source.sendFeedback(() -> Text.literal(destination + " generation is not available yet."), false);
        return 0;
    }

    private static FoodComponent food(int nutrition, float saturation) {
        return new FoodComponent.Builder().nutrition(nutrition).saturationModifier(saturation).build();
    }

    private static Block registerBlock(String path, Function<AbstractBlock.Settings, Block> factory) {
        Identifier id = Identifier.of(MOD_ID, path);
        RegistryKey<Block> blockKey = RegistryKey.of(RegistryKeys.BLOCK, id);
        Block block = Registry.register(Registries.BLOCK, blockKey, factory.apply(AbstractBlock.Settings.create().registryKey(blockKey)));
        RegistryKey<Item> itemKey = RegistryKey.of(RegistryKeys.ITEM, id);
        Registry.register(Registries.ITEM, itemKey, new BlockItem(block, new Item.Settings().registryKey(itemKey)));
        return block;
    }

    private static Item registerItem(String path, Function<Item.Settings, Item> factory) {
        Identifier id = Identifier.of(MOD_ID, path);
        RegistryKey<Item> itemKey = RegistryKey.of(RegistryKeys.ITEM, id);
        return Registry.register(Registries.ITEM, itemKey, factory.apply(new Item.Settings().registryKey(itemKey)));
    }

    private static EntityType<KoalaEntity> registerKoala(String path, boolean rainbow) {
        Identifier id = Identifier.of(MOD_ID, path);
        RegistryKey<EntityType<?>> entityKey = RegistryKey.of(RegistryKeys.ENTITY_TYPE, id);
        EntityType<KoalaEntity> type = EntityType.Builder.<KoalaEntity>create(
                        (entityType, world) -> new KoalaEntity(entityType, world, rainbow),
                        SpawnGroup.CREATURE
                )
                .dimensions(0.7f, 1.0f)
                .build(entityKey);
        Registry.register(Registries.ENTITY_TYPE, entityKey, type);
        FabricDefaultAttributeRegistry.register(type, KoalaEntity.createAttributes());
        return type;
    }

    private static final class EucalyptusStairsBlock extends StairsBlock {