Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.10.2] Structure spawns weird


Kokkie
 Share

Recommended Posts

Hello, I have a mod and I have a biome with a structure spawning in it but when it generates it sometimes is just fine but sometimes also spawns with a lot missing, my code:

public class WorldGenSimpleHouse extends WorldGenerator {

private static final BlockStateMatcher IS_GRASS = BlockStateMatcher.forBlock(Blocks.GRASS);
private final ResourceLocation HOUSE = new ResourceLocation(Reference.MODID + ":house");

public boolean generate(World worldIn, Random rand, BlockPos position) {
	while (worldIn.isAirBlock(position) && position.getY() > 2) {
		position = position.down();
	}
	if (!IS_GRASS.apply(worldIn.getBlockState(position))) {
		return false;
	}
        Random random = worldIn.getChunkFromChunkCoords(position.getX(), position.getZ()).getRandomWithSeed(987234911L);
        Rotation[] arotation = Rotation.values();
        Rotation rotation = arotation[random.nextInt(arotation.length)];
        ChunkPos chunkpos = new ChunkPos(position);
        StructureBoundingBox structureboundingbox = new StructureBoundingBox(chunkpos.getXStart(), 0, chunkpos.getZStart(), chunkpos.getXEnd(), 256, chunkpos.getZEnd());
        PlacementSettings placementsettings = (new PlacementSettings()).setRotation(rotation).setBoundingBox(structureboundingbox).func_189950_a(random);
        MinecraftServer minecraftserver = worldIn.getMinecraftServer();
	TemplateManager templatemanager = worldIn.getSaveHandler().getStructureTemplateManager();
        Template template = templatemanager.getTemplate(minecraftserver, HOUSE);
        template.func_189962_a(worldIn, position, placementsettings, 2);
	return true;
}

}

And my decorate method in my biome class

public void decorate(World worldIn, Random rand, BlockPos pos) {
	double d0 = GRASS_COLOR_NOISE.getValue((double) (pos.getX() +  / 200.0D, (double) (pos.getZ() +  / 200.0D);
	final WorldGenSimpleHouse HOUSE_GENERATOR = new WorldGenSimpleHouse();

	if (rand.nextInt(1500) == 0) {
		int i = rand.nextInt(16) + 8;
            int j = rand.nextInt(16) + 8;
            BlockPos blockpos = worldIn.getHeight(pos.add(i, 0, j)).up();
            HOUSE_GENERATOR.generate(worldIn, rand, blockpos);
		System.out.println("House generated at: X" + blockpos.getX() + ", Z" + blockpos.getZ());
	}
	this.theBiomeDecorator.flowersPerChunk = 4;
	this.theBiomeDecorator.grassPerChunk = 10;
	DOUBLE_PLANT_GENERATOR.setPlantType(BlockDoublePlant.EnumPlantType.GRASS);

	for (int i = 0; i < 7; ++i) {
		int j = rand.nextInt(16) + 8;
		int k = rand.nextInt(16) + 8;
		int l = rand.nextInt(worldIn.getHeight(pos.add(j, 0, k)).getY() + 32);
		DOUBLE_PLANT_GENERATOR.generate(worldIn, rand, pos.add(j, l, k));
	}

	super.decorate(worldIn, rand, pos);
}

Classes: 94

Lines of code: 12173

Other files: 206

Github repo: https://github.com/KokkieBeer/DeGeweldigeMod

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.