TelepathicGrunt / StructureTutorialMod

A short example showing how to register a structure and get it to generate in all biomes in NeoForge, Forge, and Fabric! (check the branches)
MIT License
264 stars 29 forks source link

World Generation Crash/Freeze #12

Closed ni-cky closed 3 years ago

ni-cky commented 3 years ago

Hi! I used the tutorial to become familiar with 1.17 world generation but ran into an issue.

I have mostly just inserted the Tutorial files into my own project to get a grasp onto them and down the line make changes to the code to implement my own features.

Minecraft does start, but if I open a world the following Exception gets thrown and the progress freezes at 4%, dead locking the game.

Advice and help would be appreciated! Exception:

[22:00:39] [IO-Worker-11/WARN] (FileUtil) Configuration conflict: there is more than one oshi.architecture.properties file on the classpath
[22:00:39] [IO-Worker-11/WARN] (Minecraft) Failed to read chunk [9, 3]
net.minecraft.util.crash.CrashException: Loading NBT data
    at net.minecraft.nbt.NbtCompound.read(NbtCompound.java:407) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound$1.read(NbtCompound.java:459) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound$1.read(NbtCompound.java:476) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound.read(NbtCompound.java:401) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound$1.read(NbtCompound.java:459) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound$1.read(NbtCompound.java:476) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound.read(NbtCompound.java:401) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound$1.read(NbtCompound.java:459) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound$1.read(NbtCompound.java:476) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtIo.read(NbtIo.java:203) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtIo.read(NbtIo.java:175) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtIo.read(NbtIo.java:171) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.world.storage.RegionBasedStorage.getTagAt(RegionBasedStorage.java:65) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.world.storage.StorageIoWorker.method_27943(StorageIoWorker.java:69) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.world.storage.StorageIoWorker.method_27939(StorageIoWorker.java:108) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.util.thread.TaskQueue$PrioritizedTask.run(TaskQueue.java:80) [minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.util.thread.TaskExecutor.runNext(TaskExecutor.java:84) [minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.util.thread.TaskExecutor.runWhile(TaskExecutor.java:139) [minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.util.thread.TaskExecutor.run(TaskExecutor.java:92) [minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) [?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) [?:?]
    at java.lang.Thread.run(Thread.java:831) [?:?]
Caused by: java.io.EOFException
    at java.io.DataInputStream.readUnsignedShort(DataInputStream.java:346) ~[?:?]
    at java.io.DataInputStream.readUTF(DataInputStream.java:595) ~[?:?]
    at java.io.DataInputStream.readUTF(DataInputStream.java:570) ~[?:?]
    at net.minecraft.nbt.NbtCompound.readString(NbtCompound.java:396) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound$1.read(NbtCompound.java:457) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound$1.read(NbtCompound.java:476) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound.read(NbtCompound.java:401) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    ... 21 more
[22:00:39] [Server thread/ERROR] (Minecraft) Couldn't load chunk [9, 3]
java.util.concurrent.CompletionException: net.minecraft.util.crash.CrashException: Loading NBT data
    at java.util.concurrent.CompletableFuture.reportJoin(CompletableFuture.java:412) ~[?:?]
    at java.util.concurrent.CompletableFuture.join(CompletableFuture.java:2114) ~[?:?]
    at net.minecraft.world.storage.StorageIoWorker.getNbt(StorageIoWorker.java:52) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.world.storage.VersionedChunkStorage.getNbt(VersionedChunkStorage.java:57) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.server.world.ThreadedAnvilChunkStorage.getUpdatedChunkNbt(ThreadedAnvilChunkStorage.java:814) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.server.world.ThreadedAnvilChunkStorage.method_17256(ThreadedAnvilChunkStorage.java:490) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1764) ~[?:?]
    at net.minecraft.util.thread.ThreadExecutor.executeTask(ThreadExecutor.java:137) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.server.world.ServerChunkManager$MainThreadExecutor.executeTask(ServerChunkManager.java:519) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.util.thread.ThreadExecutor.runTask(ThreadExecutor.java:110) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.server.world.ServerChunkManager$MainThreadExecutor.runTask(ServerChunkManager.java:527) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.server.world.ServerChunkManager.executeQueuedTasks(ServerChunkManager.java:273) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.server.MinecraftServer.runOneTask(MinecraftServer.java:832) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.server.MinecraftServer.runTask(MinecraftServer.java:818) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.util.thread.ThreadExecutor.runTasks(ThreadExecutor.java:120) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.server.MinecraftServer.runTasksTillTickEnd(MinecraftServer.java:804) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.server.MinecraftServer.prepareStartRegion(MinecraftServer.java:544) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:379) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.server.integrated.IntegratedServer.setupServer(IntegratedServer.java:67) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:728) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:272) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at java.lang.Thread.run(Thread.java:831) [?:?]
