Hello everyone,
I'm trying to create a custom nether generation for my mod (mainly adding new biomes). At first I only wanted to change the vanilla generation of the overworld but after browsing a bit on the forums, I saw a message saying that it was a bad idea to do so and creating a new WorldType was a better idea. I managed to create a new WorldType with a custom Overworld generation and moved on changing the Nether.
I looked at the Biomes o Plenty source code and managed to create a new generation for the Nether but I have a big problem now. BOP is unregistering the Nether and registering its own version of it and it is doing so only for the BOP WorldType.
My problem is that when I try to do it for my mod, the Nether generation is changed, even for the other WorldTypes. I didn't find how BOP manages to do it and I can't see what is missing in my code. The first thing that comes to my mind is to find a way to get the WorldType used for the creation of the world and, if it's the custom one, change the Nether generation but I'm not sure I can do it this way since dimensions are registered when MC is loading.
Currently, I put this in my WorldType (probably not a good idea I know):
package com.yliasterkaito.particle.world.type;
import com.yliasterkaito.particle.world.chunkgen.ChunkGeneratorTest;
import com.yliasterkaito.particle.world.provider.BiomeProviderTest;
import com.yliasterkaito.particle.world.provider.WorldProviderNetherCustom;
import net.minecraft.world.DimensionType;
import net.minecraft.world.World;
import net.minecraft.world.WorldType;
import net.minecraft.world.biome.BiomeProvider;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraftforge.common.DimensionManager;
public class WorldTypeTest extends WorldType {
public WorldTypeTest() {
super("Test");
}
@Override
public BiomeProvider getBiomeProvider(World world) {
return new BiomeProviderTest(world);
}
@Override
public IChunkGenerator getChunkGenerator(World world, String generatorOptions) {
return new ChunkGeneratorTest(world, world.getSeed());
}
public static void registerNetherOverride()
{
//DEBUG
System.out.println("Nether override starting");
DimensionManager.unregisterDimension(-1);
DimensionType netherCustom = DimensionType.register("Nether", "_nether", -1, WorldProviderNetherCustom.class, false);
DimensionManager.registerDimension(-1, netherCustom);
System.out.println("Nether override complete");
}
}
This method is initialized like this:
package com.yliasterkaito.particle.util.handlers;
import com.yliasterkaito.particle.init.ModBiomes;
import com.yliasterkaito.particle.init.ModBlocks;
import com.yliasterkaito.particle.init.ModItems;
import com.yliasterkaito.particle.init.ModRecipes;
import com.yliasterkaito.particle.util.interfaces.IHasModel;
//import com.yliasterkaito.particle.world.generation.ModWorldGen;
import com.yliasterkaito.particle.world.generation.ModWorldOreGen;
import com.yliasterkaito.particle.world.type.WorldTypeTest;
import net.minecraft.block.Block;
import net.minecraft.client.gui.GuiCreateWorld;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.item.Item;
import net.minecraft.world.WorldType;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@EventBusSubscriber
public class RegistryHandler
{
@SubscribeEvent
public static void onItemRegister(RegistryEvent.Register<Item> event)
{
event.getRegistry().registerAll(ModItems.ITEMS.toArray(new Item[0]));
}
@SubscribeEvent
public static void onBlockRegister(RegistryEvent.Register<Block> event)
{
event.getRegistry().registerAll(ModBlocks.BLOCKS.toArray(new Block[0]));
}
@SubscribeEvent
public static void onModelRegister(ModelRegistryEvent event)
{
for(Item item : ModItems.ITEMS)
{
if(item instanceof IHasModel)
{
((IHasModel)item).registerModels();
}
}
for(Block block : ModBlocks.BLOCKS)
{
if(block instanceof IHasModel)
{
((IHasModel)block).registerModels();
}
}
}
public static void preInitRegistries()
{
GameRegistry.registerWorldGenerator(new ModWorldOreGen(), 0);
ModBiomes.init();
WorldTypeTest.registerNetherOverride();
}
public static void initRegistries()
{
ModRecipes.init();
MinecraftForge.ORE_GEN_BUS.register(VanillaOreGenDisable.class);
}
public static void postInitRegistries()
{
WorldType TEST = new WorldTypeTest();
}
}
and finally (I saw things about the Common proxy thing, i'll do something about it later):
package com.yliasterkaito.particle;
import com.yliasterkaito.particle.commands.TeleportCommand;
import com.yliasterkaito.particle.proxy.CommonProxy;
import com.yliasterkaito.particle.tabs.CustomTab;
import com.yliasterkaito.particle.util.Reference;
import com.yliasterkaito.particle.util.handlers.RegistryHandler;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
@Mod(modid = Reference.MOD_ID, name = Reference.NAME, version = Reference.VERSION)
public class Main {
@Instance
public static Main instance;
public static final CreativeTabs customtab = new CustomTab("customtab");
@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.COMMON_PROXY_CLASS)
public static CommonProxy proxy;
@EventHandler
public static void PreInit(FMLPreInitializationEvent event)
{
RegistryHandler.preInitRegistries();
}
@EventHandler
public static void init(FMLInitializationEvent event)
{
RegistryHandler.initRegistries();
}
@EventHandler
public static void Postinit(FMLPostInitializationEvent event)
{
RegistryHandler.postInitRegistries();
}
@Mod.EventHandler
public void serverLoad(FMLServerStartingEvent event) {
event.registerServerCommand(new TeleportCommand());
}
}
Thx for your help