Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

You are setting you structure bounds to the size of the chunk, but your rotation is random. So your structure can generate partially outside of the chunk and outside the bounds.

  • Author

I now have this, will it work? StructureBoundingBox structureboundingbox = new StructureBoundingBox(chunkpos.getXStart() - 16, 0, chunkpos.getZStart() - 16, chunkpos.getXEnd() + 16, 256, chunkpos.getZEnd() + 16);

Classes: 94

Lines of code: 12173

Other files: 206

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

I wouldn't know, why don't you test it? But I hazard to guess that the success will depend on the size of your structure.

Guest
This topic is now closed to further replies.

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.