Posted February 23, 20205 yr 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 February 24, 20205 yr 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.