lyan_yt

Can you turn it into a plugin and fix the tr generation?

Kodari AI
KodariAug 27 at 4:01 pm 2
  1. Convert the existing project into a loadable Minecraft plugin.

  2. Trace and fix the TR generation path, then verify its registrations/configuration.

  1. Converted the datapack into a Paper plugin:

    • Added build.gradle

    • Added SoulDimensionPlugin entrypoint

    • Added plugin.yml

    • Added pack.mcmeta

    • Bundled and automatically installs/reloads the datapack into the first loaded world

  2. Fixed terrain generation:

    • Removed the invalid axis: "y" property from minecraft:deepslate

    • deepslate now uses a valid block state

The plugin resources are now under src/main/resources/data/souldimension/.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
7 364
src/main/java/com/kodari/souldimension/SoulDimensionPlugin.java
package com.kodari.souldimension;

import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;

public final class SoulDimensionPlugin extends JavaPlugin {
    private static final List<String> DATAPACK_RESOURCES = List.of(
            "data/souldimension/dimension/sculk_cave.json",
            "data/souldimension/dimension_type/sculk_cave.json",
            "data/souldimension/worldgen/noise_settings/sculk_cave.json"
    );

    @Override
    public void onEnable() {
        try {
            installDatapack();
            Bukkit.reloadData();
            getLogger().info("Soul Dimension datapack loaded.");
        } catch (IOException exception) {
            getLogger().severe("Unable to install the Soul Dimension datapack: " + exception.getMessage());
            getServer().getPluginManager().disablePlugin(this);
        }
    }

    private void installDatapack() throws IOException {
        if (Bukkit.getWorlds().isEmpty()) {
            throw new IOException("No world is loaded");
        }

        World world = Bukkit.getWorlds().get(0);
        Path datapackRoot = new File(world.getWorldFolder(), "datapacks/souldimension").toPath();
        copyResource("pack.mcmeta", datapackRoot.resolve("pack.mcmeta"));
        for (String resource : DATAPACK_RESOURCES) {
            copyResource(resource, datapackRoot.resolve(resource));
        }
    }

    private void copyResource(String resource, Path target) throws IOException {
        try (InputStream input = getResource(resource)) {
            if (input == null) {
                throw new IOException("Missing bundled resource " + resource);
            }

            Files.createDirectories(target.getParent());
            Files.copy(input, target, java.nio.file.StandardCopyOption.REPLACE_EXISTING);
        }
    }
}