Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

Edited by YliasterKaito

  • Author

Nobody replied, is there a problem with the way I presented my problem?

 

EDIT: Sorry for the double-posting, I posted twice by accident

Edited by YliasterKaito

  • 2 weeks later...
On 1/4/2019 at 12:53 AM, YliasterKaito said:

@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])); }

You need to instantiate (create) your objects in the registry event, not just register them

On 1/4/2019 at 12:53 AM, YliasterKaito said:

@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(); } } } 

IHasModel is stupid and unnecessary. Additionally you need to have this code in your client-only event subscriber, as it is it will crash a dedicated server

On 1/4/2019 at 12:53 AM, YliasterKaito said:

ModRecipes.init();

Recipes need to be in JSON

On 1/4/2019 at 12:53 AM, YliasterKaito said:

@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.COMMON_PROXY_CLASS) public static CommonProxy proxy;

Fix it, fast.

You should read http://jabelarminecraft.blogspot.com/p/minecraft-forge-1721710-biome-quick-tips.html?m=1 and http://www.minecraftforge.net/forum/topic/61757-common-issues-and-recommendations/?tab=comments#comment-289567

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

  • Author

I changed most of what you pointed out even before you replied (no more Client Proxy, changed item and block registration after reading topics here). Concerning the recipes, it's only for smelting recipes at the moment, but I'll try to make those as json files too.

I'll take a look at Jabelar's tutorial (already looked at it but not enough) and come back thx!

 

 

Edited by YliasterKaito

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.