Inspired by 2020's April Fools' 20w14infinite Snapshot, this mod brings endless randomly generated dimensions into Minecraft.
at master 49 lines 1.8 kB view raw
1package net.lerariemann.infinity.features; 2 3import com.mojang.serialization.Codec; 4import net.minecraft.core.BlockPos; 5import net.minecraft.util.RandomSource; 6import net.minecraft.world.level.LevelAccessor; 7import net.minecraft.world.level.block.state.BlockState; 8 9public class RandomRoundMushroomFeature extends RandomMushroomFeature { 10 public RandomRoundMushroomFeature(Codec<Config> codec) { 11 super(codec); 12 } 13 14 @Override 15 protected void generateCap(LevelAccessor world, RandomSource random, BlockPos start, int y, BlockPos.MutableBlockPos mutable, Config config) { 16 for (int i = y - 3; i <= y; ++i) { 17 int j = i < y ? config.foliageRadius() : config.foliageRadius() - 1; 18 for (int l = -j; l <= j; ++l) { 19 for (int m = -j; m <= j; ++m) { 20 boolean bl = l == -j; 21 boolean bl2 = l == j; 22 boolean bl3 = m == -j; 23 boolean bl4 = m == j; 24 boolean bl5 = bl || bl2; 25 boolean bl6 = bl3 || bl4; 26 if (i < y && bl5 == bl6) continue; 27 mutable.setWithOffset(start, l, i, m); 28 if (world.getBlockState(mutable).isSolidRender( 29 //? if <1.21.2 30 /*world, mutable*/ 31 )) continue; 32 BlockState blockState = config.capProvider().getState(random, start); 33 this.setBlock(world, mutable, blockState); 34 } 35 } 36 } 37 } 38 39 @Override 40 protected int getCapSize(int i, int j, int capSize, int y) { 41 int k = 0; 42 if (y < j && y >= j - 3) { 43 k = capSize; 44 } else if (y == j) { 45 k = capSize; 46 } 47 return k; 48 } 49}