Всем салют. Вопрос такой - надо генерировать камушки на поверхности. До этого писал подобное под версию 1.7.10, теперь испытываю некоторые трудности.
Логика генератора, как я понимаю, теперь строится на том, что генератор теперь не может просто ставить блок, а что-то им заменяет. Так или иначе прошу совета, как это можно написать лучше (мы же за развитие навыков, верно?=) ), ибо этот код работает, но мне не нравится, как я его написал.
А еще там есть типо ошибка в консоли, которая как бы не ошибка, но неприятно ее видеть.
Логика генератора, как я понимаю, теперь строится на том, что генератор теперь не может просто ставить блок, а что-то им заменяет. Так или иначе прошу совета, как это можно написать лучше (мы же за развитие навыков, верно?=) ), ибо этот код работает, но мне не нравится, как я его написал.
А еще там есть типо ошибка в консоли, которая как бы не ошибка, но неприятно ее видеть.
Код:
[19:21:12] [Server thread/WARN] [FML]: Tutorial Mod loaded a new chunk [11, 3] in dimension 0 (overworld) while populating chunk [12, 4], causing cascading worldgen lag.
[19:21:12] [Server thread/WARN] [FML]: Please report this to the mod's issue tracker. This log can be disabled in the Forge config.
[19:21:12] [Server thread/WARN] [FML]: Tutorial Mod loaded a new chunk [10, 3] in dimension 0 (overworld) while populating chunk [11, 3], causing cascading worldgen lag.
[19:21:12] [Server thread/WARN] [FML]: Please report this to the mod's issue tracker. This log can be disabled in the Forge config.
[19:21:12] [Server thread/WARN] [FML]: Tutorial Mod loaded a new chunk [9, 3] in dimension 0 (overworld) while populating chunk [11, 3], causing cascading worldgen lag.
[19:21:12] [Server thread/WARN] [FML]: Please report this to the mod's issue tracker. This log can be disabled in the Forge config.
[19:21:12] [Server thread/WARN] [FML]: Tutorial Mod loaded a new chunk [8, 3] in dimension 0 (overworld) while populating chunk [9, 3], causing cascading worldgen lag.
[19:21:12] [Server thread/WARN] [FML]: Please report this to the mod's issue tracker. This log can be disabled in the Forge config.
[19:21:12] [Server thread/WARN] [FML]: Tutorial Mod loaded a new chunk [7, 3] in dimension 0 (overworld) while populating chunk [9, 3], causing cascading worldgen lag.
[19:21:12] [Server thread/WARN] [FML]: Please report this to the mod's issue tracker. This log can be disabled in the Forge config.
Код:
switch (world.provider.getDimension())
{
case 0:
runGenGround(ModBlocks.tutorialMultiOre.getDefaultState(), 1, 8, 1, 255, BlockMatcher.forBlock(Blocks.AIR), world, random, chunkX, chunkZ);
break;
}
private void runGenGround(IBlockState blockToGen, int blockAmount, int chancesToSpawn, int minHeight, int maxHeight, Predicate<IBlockState> blockToReplace, World world, Random rand, int chunk_X, int chunk_Z) {
if (minHeight < 0 || maxHeight > 256 || minHeight > maxHeight)
throw new IllegalArgumentException("Illegal Height Arguments for WorldGenerator");
WorldGenMinable generator = new WorldGenMinable(blockToGen, blockAmount, blockToReplace);
for (int i = 0; i < chancesToSpawn; i++) {
int x = chunk_X * 16 + rand.nextInt(16);
int y = maxHeight;
int z = chunk_Z * 16 + rand.nextInt(16);
/*
* Generate blocks on ground
* 1 - check, if current block is AIR
* 2 - check, if block under AIR is GRASS
* 3 - move "checker" down, return to pos 2
* 4 - if 2 is true - set block to ore
*
* not using generator, use world.set
*
* */
Block currentBlock = world.getBlockState(new BlockPos(x, y, z)).getBlock();
if (currentBlock.equals(Blocks.AIR)) {
for (int j = 255; j > 0; j--) {
Block searchedBlock = world.getBlockState(new BlockPos(x, j, z)).getBlock();
if (searchedBlock.equals(Blocks.GRASS)) {
//generator.generate(world, rand, new BlockPos(x, y, z));
world.setBlockState(new BlockPos(x, j += 1, z), ModBlocks.tutorialMultiOre.getDefaultState());
break;
}
}
}
}
}