Caused by: net.minecraft.util.crash.CrashException: Loading NBT data
    at net.minecraft.nbt.NbtCompound.read(NbtCompound.java:407) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound$1.read(NbtCompound.java:459) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound$1.read(NbtCompound.java:476) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound.read(NbtCompound.java:401) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound$1.read(NbtCompound.java:459) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound$1.read(NbtCompound.java:476) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound.read(NbtCompound.java:401) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound$1.read(NbtCompound.java:459) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound$1.read(NbtCompound.java:476) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtIo.read(NbtIo.java:203) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtIo.read(NbtIo.java:175) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtIo.read(NbtIo.java:171) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.world.storage.RegionBasedStorage.getTagAt(RegionBasedStorage.java:65) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.world.storage.StorageIoWorker.method_27943(StorageIoWorker.java:69) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.world.storage.StorageIoWorker.method_27939(StorageIoWorker.java:108) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.util.thread.TaskQueue$PrioritizedTask.run(TaskQueue.java:80) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.util.thread.TaskExecutor.runNext(TaskExecutor.java:84) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.util.thread.TaskExecutor.runWhile(TaskExecutor.java:139) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.util.thread.TaskExecutor.run(TaskExecutor.java:92) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) ~[?:?]
    ... 1 more
Caused by: java.io.EOFException
    at java.io.DataInputStream.readUnsignedShort(DataInputStream.java:346) ~[?:?]
    at java.io.DataInputStream.readUTF(DataInputStream.java:595) ~[?:?]
    at java.io.DataInputStream.readUTF(DataInputStream.java:570) ~[?:?]
    at net.minecraft.nbt.NbtCompound.readString(NbtCompound.java:396) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound$1.read(NbtCompound.java:457) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound$1.read(NbtCompound.java:476) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound.read(NbtCompound.java:401) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound$1.read(NbtCompound.java:459) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound$1.read(NbtCompound.java:476) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound.read(NbtCompound.java:401) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound$1.read(NbtCompound.java:459) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound$1.read(NbtCompound.java:476) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound.read(NbtCompound.java:401) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound$1.read(NbtCompound.java:459) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtCompound$1.read(NbtCompound.java:476) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtIo.read(NbtIo.java:203) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtIo.read(NbtIo.java:175) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.nbt.NbtIo.read(NbtIo.java:171) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.world.storage.RegionBasedStorage.getTagAt(RegionBasedStorage.java:65) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.world.storage.StorageIoWorker.method_27943(StorageIoWorker.java:69) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.world.storage.StorageIoWorker.method_27939(StorageIoWorker.java:108) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.util.thread.TaskQueue$PrioritizedTask.run(TaskQueue.java:80) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.util.thread.TaskExecutor.runNext(TaskExecutor.java:84) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.util.thread.TaskExecutor.runWhile(TaskExecutor.java:139) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at net.minecraft.util.thread.TaskExecutor.run(TaskExecutor.java:92) ~[minecraft-1.17.1-project-@-mapped-net.fabricmc.yarn-1.17.1+build.31-v2.jar:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) ~[?:?]
    ... 1 more

Central classes/files from the repository with minor changes:

package com.nicky.grisha.structure_tutorial;

import com.nicky.grisha.structure_tutorial.mixin.StructuresConfigAccessor;
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.biome.v1.ModificationPhase;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Identifier;
import net.minecraft.world.gen.chunk.StructureConfig;
import net.minecraft.world.gen.feature.StructureFeature;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.HashMap;
import java.util.Map;

public class StructureTutorialMain implements ModInitializer {

    public static final Logger LOGGER = LogManager.getLogger();
    public static final String MODID = "grisha";

    @Override
    @SuppressWarnings("deprecation")
    public void onInitialize() {

        /*
         * We setup and register our structures here.
         * You should always register your stuff to prevent mod compatibility issue down the line.
         */
        STStructures.setupAndRegisterStructureFeatures();
        STConfiguredStructures.registerConfiguredStructures();

        /*
         * This is the API you will use to add anything to any biome.
         * This includes spawns, changing the biome's looks, messing with its surfacebuilders,
         * adding carvers, spawning new features... etc
         *
         * Make sure you give this an identifier to make it clear later what mod did a change and why.
         * It'll help people look to see if your mod was removing something from biomes.
         * The biome modifier identifier might also be used by modpacks to disable mod's modifiers too for customization.
         */
        BiomeModifications.create(new Identifier(MODID, "run_down_house_addition"))
                .add(   // Describes what we are doing. SInce we are adding a structure, we choose ADDITIONS.
                        ModificationPhase.ADDITIONS,

                        // Add our structure to all biomes including other modded biomes.
                        // You can filter to certain biomes based on stuff like temperature, scale, precipitation, mod id.
                        BiomeSelectors.all(),

                        // context is basically the biome itself. This is where you do the changes to the biome.
                        // Here, we will add our ConfiguredStructureFeature to the biome.
                        context -> {
                            context.getGenerationSettings().addBuiltInStructure(STConfiguredStructures.CONFIGURED_RUN_DOWN_HOUSE);
                        });
    }

    // This is optional and can be used for blacklisting the structure from dimensions.
    // These two are for making sure our ServerWorldEvents.LOAD event always fires after Fabric API's usage of the same event.
    // This is done so our changes don't get overwritten by Fabric API adding structure spacings to all dimensions.
    // To activate these methods, make this class implement this:
    //    `implements ModInitializer, DedicatedServerModInitializer, ClientModInitializer {`
    // And then go to fabric.mod.json and add this class to a "client" and "server" entry within "entrypoints" section.

//    @Override
//    public void onInitializeServer() {
//        removeStructureSpawningFromSelectedDimension();
//    }
//
//    @Override
//    public void onInitializeClient() {
//        removeStructureSpawningFromSelectedDimension();
//    }

