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

So this is my world gen everything seems to look fine but it doenst work it generates altars trees and such but it only generates them in deserts.

When it does generates it generates around 10 trees perchuck and i can't seem to find out what i'm doing wrong help please

 

 

import java.util.Random;

 

import net.minecraft.world.World;

import net.minecraft.world.chunk.IChunkProvider;

 

 

import cpw.mods.fml.common.IWorldGenerator;

import cpw.mods.fml.common.registry.GameRegistry;

 

public class WorldGeneratorTrees implements IWorldGenerator {

 

public WorldGeneratorTrees() {

GameRegistry.registerWorldGenerator(this);

}

 

@SuppressWarnings("static-access")

@Override

public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {

if(!(world.getWorldInfo().getTerrainType() == world.getWorldInfo().getTerrainType().FLAT)){

generateBigTree(world, random, chunkX, chunkZ);

generateAltar(world, random, chunkX, chunkZ);

generateOtherTree(world, random, chunkX, chunkZ);

for(int i = 0; i < 1; i++){

        int x = chunkX + random.nextInt(32);

        int z = chunkZ + random.nextInt(32);

        int y = world.getHeightValue(x, z);

        new WorldGenTeak().generate(world, random, x, y, z);

    }

 

    for(int i = 0; i < 1; i++){

        int x = chunkX + random.nextInt(32);

        int z = chunkZ + random.nextInt(32);

        int y = world.getHeightValue(x, z);

        new WorldGenHollow().generate(world, random, x, y, z);

    }

   

    for(int i = 0; i < 1; i++){

        int x = chunkX + random.nextInt(32);

        int z = chunkZ + random.nextInt(32);

        int y = world.getHeightValue(x, z);

        new WorldGenWillow().generate(world, random, x, y, z);

    }

}

}

public static void generateAltar(World world, Random random, int chunkX, int chunkZ)

    {

 

  for(int i = 0; i < 1; i++){

        int x = chunkX + random.nextInt(32);

        int z = chunkZ + random.nextInt(32);

        int y = world.getHeightValue(x, z);

        new EssenceMine().generate(world, random, x, y, z);

    }

 

    for(int i = 0; i < 1; i++){

        int x = chunkX + random.nextInt(128);

        int z = chunkZ + random.nextInt(128);

        int y = world.getHeightValue(x, z);

        new WorldGenAltarAir().generate(world, random, x, y, z);

    }

    }

public static void generateOtherTree(World world, Random random, int chunkX, int chunkZ)

    {

 

  for(int i = 0; i < 1; i++){

        int x = chunkX + random.nextInt(32);

        int z = chunkZ + random.nextInt(32);

        int y = world.getHeightValue(x, z);

        new WorldGenTeak().generate(world, random, x, y, z);

    }

 

    for(int i = 0; i < 1; i++){

        int x = chunkX + random.nextInt(32);

        int z = chunkZ + random.nextInt(32);

        int y = world.getHeightValue(x, z);

        new WorldGenHollow().generate(world, random, x, y, z);

    }

   

    for(int i = 0; i < 1; i++){

        int x = chunkX + random.nextInt(32);

        int z = chunkZ + random.nextInt(32);

        int y = world.getHeightValue(x, z);

        new WorldGenWillow().generate(world, random, x, y, z);

    }

    }

    public static void generateBigTree(World world, Random random, int chunkX, int chunkZ)

