Skip to content

Commit

Permalink
made rocks try to get the stone below if what's it's on isn't one
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Sep 14, 2023
1 parent b341457 commit dc73eb5
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,22 @@ public static boolean addOre(LevelAccessor world, BlockPos pos, Material materia

public static boolean addRock(LevelAccessor world, BlockPos pos, Material material, int chance) {
int y = Math.min(world.getHeight(Heightmap.Types.OCEAN_FLOOR, pos.getX(), pos.getZ()), world.getHeight(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, pos.getX(), pos.getZ()));
BlockState state = world.getBlockState(new BlockPos(pos.getX(), y - 1, pos.getZ()));
BlockState state = getStoneStateForRock(y - 1, pos, world);
return setRock(world, new BlockPos(pos.getX(), y, pos.getZ()), material, state, chance);
}

private static BlockState getStoneStateForRock(int y, BlockPos pos, LevelAccessor world){
BlockState fill = world.getBlockState(new BlockPos(pos.getX(), y, pos.getZ()));
StoneType stone = STONE_MAP.get(fill);
if (stone == AntimatterStoneTypes.BEDROCK){
return fill;
}
if (stone == null || !stone.doesGenerateOre()){
return getStoneStateForRock(y - 1, pos, world);
}
return fill;
}

/**
* Replaces the block at the given position with a surface rock block for the
* specified material.
Expand Down

0 comments on commit dc73eb5

Please sign in to comment.