Make Sponge to grow crops, like a bonemeal

Discussion in 'Plugin Development' started by itsss, Nov 8, 2017.

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



    I want to make Sponge Block when i right click on crops, (the sponge block is not for install) I want to make crops grows. like a bonemeal.

    Anyone has idea to make this code??? Please help me...
  2. Offline


    well stems and wheat have their setData() method to set the age of the plant. age is between 0 and 7. so you can get the data and add a random value to it and set it to Math.min(7, data) and then set the data back again.
    But I have not quiet an idea how to make grass and flowers grow if you click the ground
  3. Offline


    1 - Check for PlayerInteractEvent and check the type of block clicked using PlayerInteractEvent#getClickedBlock() and Block#getType().
    2 - If the type is grass or wheat or any other type of plant, check the material of the item in a player's hand.
    3 - If material in player's hand is a sponge, use the Block#setData() method referred by MightyOne to modify the clicked block you obtained in step 1.
    4 (optional) - If you want to, you can consume the sponge block by using the method Player#getInventory().removeItem(ItemStack item) method.
Thread Status:
Not open for further replies.

Share This Page