    /**
     * || OPTIONAL ||
     *  This is optional as Fabric API already adds your structure to all dimension.
     *  But if you want to do dimension based blacklisting, you will need to both
     *  manually remove your structure from the chunkgenerator's structure spacing map.
     * If the spacing or our structure is not added, the structure doesn't spawn in that dimension.
     */
    public static void removeStructureSpawningFromSelectedDimension() {
        // Controls the dimension blacklisting
        ServerWorldEvents.LOAD.register((MinecraftServer minecraftServer, ServerWorld serverWorld)->{

            // Need temp map as some mods use custom chunk generators with immutable maps in themselves.
            Map<StructureFeature<?>, StructureConfig> tempMap = new HashMap<>(serverWorld.getChunkManager().getChunkGenerator().getStructuresConfig().getStructures());

            // Make absolutely sure modded dimension cannot spawn our structures.
            // New dimensions under the minecraft namespace will still get it (datapacks might do this)
            if(!serverWorld.getRegistryKey().getValue().getNamespace().equals("minecraft")) {
                tempMap.keySet().remove(STStructures.RUN_DOWN_HOUSE);
            }

            // Set the new modified map of structure spacing to the dimension's chunkgenerator.
            ((StructuresConfigAccessor)serverWorld.getChunkManager().getChunkGenerator().getStructuresConfig()).setStructures(tempMap);
        });
    }
}
package com.nicky.TestStructure.structures;

import com.mojang.serialization.Codec;
import com.nicky.grisha.structure_tutorial.StructureTutorialMain;
import net.minecraft.block.BlockState;
import net.minecraft.entity.EntityType;
import net.minecraft.structure.MarginedStructureStart;
import net.minecraft.structure.PoolStructurePiece;
import net.minecraft.structure.StructureManager;
import net.minecraft.structure.StructurePiece;
import net.minecraft.structure.pool.StructurePoolBasedGenerator;
import net.minecraft.util.Identifier;
import net.minecraft.util.collection.Pool;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.Vec3i;
import net.minecraft.util.registry.DynamicRegistryManager;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.HeightLimitView;
import net.minecraft.world.Heightmap;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.SpawnSettings;
import net.minecraft.world.biome.source.BiomeSource;
import net.minecraft.world.gen.ChunkRandom;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.chunk.VerticalBlockSample;
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
import net.minecraft.world.gen.feature.StructureFeature;
import net.minecraft.world.gen.feature.StructurePoolFeatureConfig;
import org.apache.logging.log4j.Level;

public class RunDownHouseStructure extends StructureFeature<DefaultFeatureConfig> {
    public RunDownHouseStructure(Codec<DefaultFeatureConfig> codec) {
        super(codec);
    }

    /**
     * This is how the worldgen code knows what to call when it
     * is time to create the pieces of the structure for generation.
     */
    @Override
    public StructureStartFactory<DefaultFeatureConfig> getStructureStartFactory() {
        return RunDownHouseStructure.Start::new;
    }

    /**
     * This method allows us to have mobs that spawn naturally over time in our structure.
     * No other mobs will spawn in the structure of the same entity classification.
     * The reason you want to match the classifications is so that your structure's mob
     * will contribute to that classification's cap. Otherwise, it may cause a runaway
     * spawning of the mob that will never stop.
     *
     * NOTE: getDefaultSpawnList is for monsters only and getDefaultCreatureSpawnList is
     *       for creatures only. If you want to add entities of another classification,
     *       use the StructureSpawnListGatherEvent to add water_creatures, water_ambient,
     *       ambient, or misc mobs. Use that event to add/remove mobs from structures
     *       that are not your own.
     */
    private static final Pool<SpawnSettings.SpawnEntry> STRUCTURE_MONSTERS = Pool.of(
            new SpawnSettings.SpawnEntry(EntityType.ILLUSIONER, 100, 4, 9),
            new SpawnSettings.SpawnEntry(EntityType.VINDICATOR, 100, 4, 9)
    );
    @Override
    public Pool<SpawnSettings.SpawnEntry> getMonsterSpawns() {
        return STRUCTURE_MONSTERS;
    }

    private static final Pool<SpawnSettings.SpawnEntry> STRUCTURE_CREATURES = Pool.of(
            new SpawnSettings.SpawnEntry(EntityType.SHEEP, 30, 10, 15),
            new SpawnSettings.SpawnEntry(EntityType.RABBIT, 100, 1, 2)
    );
    @Override
    public Pool<SpawnSettings.SpawnEntry> getCreatureSpawns() {
        return STRUCTURE_CREATURES;
    }

