Jump to content

Recommended Posts

Posted (edited)

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
  • 2 weeks later...
Posted
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)

Posted (edited)

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

×   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

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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