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 a week or so ago I had a world generation class that worked perfectly fine, it would generate a block in a custom dimension, in this case a dimension with the id of 8. However this no longer works, and when I try to enter the custom dimension, the world gets stuck on "building terrain". I've tried generating in vanilla dimensions and the same problem occurs, so I'm guessing that the custom dimension I have is not causing the problem.

 

I haven't made any major changes inside or outside of my generation manager class in the time that this problem occurred.

 

I used a simple:

"System.out.println("Generating Block");" To see when the game tries to generate the block, and it seems that this is happening when the game gets stuck on "building terrain" (Obviously)

 

Code:

[spoiler=Generation Manager Class]

package com.custom.generation;

 

import java.util.Random;

 

import net.minecraft.block.Block;

import net.minecraft.block.BlockLog;

import net.minecraft.block.material.Material;

import net.minecraft.init.Blocks;

import net.minecraft.world.World;

import net.minecraft.world.chunk.IChunkProvider;

 

 

import cpw.mods.fml.common.IWorldGenerator;

 

public class CustomGeneration implements IWorldGenerator{

 

@Override

public void generate(Random random, int chunkX, int chunkZ, World world,

IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {

switch (world.provider.dimensionId) {

case -1:

break;

case 0:

break;

case 1:

break;

case 8:

generateCustom(world, random, chunkX * 16, chunkZ * 16);

break;

 

 

}

}

 

 

public void generateCustom(World world, Random random, int x, int z){

        //I'm pretty sure this is where the problem is caused, because I put a println here to see when this specific code is running and it seems when it gets stuck on "Building Terrain" that this code is running over and over again, which Is probably the game attempting to generate the block.

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

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

int Y = random.nextInt(16);

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

 

new WorldGenCustomNameHere().generate(world, random, X, Y, Z);

}

 

}

 

}

 

}

 

 

 

[spoiler=WorldGen Class]

package com.custom.generation;

 

import java.util.Random;

import net.minecraft.block.Block;

import net.minecraft.init.Blocks;

import net.minecraft.init.Items;

import net.minecraft.world.World;

 

 

public class WorldGenCustomNameHere {

 

public WorldGenCustomNameHere(){}

 

public boolean generate(World world, Random rand, int i, int j, int k) {

 

world.setBlock(i + 0, j + 0, k + 0, ModClassHere.CustomBlockHere);

                //this one block being generated is just a test for now

 

return true;

}

 

}

 

 

 

 

Main Mod Class, where the generator is registered:

[spoiler=Main Mod File]

        CustomGenerator generator = new CustomGenerator();

    GameRegistry.registerWorldGenerator(generator, 0);

        //right now I have this in the Pre-Initialization method.

 

 

 

 

 

Like I said above, when I run this code, the game gets stuck on the "Building Terrain" Screen when I enter whichever dimension I'm generating in. I'm not looking for code, I would just like to know what I'm doing wrong or what the issue is.

 

Thanks in advance.

 

 

 

 

There is no reason to call

new WorldGenCustomNameHere()

every time the chunk generates.  You can create one in the constructor of CustomGeneration and save it in a private field and reuse the same generator.

 

Also, "WorldGenCustomNameHere" is a terrible name.

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.

Guest
This topic is now closed to further replies.

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.