    /*
     * This is where extra checks can be done to determine if the structure can spawn here.
     * This only needs to be overridden if you're adding additional spawn conditions.
     *
     * Fun fact, if you set your structure separation/spacing to be 0/1, you can use
     * shouldStartAt to return true only if certain chunk coordinates are passed in
     * which allows you to spawn structures only at certain coordinates in the world.
     *
     * Notice how the biome is also passed in. Though, you are not going to do any biome
     * checking here as you should've added this structure to the biomes you
     * wanted already with the biome load event.
     * 
     * Basically, this method is used for determining if the land is at a suitable height,
     * if certain other structures are too close or not, or some other restrictive condition.
     *
     * For example, Pillager Outposts added a check to make sure it cannot spawn within 10 chunk of a Village.
     * (Bedrock Edition seems to not have the same check)
     * 
     * 
     * Also, please for the love of god, do not do dimension checking here.
     * If you do and another mod's dimension is trying to spawn your structure,
     * the locate command will make minecraft hang forever and break the game.
     *
     * Instead, use the removeStructureSpawningFromSelectedDimension method in
     * StructureTutorialMain class. If you check for the dimension there and do not add your
     * structure's spacing into the chunk generator, the structure will not spawn in that dimension!
     */
    @Override
    protected boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long seed, ChunkRandom chunkRandom, ChunkPos chunkPos, Biome biome, ChunkPos chunkPos2, DefaultFeatureConfig featureConfig, HeightLimitView heightLimitView) {
        BlockPos centerOfChunk = new BlockPos(chunkPos.x * 16, 0, chunkPos.z * 16);

        // Grab height of land. Will stop at first non-air block.
        int landHeight = chunkGenerator.getHeightInGround(centerOfChunk.getX(), centerOfChunk.getZ(), Heightmap.Type.WORLD_SURFACE_WG, heightLimitView);

        // Grabs column of blocks at given position. In overworld, this column will be made of stone, water, and air.
        // In nether, it will be netherrack, lava, and air. End will only be endstone and air. It depends on what block
        // the chunk generator will place for that dimension.
        VerticalBlockSample columnOfBlocks = chunkGenerator.getColumnSample(centerOfChunk.getX(), centerOfChunk.getZ(), heightLimitView);

        // Combine the column of blocks with land height and you get the top block itself which you can test.
        BlockState topBlock = columnOfBlocks.getState(centerOfChunk.up(landHeight));

        // Now we test to make sure our structure is not spawning on water or other fluids.
        // You can do height check instead too to make it spawn at high elevations.
        return topBlock.getFluidState().isEmpty(); //landHeight > 100;
    }

    /**
     * Handles calling up the structure's pieces class and height that structure will spawn at.
     */
    public static class Start extends MarginedStructureStart<DefaultFeatureConfig> {
        public Start(StructureFeature<DefaultFeatureConfig> structureIn, ChunkPos chunkPos, int referenceIn, long seedIn) {
            super(structureIn, chunkPos, referenceIn, seedIn);
        }

        @Override
        public void init(DynamicRegistryManager dynamicRegistryManager, ChunkGenerator chunkGenerator, StructureManager structureManager, ChunkPos chunkPos, Biome biome, DefaultFeatureConfig defaultFeatureConfig, HeightLimitView heightLimitView) {

            // Turns the chunk coordinates into actual coordinates we can use. (Gets center of that chunk)
            int x = chunkPos.x * 16;
            int z = chunkPos.z * 16;

            /*
             * We pass this into method_30419 to tell it where to generate the structure.
             * If method_30419's last parameter is true, blockpos's Y value is ignored and the
             * structure will spawn at terrain height instead. Set that parameter to false to
             * force the structure to spawn at blockpos's Y value instead. You got options here!
             */
            BlockPos.Mutable centerPos = new BlockPos.Mutable(x, 0, z);

            /*
             * If you are doing Nether structures, you'll probably want to spawn your structure on top of ledges.
             * Best way to do that is to use getColumnSample to grab a column of blocks at the structure's x/z position.
             * Then loop through it and look for land with air above it and set blockpos's Y value to it.
             * Make sure to set the final boolean in StructurePoolBasedGenerator.method_30419 to false so
             * that the structure spawns at blockpos's y value instead of placing the structure on the Bedrock roof!
             */
            //VerticalBlockSample blockView = chunkGenerator.getColumnSample(blockpos.getX(), blockpos.getZ(), heightLimitView);

            StructurePoolFeatureConfig structureSettingsAndStartPool = new StructurePoolFeatureConfig(() -> dynamicRegistryManager.get(Registry.STRUCTURE_POOL_KEY)
                    // The path to the starting Template Pool JSON file to read.
                    //
                    // Note, this is "structure_tutorial:run_down_house/start_pool" which means
                    // the game will automatically look into the following path for the template pool:
                    // "resources/data/structure_tutorial/worldgen/template_pool/run_down_house/start_pool.json"
                    // This is why your pool files must be in "data/<modid>/worldgen/template_pool/<the path to the pool here>"
                    // because the game automatically will check in worldgen/template_pool for the pools.
                    .get(new Identifier(StructureTutorialMain.MODID, "run_down_house/start_pool")),

                    // How many pieces outward from center can a recursive jigsaw structure spawn.
                    // Our structure is only 1 piece outward and isn't recursive so any value of 1 or more doesn't change anything.
                    // However, I recommend you keep this a decent value like 10 so people can use datapacks to add additional pieces to your structure easily.
                    // But don't make it too large for recursive structures like villages or you'll crash server due to hundreds of pieces attempting to generate!
                    10);

            // All a structure has to do is call this method to turn it into a jigsaw based structure!
            StructurePoolBasedGenerator.generate(
                    dynamicRegistryManager,
                    structureSettingsAndStartPool,
                    PoolStructurePiece::new,
                    chunkGenerator,
                    structureManager,
                    centerPos, // Position of the structure. Y value is ignored if last parameter is set to true.
                    this, // The class instance that holds the list that will be populated with the jigsaw pieces after this method.
                    this.random,
                    false, // Special boundary adjustments for villages. It's... hard to explain. Keep this false and make your pieces not be partially intersecting.
                           // Either not intersecting or fully contained will make children pieces spawn just fine. It's easier that way.
                    true, // Place at heightmap (top land). Set this to false for structure to be place at the passed in blockpos's Y value instead.
                           // Definitely keep this false when placing structures in the nether as otherwise, heightmap placing will put the structure on the Bedrock roof.
                    heightLimitView);
            // **THE FOLLOWING TWO LINES ARE OPTIONAL**
            //
            // Right here, you can do interesting stuff with the pieces in this.children such as offset the
            // center piece by 50 blocks up for no reason, remove repeats of a piece or add a new piece so
            // only 1 of that piece exists, etc. But you do not have access to the piece's blocks as this list
            // holds just the piece's size and positions. Blocks will be placed later in StructurePoolBasedGenerator.
            //
            // In this case, we do `piece.translate` to raise pieces up by 1 block so that the house is not right on
            // the surface of water or sunken into land a bit.
            //
            // Then we move the bounding box down by 1 by doing `piece.getBoundingBox().move` which will cause the
            // land formed around the structure to be lowered and not cover the doorstep. You can raise the bounding
            // box to force the structure to be buried as well. This bounding box stuff with land is only for structures
            // that you added to Structure.JIGSAW_STRUCTURES field handles adding land around the base of structures.
            //
            // By lifting the house up by 1 and lowering the bounding box, the land at bottom of house will now be
            // flush with the surrounding terrain without blocking off the doorstep.
            this.children.forEach(piece -> piece.translate(0, 1, 0));
            this.children.forEach(piece -> piece.getBoundingBox().move(0, -1, 0));

            // Since by default, the start piece of a structure spawns with it's corner at centerPos
            // and will randomly rotate around that corner, we will center the piece on centerPos instead.
            // This is so that our structure's start piece is now centered on the water check done in shouldStartAt.
            // Whatever the offset done to center the start piece, that offset is applied to all other pieces
            // so the entire structure is shifted properly to the new spot.
            Vec3i structureCenter = this.children.get(0).getBoundingBox().getCenter();
            int xOffset = centerPos.getX() - structureCenter.getX();
            int zOffset = centerPos.getZ() - structureCenter.getZ();
            for(StructurePiece structurePiece : this.children){
                structurePiece.translate(xOffset, 0, zOffset);
            }

            // Sets the bounds of the structure once you are finished.
            this.setBoundingBoxFromChildren();

            // I use to debug and quickly find out if the structure is spawning or not and where it is.
            // This is returning the coordinates of the center starting piece.
            StructureTutorialMain.LOGGER.log(Level.DEBUG, "Rundown House at " +
                    this.children.get(0).getBoundingBox().getMinX() + " " +
                    this.children.get(0).getBoundingBox().getMinY() + " " +
                    this.children.get(0).getBoundingBox().getMinZ());
        }

    }
}
{
  "required": true,
  "minVersion": "0.8",
  "package": "com.nicky.grisha.structure_tutorial.mixin",
  "compatibilityLevel": "JAVA_16",
  "mixins": [
    "NoiseChunkGeneratorMixin",
    "StructuresConfigAccessor"
  ],
  "client": [
  ],
  "injectors": {
    "defaultRequire": 1
  }
}
package com.nicky.grisha.structure_tutorial;

