Determine if Carrots and Tatters are grown

Discussion in 'Plugin Development' started by Diemex, Aug 27, 2014.

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

    Diemex

    I'm trying to determine if crops including carrots and potatoes have fully grown. Following code works but not for carrots and potatoes.

    Code:java
    1. @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
    2. public void onBlockGrow(BlockGrowEvent event)
    3. {
    4. MaterialData newDataValue = event.getNewState().getData();
    5. if (newDataValue instanceof Crops)
    6. if (((Crops) newDataValue).getState() == CropState.RIPE) //this line is never reached for carrots or potatoes
    7. {
    8. //Do something
    9. }
    10. }


    For carrots and potatoes it seems like the MaterialData returned for the new state is just that MaterialData and not Crops. For Wheat Crops is returned which is a sublass of MaterialData and has all the Data in nice enums. Is this a bug or am I missing something?

    Of course I could do the quick hackerino and just compare the datavalues. But with the upcoming update I would prefer not having hardcoded ids and datavalues floating around in my code.
     
  2. Offline

    fireblast709

    Diemex right now hackerino seems to be the only method
     
Thread Status:
Not open for further replies.

Share This Page