    {

   

    //normaal

for(int i = 0; i < 1; i++){

        int x = chunkX + random.nextInt(128);

        int z = chunkZ + random.nextInt(128);

        int y = world.getHeightValue(x, z);

new WorldGenTree(false, 5, 0, 0, false, WoodCutting.woodcuttingleaves.blockID, WoodCutting.woodcuttinglog.blockID).generate(world, random, x, y, z);

}

 

//oak

    for(int i = 0; i < 1; i++){

        int x = chunkX + random.nextInt(64);

        int z = chunkZ + random.nextInt(64);

        int y = world.getHeightValue(x, z);

        int meta = 2;

        new WorldGenBigTree(true, WoodCutting.woodcuttinglog.blockID, meta, WoodCutting.woodcuttingleaves.blockID, meta).generate(world, random, x, y, z);

    }

   

    //yew

    for(int i = 0; i < 1; i++){

        int x = chunkX + random.nextInt(128);

        int z = chunkZ + random.nextInt(128);

        int y = world.getHeightValue(x, z);

        int meta = 9;

        new WorldGenBigTree(true, WoodCutting.woodcuttinglog.blockID, meta, WoodCutting.woodcuttingleaves.blockID, meta).generate(world, random, x, y, z);

    }

   

    //mahogany

    for(int i = 0; i < 1; i++){

        int x = chunkX + random.nextInt(32);

        int z = chunkZ + random.nextInt(32);

        int y = world.getHeightValue(x, z);

        int meta = 7;

        new WorldGenBigTree(true, WoodCutting.woodcuttinglog.blockID, meta, WoodCutting.woodcuttingleaves.blockID, meta).generate(world, random, x, y, z);

    }

   

    //maple

    for(int i = 0; i < 1; i++){

        int x = chunkX + random.nextInt(32);

        int z = chunkZ + random.nextInt(32);

        int y = world.getHeightValue(x, z);

        int meta = 5;

        new WorldGenBigTree(true, WoodCutting.woodcuttinglog.blockID, meta, WoodCutting.woodcuttingleaves.blockID, meta).generate(world, random, x, y, z);

    }

    }

}

 

I'm always happy to help others!

 

Java is not my main programming language but I have alot experience in PHP/HTML/JS/CSS3/C#/SQL

Not sure about your desert problem. Maybe the problem is in one of the other World Gen files.

 

When you use .nextInt though Im pretty sure you want the upper limit to always be 16 so it only spawns into that chunk.

When you use .nextInt though Im pretty sure you want the upper limit to always be 16 so it only spawns into that chunk.

 

Just to clarify this portion.

He's talking about these lines:

 int x = chunkX + random.nextInt(32);
int z = chunkZ + random.nextInt(32);

You shouldn't generate a value higher than 15 with your random, or you're not generating inside that chunk, you're generating in a neighboring chunk.

And while you can, you shouldn't.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

To fix the desert problem we need to see the other files still. It might be something simple like using sand as the valid block to spawn the trees on.

  • Author

Okay well thanks i'll change all the values to 16 to test it again hold on

I'm always happy to help others!

 

Java is not my main programming language but I have alot experience in PHP/HTML/JS/CSS3/C#/SQL

  • Author

Nothing seems to generate now.

 

 

public WorldGeneratorTrees() {

GameRegistry.registerWorldGenerator(this);

}

 

@SuppressWarnings("static-access")

@Override

public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {

if(!(world.getWorldInfo().getTerrainType() == world.getWorldInfo().getTerrainType().FLAT)){

generateBigTree(world, random, chunkX, chunkZ);

generateAltar(world, random, chunkX, chunkZ);

generateOtherTree(world, random, chunkX, chunkZ);

for(int i = 0; i < 15; i++){

        int x = chunkX + random.nextInt(16);

        int z = chunkZ + random.nextInt(16);

        int y = world.getHeightValue(x, z);

        new WorldGenTeak().generate(world, random, x, y, z);

    }

 

    for(int i = 0; i < 15; i++){

        int x = chunkX + random.nextInt(16);

        int z = chunkZ + random.nextInt(16);

        int y = world.getHeightValue(x, z);

        new WorldGenHollow().generate(world, random, x, y, z);

    }

   

    for(int i = 0; i < 15; i++){

        int x = chunkX + random.nextInt(16);

        int z = chunkZ + random.nextInt(16);

        int y = world.getHeightValue(x, z);

        new WorldGenWillow().generate(world, random, x, y, z);

    }

}

}

