Modding 1.4.7: Basic Biome

In this tutorial I will show you how to create your own custom Biome. We will start coding in the mod file for this. This is the file I start with.

package tutorial;

import net.minecraftforge.common.DimensionManager;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;

@Mod(modid = "Tutorial_Tutorialmod", name = "Tutorial", version = "1.0")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class Tutorial
{
       @SidedProxy(clientSide = "tutorial.ClientProxyTutorial", serverSide = "tutorial.CommonProxyTutorial")
       public static CommonProxyTutorial proxy;
      
       public static int dimension = 20;
      
       @Init
       public void load(FMLInitializationEvent event)
       {
             proxy.registerRenderThings();
            
             DimensionManager.registerProviderType(dimension, WorldProviderTutorial.class, false);
             DimensionManager.registerDimension(dimension, dimension);
       }
}

To create your first biome you will have to add this line of code above the @Init and below the proxy line.

public static BiomeGenBase tutorialBiome;

This line will make a BiomeGenBase object called tutorialBiome.
Now use this object in the load method by adding this line of code.

tutorialBiome = new BiomeGenTutorial(53);

This line will set the tutorialBiome variable to the BiomeGenTutorial file. Right now you will get an error under the BiomeGenTutorial, but we will fix that in just a second by creating that file. The paramter you see inside of the BiomeGenTutorial is the id of the Biome. I suggest taking a pretty high number to make sure it doesn't conflict with Minecraft soon. Don't make it too high though. Somewhere between 50-70 should work fine.
Now hover your mouse over the BiomeGenTutorial and create the class. You will get something like this.

package tutorial;

import net.minecraft.world.biome.BiomeGenBase;

public class BiomeGenTutorial extends BiomeGenBase
{

}

You will get an error under the file name. To fix that hover over it and click create constructor. Now you will have no more errors in any of these files and the biome will be made out of grass and dirt without anything special. It will also spawn all the mobs like any other biome.
The biome file should now look like this.

package tutorial;

import net.minecraft.world.biome.BiomeGenBase;

public class BiomeGenTutorial extends BiomeGenBase
{
       public BiomeGenTutorial(int par1)
       {
             super(par1);
       }
}

Now to make your biome generate in the normal world you will have to add this line of code to the load method in your mod file, but make sure it is after the tutorialBiome = File line or it will give you errors.

GameRegistry.addBiome(tutorialBiome);

This is a really simple line of code. It will simply add the biome in the parameters to the overworld generation. If you don't want your biome to generate in the overworld, but in a custom dimension you should not add this line of code.

The whole mod file should now look like this.

package tutorial;

import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.DimensionManager;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;

@Mod(modid = "Tutorial_Tutorialmod", name = "Tutorial", version = "1.0")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class Tutorial
{
       @SidedProxy(clientSide = "tutorial.ClientProxyTutorial", serverSide = "tutorial.CommonProxyTutorial")
       public static CommonProxyTutorial proxy;
      
       public static int dimension = 20;
      
       public static BiomeGenBase tutorialBiome;
      
       @Init
       public void load(FMLInitializationEvent event)
       {
             proxy.registerRenderThings();
            
             tutorialBiome = new BiomeGenTutorial(53);
            
             GameRegistry.addBiome(tutorialBiome);
            
             DimensionManager.registerProviderType(dimension, WorldProviderTutorial.class, false);
             DimensionManager.registerDimension(dimension, dimension);
       }
}

In the next tutorial I will show you how to add some custom settings to your biome.

When you are done you should go back to the tutorials list here.

1 opmerking:

  1. ROBLOX is driven by a growing community of over 300,000 creators who generate an infinite variety of highly immersive experiences.

    These experiences range from 3D multi-player games and competitions, to interactive adventures where friends can take on new avatars imagining what it's like to be a dinosaur, a miner in a quarry or an astronaut on a space exploration.

    BeantwoordenVerwijderen