Jump to content

[SOLVED] Custom Melon Like Block Aint Generating


Manslaughter777

Recommended Posts

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 :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.