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

I cant get my custom melon like block (Sweet berry bush) to generate in my dimension.

Ive copied and changed what was in the WorldGenMelon class but still doesnt work.

 

WorldGenBerryBush class

 

 

package com.manslaughter777.crystaldimension.world.gen.feature;

import java.util.Random;

import com.manslaughter777.crystaldimension.Main;

import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;

public class WorldGenBerryBushes extends WorldGenerator
{

    public boolean generate(World world, Random random, int x, int y, int z)
    {
        for (int l = 0; l < 64; ++l)
        {
            int x1 = x + random.nextInt( - random.nextInt(;
            int y1 = y + random.nextInt(4) - random.nextInt(4);
            int z1 = z + random.nextInt( - random.nextInt(;

            if (Main.sweetBerryBush.canPlaceBlockAt(world, x1, y1, z1) && world.getBlock(x1, y1 - 1, z1) == Main.crystoilGrass)
            {
                world.setBlock(x1, y1, z1, Main.sweetBerryBush, 0, 2);
            }
        }

        return true;
    }
}

 

 

 

PlantGenerator class

 

 

package com.manslaughter777.crystaldimension.world.gen;

import java.util.Random;

import com.manslaughter777.crystaldimension.Main;
import com.manslaughter777.crystaldimension.world.gen.feature.WorldGenBerryBushes;
import com.manslaughter777.crystaldimension.world.gen.feature.WorldGenCrystalTrees;
import com.manslaughter777.crystaldimension.world.gen.feature.WorldGenIlluminateTrees;
import com.manslaughter777.crystaldimension.world.gen.feature.WorldGenOres;

import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenTrees;
import cpw.mods.fml.common.IWorldGenerator;

public class PlantsGenerator implements IWorldGenerator {

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
	switch (world.provider.dimensionId) {
	case -1:
		generateNether(world, random, chunkX * 16, chunkZ * 16);
	case 0:
		generateSurface(world, random, chunkX * 16, chunkZ * 16);
	case 1:
		generateEnd(world, random, chunkX * 16, chunkZ * 16);
	case 7:
		generateCrystal(world, random, chunkX * 16, chunkZ * 16);
	}

}

private void generateEnd(World world, Random random, int x, int z) {

}

private void generateSurface(World world, Random random, int x, int z) {

}

private void generateNether(World world, Random random, int x, int z) {

}

private void generateCrystal(World world, Random random, int x, int z) {

	BiomeGenBase biomeGenBase = world.getWorldChunkManager().getBiomeGenAt(x + 16, z + 16);

	if (biomeGenBase == Main.crystalBiome)

		this.addPlantsSpawn(world, random, x, z, 16, 256, 16, 60);
}

private void addPlantsSpawn(World world, Random random, int xPos, int zPos, int maxX, int maxY, int maxZ, int chanceToSpawn) {
	for (int i = 0; i < chanceToSpawn; i++) {
		int posX = xPos + random.nextInt(maxX); //16
		int posY = random.nextInt(maxY); //how high
		int posZ = zPos + random.nextInt(maxZ); //16
		(new WorldGenBerryBushes()).generate(world, random, posX, posY, posZ);
	}
}
}

 

 

 

Any help is much appreciated :)

  • Author

a) Why is your Dimension ID hardcoded?

b) You don't need to use IWorldGenerator for your own dimension.

The dimension Id is there cause if I want to change the id I don't need to write 7 everywhere and I've used IWorldGenerator for trees and ores so idk why melons arnt working.... Anyway ill check it out and see what happens

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.