Solved Spawn RIPE seed

Discussion in 'Spigot Plugin Development' started by JeckBiagio_, Jul 23, 2018.

Thread Status:
Not open for further replies.
  1. Hi, i've tried to spawn a ripe seed but spawns a normal one; This is the method that i use:
    Code (Java):
    Block b = player.getLocation().getBlock();
            b.setType(Material.CROPS);
            Crops c = (Crops) b.getState().getData();
            c.setData(CropState.RIPE.getData());
     
  2. Not sure but I think you need to update it's state after setting the data.
     
  3. You know how?
     
  4. Sure, it's Block#getState#update.
     
  5. Thanks
     
  6. Make sure to mark the thread as solved if you have no further issues.
     
  7. Doesn't work; the crop doesn't grow
     
  8. Try:
    Code (Java):

    Block b = player.getLocation().getBlock();
            b.setType(Material.CROPS);
    BlockState c = (Crops) b.getState();
            c.setState(CropState.RIPE);
    // update state
     
     
    #8 darklazerog, Jul 23, 2018
    Last edited: Jul 23, 2018
  9. Code (Java):
    Block b = player.getLocation().getBlock();
    b.setType(Material.CROPS);
    BlockState state = b.getState();
    Crops c = (Crops) state.getData();
    c.setData(CropState.RIPE.getData());
    state.setData(c);
    state.update();
    You need to hold on to the blockstate and modify that, once you've finished your modification then you do the update() call.
     
    • Agree Agree x 1
  10. It works. Thanks
     
Thread Status:
Not open for further replies.