I have updated the code in the initial post to include the new getLoadedChunkCount method from 1.3.1.
As to making your own End or Nether generator's, that will require replacing classes within Minecraft, which may be a bit more extensive than most people want to deal with. I am not sure if Forge's Dimension manager or the Dimension API allow the core dimensions to be overridden. I will have to look into that.
Rollback Post to RevisionRollBack
Have a mod with options? Mod Options API is the API for you. Let your users configure your mod options with ease.
hm... I followed ever step, It compiles correctly. But no new world type on world creation. Does this work on 1.3.1?
nvm Got it to work XD
Only issue is that the button says WorldType: generator.generator.MAJESTIC
public void load()
{
ModLoader.addLocalization("generator.MAJESTIC", "Majestic");
}
package net.minecraft.src;
public class MajesticJungleWorldType extends WorldType {
public MajesticJungleWorldType() {
super(12, "generator.MAJESTIC");
// The first parameter is the id number of the WorldType,
// vanilla Minecraft uses 0, 1, and 8 already. The max that can be used is 15,
// The second parameter is our textname for our WorldType, the case needs to
// match the "generator.void" localization in the "mod_" file.
}
The getTranslateName method adds the "generator." to the beginning of the string for you, so when you make a new world type, just use the base name "MAJESTIC", you don't want to add the "generator." part.
hm... I followed ever step, It compiles correctly. But no new world type on world creation. Does this work on 1.3.1?
nvm Got it to work XD
Only issue is that the button says WorldType: generator.generator.MAJESTIC
public void load()
{
ModLoader.addLocalization("generator.MAJESTIC", "Majestic");
}
package net.minecraft.src;
public class MajesticJungleWorldType extends WorldType {
public MajesticJungleWorldType() {
super(12, "generator.MAJESTIC");
// The first parameter is the id number of the WorldType,
// vanilla Minecraft uses 0, 1, and 8 already. The max that can be used is 15,
// The second parameter is our textname for our WorldType, the case needs to
// match the "generator.void" localization in the "mod_" file.
}
Rollback Post to RevisionRollBack
Have a mod with options? Mod Options API is the API for you. Let your users configure your mod options with ease.
Alright, just a quick question. Do you know where the spawn information for a new world type is? Because I have a my own GuiScreen thing and I want it to display like a info screen as soon as you spawn into the world type.
Your initial spawn location is set in findBiomePosition inside your ChunkManager. However if you are using forge, there is a hook inside the WorldType called onGUICreateWorldPress that was put in place for just that need.
Alright, just a quick question. Do you know where the spawn information for a new world type is? Because I have a my own GuiScreen thing and I want it to display like a info screen as soon as you spawn into the world type.
Rollback Post to RevisionRollBack
Have a mod with options? Mod Options API is the API for you. Let your users configure your mod options with ease.
Sorry to bother you again but how would you apply it into code like this?
package net.minecraft.src;
import java.util.*;
public class SinCityChunkManager extends WorldChunkManager {
private List biomesToSpawnIn;
public SinCityChunkManager() {
biomesToSpawnIn = new ArrayList();
biomesToSpawnIn.add(BiomeGenBase.plains); // Which biomes can you spawn in?
}
public SinCityChunkManager(World world) {
this();
// Just to keep the original constructor from being called, save the
// world value if you need it later.
}
// Gets the list of valid biomes for the player to spawn in.
public List getBiomesToSpawnIn() {
return biomesToSpawnIn;
}
private BiomeGenBase activeBiome(int i, int j) {
return BiomeGenBase.plains;
// You can set the biome based on the X(i) and Z(j) location, here I am just
// setting the whole world to plains biome.
}
// Returns the BiomeGenBase related to the x, z position on the world.
public BiomeGenBase getBiomeGenAt(int i, int j) {
return activeBiome(i, j);
// Same as the above method, there is a lot of this in the Minecraft code.
}
// Returns a list of rainfall values for the specified blocks. Args: listToReuse, x, z, width, length.
// Ours will set the rainfall to 0 everywhere.
public float[] getRainfall(float par1ArrayOfFloat[], int par2, int par3, int par4, int par5) {
if (par1ArrayOfFloat == null || par1ArrayOfFloat.length < par4 * par5) {
par1ArrayOfFloat = new float[par4 * par5];
}
Arrays.fill(par1ArrayOfFloat, 0, par4 * par5, 0.0F);
return par1ArrayOfFloat;
}
// Returns a list of temperatures to use for the specified blocks. Args: listToReuse, x, y, width, length
// Ours will set the temp to 0 everywhere.
public float[] getTemperatures(float par1ArrayOfFloat[], int par2, int par3, int par4, int par5) {
if (par1ArrayOfFloat == null || par1ArrayOfFloat.length < par4 * par5) {
par1ArrayOfFloat = new float[par4 * par5];
}
Arrays.fill(par1ArrayOfFloat, 0, par4 * par5, 0.0F);
return par1ArrayOfFloat;
}
// Returns an array of biomes for the location input.
// Everywhere is plains...
public BiomeGenBase[] getBiomesForGeneration(BiomeGenBase par1ArrayOfBiomeGenBase[], int par2, int par3, int par4, int par5) {
if (par1ArrayOfBiomeGenBase == null || par1ArrayOfBiomeGenBase.length < par4 * par5) {
par1ArrayOfBiomeGenBase = new BiomeGenBase[par4 * par5];
}
Arrays.fill(par1ArrayOfBiomeGenBase, 0, par4 * par5, BiomeGenBase.plains);
return par1ArrayOfBiomeGenBase;
}
// Returns biomes to use for the blocks and loads the other data like temperature and humidity onto the WorldChunkManager Args: oldBiomeList, x, z, width, depth
// Everywhere is STILL plains...
public BiomeGenBase[] loadBlockGeneratorData(BiomeGenBase par1ArrayOfBiomeGenBase[], int par2, int par3, int par4, int par5) {
if (par1ArrayOfBiomeGenBase == null || par1ArrayOfBiomeGenBase.length < par4 * par5) {
par1ArrayOfBiomeGenBase = new BiomeGenBase[par4 * par5];
}
Arrays.fill(par1ArrayOfBiomeGenBase, 0, par4 * par5, BiomeGenBase.plains);
return par1ArrayOfBiomeGenBase;
}
// checks given Chunk's Biomes against List of allowed ones
public boolean areBiomesViable(int i, int j, int k, List list) {
return true; // Since we only used plains, yep they are allowed.
}
// Return a list of biomes for the specified blocks. Args: listToReuse, x, y, width, length, cacheFlag (if false, don't check biomeCache to avoid infinite loop in BiomeCacheBlock)
public BiomeGenBase[] getBiomeGenAt(BiomeGenBase par1ArrayOfBiomeGenBase[], int par2, int par3, int par4, int par5, boolean par6) {
return loadBlockGeneratorData(par1ArrayOfBiomeGenBase, par2, par3, par4, par5);
}
// Finds a valid position within a range, that is once of the listed biomes.
public ChunkPosition findBiomePosition(int i, int j, int k, List list, Random random) {
return new ChunkPosition(0, 0, 0); // Y position ignored, uses sea level for y spawn.
// This will set your spawn X amd Z location.
}
}
Also the Gui Code if needed
package net.minecraft.src;
import java.awt.image.BufferedImage;
import java.util.List;
import net.minecraft.client.Minecraft;
import org.lwjgl.input.Keyboard;
import java.util.Random;
import org.lwjgl.opengl.GL11;
import org.lwjgl.input.Mouse;
public class GuiSinCity extends GuiScreen
{
private BufferedImage img;
private int imgID = 1000;
public GuiSinCity(EntityPlayer entityplayer)
{
}
public void initGui()
{
controlList.clear();
controlList.add(new GuiButton(1, width / 2 + 10, height / 2 + 150, 98, 20, "Police"));
controlList.add(new GuiButton(2, width / 2 - 110, height / 2 + 150, 98, 20, "Criminal"));
}
protected void actionPerformed(GuiButton guibutton){
if(guibutton.id == 1)
{
mc.displayGuiScreen(new GuiSCIntro1(mc.thePlayer));
}
if(guibutton.id == 2)
{
mc.displayGuiScreen(new GuiSCIntro2(mc.thePlayer));
}
}
public void drawLargeStringWithShadow(String text, int x, int y, int color)
{
GL11.glScalef(2F, 2F, 2F);
fontRenderer.drawStringWithShadow(text, x / 2, y / 2, color);
GL11.glScalef(0.5F, 0.5F, 0.5F);
}
public void drawBorderedRect(int x, int y, int x1, int y1, int size, int borderC, int insideC)
{
drawRect(x, y, x1, y1, borderC);
drawRect(x + size, y + size, x1 - size, y1 - size, insideC);
}
public void drawScreen(int i, int j, float f)
{
drawDefaultBackground();
drawBorderedRect(235, 50, 448, 280, 1, 0xFF3c3c3c, 0xFF5c5c5c);
drawLargeStringWithShadow("Introduction.", mc.displayWidth / 5 , (mc.displayHeight / 2) - 340, 0x44ff11);
drawCenteredString(fontRenderer,"Sup Homie, Welcome to SinCity.", width / 2, 60, 0x44ff11);
drawCenteredString(fontRenderer,"This world isn't like anything", width / 2, 70, 0x44ff11);
drawCenteredString(fontRenderer,"you've ever experienced", width / 2, 80, 0x44ff11);
drawCenteredString(fontRenderer,"so get yo ass ready and lets go" , width / 2, 90, 0x44ff11);
drawCenteredString(fontRenderer,"You can either pick from 2 classes", width / 2, 100, 0x44ff11);
drawCenteredString(fontRenderer, "which is either Criminal or Police.", width / 2, 110, 0x44ff11);
drawCenteredString(fontRenderer,"Criminals love to cause trouble in SinCity", width / 2, 120, 0x44ff11);
drawCenteredString(fontRenderer,"and do things from robbing banks", width / 2, 130, 0x44ff11);
drawCenteredString(fontRenderer,"to shooting at the cops", width / 2, 140, 0x44ff11);
drawCenteredString(fontRenderer,"if you think you got the balls go for it.", width / 2, 150, 0x44ff11);
drawCenteredString(fontRenderer,"On the other hand you have Police,", width / 2, 160, 0x44ff11);
drawCenteredString(fontRenderer,"Not many people appreciate the five-o", width / 2, 170, 0x44ff11);
drawCenteredString(fontRenderer,"but if you wanna play Mr.GoodyTwoShoes", width / 2, 180, 0x44ff11);
drawCenteredString(fontRenderer,"this is the choice for you.", width / 2, 190, 0x44ff11);
drawCenteredString(fontRenderer, "The Police class enables you to do things", width / 2, 200, 0x44ff11);
drawCenteredString(fontRenderer,"from patrolling the streets", width / 2, 210, 0x44ff11);
drawCenteredString(fontRenderer,"to arresting bank robbers.", width / 2, 220, 0x44ff11);
drawCenteredString(fontRenderer,"Alright now you got the", width / 2, 230, 0x44ff11);
drawCenteredString(fontRenderer, "rundown of both classes," , width / 2, 240, 0x44ff11);
drawCenteredString(fontRenderer,"Click either Criminal or Police below", width / 2, 250, 0x44ff11);
drawCenteredString(fontRenderer, "and get ready to enter SinCity!", width / 2, 260, 0x44ff11);
super.drawScreen(i, j, f);
//drawCenteredString(fontRenderer,, width / 2, 60, 0x44ff11);
}
public boolean doesGuiPauseGame()
{
return false;
}
}
What do you meen this doesn't work with forge? I just checked forge and it seems like world types are completely doable with forge.
It works with Forge now, that is a VERY recent addition to Forge, at the time people were having problems it was because the people who maintain Forge were denying there was an issue with the version of ModLoader that was not working. They have since added the needed code to the Forge ModLoader, so the code will work fine.
Rollback Post to RevisionRollBack
Have a mod with options? Mod Options API is the API for you. Let your users configure your mod options with ease.
Sorry if I am not understanding the code, but how do I use the getBiomesForGeneration, or change the one in the tutorials chunk manager to include a list of biomes instead of just plains?
The getBiomesForGeneration method I mentioned above is how you set which biomes are used, your generator decides where they go.
Could you show us written method that for example removes one of the vanilla biomes and adds one new? I'm trying to get it working, but even if I return array with only one mine biome in getBiomesForGeneration, there are still all vanilla biomes in my game.
I have added a "simple" bit of biome code to the post. This doesn't really use the biomes for any generation, it just sets them to arbitrary values based on location. Dealing with the biome cache would be a whole other tutorial.
Rollback Post to RevisionRollBack
Have a mod with options? Mod Options API is the API for you. Let your users configure your mod options with ease.
I have added a "simple" bit of biome code to the post. This doesn't really use the biomes for any generation, it just sets them to arbitrary values based on location. Dealing with the biome cache would be a whole other tutorial.
Lots of people are wanting a custom world type with more than one biome, so as we eagerly await your decision for that, I have asked several others who have custom world type tutorials, much toward forge, though seemingly based off your tutorial. They too have only one biome. So my only suggestion is if you know, please write out the process for us and help the community get better together, as it is, aside from your tutorial, there are about 5 other tutorials out there that all have only one biome capability, so most likely we are ALL waiting for you...
As to making your own End or Nether generator's, that will require replacing classes within Minecraft, which may be a bit more extensive than most people want to deal with. I am not sure if Forge's Dimension manager or the Dimension API allow the core dimensions to be overridden. I will have to look into that.
hm... I followed ever step, It compiles correctly. But no new world type on world creation. Does this work on 1.3.1?nvm Got it to work XD
Only issue is that the button says WorldType: generator.generator.MAJESTIC
Also the Gui Code if needed
Use the getBiomesForGeneration method in your Chunk Manager to set up the biome array.
It works with Forge now, that is a VERY recent addition to Forge, at the time people were having problems it was because the people who maintain Forge were denying there was an issue with the version of ModLoader that was not working. They have since added the needed code to the Forge ModLoader, so the code will work fine.
Find out how I generate....coolAlias...world structure generation and rotation tool...
Could you show us written method that for example removes one of the vanilla biomes and adds one new? I'm trying to get it working, but even if I return array with only one mine biome in getBiomesForGeneration, there are still all vanilla biomes in my game.
Divine smoker mod - Hookah in Minecraft: http://www.minecraftforum.net/topic/1689980-172splanspdivine-smoker-water-pipe-modhookahshisha-11/
And are you planning on writing it?
Divine smoker mod - Hookah in Minecraft: http://www.minecraftforum.net/topic/1689980-172splanspdivine-smoker-water-pipe-modhookahshisha-11/
Divine smoker mod - Hookah in Minecraft: http://www.minecraftforum.net/topic/1689980-172splanspdivine-smoker-water-pipe-modhookahshisha-11/
Find out how I generate....coolAlias...world structure generation and rotation tool...