Your mod is probably lagging during world generation due to how it replaces blocks around your custom ore. Right now, it randomly picks spots around the ore and changes blocks there. This process can be slow, especially if it's dealing with lots of blocks or a big area. To fix it, try replacing fewer blocks, picking spots more efficiently, and changing blocks in a smarter way. This should help your mod run smoother when generating worlds. Here is an example of how you can do this
// Inside the if (placed) block
if (placed) {
BlockState surroundingBlockState = BlockInit.ABERRANT_MINERALOID.get().defaultBlockState();
int veinSize = ctx.config().size;
int maxBlocksToReplace = (int) Math.ceil(veinSize * 0.1); // Replace 10% of vein size
int numBlocksToCorrupt = Math.min(maxBlocksToReplace, 1000); // Limit to 1000 blocks
List<BlockPos> positionsToReplace = new ArrayList<>();
// Loop until reaching the limit of blocks to replace
while (positionsToReplace.size() < numBlocksToCorrupt) {
BlockPos randomPos = offsetOrigin.offset(
ctx.random().nextInt(2 * areaSizeX + 1) - areaSizeX,
ctx.random().nextInt(2 * areaSizeY + 1) - areaSizeY,
ctx.random().nextInt(2 * areaSizeZ + 1) - areaSizeZ
);
if (world.getBlockState(randomPos).is(ModBlockTags.STONE_ABERRANTABLE)) {
positionsToReplace.add(randomPos);
}
}
// Replace blocks in bulk
for (BlockPos pos : positionsToReplace) {
world.setBlock(pos, surroundingBlockState, 2);
}
}
If you've tried more effective ways to generate your blocks around your ores, it may also be because of issues on your side, not the mod. Adjust the parameters as needed based on your performance testing and requirements.