import com.nicky.TestStructure.structures.RunDownHouseStructure;
import net.fabricmc.fabric.api.structure.v1.FabricStructureBuilder;
import net.minecraft.util.Identifier;
import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.chunk.StructureConfig;
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
import net.minecraft.world.gen.feature.FeatureConfig;
import net.minecraft.world.gen.feature.StructureFeature;

public class STStructures {

    /**
    /**
     * Registers the structure itself and sets what its path is. In this case, the
     * structure will have the Identifier of structure_tutorial:run_down_house.
     *
     * It is always a good idea to register your Structures so that other mods and datapacks can
     * use them too directly from the registries. It great for mod/datapacks compatibility.
     */
    public static StructureFeature<DefaultFeatureConfig> RUN_DOWN_HOUSE = new RunDownHouseStructure(DefaultFeatureConfig.CODEC);

    /**
     * This is where we use Fabric API's structure API to setup the StructureFeature
     * See the comments in below for more details.
     */
    public static void setupAndRegisterStructureFeatures() {

        // This is Fabric API's builder for structures.
        // It has many options to make sure your structure will spawn and work properly.
        // Give it your structure and the identifier you want for it.
        FabricStructureBuilder.create(new Identifier(StructureTutorialMain.MODID, "run_down_house"), RUN_DOWN_HOUSE)

                /* Generation stage for when to generate the structure. there are 10 stages you can pick from!
                   This surface structure stage places the structure before plants and ores are generated. */
                .step(GenerationStep.Feature.SURFACE_STRUCTURES)

                .defaultConfig(new StructureConfig(
                        10, /* average distance apart in chunks between spawn attempts */
                        5, /* minimum distance apart in chunks between spawn attempts. MUST BE LESS THAN ABOVE VALUE */
                        399117345 /* this modifies the seed of the structure so no two structures always spawn over each-other. Make this large and unique. */))

                /* Always set this or else re-entering SuperFlat worldtype will crash.
                   Getting structures to spawn in Superflat is a bit buggy right now so don't focus too much on this. */
                .superflatFeature(RUN_DOWN_HOUSE.configure(FeatureConfig.DEFAULT))

                /*
                 * Whether surrounding land will be modified automatically to conform to the bottom of the structure.
                 * Basically, it adds land at the base of the structure like it does for Villages and Outposts.
                 * Doesn't work well on structure that have pieces stacked vertically or change in heights.
                 *
                 * Note: The air space this method will create will be filled with water if the structure is below sealevel.
                 * This means this is best for structure above sealevel so keep that in mind.
                 */
                .adjustsSurface()

                /* Finally! Now we register our structure and everything above will take effect. */
                .register();

        // Add more structures here and so on
    }
}
package com.nicky.grisha.structure_tutorial;

