Solved Speed up crop growth?

Discussion in 'Plugin Development' started by Hex_27, Feb 21, 2015.

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

    Hex_27

    I'm trying to get crops nearby a specific block to grow faster by using this code:
    Code:
    //this checks if there's a special block nearby
            if(hasNearbyGModel(event.getBlock(), 1) != null){
                //this checks the block's kind
                if(hasNearbyGModel(event.getBlock(), 1) == Material.IRON_BLOCK){
                   
                    event.getBlock().setData((byte) (event.getNewState().getRawData() + (byte) 1));
    
                    //this checks the block's kind
                }else
    if(hasNearbyGModel(event.getBlock(), 1) == Material.GOLD_BLOCK){
                   
                    event.getBlock().setData((byte) (event.getNewState().getRawData() + (byte) 2));
                   
    //this checks the block's kind
                }else if(hasNearbyGModel(event.getBlock(), 1) == Material.EMERALD_BLOCK){
                   
                    event.getBlock().setData((byte) (event.getNewState().getRawData() + (byte) 3));
                   
                }
               
            }
    So basically, I'm using BlockGrowEvent to do this, and attempting to change the plant's data to let it grow
     
  2. BlockGrowMethod, get the blocks data, increase by 1, set.

    Code:
        @EventHandler
        public void on(BlockGrowEvent e) {
            e.getBlock().setData((byte) (e.getBlock().getData() + 1));
        }
    Untested, but should increase growth rate by 2x?

    Try it. You may also want to check if the block is fully grown or not first, to avoid over-setting the data value.
     
  3. Offline

    Hex_27

Thread Status:
Not open for further replies.

Share This Page