Skip to content

Commit

Permalink
fix(worldgen): fix a few bugs with fallentreefeature
Browse files Browse the repository at this point in the history
  • Loading branch information
CallMeEchoCodes committed Dec 12, 2024
1 parent b285f36 commit a9cc74c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"data": {
"Name": "minecraft:air"
},
"weight": 8
"weight": 6
},
{
"data": {
Expand All @@ -21,7 +21,7 @@
"west": "false"
}
},
"weight": 2
"weight": 4
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import dev.spiritstudios.hollow.block.PolyporeBlock;
import dev.spiritstudios.hollow.registry.HollowBlocks;
import dev.spiritstudios.specter.api.core.exception.UnreachableException;
import net.fabricmc.fabric.api.tag.convention.v2.ConventionalBlockTags;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
Expand Down Expand Up @@ -50,13 +52,13 @@ public boolean generate(FeatureContext<Config> context) {

for (int i = 0; i < size; i++) {
BlockPos pos = origin.offset(axis, i);
world.setBlockState(pos, state, Block.NOTIFY_LISTENERS);
world.setBlockState(pos, state, Block.NOTIFY_ALL);

if (world.isAir(pos.up())) {
BlockState top = config.topBlockProvider().get(random, pos.up());
world.setBlockState(pos.up(), top, Block.NOTIFY_LISTENERS);
world.setBlockState(pos.up(), top, Block.NOTIFY_ALL);
if (top.isOf(Blocks.MOSS_CARPET))
world.setBlockState(pos, state.withIfExists(HollowLogBlock.MOSSY, true), Block.NOTIFY_LISTENERS);
world.setBlockState(pos, state.withIfExists(HollowLogBlock.MOSSY, true), Block.NOTIFY_ALL);
}

Direction direction = switch (axis) {
Expand All @@ -66,13 +68,19 @@ public boolean generate(FeatureContext<Config> context) {
};

BlockPos sidePos = pos.offset(direction);
if (!world.isAir(sidePos) && !world.getBlockState(sidePos).isReplaceable()) continue;
BlockState sideState = world.getBlockState(sidePos);
if (!sideState.isAir() && !sideState.isReplaceable()) continue;
if (sideState.isOf(Blocks.TALL_GRASS) || sideState.isIn(BlockTags.TALL_FLOWERS)) continue;

world.setBlockState(
sidePos,
config.sideBlockProvider.get(random, sidePos)
.withIfExists(Properties.HORIZONTAL_FACING, direction),
Block.NOTIFY_LISTENERS
.withIfExists(Properties.HORIZONTAL_FACING, direction)
.withIfExists(Properties.NORTH, direction == Direction.SOUTH)
.withIfExists(Properties.SHORT, direction == Direction.NORTH)
.withIfExists(Properties.EAST, direction == Direction.WEST)
.withIfExists(Properties.WEST, direction == Direction.EAST),
Block.NOTIFY_ALL
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public static void bootstrap(Registerable<ConfiguredFeature<?, ?>> featureRegist
.add(Blocks.MOSS_CARPET.getDefaultState(), 5)
.build()),
new WeightedBlockStateProvider(DataPool.<BlockState>builder()
.add(Blocks.AIR.getDefaultState(), 8)
.add(Blocks.VINE.getDefaultState(), 2)
.add(Blocks.AIR.getDefaultState(), 6)
.add(Blocks.VINE.getDefaultState(), 4)
.build())
)
)
Expand Down

0 comments on commit a9cc74c

Please sign in to comment.