Inspired by 2020's April Fools' 20w14infinite Snapshot, this mod brings endless randomly generated dimensions into Minecraft.
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 RandomFlatMushroomFeature extends RandomMushroomFeature {
10 public RandomFlatMushroomFeature(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 int i = config.foliageRadius();
17 for (int j = -i; j <= i; ++j) {
18 for (int k = -i; k <= i; ++k) {
19 boolean bl = j == -i;
20 boolean bl2 = j == i;
21 boolean bl3 = k == -i;
22 boolean bl4 = k == i;
23 boolean bl5 = bl || bl2;
24 boolean bl6 = bl3 || bl4;
25 if (bl5 && bl6) continue;
26 mutable.setWithOffset(start, j, y, k);
27 if (world.getBlockState(mutable).isSolidRender(
28 //? if <1.21.2
29 /*world, mutable*/
30 )) continue;
31 BlockState blockState = config.capProvider().getState(random, start);
32 this.setBlock(world, mutable, blockState);
33 }
34 }
35 }
36
37 @Override
38 protected int getCapSize(int i, int j, int capSize, int y) {
39 return y <= 3 ? 0 : capSize;
40 }
41}