27 mars 2020, 09:10

Bonjour, j’essaie de générer une nouvelle structure de manière aléatoire (pour le moment elle génère pas grand chose), je me suis basé sur le code du jeu afin de le faire mais lorsque je lance le jeu, il me dit que mon Mod a un problème au niveau du CommonSetup event et en lisant les logs il me dit que je rajoute ma structure trop tard

[27mars2020 12:39:46.305] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--gameDir, ., --launchTarget, fmluserdevclient, --fml.mcpVersion, 20190829.143755, --fml.mcVersion, 1.14.4, --fml.forgeGroup, net.minecraftforge, --fml.forgeVersion, 28.2.0, --version, MOD_DEV, --assetIndex, 1.14, --assetsDir, C:\Users\Turpin\.gradle\caches\forge_gradle\assets, --username, Dev, --accessToken, ????????, --userProperties, {}]
[27mars2020 12:39:46.311] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 4.1.0+62+5bfa59b starting: java version 1.8.0_161 by Oracle Corporation
[27mars2020 12:39:47.113] [main/INFO] [net.minecraftforge.fml.loading.FixSSL/CORE]: Added Lets Encrypt root certificates as additional trust
[27mars2020 12:39:49.042] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'fmluserdevclient' with arguments [--version, MOD_DEV, --gameDir, ., --assetsDir, C:\Users\Turpin\.gradle\caches\forge_gradle\assets, --assetIndex, 1.14, --username, Dev, --accessToken, ????????, --userProperties, {}]
[27mars2020 12:39:53.683] [Client thread/INFO] [net.minecraft.client.Minecraft/]: Setting user: Dev
[27mars2020 12:40:21.102] [Client thread/WARN] [net.minecraft.client.GameSettings/]: Skipping bad option: lastServer:
[27mars2020 12:40:21.289] [Client thread/INFO] [net.minecraft.client.Minecraft/]: LWJGL Version: 3.2.2 build 10
[27mars2020 12:40:25.318] [modloading-worker-3/INFO] [net.minecraftforge.common.ForgeMod/FORGEMOD]: Forge mod loading, version 28.2.0, for MC 1.14.4 with MCP 20190829.143755
[27mars2020 12:40:25.318] [modloading-worker-3/INFO] [net.minecraftforge.common.MinecraftForge/FORGE]: MinecraftForge v28.2.0 Initialized
[27mars2020 12:40:35.017] [Client thread/INFO] [com.mojang.text2speech.NarratorWindows/]: Narrator library for x64 successfully loaded
[27mars2020 12:40:39.887] [modloading-worker-2/ERROR] [net.minecraftforge.fml.javafmlmod.FMLModContainer/]: Exception caught during firing event: null
	Index: 1
	Listeners:
		0: NORMAL
		1: net.minecraftforge.eventbus.EventBus$$Lambda$2001/940454178@1ad9bf9b
java.lang.ExceptionInInitializerError
	at fr.swordeus.spellz.world.StructureGeneration.setupStructures(StructureGeneration.java:14)
	at fr.swordeus.spellz.SpellzMod.setup(SpellzMod.java:34)
	at net.minecraftforge.eventbus.EventBus.doCastFilter(EventBus.java:212)
	at net.minecraftforge.eventbus.EventBus.lambda$addListener$11(EventBus.java:204)
	at net.minecraftforge.eventbus.EventBus.post(EventBus.java:258)
	at net.minecraftforge.fml.javafmlmod.FMLModContainer.fireEvent(FMLModContainer.java:106)
	at java.util.function.Consumer.lambda$andThen$0(Consumer.java:65)
	at java.util.function.Consumer.lambda$andThen$0(Consumer.java:65)
	at net.minecraftforge.fml.ModContainer.transitionState(ModContainer.java:112)
	at net.minecraftforge.fml.ModList.lambda$null$10(ModList.java:134)
	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
	at java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:291)
	at java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:731)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinTask.doInvoke(ForkJoinTask.java:401)
	at java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:734)
	at java.util.stream.ForEachOps$ForEachOp.evaluateParallel(ForEachOps.java:160)
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateParallel(ForEachOps.java:174)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:233)
	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
	at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:583)
	at net.minecraftforge.fml.ModList.lambda$dispatchParallelEvent$11(ModList.java:134)
	at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: java.lang.IllegalStateException: The object fr.swordeus.spellz.world.structure.RuinedCastleStructure@3eaad85 (name spellz:ruined_castle) is being added too late.
	at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:348)
	at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:308)
	at net.minecraftforge.registries.NamespacedWrapper.register(NamespacedWrapper.java:56)
	at net.minecraftforge.registries.NamespacedWrapper.register(NamespacedWrapper.java:65)
	at net.minecraftforge.registries.NamespacedWrapper.register(NamespacedWrapper.java:34)
	at net.minecraft.util.registry.Registry.register(Registry.java:240)
	at net.minecraft.util.registry.Registry.register(Registry.java:236)
	at fr.swordeus.spellz.world.structure.CustomFeature.<clinit>(CustomFeature.java:19)
	... 29 more

