1.15.2 Beehive API

Discussion in 'Spigot Plugin Development' started by Donkelyn, Aug 23, 2020.

  1. Yo I'm tryna figure out bee api. What I wanna do is just detect when the honey level goes up by 1 and then set it to the max honey level. I honestly have no clue how to do this and can't find anything else online. Any help is appreciated thank you!

    Code (Text):
    public class beeKeeper implements Listener {

        public void bees(EntityEnterBlockEvent e) {
            Entity ent = e.getEntity();
            if (ent.getType() != EntityType.BEE) {
            Block b = e.getBlock();
            if (b.getType() != Material.BEEHIVE) {
            Beehive h = (Beehive) b;

        private void honeyCheck(Beehive h) {
            new BukkitRunnable() {
                public void run() {
                    int honey = h.getHoneyLevel();
                    if (honey > 0) {
                }.runTaskLater(main.plugin, 100);
    This is my current code and my output is 1, 3, 5 and then I get an error in the console. Is there any issues you can see that will fix the code?
    #1 Donkelyn, Aug 23, 2020
    Last edited: Aug 24, 2020
  2. Listen to EntityEnterBlockEvent and check for the honey-level of the bee-hive. You'll probably have to delay checking for the amount since I believe the honey-level will only be set after the bee enters the hive
  3. What would be the way I get the honey level as there isn't a method for that.

    NVM i had the wrong beehive imported thank you!
  4. Instead of delay, make a simple addition with the entity's honey and the hive's one.
    • Agree Agree x 1
  5. The issue I currently have is I cannot convert the e.getBlock into a Beehive object
  6. That's because Beehive extends BlockData, not Block. Also, because you're going to run into this later, once you've modified the Beehive you'll have to set the block's data - changes don't immediately take effect.
    • Agree Agree x 1