Jump to content

[Solved] [1.14.4] NPE while generating structure


Recommended Posts

Posted (edited)

Hello,

 

I had a problem while Minecraft is trying to generate my structure (located in : "data/skillsstones/structures/"), the game produce a Null Pointer Exception, here is the entire error :

Spoiler

[17:43:31] [Server thread/ERROR] [minecraft/MinecraftServer]: Encountered an unexpected exception
net.minecraft.crash.ReportedException: Exception generating new chunk
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:833) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:764) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:112) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:622) [?:?] {re:classloading,pl:accesstransformer:B}
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_221] {}
Caused by: java.lang.NullPointerException
	at net.minecraft.world.gen.feature.template.Template.func_215388_b(Template.java:541) ~[?:?] {re:classloading}
	at net.minecraft.world.gen.feature.structure.TemplateStructurePiece.setup(SourceFile:46) ~[?:?] {re:classloading}
	at com.zeide.skillsstones.common.generation.feature.NaturalTotemPiece.loadStructure(NaturalTotemPiece.java:51) ~[?:?] {re:classloading}
	at com.zeide.skillsstones.common.generation.feature.NaturalTotemPiece.<init>(NaturalTotemPiece.java:32) ~[?:?] {re:classloading}
	at com.zeide.skillsstones.common.generation.feature.NaturalTotemStructure$Start.init(NaturalTotemStructure.java:68) ~[?:?] {re:classloading}
	at net.minecraft.world.gen.ChunkGenerator.initStructureStarts(ChunkGenerator.java:162) ~[?:?] {re:classloading}
	at net.minecraft.world.chunk.ChunkStatus.lambda$static$2(ChunkStatus.java:41) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.chunk.ChunkStatus.func_223198_a(ChunkStatus.java:196) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.server.ChunkManager.lambda$null$17(ChunkManager.java:509) ~[?:?] {re:classloading}
	at com.mojang.datafixers.util.Either$Left.map(Either.java:38) ~[datafixerupper-2.0.24.jar:?] {}
	at net.minecraft.world.server.ChunkManager.lambda$func_223156_b$19(ChunkManager.java:507) ~[?:?] {re:classloading}
	at java.util.concurrent.CompletableFuture.uniCompose(CompletableFuture.java:952) ~[?:1.8.0_221] {}
	at java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:926) ~[?:1.8.0_221] {}
	at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:442) ~[?:1.8.0_221] {}
	at net.minecraft.world.chunk.ChunkTaskPriorityQueueSorter.func_219083_b(SourceFile:58) ~[?:?] {re:classloading}
	at net.minecraft.util.concurrent.DelegatedTaskExecutor.driveOne(SourceFile:83) ~[?:?] {re:classloading}
	at net.minecraft.util.concurrent.DelegatedTaskExecutor.driveWhile(SourceFile:123) ~[?:?] {re:classloading}
	at net.minecraft.util.concurrent.DelegatedTaskExecutor.run(SourceFile:91) ~[?:?] {re:classloading}
	at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402) ~[?:1.8.0_221] {}
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) ~[?:1.8.0_221] {}
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) ~[?:1.8.0_221] {}
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) ~[?:1.8.0_221] {}
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) ~[?:1.8.0_221] {}
[17:43:31] [Server thread/ERROR] [minecraft/MinecraftServer]: This crash report has been saved to: D:\Developpement\Java\Minecraft\Mod\Skills Stones\run\.\crash-reports\crash-2020-02-23_17.43.31-server.txt

 

Here is my Structure Piece

Spoiler

import com.zeide.skillsstones.SkillsStones;
import com.zeide.skillsstones.common.generation.StructureGeneration;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.world.IWorld;
import net.minecraft.world.gen.feature.structure.TemplateStructurePiece;
import net.minecraft.world.gen.feature.template.BlockIgnoreStructureProcessor;
import net.minecraft.world.gen.feature.template.PlacementSettings;
import net.minecraft.world.gen.feature.template.Template;
import net.minecraft.world.gen.feature.template.TemplateManager;

import java.util.Random;

public class NaturalTotemPiece extends TemplateStructurePiece {