import net.minecraft.util.Identifier;
import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.gen.feature.ConfiguredStructureFeature;
import net.minecraft.world.gen.feature.DefaultFeatureConfig;

public class STConfiguredStructures {
    /**
     * Static instance of our configured structure so we can reference it and add it to biomes easily.
     */
    public static ConfiguredStructureFeature<?, ?> CONFIGURED_RUN_DOWN_HOUSE = STStructures.RUN_DOWN_HOUSE.configure(DefaultFeatureConfig.DEFAULT);

    /**
     * Registers the configured structure which is what gets added to the biomes.
     * You can use the same identifier for the configured structure as the regular structure
     * because the two fo them are registered to different registries.
     *
     * We can register configured structures at any time before a world is clicked on and made.
     * But the best time to register configured features by code is honestly to do it in onInitialize.
     */
    public static void registerConfiguredStructures() {
        Registry<ConfiguredStructureFeature<?, ?>> registry = BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE;
        Registry.register(registry, new Identifier(StructureTutorialMain.MODID, "configured_run_down_house"), CONFIGURED_RUN_DOWN_HOUSE);
    }
TelepathicGrunt commented 3 years ago

what were the specific changes you have done? This looks like either the structure or configuredstructure isnt actually registered

ni-cky commented 3 years ago

I made the following change (as far as I can see9: StructureTutorialMain:

public static final String MODID = "structure_tutorial"; to public static final String MODID = "grisha";

I tried changing this back but it still does not work.

TelepathicGrunt commented 3 years ago

Make sure you are using the very latest version of fabric api. And after you change the modid, change the folder in the resources/data folder to your modid as well so it matches up. And then test in a brand new world. If you try and enter a world made with the old modid, it's gonna throw errors so do new worlds during these early testing

ni-cky commented 3 years ago

Okay, update time. For ease of testing I just used your Mod ID for now and it does load new worlds at least. Or it does so mostly. cause either while loading or as soon as you are inside the world for a few seconds the following exception gets thrown:

---- Minecraft Crash Report ----
// There are four lights!

Time: 02.08.21, 16:10
Description: Exception generating new chunk

java.lang.NullPointerException: Cannot invoke "net.minecraft.structure.pool.StructurePool.getRandomElement(java.util.Random)" because "structurePool" is null
    at net.minecraft.structure.pool.StructurePoolBasedGenerator.generate(StructurePoolBasedGenerator.java:46)
    at com.nicky.TestStructure.structures.RunDownHouseStructure$Start.init(RunDownHouseStructure.java:175)
    at com.nicky.TestStructure.structures.RunDownHouseStructure$Start.init(RunDownHouseStructure.java:1)
    at net.minecraft.world.gen.feature.StructureFeature.tryPlaceStart(StructureFeature.java:272)
    at net.minecraft.world.gen.feature.ConfiguredStructureFeature.tryPlaceStart(ConfiguredStructureFeature.java:43)
    at net.minecraft.world.gen.chunk.ChunkGenerator.setStructureStart(ChunkGenerator.java:297)
    at net.minecraft.world.gen.chunk.ChunkGenerator.setStructureStarts(ChunkGenerator.java:285)
    at net.minecraft.world.chunk.ChunkStatus.method_16556(ChunkStatus.java:182)
    at net.minecraft.world.chunk.ChunkStatus.runGenerationTask(ChunkStatus.java:136)
    at net.minecraft.server.world.ThreadedAnvilChunkStorage.method_17225(ThreadedAnvilChunkStorage.java:540)
    at com.mojang.datafixers.util.Either$Left.map(Either.java:38)
    at net.minecraft.server.world.ThreadedAnvilChunkStorage.method_17224(ThreadedAnvilChunkStorage.java:537)
    at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1146)
    at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:478)
    at net.minecraft.server.world.ChunkTaskPrioritySystem.method_17634(ChunkTaskPrioritySystem.java:48)
    at net.minecraft.util.thread.TaskExecutor.runNext(TaskExecutor.java:84)
    at net.minecraft.util.thread.TaskExecutor.runWhile(TaskExecutor.java:139)
    at net.minecraft.util.thread.TaskExecutor.run(TaskExecutor.java:92)
    at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1434)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:295)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)

