1.16.5 How to check if a crop is fully grown

Discussion in 'Spigot Plugin Development' started by CoderBoyo, Jun 15, 2021.

  1. There are plenty of methods out there that are from 2016 and are all decapricated, so how do you do it now days? (yes i know you can still use those i just don't like doing that)

    One more thing my jar file seems unreasonably large almost 40 megabytes. I think that its somehow including the spigot jar in my jar. I use intellij how do i fix this?
  2. Alright I can answer question 1;
    You can do this by getting the wheats 'age', this is done with:
    Code (Java):
    Ageable ageable = (Ageable) block.getBlockData();
    if (ageable.getAge() == 7) {
        //Fully grown, Do stuff
    As you can see if the wheats 'age' is 7 it will pass through the if operator, thats because wheats fully grown age is age 7,
    We can simply check if the wheats age is 7 to see if its fully grown
    #2 ItsUhFinn, Jun 15, 2021
    Last edited: Jun 15, 2021
    • Agree Agree x 1
  3. what do you get the full grown age of other crops that aren't wheat?
  4. Most crops fully grown age is 7
    #4 ItsUhFinn, Jun 15, 2021
    Last edited: Jun 15, 2021
  5. oh ty
  6. It works just the same way, you can see everything that is ageable by searching for it in the javadocs.
    For example bamboo: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/block/data/type/Bamboo.html
    If it extends Ageable then you can cast it to Ageable and get the age.

    Then, about your IntelliJ problem. Inside of your module settings and under dependencies you should see a server jar assuming you aren't using maven or gradle. If you see that make sure the dropdown next to it is set to provided or not to include, if there isn't anything of that nature in the dropdown you can send a screenshot of the options.
    If you're exporting the plugin with what I believe is called the 'Artifacts' section in IntelliJ make sure that the spigot jar isn't included in that build. If you have anything under the artifacts tab send a screenshot of that also.
  7. Excluding nether wart, melon, pumpkin, cocoa beans, saplings, sweet berries, etc.

    Instead of checking against an abatrity number, check using Ageable#getMaximumAge
  8. Thanks! everthing works now
    (exept the file size)
  9. Um just did some testing and it only works on wheat even when i use ageable.getMaximumAge
  10. Yeah thats correct, I didnt think about some of them, And #getMaximumAge is a lot more efficient
    Just a note though, Melons, Pumpkins and sweet berries Maximum Age is 7


    What other crop are you trying it on
  11. Did you even read the second half of my message? I wrote it all to try and help you with that.
  12. I am using maven
  13. Could you share your pom.xml? You should have <scope>provided</scope> in the spigot dependency.
  14. Code (Text):
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">