    public NaturalTotemPiece(TemplateManager templateManager) {

        super(StructureGeneration.NATURAL_TOTEM_PIECE, 0);

        loadStructure(templateManager);

    }

    public NaturalTotemPiece(TemplateManager templateManager, CompoundNBT compoundNBT) {

        super(StructureGeneration.NATURAL_TOTEM_PIECE, compoundNBT);

        loadStructure(templateManager);

    }

    private void loadStructure(TemplateManager templateManager) {

        Template template = templateManager.getTemplateDefaulted(new ResourceLocation(SkillsStones.MOD_ID, "natural_totem"));
        PlacementSettings placementSettings = new PlacementSettings().setIgnoreEntities(true).addProcessor(BlockIgnoreStructureProcessor.STRUCTURE_BLOCK);

        setup(template, templatePosition, placementSettings);

    }

    @Override
    protected void handleDataMarker(String s, BlockPos blockPos, IWorld iWorld, Random random, MutableBoundingBox mutableBoundingBox) {}
}

Here is my Structure :

Spoiler

import com.mojang.datafixers.Dynamic;
import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.gen.feature.NoFeatureConfig;
import net.minecraft.world.gen.feature.structure.ScatteredStructure;
import net.minecraft.world.gen.feature.structure.Structure;
import net.minecraft.world.gen.feature.structure.StructureStart;
import net.minecraft.world.gen.feature.template.TemplateManager;

import java.util.function.Function;

public class NaturalTotemStructure extends ScatteredStructure<NoFeatureConfig> {

    public NaturalTotemStructure(Function<Dynamic<?>, ? extends NoFeatureConfig> feature) {

        super(feature);

    }

    @Override
    protected int getSeedModifier() {

        return 165745296;

    }

    @Override
    public IStartFactory getStartFactory() {

        return Start::new;

    }

    @Override
    public String getStructureName() {

        return "natural_totem";

    }

    @Override
    public int getSize() {

        return 8;

    }

    public static class Start extends StructureStart {

        Start(Structure<?> structureIn, int p_i50515_2_, int p_i50515_3_, Biome p_i50515_4_, MutableBoundingBox p_i50515_5_, int p_i50515_6_, long p_i50515_7_) {
            super(structureIn, p_i50515_2_, p_i50515_3_, p_i50515_4_, p_i50515_5_, p_i50515_6_, p_i50515_7_);
        }

        @Override
        public void init(ChunkGenerator<?> generator, TemplateManager templateManagerIn, int chunkX, int chunkZ, Biome biomeIn) {

            NaturalTotemPiece naturalTotemPiece  = new NaturalTotemPiece(templateManagerIn);

            this.components.add(naturalTotemPiece);
            this.recalculateStructureSize();

        }

    }

}

Finally here is where i'm registering all : (I call initStructurePieceType() and createFeatures() in an other class)

Spoiler

import com.zeide.skillsstones.SkillsStones;
import com.zeide.skillsstones.common.generation.feature.NaturalTotemPiece;
import com.zeide.skillsstones.common.generation.feature.NaturalTotemStructure;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.GenerationStage;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.IFeatureConfig;
import net.minecraft.world.gen.feature.NoFeatureConfig;
import net.minecraft.world.gen.feature.structure.IStructurePieceType;
import net.minecraft.world.gen.feature.structure.Structure;
import net.minecraft.world.gen.placement.IPlacementConfig;
import net.minecraft.world.gen.placement.Placement;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.ObjectHolder;