A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Render thread
Stacktrace:
    at net.minecraft.structure.pool.StructurePoolBasedGenerator.generate(StructurePoolBasedGenerator.java:46)
    at com.nicky.TestStructure.structures.RunDownHouseStructure$Start.init(RunDownHouseStructure.java:175)
    at com.nicky.TestStructure.structures.RunDownHouseStructure$Start.init(RunDownHouseStructure.java:1)
    at net.minecraft.world.gen.feature.StructureFeature.tryPlaceStart(StructureFeature.java:272)
    at net.minecraft.world.gen.feature.ConfiguredStructureFeature.tryPlaceStart(ConfiguredStructureFeature.java:43)
    at net.minecraft.world.gen.chunk.ChunkGenerator.setStructureStart(ChunkGenerator.java:297)
    at net.minecraft.world.gen.chunk.ChunkGenerator.setStructureStarts(ChunkGenerator.java:285)
    at net.minecraft.world.chunk.ChunkStatus.method_16556(ChunkStatus.java:182)
    at net.minecraft.world.chunk.ChunkStatus.runGenerationTask(ChunkStatus.java:136)

-- Chunk to be generated --
Details:
    Location: 13,14
    Position hash: 60129542157
    Generator: net.minecraft.world.gen.chunk.NoiseChunkGenerator@7ad112ea
Stacktrace:
    at net.minecraft.server.world.ThreadedAnvilChunkStorage.method_17225(ThreadedAnvilChunkStorage.java:540)
    at com.mojang.datafixers.util.Either$Left.map(Either.java:38)
    at net.minecraft.server.world.ThreadedAnvilChunkStorage.method_17224(ThreadedAnvilChunkStorage.java:537)
    at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1146)
    at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:478)
    at net.minecraft.server.world.ChunkTaskPrioritySystem.method_17634(ChunkTaskPrioritySystem.java:48)
    at net.minecraft.util.thread.TaskExecutor.runNext(TaskExecutor.java:84)
    at net.minecraft.util.thread.TaskExecutor.runWhile(TaskExecutor.java:139)
    at net.minecraft.util.thread.TaskExecutor.run(TaskExecutor.java:92)

-- Affected level --
Details:
    All players: 0 total; []
    Chunk stats: 529
    Level dimension: minecraft:overworld
    Level spawn location: World: (152,64,152), Section: (at 8,0,8 in 9,4,9; chunk contains blocks 144,0,144 to 159,255,159), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
    Level time: 0 game time, 0 day time
    Level name: Generation Test III
    Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
    Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
    Known server brands: fabric
    Level was modded: true
    Level storage version: 0x04ABD - Anvil
Stacktrace:
    at net.minecraft.server.MinecraftServer.createWorlds(MinecraftServer.java:422)
    at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:377)
    at net.minecraft.server.integrated.IntegratedServer.setupServer(IntegratedServer.java:67)
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:728)
    at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:272)
    at java.base/java.lang.Thread.run(Thread.java:831)

