Skip to content

🦇 Bat Ecology, Photophobia & Daytime Roosting ​

Feature ParameterSpecification Details
Primary AI Goal Classnet.vanillaoutsider.betterbats.ai.BatSleepGoal
Roost Validator Classnet.vanillaoutsider.betterbats.ai.BatRoostHelper
Daytime Sky Light LimitSky Light = 0
Daytime Block Light LimitBlock Light <= 7
Roost Search Radius16 blocks (Horizontal) / 10 blocks (Vertical)
Cluster PreferencePrefers roosting within 5x3x5 blocks of existing resting bats
Supported Roost SurfacesSolid ceilings, stalactites, lanterns, chains, fences, walls, leaves

☀️ Daytime Photophobia Mechanics ​

Unlike vanilla Minecraft where bats randomly fly regardless of time or daylight, Better Bats introduces Photophobia. During daylight hours (level.isBrightOutside()) or when raining while exposed to sky (level.isRaining() && level.canSeeSky(pos)), bats actively seek out dark cave overhangs or covered roosting spots.

                  ┌────────────────────────┐
                  │   Daylight / Storm     │
                  └───────────┬────────────┘
                              │
                    Can see sky / Bright?
                     ┌────────┴────────┐
                    YES                NO
                     │                 │
           ┌─────────▼────────┐  ┌─────▼────────┐
           │ Seek Dark Cover  │  │ Check Roost  │
           │  (BatSleepGoal)  │  │ Surface Type │
           └─────────┬────────┘  └─────┬────────┘
                     │                 │
             Sky Light == 0 &&         │
             Block Light <= 7?         │
                     │                 │
           ┌─────────▼─────────────────▼────────┐
           │     Attach Ceiling & Sleep         │
           │        (setResting(true))          │
           └────────────────────────────────────┘

🪨 Valid Roosting Surfaces (BatRoostHelper) ​

Roosting is evaluated via BatRoostHelper.isSuitableRoost(Level level, BlockPos pos, BlockPos above):

  1. Solid Ceiling Blocks: Any block with a sturdy bottom face (aboveState.isFaceSturdy(level, above, Direction.DOWN)) or redstone conductor.
  2. Pointed Dripstone / Speleothem: Stalactite tips pointing downwards (SpeleothemBlock.TIP_DIRECTION == Direction.DOWN).
  3. Hanging Lanterns: Lanterns suspended from ceilings (LanternBlock.HANGING == true).
  4. Hanging Chains & Supports: Blocks tagged under #minecraft:chains, #minecraft:fences, #minecraft:walls, and #minecraft:leaves.
java
public static boolean isSuitableRoost(Level level, BlockPos pos, BlockPos above) {
    if (!level.isEmptyBlock(pos)) return false;
    BlockState aboveState = level.getBlockState(above);
    if (aboveState.isAir()) return false;

    if (aboveState.isFaceSturdy(level, above, Direction.DOWN) || aboveState.isRedstoneConductor(level, pos)) return true;
    if (aboveState.getBlock() instanceof SpeleothemBlock || aboveState.getBlock() instanceof PointedDripstoneBlock) {
        if (aboveState.hasProperty(SpeleothemBlock.TIP_DIRECTION) && aboveState.getValue(SpeleothemBlock.TIP_DIRECTION) == Direction.DOWN) return true;
    }
    if (aboveState.getBlock() instanceof LanternBlock && aboveState.getValue(LanternBlock.HANGING)) return true;
    return aboveState.is(BlockTags.CHAINS) || aboveState.is(BlockTags.FENCES) || aboveState.is(BlockTags.WALLS) || aboveState.is(BlockTags.LEAVES);
}

🦇 Roost Clustering Behavior ​

When a bat decides to sleep, it scans a 16-block bounding box for already resting bats. If resting bats are present, it prioritizes selecting a candidate roost block offset within a 5x3x5 neighborhood of its fellow bats, creating natural colony clusters on cave ceilings and under dark structures.


Official documentation & web portal for Dasik Igaijinn mods.