How to make a tree insta-grow?

Discussion in 'Plugin Development' started by Eliteninja42, Feb 24, 2014.

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

    Eliteninja42

    This is what I have but it won't work.
    Code:
      @EventHandler
            public void onPlayerInteract1(BlockPlaceEvent e) {
              Player player = e.getPlayer();
                Block block = e.getBlockPlaced();
                  if (Cultivator.contains(player.getName())){
                      if(block.getType() == Material.SAPLING) {
                          Location bloc = block.getLocation();
                          bloc.getWorld().generateTree(bloc, TreeType.TREE);
                          }
                  }
              }         
          }
     
  2. Offline

    CrazyGuy3000

    try "e.getLocation()"
     
  3. Offline

    Eliteninja42

    CrazyGuy3000 Undefined type for BlockPlaceEvent

    Code:
    if (Cultivator.contains(player.getName())){
                      if(e.getBlock() == Block.SAPLING){
                            World world = e.getBlock().getWorld();
                            Location loc = e.getBlock().getLocation();
                            world.generateTree(loc, TreeType.TREE);
    why is block.sapling wrong

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  4. Offline

    Eliteninja42

    Im_Zeus I figured out the tree. Now i'm stuck on making seeds insta grow....
     
  5. Offline

    Alshain01

    Because Block is not an enum. You had it right the first time.

    Hmm, from what I can tell there does not appear to be any API for "growable" blocks. Unfortunate really, that would be useful. Maybe someone else might know where to find it.

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

    Eliteninja42

    Alshain01 I've seen people do it before I just don't know how....
     
  7. Eliteninja42 Why not just set the block to wheat, or whatever?
     
  8. Offline

    Alshain01

    It's probably Metadata, but I can't tell you what it would be.
     
  9. Offline

    maxben34

    Alshain01
    That is correct. Idk either :p

    Simple solution would be to just replace the seeds with hay bails instead :).
     
  10. Offline

    CrazyGuy3000

    Hay bails? why..?
     
  11. Offline

    maxben34

    I'm pretty sure Hay Bails are 4 wheat... so it would be 1 seed = 4 wheat....
     
  12. Offline

    CrazyGuy3000

    9 Wheat* but you can probably change that with a custom recipe ;) *nudge*
     
  13. Offline

    Eliteninja42

    Lol well I need wheat not hay bails

    Does anyone know how to make a seed a piece of wheat instanly?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  14. Offline

    xize

    for wheat could you not use setData? and not the setData from getState but the one from Block.setData() ?
     
  15. Offline

    Eliteninja42

    xize How do you properly use this
     
  16. Offline

    xize

    Eliteninja42
    try doing Block.setData((Byte)1); and see if it changes since theres no api I think you need to look or in Block.setData() or the setData in the BlockState
     
  17. Offline

    Eliteninja42

    xize Can you show an example. I can't get it to work.
     
  18. Offline

    xize

    well ill give it a try but I'm clueless if it works:

    Code:
    @EventHandler
    public void onPlace(BlockPlaceEvent e) {
       if(e.getBlock().getType() == Material.SEEDS) {
          e.getBlock().setIdAndData(Material.SEEDS, (Byte) 8, true);
       }
    }
    
    typed from my iphone, some methods are may wrong spelled
     
  19. Offline

    Conarnar

    Seeds aren't blocks so BlockPlaceEvent isn't good for this. Try PlayerInteractEvent instead.
     
  20. Offline

    xize

  21. Offline

    Eliteninja42

    What about pumpkins and melons they are the only ones I can't get.
     
Thread Status:
Not open for further replies.

Share This Page