-- System Details --
Details:
    Minecraft Version: 1.17.1
    Minecraft Version ID: 1.17.1
    Operating System: Windows 10 (amd64) version 10.0
    Java Version: 16.0.1, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode, sharing), Oracle Corporation
    Memory: 1411439936 bytes (1346 MiB) / 1986002944 bytes (1894 MiB) up to 4282384384 bytes (4084 MiB)
    CPUs: 4
    Processor Vendor: GenuineIntel
    Processor Name: Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
    Identifier: Intel64 Family 6 Model 158 Stepping 9
    Microarchitecture: unknown
    Frequency (GHz): 3,41
    Number of physical packages: 1
    Number of physical CPUs: 4
    Number of logical CPUs: 4
    Graphics card #0 name: NVIDIA GeForce GTX 1060 6GB
    Graphics card #0 vendor: NVIDIA (0x10de)
    Graphics card #0 VRAM (MB): 4095,00
    Graphics card #0 deviceId: 0x1c03
    Graphics card #0 versionInfo: DriverVersion=27.21.14.5671
    Memory slot #0 capacity (MB): 8192,00
    Memory slot #0 clockSpeed (GHz): 2,13
    Memory slot #0 type: DDR4
    Memory slot #1 capacity (MB): 8192,00
    Memory slot #1 clockSpeed (GHz): 2,13
    Memory slot #1 type: DDR4
    Virtual memory max (MB): 20043,35
    Virtual memory used (MB): 12785,01
    Swap memory total (MB): 3712,00
    Swap memory used (MB): 74,45
    JVM Flags: 2 total; -XX:+ShowCodeDetailsInExceptionMessages -XX:+ShowCodeDetailsInExceptionMessages
    Fabric Mods: 
        fabric: Fabric API 0.37.1+1.17
        fabric-api-base: Fabric API Base 0.3.0+a02b446318
        fabric-api-lookup-api-v1: Fabric API Lookup API (v1) 1.2.0+2b5c62d018
        fabric-biome-api-v1: Fabric Biome API (v1) 3.1.11+c345aea818
        fabric-blockrenderlayer-v1: Fabric BlockRenderLayer Registration (v1) 1.1.5+a02b446318
        fabric-command-api-v1: Fabric Command API (v1) 1.1.3+5ab9934c18
        fabric-commands-v0: Fabric Commands (v0) 0.2.2+92519afa18
        fabric-containers-v0: Fabric Containers (v0) 0.1.12+a02b446318
        fabric-content-registries-v0: Fabric Content Registries (v0) 0.2.2+a02b446318
        fabric-crash-report-info-v1: Fabric Crash Report Info (v1) 0.1.5+be9da31018
        fabric-dimensions-v1: Fabric Dimensions API (v1) 2.0.11+6cefd57718
        fabric-entity-events-v1: Fabric Entity Events (v1) 1.1.0+a02b446318
        fabric-events-interaction-v0: Fabric Events Interaction (v0) 0.4.9+a722d8c018
        fabric-events-lifecycle-v0: Fabric Events Lifecycle (v0) 0.2.1+92519afa18
        fabric-game-rule-api-v1: Fabric Game Rule API (v1) 1.0.7+6cefd57718
        fabric-item-api-v1: Fabric Item API (v1) 1.2.4+a02b446318
        fabric-item-groups-v0: Fabric Item Groups (v0) 0.2.10+b7ab612118
        fabric-key-binding-api-v1: Fabric Key Binding API (v1) 1.0.4+a02b446318
        fabric-keybindings-v0: Fabric Key Bindings (v0) 0.2.2+36b77c3e18
        fabric-lifecycle-events-v1: Fabric Lifecycle Events (v1) 1.4.4+a02b446318
        fabric-loot-tables-v1: Fabric Loot Tables (v1) 1.0.4+a02b446318
        fabric-mining-levels-v0: Fabric Mining Levels (v0) 0.1.3+92519afa18
        fabric-models-v0: Fabric Models (v0) 0.3.0+a02b446318
        fabric-networking-api-v1: Fabric Networking API (v1) 1.0.12+6cefd57718
        fabric-networking-blockentity-v0: Fabric Networking Block Entity (v0) 0.2.11+a02b446318
        fabric-networking-v0: Fabric Networking (v0) 0.3.2+92519afa18
        fabric-object-builder-api-v1: Fabric Object Builder API (v1) 1.10.9+b7ab612118
        fabric-object-builders-v0: Fabric Object Builders (v0) 0.7.3+a02b446318
        fabric-particles-v1: Fabric Particles (v1) 0.2.4+a02b446318
        fabric-registry-sync-v0: Fabric Registry Sync (v0) 0.7.10+e2961fee18
        fabric-renderer-api-v1: Fabric Renderer API (v1) 0.4.4+5f02c96918
        fabric-renderer-indigo: Fabric Renderer - Indigo 0.4.8+a02b446318
        fabric-renderer-registries-v1: Fabric Renderer Registries (v1) 3.2.0+a02b446318
        fabric-rendering-data-attachment-v1: Fabric Rendering Data Attachment (v1) 0.1.5+a02b446318
        fabric-rendering-fluids-v1: Fabric Rendering Fluids (v1) 0.1.13+a02b446318
        fabric-rendering-v0: Fabric Rendering (v0) 1.1.2+92519afa18
        fabric-rendering-v1: Fabric Rendering (v1) 1.6.0+a02b446318
        fabric-resource-loader-v0: Fabric Resource Loader (v0) 0.4.8+a00e834b18
        fabric-screen-api-v1: Fabric Screen API (v1) 1.0.4+155f865c18
        fabric-screen-handler-api-v1: Fabric Screen Handler API (v1) 1.1.8+a02b446318
        fabric-structure-api-v1: Fabric Structure API (v1) 1.1.13+5ab9934c18
        fabric-tag-extensions-v0: Fabric Tag Extensions (v0) 1.1.4+a02b446318
        fabric-textures-v0: Fabric Textures (v0) 1.0.6+a02b446318
        fabric-tool-attribute-api-v1: Fabric Tool Attribute API (v1) 1.2.12+b7ab612118
        fabric-transfer-api-v1: Fabric Transfer API (v1) 1.0.0+3fe3c3f518
        fabricloader: Fabric Loader 0.11.6
        grisha: Grisha ${2.0.0}
        jankson: Jankson 3.0.1+j1.2.0
        java: Java HotSpot(TM) 64-Bit Server VM 16
        libgui: LibGui 4.1.5+1.17.1
        libninepatch: LibNinePatch 1.1.0
        minecraft: Minecraft 1.17.1
    Player Count: 0 / 8; []
    Data Packs: vanilla, Fabric Mods
    Type: Integrated Server (map_client.txt)
    Is Modded: Definitely; Client brand changed to 'fabric'
TelepathicGrunt commented 3 years ago

java.lang.NullPointerException: Cannot invoke "net.minecraft.structure.pool.StructurePool.getRandomElement(java.util.Random)" because "structurePool" is null that specific error is caused when the pool file is unable to be found or is empty. Make sure your pool file is in the path you gave to structureSettingsAndStartPool or change structureSettingsAndStartPool's path to your pool file. Also make sure the nbt path in the pool file itself is also correct. If the structureSettingsAndStartPool is pointing to the wrong path, this crash occurs. If the pool file has an nbt path that is incorrect, it nukes itself to become empty and causes that crash

StructurePoolFeatureConfig structureSettingsAndStartPool = new StructurePoolFeatureConfig(() -> dynamicRegistryManager.get(Registry.STRUCTURE_POOL_KEY)
                    .get(new Identifier(StructureTutorialMain.MODID, "run_down_house/start_pool")),
                    10);
ni-cky commented 3 years ago

It works now! Thanks a lot for the help!