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

Hey guys,

I made a few new plants and now I wonder how I can get them to spawn just like minecraft flowers

Thanks in advance :)

Have you ever made an IWorldGenerator for ores? It's the same thing, but use WorldGenFlowers instead of WorldGenMineable.

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

  • Author

Have you ever made an IWorldGenerator for ores? It's the same thing, but use WorldGenFlowers instead of WorldGenMineable.

unfortunatly not, you know a good tutorial on that?

Add this to you initializationEvent: "GameRegistry.registerWorldGenerator(new RPGGenerator(), 1);".

But use instead of my class a new class that implements IWorldGenerator.

If you have eclipse, you can use "add unimplement methods" to get the method you will have to use.

That method is called every time a new chunk is generated, I hope I have you told enough.

Have a look here on how to make a worldgen class. Look where I use WorldGenWaterPlants, it's very similar to WorldGenFlowers.

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

  • Author

Alright Thanks so far, but I get a crash :/

Dont know why it wont work, only thing im not too sure about is where to register my generator? (currently in my preInit)

There's my code :

 

public class PlantGenerator implements IWorldGenerator
{
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
	if(world.provider.dimensionId == 0) generateFlowers(world, random, chunkX*16, chunkZ*16);

}

private void generateFlowers(World world, Random random, int x, int z) {
	for(int i = 0; i < 3; i++){
	int xCoord = x + random.nextInt(16);
	int zCoord = z + random.nextInt(16);
	new WorldGenFlowers(Blocks.red_flower).generate(world, random, xCoord, world.getHeightValue(xCoord, zCoord), zCoord);
	}
}
}





public static PlantGenerator plantGene;
    public void preInit(FMLPreInitializationEvent event) {
	GameRegistry.registerWorldGenerator(plantGene, 0);
}

 

Crash:

 

 

java.lang.NullPointerException: at index 0
at com.google.common.collect.ObjectArrays.checkElementNotNull(ObjectArrays.java:240) ~[guava-15.0.jar:?]
at com.google.common.collect.ObjectArrays.checkElementsNotNull(ObjectArrays.java:231) ~[guava-15.0.jar:?]
at com.google.common.collect.ObjectArrays.checkElementsNotNull(ObjectArrays.java:226) ~[guava-15.0.jar:?]
at com.google.common.collect.ImmutableList.construct(ImmutableList.java:303) ~[guava-15.0.jar:?]
at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:258) ~[guava-15.0.jar:?]
at cpw.mods.fml.common.registry.GameRegistry.computeSortedGeneratorList(GameRegistry.java:120) ~[GameRegistry.class:?]
at cpw.mods.fml.common.registry.GameRegistry.generateWorld(GameRegistry.java:95) ~[GameRegistry.class:?]
at net.minecraft.world.gen.ChunkProviderServer.populate(ChunkProviderServer.java:310) ~[ChunkProviderServer.class:?]
at net.minecraft.world.chunk.Chunk.populateChunk(Chunk.java:1163) ~[Chunk.class:?]
at net.minecraftforge.common.chunkio.ChunkIOProvider.callStage2(ChunkIOProvider.java:52) ~[ChunkIOProvider.class:?]
at net.minecraftforge.common.chunkio.ChunkIOProvider.callStage2(ChunkIOProvider.java:12) ~[ChunkIOProvider.class:?]
at net.minecraftforge.common.util.AsynchronousExecutor$Task.finish(AsynchronousExecutor.java:189) ~[AsynchronousExecutor$Task.class:?]
at net.minecraftforge.common.util.AsynchronousExecutor.finishActive(AsynchronousExecutor.java:354) ~[AsynchronousExecutor.class:?]
at net.minecraftforge.common.chunkio.ChunkIOExecutor.tick(ChunkIOExecutor.java:30) ~[ChunkIOExecutor.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:657) ~[MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:608) ~[MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) ~[integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:747) [MinecraftServer$2.class:?]

 

Do it like that:

 

// Worldgenerator Registration

GameRegistry.registerWorldGenerator(new WorldGenerator(), 1);

 

and put it in the init or even post-init

That's not the problem, it looks like he's registering it. The problem is you don't assign that PlantGenerator field a value before registering it.

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

  • Author

uhm now I got another problem, when i create a new world it takes around 50 times longer and theres a huge hole where i spawn where there are just no blocks at all, and it takes another 5 min to fill that gap, not too sure if thats caused by my epic generator tho..

But Thanks anyway :)

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.