Skip to content

Commit

Permalink
huge pale mushrooms
Browse files Browse the repository at this point in the history
  • Loading branch information
AViewFromTheTop committed Jan 8, 2025
1 parent 919bf98 commit 8bf21d7
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"east": "true",
"north": "true",
"south": "true",
"up": "true",
"up": "false",
"west": "true"
}
}
},
"foliage_radius": 3,
"foliage_radius": 2,
"stem_provider": {
"type": "minecraft:simple_state_provider",
"state": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import net.frozenblock.wilderwild.config.WWAmbienceAndMiscConfig;
import net.frozenblock.wilderwild.entity.Tumbleweed;
import net.frozenblock.wilderwild.particle.options.WWFallingLeavesParticleOptions;
import net.frozenblock.wilderwild.worldgen.feature.configured.WWTreeConfigured;
import net.frozenblock.wilderwild.worldgen.feature.placed.WWMiscPlaced;
import net.frozenblock.wilderwild.worldgen.impl.sapling.WWTreeGrowers;
import net.minecraft.core.BlockPos;
Expand All @@ -90,7 +91,6 @@
import net.minecraft.core.registries.Registries;
import net.minecraft.data.BlockFamilies;
import net.minecraft.data.BlockFamily;
import net.minecraft.data.worldgen.features.TreeFeatures;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
Expand All @@ -111,9 +111,7 @@
import net.minecraft.world.level.block.FenceGateBlock;
import net.minecraft.world.level.block.FlowerBlock;
import net.minecraft.world.level.block.FlowerPotBlock;
import net.minecraft.world.level.block.HugeMushroomBlock;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.MushroomBlock;
import net.minecraft.world.level.block.PressurePlateBlock;
import net.minecraft.world.level.block.RotatedPillarBlock;
import net.minecraft.world.level.block.SaplingBlock;
Expand Down Expand Up @@ -766,7 +764,7 @@ public final class WWBlocks {
.ignitedByLava()
);
public static final PaleMushroomBlock PALE_MUSHROOM = register("pale_mushroom",
properties -> new PaleMushroomBlock(TreeFeatures.HUGE_RED_MUSHROOM, properties),
properties -> new PaleMushroomBlock(WWTreeConfigured.HUGE_PALE_MUSHROOM.getKey(), properties),
BlockBehaviour.Properties.of()
.mapColor(MapColor.COLOR_GRAY)
.noCollission()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1392,13 +1392,13 @@ public static void registerTreeConfigured(BootstrapContext<ConfiguredFeature<?,
BlockStateProvider.simple(
WWBlocks.PALE_MUSHROOM_BLOCK
.defaultBlockState()
.setValue(HugeMushroomBlock.UP, true)
.setValue(HugeMushroomBlock.UP, false)
.setValue(HugeMushroomBlock.DOWN, false)
),
BlockStateProvider.simple(
Blocks.MUSHROOM_STEM.defaultBlockState().setValue(HugeMushroomBlock.UP, false).setValue(HugeMushroomBlock.DOWN, false)
),
3
2
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,59 +16,70 @@ public HugePaleMushroomFeature(Codec<HugeMushroomFeatureConfiguration> codec) {
super(codec);
}

@Override
protected int getTreeHeight(@NotNull RandomSource randomSource) {
return randomSource.nextInt(3) + 4;
}

@Override
protected void makeCap(
LevelAccessor levelAccessor,
RandomSource randomSource,
BlockPos blockPos,
int i,
int height,
BlockPos.MutableBlockPos mutableBlockPos,
@NotNull HugeMushroomFeatureConfiguration hugeMushroomFeatureConfiguration
HugeMushroomFeatureConfiguration hugeMushroomFeatureConfiguration
) {
int radius = hugeMushroomFeatureConfiguration.foliageRadius;
for (int j = height - 1; j <= height + 1; j++) {
int radius = j < height + 1 ? hugeMushroomFeatureConfiguration.foliageRadius : hugeMushroomFeatureConfiguration.foliageRadius - 1;
int withinRadius = hugeMushroomFeatureConfiguration.foliageRadius - 2;

for (int x = -radius; x <= radius; x++) {
for (int l = -radius; l <= radius; l++) {
boolean negX = x == -radius;
boolean posX = x == radius;
boolean bl3 = l == -radius;
boolean bl4 = l == radius;
boolean bl5 = negX || posX;
boolean bl6 = bl3 || bl4;
if (!bl5 || !bl6) {
mutableBlockPos.setWithOffset(blockPos, x, i, l);
if (!levelAccessor.getBlockState(mutableBlockPos).isSolidRender()) {
boolean west = negX || bl6 && x == 1 - radius;
boolean east = posX || bl6 && x == radius - 1;
boolean north = bl3 || bl5 && l == 1 - radius;
boolean south = bl4 || bl5 && l == radius - 1;
BlockState blockState = hugeMushroomFeatureConfiguration.capProvider.getState(randomSource, blockPos);
if (blockState.hasProperty(HugeMushroomBlock.WEST)
&& blockState.hasProperty(HugeMushroomBlock.EAST)
&& blockState.hasProperty(HugeMushroomBlock.NORTH)
&& blockState.hasProperty(HugeMushroomBlock.SOUTH)) {
blockState = blockState.setValue(HugeMushroomBlock.WEST, west)
.setValue(HugeMushroomBlock.EAST, east)
.setValue(HugeMushroomBlock.NORTH, north)
.setValue(HugeMushroomBlock.SOUTH, south);
}
for (int m = -radius; m <= radius; m++) {
for (int n = -radius; n <= radius; n++) {
boolean onNegX = m == -radius;
boolean onPosX = m == radius;
boolean onNegZ = n == -radius;
boolean onPosZ = n == radius;
boolean onX = onNegX || onPosX;
boolean onZ = onNegZ || onPosZ;
boolean onCorner = onX && onZ;
boolean onEdge = onX || onZ;
if (j >= height + 1 || ((onX != onZ) || (j == height && !onCorner))) {
mutableBlockPos.setWithOffset(blockPos, m, j, n);
if (!levelAccessor.getBlockState(mutableBlockPos).isSolidRender()) {
BlockState blockState = hugeMushroomFeatureConfiguration.capProvider.getState(randomSource, blockPos);
if (blockState.hasProperty(HugeMushroomBlock.WEST)
&& blockState.hasProperty(HugeMushroomBlock.EAST)
&& blockState.hasProperty(HugeMushroomBlock.NORTH)
&& blockState.hasProperty(HugeMushroomBlock.SOUTH)
&& blockState.hasProperty(HugeMushroomBlock.UP)
) {
boolean hasUpState = j >= height + 1 || (onEdge && j == height);
blockState = blockState
.setValue(HugeMushroomBlock.UP, hasUpState)
.setValue(HugeMushroomBlock.WEST, m < -withinRadius)
.setValue(HugeMushroomBlock.EAST, m > withinRadius)
.setValue(HugeMushroomBlock.NORTH, n < -withinRadius)
.setValue(HugeMushroomBlock.SOUTH, n > withinRadius);
}

this.setBlock(levelAccessor, mutableBlockPos, blockState);
this.setBlock(levelAccessor, mutableBlockPos, blockState);
}
}
}
}
}
}

@Override
protected int getTreeRadiusForHeight(int i, int j, int radius, int height) {
int finalRadius = 0;
if (height < j && height >= j - 3) {
finalRadius = radius;
} else if (height == j) {
finalRadius = radius;
protected int getTreeRadiusForHeight(int i, int j, int k, int l) {
int m = 0;
if (l < j + 1 && l >= j - 1) {
m = k;
} else if (l == j) {
m = k;
}

return finalRadius;
return m;
}
}

0 comments on commit 8bf21d7

Please sign in to comment.