Started by
HectorTheSquid
on
Topic category: Help with MCreator software
I made a new biome and I want to add an ore generation to it, but the MCreator block creator generates it in the whole world, the thing I want to make is that the ore only spawns in that specific biome so that it encourages players to search for it and not just dig down.
In generateSurface() check for your biome ,so it looks like this:
public void generateSurface(World world, java.util.Random rand, int chunkX, int chunkZ){
for(int i = 0; i < 17; i++){
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(68)+74;
int randPosZ = chunkZ + rand.nextInt(16);
if(world.getBiomeGenForCoords(new BlockPos(randPosX, randPosY, randPosZ))..biomeName == "Forest"){
(new WorldGenMinable(mcreator_copperOre.block.getDefaultState(), 3)).generate(world, rand, new BlockPos(randPosX, randPosY, randPosZ));}
}
}
Where "Forest" is a name of your biome.
You can also check directly for the biome or for its instance.
@#1
I put this code:
public void generateSurface(World world, java.util.Random rand, int chunkX, int chunkZ){
for(int i = 0; i < 17; i++){
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(68)+74;
int randPosZ = chunkZ + rand.nextInt(16);
if(world.getBiomeGenForCoords(new BlockPos(randPosX, randPosY, randPosZ))..biomeName == "Darklands"){
(new WorldGenMinable(mcreator_DarkOre.block.getDefaultState(), 3)).generate(world, rand, new BlockPos(randPosX, randPosY, randPosZ));}
}
}
but when I save and build it I get an error:
warning: [options] bootstrap class path not set in conjunction with -source 1.6
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_darklands.java:57: error: illegal '.'
if(world.getBiomeGenForCoords(new BlockPos(randPosX, randPosY, randPosZ))..biomeName == "Darklands"){
^
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_darklands.java:57: error: ';' expected
if(world.getBiomeGenForCoords(new BlockPos(randPosX, randPosY, randPosZ))..biomeName == "Darklands"){
^
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_darklands.java:57: error: variable declaration not allowed here
Please help
My bad accidentally wrote two dots right before biomeName
@#2 I removed the dot, but that solves only one of the four errors, the other three are still there:
warning: [options] bootstrap class path not set in conjunction with -source 1.6
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_darklands.java:357: error: <identifier> expected
par1World.setBlock(i1, j1, k1, Block.(DarkOre).7, 0, 2);
^
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_darklands.java:357: error: ')' expected
par1World.setBlock(i1, j1, k1, Block.(DarkOre).7, 0, 2);
^
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_darklands.java:357: error: illegal start of expression
Thanks for your help btw
This is in some other part of the code because I do not know your whole code I can not tell very much. Also because of the name of the element, it seems that you use the code directly in the biome. If so, I would personally recommend more use it in the block.
@#3
Okay, here you have the whole code of both the biome and the block
Biome:
package mod.mcreator;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.common.BiomeManager;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraft.world.gen.feature.WorldGenAbstractTree;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.World;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.ResourceLocation;
import net.minecraft.item.ItemStack;
import net.minecraft.init.Blocks;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.Block;
import java.util.Random;
public class mcreator_darklands {
static Biome.BiomeProperties customProps = null;
public static BiomeGendarklands biome = null;
static {
customProps = new Biome.BiomeProperties("darklands");
customProps.setRainfall(0.0F);
customProps.setBaseHeight(0.1F);
customProps.setHeightVariation(0.5F);
customProps.setWaterColor(0x330066);
biome = new BiomeGendarklands(customProps);
}
public static Object instance;
public mcreator_darklands() {
}
public void load(FMLInitializationEvent event) {
Biome.REGISTRY.register(43, new ResourceLocation("darklands"), biome);
BiomeDictionary.addTypes(biome, BiomeDictionary.Type.FOREST);
BiomeManager.addSpawnBiome(biome);
BiomeManager.addBiome(BiomeManager.BiomeType.WARM, new BiomeManager.BiomeEntry(biome, 10));
}
public void generateNether(World world, Random random, int chunkX, int chunkZ) {
}
public void generateSurface(World world, java.util.Random rand, int chunkX, int chunkZ){
for(int i = 0; i < 17; i++){
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(68)+74;
int randPosZ = chunkZ + rand.nextInt(16);
if(world.getBiomeGenForCoords(new BlockPos(randPosX, randPosY, randPosZ)).biomeName == "Darklands"){
(new WorldGenMinable(mcreator_DarkOre.block.getDefaultState(), 3)).generate(world, rand, new BlockPos(randPosX, randPosY, randPosZ));}
}
}
public void registerRenderers() {
}
public int addFuel(ItemStack fuel) {
return 0;
}
public void serverLoad(FMLServerStartingEvent event) {
}
public void preInit(FMLPreInitializationEvent event) {
}
static class BiomeGendarklands extends Biome {
@SuppressWarnings("unchecked")
public BiomeGendarklands(Biome.BiomeProperties mycustomProps) {
super(mycustomProps);
topBlock = Blocks.GRASS.getDefaultState();
fillerBlock = Blocks.DIRT.getDefaultState();
theBiomeDecorator.generateLakes = true;
theBiomeDecorator.treesPerChunk = 12;
theBiomeDecorator.flowersPerChunk = 0;
theBiomeDecorator.grassPerChunk = 0;
theBiomeDecorator.deadBushPerChunk = 4;
theBiomeDecorator.mushroomsPerChunk = 12;
theBiomeDecorator.reedsPerChunk = 0;
theBiomeDecorator.cactiPerChunk = 3;
theBiomeDecorator.sandPerChunk = 2;
}
@Override
public WorldGenAbstractTree genBigTreeChance(Random rand) {
return new Tree();
}
class Tree extends WorldGenAbstractTree {
/** The minimum height of a generated tree. */
private final int minTreeHeight;
/** True if this tree should grow Vines. */
private final boolean vinesGrow;
/** The metadata value of the wood to use in tree generation. */
private final int metaWood;
/** The metadata value of the leaves to use in tree generation. */
private final int metaLeaves;
public Tree() {
super(false);
this.minTreeHeight = 19;
this.metaWood = 0;
this.metaLeaves = 0;
this.vinesGrow = false;
}
public boolean generate(World par1World, Random par2Random, BlockPos pos) {
int par3 = pos.getX();
int par4 = pos.getY();
int par5 = pos.getZ();
int var6 = par2Random.nextInt(3) + this.minTreeHeight;
boolean var7 = true;
if (par4 >= 1 && par4 + var6 + 1 <= 256) {
int var8;
byte var9;
int var11;
int var12;
for (var8 = par4; var8 <= par4 + 1 + var6; ++var8) {
var9 = 1;
if (var8 == par4) {
var9 = 0;
}
if (var8 >= par4 + 1 + var6 - 2) {
var9 = 2;
}
for (int var10 = par3 - var9; var10 <= par3 + var9 && var7; ++var10) {
for (var11 = par5 - var9; var11 <= par5 + var9 && var7; ++var11) {
if (var8 >= 0 && var8 < 256) {
Block var12s = par1World.getBlockState(new BlockPos(var10, var8, var11)).getBlock();
var12 = Block.getIdFromBlock(var12s);
if (var12 != 0 && var12s != Blocks.AIR && var12s != Blocks.GRASS && var12s != Blocks.DIRT
&& var12s != mcreator_darkLog.block) {
var7 = false;
}
} else {
var7 = false;
}
}
}
}
if (!var7) {
return false;
} else {
Block var8s = par1World.getBlockState(new BlockPos(par3, par4 - 1, par5)).getBlock();
var8 = Block.getIdFromBlock(var8s);
if ((var8s == Blocks.GRASS || var8s == Blocks.DIRT) && par4 < 256 - var6 - 1) {
par1World.setBlockState(new BlockPos(par3, par4 - 1, par5), Blocks.DIRT.getDefaultState(), 3);
var9 = 3;
byte var18 = 0;
int var13;
int var14;
int var15;
for (var11 = par4 - var9 + var6; var11 <= par4 + var6; ++var11) {
var12 = var11 - (par4 + var6);
var13 = var18 + 1 - var12 / 2;
for (var14 = par3 - var13; var14 <= par3 + var13; ++var14) {
var15 = var14 - par3;
for (int var16 = par5 - var13; var16 <= par5 + var13; ++var16) {
int var17 = var16 - par5;
if ((Math.abs(var15) != var13 || Math.abs(var17) != var13 || par2Random.nextInt(2) != 0 && var12 != 0)) {
par1World
.setBlockState(new BlockPos(var14, var11, var16), mcreator_darkLeaves.block.getDefaultState(), 3);
}
}
}
}
for (var11 = 0; var11 < var6; ++var11) {
Block var12s = par1World.getBlockState(new BlockPos(par3, par4 + var11, par5)).getBlock();
var12 = Block.getIdFromBlock(var12s);
if (var12 == 0 || var12s == mcreator_darkLeaves.block) {
par1World.setBlockState(new BlockPos(par3, par4 + var11, par5), mcreator_darkLog.block.getDefaultState(), 3);
if (this.vinesGrow && var11 > 0) {
if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(new BlockPos(par3 - 1, par4 + var11, par5))) {
par1World.setBlockState(new BlockPos(par3 - 1, par4 + var11, par5), Blocks.AIR.getDefaultState(), 3);
}
if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(new BlockPos(par3 + 1, par4 + var11, par5))) {
par1World.setBlockState(new BlockPos(par3 + 1, par4 + var11, par5), Blocks.AIR.getDefaultState(), 3);
}
if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(new BlockPos(par3, par4 + var11, par5 - 1))) {
par1World.setBlockState(new BlockPos(par3, par4 + var11, par5 - 1), Blocks.AIR.getDefaultState(), 3);
}
if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(new BlockPos(par3, par4 + var11, par5 + 1))) {
par1World.setBlockState(new BlockPos(par3, par4 + var11, par5 + 1), Blocks.AIR.getDefaultState(), 3);
}
}
}
}
if (this.vinesGrow) {
for (var11 = par4 - 3 + var6; var11 <= par4 + var6; ++var11) {
var12 = var11 - (par4 + var6);
var13 = 2 - var12 / 2;
for (var14 = par3 - var13; var14 <= par3 + var13; ++var14) {
for (var15 = par5 - var13; var15 <= par5 + var13; ++var15) {
if (par1World.getBlockState(new BlockPos(var14, var11, var15)).getBlock() == mcreator_darkLeaves.block) {
if (par2Random.nextInt(4) == 0
&& Block.getIdFromBlock(par1World.getBlockState(new BlockPos(var14 - 1, var11, var15))
.getBlock()) == 0) {
this.growVines(par1World, var14 - 1, var11, var15, 8);
}
if (par2Random.nextInt(4) == 0
&& Block.getIdFromBlock(par1World.getBlockState(new BlockPos(var14 + 1, var11, var15))
.getBlock()) == 0) {
this.growVines(par1World, var14 + 1, var11, var15, 2);
}
if (par2Random.nextInt(4) == 0
&& Block.getIdFromBlock(par1World.getBlockState(new BlockPos(var14, var11, var15 - 1))
.getBlock()) == 0) {
this.growVines(par1World, var14, var11, var15 - 1, 1);
}
if (par2Random.nextInt(4) == 0
&& Block.getIdFromBlock(par1World.getBlockState(new BlockPos(var14, var11, var15 + 1))
.getBlock()) == 0) {
this.growVines(par1World, var14, var11, var15 + 1, 4);
}
}
}
}
}
if (par2Random.nextInt(5) == 0 && var6 > 5) {
for (var11 = 0; var11 < 2; ++var11) {
for (var12 = 0; var12 < 4; ++var12) {
if (par2Random.nextInt(4 - var11) == 0) {
var13 = par2Random.nextInt(3);
par1World.setBlockState(new BlockPos(par3, par4 + var6 - 5 + var11, par5),
Blocks.AIR.getDefaultState(), 3);
}
}
}
}
}
return true;
} else {
return false;
}
}
} else {
return false;
}
}
/**
* Grows vines downward from the given block for a given length.
* Args: World, x, starty, z, vine-length
*/
private void growVines(World par1World, int par2, int par3, int par4, int par5) {
par1World.setBlockState(new BlockPos(par2, par3, par4), Blocks.AIR.getDefaultState(), 3);
int var6 = 4;
while (true) {
--par3;
if (Block.getIdFromBlock(par1World.getBlockState(new BlockPos(par2, par3, par4)).getBlock()) != 0 || var6 <= 0) {
return;
}
par1World.setBlockState(new BlockPos(par2, par3, par4), Blocks.AIR.getDefaultState(), 3);
--var6;
}
}
protected boolean canGrowInto(Block blockType) {
return true;
}
public void generateSaplings(World worldIn, Random random, BlockPos pos) {
}
/**
* sets dirt at a specific location if it isn't already dirt
*/
protected void setDirtAt(World worldIn, BlockPos pos) {
if (worldIn.getBlockState(pos).getBlock() != Blocks.DIRT) {
this.setBlockAndNotifyAdequately(worldIn, pos, Blocks.DIRT.getDefaultState());
}
}
public boolean isReplaceable(World world, BlockPos pos) {
net.minecraft.block.state.IBlockState state = world.getBlockState(pos);
return state.getBlock().isAir(state, world, pos) || state.getBlock().isLeaves(state, world, pos)
|| state.getBlock().isWood(world, pos) || canGrowInto(state.getBlock());
}
}
@SideOnly(Side.CLIENT)
@Override
public int getGrassColorAtPos(BlockPos pos) {
return 0x000000;
}
@SideOnly(Side.CLIENT)
@Override
public int getFoliageColorAtPos(BlockPos pos) {
return 0x000000;
}
@SideOnly(Side.CLIENT)
@Override
public int getSkyColorByTemp(float currentTemperature) {
return 0x000000;
}
}
public void decorate(World par1World, Random par2Random, int par3, int par4)
{
super.decorate(par1World, par2Random, par3, par4);
int k = 3 + par2Random.nextInt(6);
int l;
int i1;
int j1;
for (l = 0; l < k; ++l)
{
i1 = par3 + par2Random.nextInt(16);
j1 = par2Random.nextInt(28) + 4;
int k1 = par4 + par2Random.nextInt(16);
int l1 = par1World.getBlockId(i1, j1, k1);
if (l1 == Block.stone.blockID)
{
par1World.setBlock(i1, j1, k1, Block.(DarkOre).7, 0, 2);
}
}
for (k = 0; k < 7; ++k)
{
l = par3 + par2Random.nextInt(16);
i1 = par2Random.nextInt(64);
j1 = par4 + par2Random.nextInt(16);
this.theWorldGenerator.generate(par1World, par2Random, l, i1, j1);
}
}
}
Block (Ore):
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraft.world.World;
import net.minecraft.world.IBlockAccess;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.Item;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.Minecraft;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.material.Material;
import net.minecraft.block.SoundType;
import net.minecraft.block.Block;
import java.util.Random;
public class mcreator_darkOre {
public mcreator_darkOre() {
}
public static BlockDarkOre block;
public static Object instance;
public int addFuel(ItemStack fuel) {
return 0;
}
public void serverLoad(FMLServerStartingEvent event) {
}
public void preInit(FMLPreInitializationEvent event) {
block.setRegistryName("darkore");
GameRegistry.register(block);
GameRegistry.register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
}
public void registerRenderers() {
}
public void load(FMLInitializationEvent event) {
if (event.getSide() == Side.CLIENT) {
Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
.register(Item.getItemFromBlock(block), 0, new ModelResourceLocation("testenvironmentmod:darkore", "inventory"));
}
}
static {
block = (BlockDarkOre) (new BlockDarkOre().setHardness(3.0F).setResistance(15.0F).setLightLevel(0.0F).setUnlocalizedName("DarkOre")
.setLightOpacity(0).setCreativeTab(CreativeTabs.BUILDING_BLOCKS));
block.setHarvestLevel("pickaxe", 5);
}
public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
}
public void generateNether(World world, Random random, int chunkX, int chunkZ) {
}
static class BlockDarkOre extends Block {
int a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0;
boolean red = false;
protected BlockDarkOre() {
super(Material.GROUND);
setSoundType(SoundType.STONE);
}
@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
int i = pos.getX();
int j = pos.getY();
int k = pos.getZ();
world.scheduleUpdate(new BlockPos(i, j, k), this, this.tickRate(world));
}
@Override
public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
return red ? 15 : 0;
}
@Override
public int getStrongPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
return red ? 15 : 0;
}
@SideOnly(Side.CLIENT)
@Override
public BlockRenderLayer getBlockLayer() {
return BlockRenderLayer.SOLID;
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
return new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
}
@Override
public int tickRate(World world) {
return 10;
}
@Override
public int quantityDropped(Random par1Random) {
return 1;
}
}
}
I think this should really be a feature in mcreator, but until then thanks for your help