Add ITerrainGenerator with GenerationUnit fork support for cross-chunk modifications#22
Add ITerrainGenerator with GenerationUnit fork support for cross-chunk modifications#22
Conversation
…k modifications Co-authored-by: CoPokBl <59753822+CoPokBl@users.noreply.github.com>
…ions Co-authored-by: CoPokBl <59753822+CoPokBl@users.noreply.github.com>
|
@copilot ITerrainGenerator should implement ITerrainProvider, it's supposed to be a higher level abstraction. The generation unit can be multiple chunk if the GetChunks call is used. |
…hunk support Co-authored-by: CoPokBl <59753822+CoPokBl@users.noreply.github.com>
Done in 0bae5af. |
|
@copilot Add the following additional functionality: Adding structures using forks is trivial. Here is the same example written with the Block.Setter utility: Instance instance = ...;
instance.setGenerator(unit -> {
Random random = ...;
Point start = unit.absoluteStart();
// Create a snow carpet for the snowmen
unit.modifier().fillHeight(-64, -60, Block.SNOW);
// Exit out if unit is not the bottom unit or 5 in 6 times
if (start.y() > -64 || random.nextInt(6) != 0) {
return;
}
// Add the snowman
unit.fork(setter -> {
for (int x = 0; x < 3; x++) {
for (int y = 0; y < 19; y++) {
for (int z = 0; z < 3; z++) {
setter.setBlock(start.add(x, y, z), Block.POWDER_SNOW);
}
}
}
setter.setBlock(start.add(1, 19, 1), Block.JACK_O_LANTERN);
});
}); |
Co-authored-by: CoPokBl <59753822+CoPokBl@users.noreply.github.com>
Done in cf2e83b. Added Usage: unit.Fork(setter => {
for (int x = 0; x < 3; x++) {
for (int y = 0; y < 19; y++) {
for (int z = 0; z < 3; z++) {
setter.SetBlock(start + new Vec3<int>(x, y, z), Block.PowderSnow);
}
}
}
setter.SetBlock(start + new Vec3<int>(1, 19, 1), Block.JackOLantern);
}); |
|
@copilot This doesnt work when forks expand into different chunks, _pendingForkModifications is also not added to |
…ries Co-authored-by: CoPokBl <59753822+CoPokBl@users.noreply.github.com>
I've added more comprehensive tests in 9173389 for fork functionality spanning multiple chunks, and all 39 tests pass including:
Could you provide a specific test case that fails? The I'd like to understand the exact scenario that's failing so I can fix it correctly. |
ITerrainGeneratorextendITerrainProvider(per owner feedback)MinYproperty toITerrainGeneratorinterfaceITerrainProviderimplementation toLambdaTerrainGeneratorMultiChunkGenerationUnitforGetChunkscalls with multiple chunksGeneratorTerrainProviderclassForkedGenerationUnitto use array indices instead of copyingChunkGenerationModifierinstances inMultiChunkGenerationModifierIBlockSetterinterface for auto-expanding fork boundsFork(Action<IBlockSetter>)method toIGenerationUnitwith automatic bounds detectionAutoExpandingBlockSetterimplementationOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.