Howto see if a block is wet from rain

Discussion in 'Plugin Development' started by zwarmapapa, Feb 23, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    zwarmapapa

    The title says it all, how do I check if a block is wet from rain?
    How does minecraft check if a farmland should get wet or not when it is raining?

    Currently I'm using getLightFromSky(), but that won't work with glass blocks.

    Does anyone got a good idea how to check if a block is (or will be) wet from rain?
     
  2. Offline

    ZNickq

    check if it's the highest non-air block at those x y coordinates :)
     
  3. Offline

    Pandemoneus

    And check whether it's in a desert biome. :p
     
  4. Offline

    zwarmapapa

    Yeah, it's checking if it's in a desert/taiga/tundra.


    That would give strange things, like when there is a ladder above, but this gave me an idea.
    I guess I'll check if there is any glass block above, and else use the sunlight-level <= 12, that would fix both problems.
    Thanks :p
    Edit: only checking the 3 blocks above seems more realistic (since rain also move sideways a little bit), and besides that, it's also allot faster to check.

    Edit2: but this gives me another problem, when you've made a house of glass, 10 high, then rain shouldn't be able to get in it either...
    Code:
    [][][][][][][][][][]
    []                []
    []                []
    []                []
    []                []
    []                []
    []                []
    []                []
    []                []
    []                []
    []        i       []  (i is my torch)
    
    So, how is minecraft checking if it should wet farmland?
     
  5. Offline

    Milkywayz

    Well why would farmland get wet when theres a roof above it? This kinda encourages above ground farms not to mention its realistic..
     
  6. Offline

    nisovin

    Minecraft starts at the top of the world, then scans downward until it finds the first solid or liquid block. Then it checks if that block is higher than the soil block. If it is, then the soil gets no water.
     
  7. Offline

    zwarmapapa

    Ah ok, thanks.
     
  8. Offline

    ferrybig

    Code:java
    1. Block toCheck;
    2. boolean isWetFromRain = toCheck.getHighestBlockAt(toCheck.getX(),toCheck.getZ()).getY() != toCheck.getY();
     
  9. Offline

    zwarmapapa

    ehm....
    Isn't it this?
    Code:java
    1. boolean sheltered = ( toCheck.getWorld().getHighestBlockAt( toCheck.getLocation ).getY() > toCheck.getY() );
     
Thread Status:
Not open for further replies.

Share This Page