Résolu Problème de génération de structures
-
Mes structures se génère, suite à ma demande d’aide, mais j’ai un nouveau problème. Elles se génèrent des dizaines de fois dans le même coin, souvent enterrées, et sont parfois empilées. Aussi, lorsque je m’éloigne du point de spawn, plus aucune ne se génère. Quel est le problème ?
J’ai utilisé l’outil SchematicToJava et modifié tous les Block en Blocks. J’ai enlevé les .blockID et changé les setBlockWithMetadata ( je crois ) en setBlock et ai rajouté un flag à la fin pour que la fonction marche correctement. J’ai ajouté une fonction generate, puisque celle par défaut était invalide ( mauvais paramètres ).
Ma classe Campement.java ( Le WorldGeneration de ma structure ) :
import java.util.Random; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.feature.WorldGenerator; import scala.Console; import cpw.mods.fml.common.IWorldGenerator; public class Campement extends WorldGenerator implements IWorldGenerator { protected Block[] GetValidSpawnBlocks() { return new Block[] { Blocks.grass }; } public boolean LocationIsValidSpawn(World world, int i, int j, int k){ int distanceToAir = 0; Block check = world.getBlock(i, j, k); while (check != Blocks.air){ distanceToAir++; check = world.getBlock(i, j + distanceToAir, k); } if (distanceToAir > 3){ return false; } j += distanceToAir - 1; Block block = world.getBlock(i, j, k); Block blockAbove = world.getBlock(i, j+1, k); Block blockBelow = world.getBlock(i, j-1, k); for (Block x : GetValidSpawnBlocks()){ if (blockAbove != Blocks.air){ return false; } if (block == x){ return true; }else if (block == Blocks.snow && blockBelow == x){ return true; } } return false; } public Campement() { } public boolean generate(World world, Random rand, int i, int j, int k) { //check that each corner is one of the valid spawn blocks if(!LocationIsValidSpawn(world, i, j, k) || !LocationIsValidSpawn(world, i + 13, j, k) || !LocationIsValidSpawn(world, i + 13, j, k + 19) || !LocationIsValidSpawn(world, i, j, k + 19)) { return false; } for (int n = 0; n < 15; ++n) { for (int m = 0; m < 21; ++m) { world.setBlock(i + n - 1, j - 1, k + m - 1, Blocks.grass, 0, 2); for (int o = 0; m < 4; ++m) { world.setBlock(i + n - 1, j + o, k + m - 1, Blocks.air, 0, 3); } } } world.setBlock(i + 0, j + 0, k + 7, Blocks.wool, 8, 2); world.setBlock(i + 0, j + 0, k + 9, Blocks.fence, 0, 2); world.setBlock(i + 0, j + 0, k + 11, Blocks.fence, 0, 2); world.setBlock(i + 0, j + 0, k + 13, Blocks.wool, 8, 0); world.setBlock(i + 0, j + 1, k + 8, Blocks.wool, 8, 2); world.setBlock(i + 0, j + 1, k + 9, Blocks.fence, 0, 2); world.setBlock(i + 0, j + 1, k + 11, Blocks.fence, 0, 2); world.setBlock(i + 0, j + 1, k + 12, Blocks.wool, 8, 2); world.setBlock(i + 0, j + 2, k + 9, Blocks.wool, 8, 2); world.setBlock(i + 0, j + 2, k + 11, Blocks.wool, 8, 2); world.setBlock(i + 0, j + 3, k + 10, Blocks.wool, 8, 2); world.setBlock(i + 1, j + 0, k + 7, Blocks.wool, 8, 2); world.setBlock(i + 1, j + 0, k + 8, Blocks.chest, 3, 2); world.setBlock(i + 1, j + 0, k + 12, Blocks.bed, 9, 2); world.setBlock(i + 1, j + 0, k + 13, Blocks.wool, 8, 2); world.setBlock(i + 1, j + 1, k + 8, Blocks.wool, 8, 2); world.setBlock(i + 1, j + 1, k + 12, Blocks.wool, 8, 2); world.setBlock(i + 1, j + 2, k + 9, Blocks.wool, 8, 2); world.setBlock(i + 1, j + 2, k + 11, Blocks.wool, 8, 2); world.setBlock(i + 1, j + 3, k + 10, Blocks.wool, 8, 2); world.setBlock(i + 2, j + 0, k + 7, Blocks.wool, 8, 2); world.setBlock(i + 2, j + 0, k + 12, Blocks.bed, 1, 2); world.setBlock(i + 2, j + 0, k + 13, Blocks.wool, 8, 2); world.setBlock(i + 2, j + 1, k + 8, Blocks.wool, 8, 2); world.setBlock(i + 2, j + 1, k + 12, Blocks.wool, 8, 2); world.setBlock(i + 2, j + 2, k + 9, Blocks.wool, 8, 2); world.setBlock(i + 2, j + 2, k + 11, Blocks.wool, 8, 2); world.setBlock(i + 2, j + 3, k + 10, Blocks.wool, 8, 2); world.setBlock(i + 3, j + 0, k + 7, Blocks.wool, 8, 2); world.setBlock(i + 3, j + 0, k + 13, Blocks.wool, 8, 2); world.setBlock(i + 3, j + 1, k + 8, Blocks.wool, 8, 2); world.setBlock(i + 3, j + 1, k + 12, Blocks.wool, 8, 2); world.setBlock(i + 3, j + 2, k + 9, Blocks.wool, 8, 2); world.setBlock(i + 3, j + 2, k + 11, Blocks.wool, 8, 2); world.setBlock(i + 3, j + 3, k + 10, Blocks.wool, 8, 2); world.setBlock(i + 4, j + 0, k + 7, Blocks.wool, 8, 2); world.setBlock(i + 4, j + 0, k + 9, Blocks.fence, 0, 2); world.setBlock(i + 4, j + 0, k + 11, Blocks.fence, 0, 2); world.setBlock(i + 4, j + 0, k + 13, Blocks.wool, 8, 2); world.setBlock(i + 4, j + 1, k + 8, Blocks.wool, 8, 2); world.setBlock(i + 4, j + 1, k + 9, Blocks.fence, 0, 2); world.setBlock(i + 4, j + 1, k + 11, Blocks.fence, 0, 2); world.setBlock(i + 4, j + 1, k + 12, Blocks.wool, 8, 2); world.setBlock(i + 4, j + 2, k + 9, Blocks.wool, 8, 2); world.setBlock(i + 4, j + 2, k + 11, Blocks.wool, 8, 2); world.setBlock(i + 4, j + 3, k + 10, Blocks.wool, 8, 2); world.setBlock(i + 5, j + 0, k + 0, Blocks.wool, 7, 2); world.setBlock(i + 5, j + 0, k + 1, Blocks.wool, 7, 2); world.setBlock(i + 5, j + 0, k + 2, Blocks.wool, 7, 2); world.setBlock(i + 5, j + 0, k + 3, Blocks.wool, 7, 2); world.setBlock(i + 5, j + 0, k + 4, Blocks.wool, 7, 2); world.setBlock(i + 6, j + 1, k + 0, Blocks.wool, 7, 2); world.setBlock(i + 6, j + 1, k + 1, Blocks.wool, 7, 2); world.setBlock(i + 6, j + 1, k + 2, Blocks.wool, 7, 2); world.setBlock(i + 6, j + 1, k + 3, Blocks.wool, 7, 2); world.setBlock(i + 6, j + 1, k + 4, Blocks.wool, 7, 2); world.setBlock(i + 7, j + 0, k + 0, Blocks.fence, 0, 2); world.setBlock(i + 7, j + 0, k + 4, Blocks.fence, 0, 2); world.setBlock(i + 7, j + 0, k + 11, Blocks.stone_slab, 3, 2); world.setBlock(i + 7, j + 0, k + 15, Blocks.wool, 12, 2); world.setBlock(i + 7, j + 0, k + 16, Blocks.wool, 12, 2); world.setBlock(i + 7, j + 0, k + 17, Blocks.wool, 12, 2); world.setBlock(i + 7, j + 0, k + 18, Blocks.wool, 12, 2); world.setBlock(i + 7, j + 0, k + 19, Blocks.wool, 12, 2); world.setBlock(i + 7, j + 1, k + 0, Blocks.fence, 0, 2); world.setBlock(i + 7, j + 1, k + 4, Blocks.fence, 0, 2); world.setBlock(i + 7, j + 2, k + 0, Blocks.wool, 7, 2); world.setBlock(i + 7, j + 2, k + 1, Blocks.wool, 7, 2); world.setBlock(i + 7, j + 2, k + 2, Blocks.wool, 7, 2); world.setBlock(i + 7, j + 2, k + 3, Blocks.wool, 7, 2); world.setBlock(i + 7, j + 2, k + 4, Blocks.wool, 7, 2); world.setBlock(i + 8, j + 0, k + 10, Blocks.stone_slab, 3, 2); world.setBlock(i + 8, j + 0, k + 11, Blocks.fire, 15, 2); world.setBlock(i + 8, j -1, k + 11, Blocks.netherrack, 0, 2); world.setBlock(i + 8, j + 0, k + 12, Blocks.stone_slab, 3, 2); world.setBlock(i + 8, j + 0, k + 16, Blocks.chest, 5, 2); world.setBlock(i + 8, j + 1, k + 15, Blocks.wool, 12, 2); world.setBlock(i + 8, j + 1, k + 16, Blocks.wool, 12, 2); world.setBlock(i + 8, j + 1, k + 17, Blocks.wool, 12, 2); world.setBlock(i + 8, j + 1, k + 18, Blocks.wool, 12, 2); world.setBlock(i + 8, j + 1, k + 19, Blocks.wool, 12, 2); world.setBlock(i + 8, j + 3, k + 0, Blocks.wool, 7, 2); world.setBlock(i + 8, j + 3, k + 1, Blocks.wool, 7, 2); world.setBlock(i + 8, j + 3, k + 2, Blocks.wool, 7, 2); world.setBlock(i + 8, j + 3, k + 3, Blocks.wool, 7, 2); world.setBlock(i + 8, j + 3, k + 4, Blocks.wool, 7, 2); world.setBlock(i + 9, j + 0, k + 0, Blocks.fence, 0, 2); world.setBlock(i + 9, j + 0, k + 4, Blocks.fence, 0, 2); world.setBlock(i + 9, j + 0, k + 11, Blocks.stone_slab, 3, 2); world.setBlock(i + 9, j + 0, k + 15, Blocks.fence, 0, 2); world.setBlock(i + 9, j + 0, k + 19, Blocks.fence, 0, 2); world.setBlock(i + 9, j + 1, k + 0, Blocks.fence, 0, 2); world.setBlock(i + 9, j + 1, k + 4, Blocks.fence, 0, 2); world.setBlock(i + 9, j + 1, k + 15, Blocks.fence, 0, 2); world.setBlock(i + 9, j + 1, k + 19, Blocks.fence, 0, 2); world.setBlock(i + 9, j + 2, k + 0, Blocks.wool, 7, 2); world.setBlock(i + 9, j + 2, k + 1, Blocks.wool, 7, 2); world.setBlock(i + 9, j + 2, k + 2, Blocks.wool, 7, 2); world.setBlock(i + 9, j + 2, k + 3, Blocks.wool, 7, 2); world.setBlock(i + 9, j + 2, k + 4, Blocks.wool, 7, 2); world.setBlock(i + 9, j + 2, k + 15, Blocks.wool, 12, 2); world.setBlock(i + 9, j + 2, k + 16, Blocks.wool, 12, 2); world.setBlock(i + 9, j + 2, k + 17, Blocks.wool, 12, 2); world.setBlock(i + 9, j + 2, k + 18, Blocks.wool, 12, 2); world.setBlock(i + 9, j + 2, k + 19, Blocks.wool, 12, 2); world.setBlock(i + 10, j + 0, k + 1, Blocks.bed, 10, 2); world.setBlock(i + 10, j + 0, k + 2, Blocks.bed, 2, 2); world.setBlock(i + 10, j + 1, k + 0, Blocks.wool, 7, 2); world.setBlock(i + 10, j + 1, k + 1, Blocks.wool, 7, 2); world.setBlock(i + 10, j + 1, k + 2, Blocks.wool, 7, 2); world.setBlock(i + 10, j + 1, k + 3, Blocks.wool, 7, 2); world.setBlock(i + 10, j + 1, k + 4, Blocks.wool, 7, 2); world.setBlock(i + 10, j + 3, k + 15, Blocks.wool, 12, 2); world.setBlock(i + 10, j + 3, k + 16, Blocks.wool, 12, 2); world.setBlock(i + 10, j + 3, k + 17, Blocks.wool, 12, 2); world.setBlock(i + 10, j + 3, k + 18, Blocks.wool, 12, 2); world.setBlock(i + 10, j + 3, k + 19, Blocks.wool, 12, 2); world.setBlock(i + 11, j + 0, k + 0, Blocks.wool, 7, 2); world.setBlock(i + 11, j + 0, k + 1, Blocks.wool, 7, 2); world.setBlock(i + 11, j + 0, k + 2, Blocks.wool, 7, 2); world.setBlock(i + 11, j + 0, k + 3, Blocks.wool, 7, 2); world.setBlock(i + 11, j + 0, k + 4, Blocks.wool, 7, 2); world.setBlock(i + 11, j + 0, k + 15, Blocks.fence, 0, 2); world.setBlock(i + 11, j + 0, k + 19, Blocks.fence, 0, 2); world.setBlock(i + 11, j + 1, k + 15, Blocks.fence, 0, 2); world.setBlock(i + 11, j + 1, k + 19, Blocks.fence, 0, 2); world.setBlock(i + 11, j + 2, k + 15, Blocks.wool, 12, 2); world.setBlock(i + 11, j + 2, k + 16, Blocks.wool, 12, 2); world.setBlock(i + 11, j + 2, k + 17, Blocks.wool, 12, 2); world.setBlock(i + 11, j + 2, k + 18, Blocks.wool, 12, 2); world.setBlock(i + 11, j + 2, k + 19, Blocks.wool, 12, 2); world.setBlock(i + 12, j + 0, k + 8, Blocks.fence, 0, 2); world.setBlock(i + 12, j + 0, k + 17, Blocks.bed, 0, 2); world.setBlock(i + 12, j + 0, k + 18, Blocks.bed, 8, 2); world.setBlock(i + 12, j + 1, k + 8, Blocks.skull, 1, 2); world.setBlock(i + 12, j + 1, k + 15, Blocks.wool, 12, 2); world.setBlock(i + 12, j + 1, k + 16, Blocks.wool, 12, 2); world.setBlock(i + 12, j + 1, k + 17, Blocks.wool, 12, 2); world.setBlock(i + 12, j + 1, k + 18, Blocks.wool, 12, 2); world.setBlock(i + 12, j + 1, k + 19, Blocks.wool, 12, 2); world.setBlock(i + 13, j + 0, k + 11, Blocks.fence, 0, 2); world.setBlock(i + 13, j + 0, k + 15, Blocks.wool, 12, 2); world.setBlock(i + 13, j + 0, k + 16, Blocks.wool, 12, 2); world.setBlock(i + 13, j + 0, k + 17, Blocks.wool, 12, 2); world.setBlock(i + 13, j + 0, k + 18, Blocks.wool, 12, 2); world.setBlock(i + 13, j + 0, k + 19, Blocks.wool, 12, 2); world.setBlock(i + 13, j + 1, k + 11, Blocks.skull, 1, 2); return true; } public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { for (int i = 0; i < 257; ++i) { this.generate(world, random, chunkX*16, chunkZ*16, i); } } }
-
Le code de SchematicsToJava est vraiment mal fait, mes structures spawnaient toujours sous terre ou en l’air, essaye de modifier la méthode locationIsValidSpawn()
-
D’accord, je vais essayer ça.