public static void generateAltar(World world, Random random, int chunkX, int chunkZ)

    {

 

  for(int i = 0; i < 1; i++){

        int x = chunkX + random.nextInt(16);

        int z = chunkZ + random.nextInt(16);

        int y = world.getHeightValue(x, z);

        new EssenceMine().generate(world, random, x, y, z);

    }

 

    for(int i = 0; i < 1; i++){

        int x = chunkX + random.nextInt(16);

        int z = chunkZ + random.nextInt(16);

        int y = world.getHeightValue(x, z);

        new WorldGenAltarAir().generate(world, random, x, y, z);

    }

    }

public static void generateOtherTree(World world, Random random, int chunkX, int chunkZ)

    {

 

  for(int i = 0; i < 1; i++){

        int x = chunkX + random.nextInt(16);

        int z = chunkZ + random.nextInt(16);

        int y = world.getHeightValue(x, z);

        new WorldGenTeak().generate(world, random, x, y, z);

    }

 

    for(int i = 0; i < 1; i++){

        int x = chunkX + random.nextInt(16);

        int z = chunkZ + random.nextInt(16);

        int y = world.getHeightValue(x, z);

        new WorldGenHollow().generate(world, random, x, y, z);

    }

   

    for(int i = 0; i < 1; i++){

        int x = chunkX + random.nextInt(16);

        int z = chunkZ + random.nextInt(16);

        int y = world.getHeightValue(x, z);

        new WorldGenWillow().generate(world, random, x, y, z);

    }

    }

    public static void generateBigTree(World world, Random random, int chunkX, int chunkZ)

    {

   

    //normaal

for(int i = 0; i < 1; i++){

        int x = chunkX + random.nextInt(16);

        int z = chunkZ + random.nextInt(16);

        int y = world.getHeightValue(x, z);

new WorldGenTree(false, 5, 0, 0, false, WoodCutting.woodcuttingleaves.blockID, WoodCutting.woodcuttinglog.blockID).generate(world, random, x, y, z);

}

 

//oak

    for(int i = 0; i < 1; i++){

        int x = chunkX + random.nextInt(16);

        int z = chunkZ + random.nextInt(16);

        int y = world.getHeightValue(x, z);

        int meta = 2;

        new WorldGenBigTree(true, WoodCutting.woodcuttinglog.blockID, meta, WoodCutting.woodcuttingleaves.blockID, meta).generate(world, random, x, y, z);

    }

   

    //yew

    for(int i = 0; i < 1; i++){

        int x = chunkX + random.nextInt(16);

        int z = chunkZ + random.nextInt(16);

        int y = world.getHeightValue(x, z);

        int meta = 9;

        new WorldGenBigTree(true, WoodCutting.woodcuttinglog.blockID, meta, WoodCutting.woodcuttingleaves.blockID, meta).generate(world, random, x, y, z);

    }

   

    //mahogany

    for(int i = 0; i < 1; i++){

        int x = chunkX + random.nextInt(16);

        int z = chunkZ + random.nextInt(16);

        int y = world.getHeightValue(x, z);

        int meta = 7;

        new WorldGenBigTree(true, WoodCutting.woodcuttinglog.blockID, meta, WoodCutting.woodcuttingleaves.blockID, meta).generate(world, random, x, y, z);

    }

   

    //maple

    for(int i = 0; i < 1; i++){

        int x = chunkX + random.nextInt(16);

        int z = chunkZ + random.nextInt(16);

        int y = world.getHeightValue(x, z);

        int meta = 5;

        new WorldGenBigTree(true, WoodCutting.woodcuttinglog.blockID, meta, WoodCutting.woodcuttingleaves.blockID, meta).generate(world, random, x, y, z);

    }

    }

}

 

on the models so they should spawn normally

protected int[] GetValidSpawnBlocks() {

return new int[] {

Block.grass.blockID,

Block.dirt.blockID

};

}

 

I'm always happy to help others!

 

Java is not my main programming language but I have alot experience in PHP/HTML/JS/CSS3/C#/SQL

You need to multiply chunkX and chunkZ by 16, as they are chunk coordinates, not world coordinates.

 

int x = chunkX*16 + random.nextInt(16);

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

I thank you sir ^^

I'm always happy to help others!

 

Java is not my main programming language but I have alot experience in PHP/HTML/JS/CSS3/C#/SQL

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.