"Melt" snow when above certain light level?

Discussion in 'Plugin Development' started by thehutch, Aug 11, 2011.

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

    thehutch

    I'm having issues with set snow to air when it is encounters light above 7. Also I want to be slow rather than all at once.
    I've tried get the block below the player and the chunk and setting snow to air but it isn't working.

    Heres the code.

    Code:
        @Override
        public void onPlayerMove(PlayerMoveEvent event) {
    
            Player player = event.getPlayer();
            Block block = player.getLocation().getBlock();
            Chunk b = block.getChunk();
            double blockX = player.getLocation().getX();
            double blockZ = player.getLocation().getZ();
            double blockY = player.getLocation().getY();
            byte lightLevel = block.getLightLevel();
     
            if ( block.getType() == Material.SNOW  && lightLevel > 7 || b.getChunkSnapshot().equals(Material.SNOW) && lightLevel > 7) {
                    block.setTypeId(0);
    
            }
            }
        }
    Yes I know I haven't used all the variables but I don't know how to get a radius

    Could anyone help? been trying all day.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 18, 2016
  2. Offline

    s1mpl3x

    i don't know what you are doing with that chunkSnapshot... and didn't read the whole think but as far as is understand it i think your error is in your if condition.

    Code:
            if (( block.getType() == Material.SNOW  && lightLevel > 7) || (b.getChunkSnapshot().equals(Material.SNOW) && lightLevel > 7)) {
                    block.setTypeId(0);
    
            }
     
  3. Offline

    thehutch

    Oh hey simplex any idea on how I should fix it?
     
  4. Offline

    s1mpl3x

    i changed the part i interpreted as wrong in the post above
     
  5. Offline

    thehutch

    Hmm ok well 50% works kinda, when you walk over it the snow turns to air but not anything else only when you walk over it.

    I want it so the snow melts slow if the lightlevel is above 7
     
  6. Offline

    s1mpl3x

    hm ok i guess you want to keep onPlayerMove as a trigger and clear the snow in that chunk the player currently is.
    A way to do this would be to get all snow block in that chunk, put em in a list and then start a delayed task that removes the snow one after the other (in a rnd order so it looks better) and if the list is empty, kill the task. If you do it like that you have to ensure that such a task and list is only generated once for a chunk.
     
  7. Offline

    thehutch

    Ok so here are the variables I have do I need anything else?

    @Override
    public void onPlayerMove(PlayerMoveEvent event) {

    Player player = event.getPlayer();
    Block playersFeet = player.getLocation().getBlock().getRelative(0,-1,0);
    Block blockBelowPlayer = player.getLocation().getBlock().getRelative(BlockFace.DOWN);
    Chunk chunk = player.getWorld().getChunkAt(blockBelowPlayer);
    byte lightLevelOfPlayersFeet = playersFeet.getLightLevel();
    byte lightLevelOfBlockBelowPlayer = blockBelowPlayer.getLightLevel();
     
Thread Status:
Not open for further replies.

Share This Page