@Mod.EventBusSubscriber(modid = SkillsStones.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
@ObjectHolder(SkillsStones.MOD_ID)
public class StructureGeneration {

    public static IStructurePieceType NATURAL_TOTEM_PIECE;

    @ObjectHolder(SkillsStones.MOD_ID + ":natural_totem")
    public static Structure<NoFeatureConfig> NATURAL_TOTEM_FEATURE;

    @SubscribeEvent
    public static void registerFeature(RegistryEvent.Register<Feature<?>> event) {

        event.getRegistry().register(new NaturalTotemStructure(NoFeatureConfig::deserialize).setRegistryName("skillsstones:natural_totem"));

    }

    public static void initStructurePieceType() {

        NATURAL_TOTEM_PIECE = Registry.register(Registry.STRUCTURE_PIECE, new ResourceLocation(SkillsStones.MOD_ID, "natural_totem"), NaturalTotemPiece::new);

    }

    public static void createFeatures() {

        for(Biome biome : ForgeRegistries.BIOMES) {

            if(biome.getCategory() != Biome.Category.NETHER && biome.getCategory() != Biome.Category.THEEND) {

                biome.addStructure(NATURAL_TOTEM_FEATURE, IFeatureConfig.NO_FEATURE_CONFIG);
                biome.addFeature(GenerationStage.Decoration.SURFACE_STRUCTURES, Biome.createDecoratedFeature(NATURAL_TOTEM_FEATURE, IFeatureConfig.NO_FEATURE_CONFIG, Placement.NOPE, IPlacementConfig.NO_PLACEMENT_CONFIG));

            }

        }

    }

}

Last thing, i saw that Minecraft use the seed modifier  : "165745296". So, I use it but I don't know what does it change. 

Also, I want to my structure be really really rare and i don't know how can I do this.

 

Thanks a lot.

 

EDIT :

 

I forgot to provide BlockPos with my Structure Piece.

Edited by Zeide

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Add the crash-report or latest.log (logs-folder) with sites like https://mclo.gs/ and paste the link to it here  
    • So i have a forge modded aternos server that worked just fine for a month untill today it suddenly crashes most of the time giving errors and idk which mod is causing the error or its smth else here is the crash log link https://mclo.gs/gGkzGKT
    • Struggling to decipher a crash report I'm getting in a custom modpack I'm tinkering with. The crash happens on startup, but weirdly, only some of the time. It seems to be related to Steves Carts, but weirdly it only started happening recently, and I can't identify if another mod is conflicting, or why it is only happening some of the time:   java.lang.NullPointerException: Cannot invoke "net.minecraft.world.entity.player.Player.m_20202_()" because "player" is null at vswe.stevescarts.events.OverlayEventHandler.onRenderTick(OverlayEventHandler.java:24) ~[stevescarts-1.20.1-1.1.14.jar%23527!/:1.20.1-1.1.14] {re:classloading} at net.minecraftforge.eventbus.EventBus.doCastFilter(EventBus.java:260) ~[eventbus-6.0.5.jar%23127!/:?] {} at net.minecraftforge.eventbus.EventBus.lambda$addListener$11(EventBus.java:252) ~[eventbus-6.0.5.jar%23127!/:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.5.jar%23127!/:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.5.jar%23127!/:?] {} at net.minecraftforge.event.ForgeEventFactory.onRenderTickEnd(ForgeEventFactory.java:919) ~[forge-1.20.1-47.1.106-universal.jar%23581!/:?] {re:mixin,re:classloading,pl:mixin:APP:modernfix-forge.mixins.json:perf.potential_spawns_alloc.ForgeEventFactoryMixin,pl:mixin:A} at net.minecraft.client.Minecraft.m_91383_(Minecraft.java:1148) ~[client-1.20.1-20230612.114412-srg.jar%23576!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick_render_call,xf:fml:xaerominimap:xaero_minecraftclient,xf:fml:xaeroworldmap:xaero_wm_minecraftclient,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick_render_call,xf:fml:xaerominimap:xaero_minecraftclient,xf:fml:xaeroworldmap:xaero_wm_minecraftclient,pl:mixin:A,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.m_91374_(Minecraft.java:718) ~[client-1.20.1-20230612.114412-srg.jar%23576!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick_render_call,xf:fml:xaerominimap:xaero_minecraftclient,xf:fml:xaeroworldmap:xaero_wm_minecraftclient,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick,xf:fml:xaeroworldmap:xaero_wm_minecraft_runtick_render_call,xf:fml:xaerominimap:xaero_minecraftclient,xf:fml:xaeroworldmap:xaero_wm_minecraftclient,pl:mixin:A,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:218) ~[minecraft-1.20.1-client.jar:?] {re:mixin,pl:runtimedistcleaner:A,re:classloading,pl:mixin:APP:flywheel.mixins.json:ClientMainMixin,pl:mixin:A,pl:runtimedistcleaner:A}     Including some extra info in case any of it is relevant^. Appreciate any ideas/advice!    
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.