Premièrement : le sysout s'active bien à la génération du monde on le voit dans la console mais je continue de jouer et les sysout persistent un problème avec la boucle ? je ne sais pas
Deuxièmement : j'ai réussi à trouver ma structure mais elle est concentré dans un seul chunk et comme le code de génération continue je vois ma structure poppé à l'infini juste dans ce chunk
Quelqu'un peut m'expliquer ? (j'ai suivi le tuto de Checconio)
Ma classe pour générer mes minerais et ma structure :
Code : Tout sélectionner
package raven.tacoscraft;
import java.util.Random;
import cpw.mods.fml.common.IWorldGenerator;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import raven.tacoscraft.structure.SapphireCastle;
public class FactoriteGeneration 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, chunkZ);
break;
case 0:
generateOverworld(world, random, chunkX, chunkZ);
break;
case 1:
generateEnd(world, random, chunkX, chunkZ);
break;
}
}
public void generateNether(World world, Random rand, int x, int z) {
generateOre(Factoria.blockNetherVoltiteOre, world, rand, x, z, 3 , 9, 2, 20, 100, Blocks.netherrack);
}
private void addStruture(String string, Random rand, World world, int posX , int posZ, int minY, int maxY, int spawnChance)
{
for(int i = 0; i < spawnChance ; i++) {
int chunkSize = 16;
int x = posX + rand.nextInt(chunkSize);
int y = minY + rand.nextInt(maxY - minY);
int z = posZ + rand.nextInt(chunkSize);
new SapphireCastle().init(world, rand, x, y, z);
System.out.println("structure généré");
}
}
public void generateOverworld(World world, Random rand, int x, int z) {
generateOre(Factoria.blockFactoriteOre, world, rand, x, z, 1 , 6, 2, 4, 8, Blocks.stone);
generateOre(Factoria.blockTinOre, world, rand, x, z, 2 , 9, 3, 12, 18, Blocks.stone);
generateOre(Factoria.blockLithiumOre, world, rand, x, z, 1 , 8, 2, 4, 12, Blocks.stone);
this.addStruture("sapphireCastle", rand, world, x, z, 50, 128, 60);
}
public void generateEnd(World world, Random rand, int X, int Z) {
}
public void generateOre(Block block, World world, Random random, int chunkX, int chunkZ, int minVienSize,
int maxVienSize, int chance, int minY, int maxY, Block generateIn) {
int vienSize = minVienSize + random.nextInt(maxVienSize - minVienSize);
int heightRange = maxY - minY;
WorldGenMinable gen = new WorldGenMinable(block, vienSize, generateIn);
for (int i = 0; i < chance; i++) {
int xRand = chunkX * 16 + random.nextInt(16);
int yRand = random.nextInt(heightRange) + minY;
int zRand = chunkZ * 16 + random.nextInt(16);
gen.generate(world, random, xRand, yRand, zRand);
System.out.println("minerai généré");
}
}
}
Code : Tout sélectionner
package raven.tacoscraft.structure;
import java.util.Random;
import net.minecraft.world.World;
public class StructureGen {
public static final String sapphireCastle = "sapphireCastle";
public boolean generate(String name, World world, Random rand, int x , int y ,int z )
{
switch(name)
{
case sapphireCastle:
SapphireCastle.init(world, rand, x, y, z);
break;
}
return true;
}
}
Code : Tout sélectionner
package raven.tacoscraft.structure;
import java.util.Random;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenerator;
import raven.tacoscraft.Factoria;
import raven.tacoscraft.entity.EntityCorruptedBot;
import cpw.mods.fml.common.IWorldGenerator;
public class SapphireCastle
{
public static void init(World world, Random rand, int x, int y, int z)
{
if(world.getBlock(x, y - 1 , z) == Blocks.grass && world.isAirBlock(x, y + 1, z) ) {
//Diagonals
//Up Left
//B2
world.setBlock(x + 1, y , z + 1, Blocks.stonebrick);
//A1
world.setBlock(x + 2, y, z + 2, Blocks.stonebrick);
//Up Right
//D2
world.setBlock(x + 1, y, z - 1, Blocks.stonebrick);
//E1
world.setBlock(x + 2, y, z - 2, Blocks.stonebrick);
//Down Left
//B4
world.setBlock(x - 1, y, z + 1, Blocks.stonebrick);
//A5
world.setBlock(x - 2, y, z + 2, Blocks.stonebrick);
//Down Right
//B4
world.setBlock(x - 1, y, z + 1, Blocks.stonebrick);
//A5
world.setBlock(x - 2, y , z + 2, Blocks.stonebrick);
//B Fill
//B1
world.setBlock(x + 2, y, z + 1, Blocks.stonebrick);
//B5
world.setBlock(x - 2, y, z + 1, Blocks.stonebrick);
//D Fill
//D1
world.setBlock(x + 2, y, z - 1, Blocks.stonebrick);
//D5
world.setBlock(x - 2, y, z - 1, Blocks.stonebrick);
//A Fill
//A2
world.setBlock(x + 1, y, z + 2, Blocks.stonebrick);
//A4
world.setBlock(x - 1, y, z + 2, Blocks.stonebrick);
//E Fill
//E2
world.setBlock(x + 1, y, z - 2, Blocks.stonebrick);
//E4
world.setBlock(x - 1, y, z - 2, Blocks.stonebrick);
//Center
world.setBlock(x, y, z, Factoria.blockLithium);
//Straight
//Forward
//C2
world.setBlock(x + 1 , y , z, Blocks.stonebrick);
//C1
world.setBlock(x + 2, y , z, Blocks.stonebrick);
//Backwards
//C4
world.setBlock(x - 1 , y , z, Blocks.stonebrick);
//C5
world.setBlock(x - 2, y , z, Blocks.stonebrick);
//Left
//B3
world.setBlock(x, y , z + 1, Blocks.stonebrick);
//A3
world.setBlock(x, y , z + 2, Blocks.stonebrick);
//Right
//D3
world.setBlock(x , y , z - 1, Blocks.stonebrick);
//E3
world.setBlock(x, y , z - 2, Blocks.stonebrick);
EntityCorruptedBot bot = new EntityCorruptedBot(world);
bot.setPosition(x, y + 1, z);
world.spawnEntityInWorld(bot);
}
}
}