Skip to content

Commit

Permalink
Hopefully make permafrost replace less blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
quat1024 committed Dec 21, 2023
1 parent 89d8d05 commit 228f8b1
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;

import net.minecraft.world.level.levelgen.Heightmap;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.base.handler.MiscUtil;
import org.violetmoon.quark.content.world.undergroundstyle.base.UndergroundStyleGenerator.Context;

import java.util.function.Predicate;

public abstract class UndergroundStyle {

private static final TagKey<Block> fillerTag = BlockTags.create(new ResourceLocation(Quark.MOD_ID, "underground_biome_replaceable"));
public static final Predicate<BlockState> UNDERGROUND_BIOME_REPLACEABLE = state -> state != null && state.is(fillerTag);
private static final TagKey<Block> UNDERGROUND_BIOME_REPLACEABLE = BlockTags.create(new ResourceLocation(Quark.MOD_ID, "underground_biome_replaceable"));

public boolean canReplace(BlockState state) {
return state.canBeReplaced() || state.is(UNDERGROUND_BIOME_REPLACEABLE);
}

public final void fill(Context context, BlockPos pos) {
LevelAccessor world = context.world;
Expand All @@ -43,24 +43,26 @@ else if(isInside(state))
public abstract void fillWall(Context context, BlockPos pos, BlockState state);
public abstract void fillInside(Context context, BlockPos pos, BlockState state);

//nb. checking isSolidRender so that air doesn't count as a floor or wall etc

public boolean isFloor(LevelAccessor world, BlockPos pos, BlockState state) {
if(!state.isSolidRender(world, pos))
if(!state.isSolidRender(world, pos) || !canReplace(state))
return false;

BlockPos upPos = pos.above();
return world.isEmptyBlock(upPos) || world.getBlockState(upPos).canBeReplaced();
}

public boolean isCeiling(LevelAccessor world, BlockPos pos, BlockState state) {
if(!state.isSolidRender(world, pos))
if(!state.isSolidRender(world, pos) || !canReplace(state))
return false;

BlockPos downPos = pos.below();
return world.isEmptyBlock(downPos) || world.getBlockState(downPos).canBeReplaced();
}

public boolean isWall(LevelAccessor world, BlockPos pos, BlockState state) {
if(!state.isSolidRender(world, pos) || !UNDERGROUND_BIOME_REPLACEABLE.test(state))
if(!state.isSolidRender(world, pos) || !canReplace(state))
return false;

return isBorder(world, pos);
Expand All @@ -84,7 +86,7 @@ public boolean isBorder(LevelAccessor world, BlockPos pos) {
}

public boolean isInside(BlockState state) {
return UNDERGROUND_BIOME_REPLACEABLE.test(state);
return state.is(UNDERGROUND_BIOME_REPLACEABLE);
}

}

0 comments on commit 228f8b1

Please sign in to comment.