[27mars2020 12:40:39.896] [modloading-worker-2/ERROR] [net.minecraftforge.fml.javafmlmod.FMLModContainer/LOADING]: Caught exception during event FMLCommonSetupEvent dispatch for modid spellz
java.lang.ExceptionInInitializerError: null
	at fr.swordeus.spellz.world.StructureGeneration.setupStructures(StructureGeneration.java:14) ~[main/:?]
	at fr.swordeus.spellz.SpellzMod.setup(SpellzMod.java:34) ~[main/:?]
	at net.minecraftforge.eventbus.EventBus.doCastFilter(EventBus.java:212) ~[eventbus-1.0.0-service.jar:?]
	at net.minecraftforge.eventbus.EventBus.lambda$addListener$11(EventBus.java:204) ~[eventbus-1.0.0-service.jar:?]
	at net.minecraftforge.eventbus.EventBus.post(EventBus.java:258) ~[eventbus-1.0.0-service.jar:?]
	at net.minecraftforge.fml.javafmlmod.FMLModContainer.fireEvent(FMLModContainer.java:106) ~[?:28.2]
	at java.util.function.Consumer.lambda$andThen$0(Consumer.java:65) ~[?:1.8.0_161]
	at java.util.function.Consumer.lambda$andThen$0(Consumer.java:65) ~[?:1.8.0_161]
	at net.minecraftforge.fml.ModContainer.transitionState(ModContainer.java:112) ~[?:?]
	at net.minecraftforge.fml.ModList.lambda$null$10(ModList.java:134) ~[?:?]
	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) ~[?:1.8.0_161]
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) ~[?:1.8.0_161]
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) ~[?:1.8.0_161]
	at java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:291) ~[?:1.8.0_161]
	at java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:731) ~[?:1.8.0_161]
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) ~[?:1.8.0_161]
	at java.util.concurrent.ForkJoinTask.doInvoke(ForkJoinTask.java:401) ~[?:1.8.0_161]
	at java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:734) ~[?:1.8.0_161]
	at java.util.stream.ForEachOps$ForEachOp.evaluateParallel(ForEachOps.java:160) ~[?:1.8.0_161]
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateParallel(ForEachOps.java:174) ~[?:1.8.0_161]
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:233) ~[?:1.8.0_161]
	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418) ~[?:1.8.0_161]
	at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:583) ~[?:1.8.0_161]
	at net.minecraftforge.fml.ModList.lambda$dispatchParallelEvent$11(ModList.java:134) ~[?:?]
	at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386) [?:1.8.0_161]
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) [?:1.8.0_161]
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) [?:1.8.0_161]
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) [?:1.8.0_161]
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) [?:1.8.0_161]
Caused by: java.lang.IllegalStateException: The object fr.swordeus.spellz.world.structure.RuinedCastleStructure@3eaad85 (name spellz:ruined_castle) is being added too late.
	at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:348) ~[?:?]
	at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:308) ~[?:?]
	at net.minecraftforge.registries.NamespacedWrapper.register(NamespacedWrapper.java:56) ~[?:?]
	at net.minecraftforge.registries.NamespacedWrapper.register(NamespacedWrapper.java:65) ~[?:?]
	at net.minecraftforge.registries.NamespacedWrapper.register(NamespacedWrapper.java:34) ~[?:?]
	at net.minecraft.util.registry.Registry.register(Registry.java:240) ~[?:?]
	at net.minecraft.util.registry.Registry.register(Registry.java:236) ~[?:?]
	at fr.swordeus.spellz.world.structure.CustomFeature.<clinit>(CustomFeature.java:19) ~[?:?]
	... 29 more

Le code de la classe principale :

package fr.swordeus.spellz;

import java.util.logging.Logger;

import fr.swordeus.spellz.init.ModBlocks;
import fr.swordeus.spellz.init.ModItems;
import fr.swordeus.spellz.world.OreGeneration;
import fr.swordeus.spellz.world.StructureGeneration;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;

@Mod(SpellzMod.MODID)
public class SpellzMod {

	public static final String MODID = "spellz";
	
	public static final Logger logger = Logger.getLogger(MODID);
	
	public SpellzMod(){
		
		FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
		FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup);
		
		MinecraftForge.EVENT_BUS.register(ModItems.INSTANCE);
		MinecraftForge.EVENT_BUS.register(ModBlocks.INSTANCE);
	}
	
	public void setup(final FMLCommonSetupEvent e) {
		
		logger.info("Mod setup Loading");
		StructureGeneration.setupStructures();
		OreGeneration.setupGeneration();
		
	}
	
	public void clientSetup(final FMLClientSetupEvent e) {
		
		logger.info("Mod Client setup Loading");
	}
	
}

J’ai essayé de placer l’instruction StructureGenerator.setupStructures() après la génération des minerais ou encore dans le clientSetup mais cela ne marche toujours pas

Le code de la classe StructureGenerator :

package fr.swordeus.spellz.world;

import fr.swordeus.spellz.world.structure.CustomFeature;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.feature.IFeatureConfig;
import net.minecraftforge.registries.ForgeRegistries;

public class StructureGeneration {

	public static void setupStructures() {
		
		for(Biome biome : ForgeRegistries.BIOMES) {
			
			biome.addStructure(CustomFeature.RUINED_CASTLE, IFeatureConfig.NO_FEATURE_CONFIG);
		}
	}
}