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

    • I am having some issues starting an RLCraft server on a minimal install of Debian 12. I have Java installed and I'm able to start the vanilla Minecraft server jar no problem and people can join and play without any issues, as soon as I try to create a new directory with the Forge jar the initial install with the INSTALLER jar works when I use the java command with the --installServer flag, but as soon as I try to start the server using the forge jar that is NOT labelled with installer I get the following error: A problem occurred running the Server launcher.java.lang.reflect.InvocationTargetException         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)         at java.base/java.lang.reflect.Method.invoke(Method.java:569)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.run(ServerLaunchWrapper.java:70)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.main(ServerLaunchWrapper.java:34) Caused by: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')         at net.minecraft.launchwrapper.Launch.<init>(Launch.java:34)         at net.minecraft.launchwrapper.Launch.main(Launch.java:28)         ... 6 more   I have tried using newer versions of Java directly from Oracle as well. Has anybody been successful in starting and running a RLCraft server from the terminal on a Linux machine? I cannot figure out why it doesn't want to work but the vanilla jar works without issue. Thank you in advance!
    • This is my latest attempt :  public class ManaScreen extends Screen { Mana mana = new Mana(); boolean removeManaBar = false; ResourceLocation manaBar = ResourceLocation.fromNamespaceAndPath(RSGArmoury.MOD_ID, "/textures/block/spawnable_arena_wall.png"); public ManaScreen() { super(Component.literal("Mana")); } @Override protected void init() { super.init(); Minecraft.getInstance().setScreen(this); } @Override public boolean isPauseScreen() { return false; } @Override public void render(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) { pGuiGraphics.blit(manaBar, 10, -10, 0, 0, mana.getMana(), 10, mana.getMana(), 10); if (removeManaBar) { this.onClose(); return; } super.render(pGuiGraphics, pMouseX, pMouseY, pPartialTick); } public void addManaBar() { removeManaBar = false; Minecraft.getInstance().setScreen(new ManaScreen()); } public boolean removeManaBar() { return removeManaBar = true; } }
    • I tried a few different things that all didnt work. Right now I have nothing but what I had that seemed most likely to work was just a guiOverlay.blit(x, y, z, vx, vy, getMana()). I dont remember the exact code but it was somthing along those lines. It was in a new class extending screen I believe.
    • yo help pls  i get this error message The game crashed whilst rendering screen Error: java.lang.NullPointerException: Rendering screen https://pastebin.com/fHwr7nXA
    • Please share a link to your crash report, as explained in the FAQ
  • Topics

×
×
  • Create New...

Important Information

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