1.15.2 .getType() not working with BARREL

Discussion in 'Spigot Plugin Development' started by jacob123, Apr 7, 2021.

  1. When I use this code:
    Code (Java):
    @EventHandler(
                ignoreCancelled = true,
                priority = EventPriority.HIGH
        )
        public void onInteract(PlayerInteractEvent e) {
            if (e.getAction() == Action.PHYSICAL || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
                boolean allow = this.blockinteract(e.getPlayer(), e.getClickedBlock());
                e.getPlayer().sendMessage(e.getClickedBlock().getType().toString());
                if (!allow) {
                    e.setCancelled(true);
                }

            }
        }
    And I click on a Barrel I always get that the ClickedBlockType = AIR, but I clicked on a Barrel.
     
  2. SteelPhoenix

    Moderator

    do you specify an api version in the plugin.yml file?
     
  3. No
     
  4. Action.PHYSICAL may not mean what you think it does (the link is funny, I suggest you click it).

    The "OR" condition in the interact method leaves an eyebrow to be raised as well. I also don't understand the context of the this.blockinteract method, but if it too fires a PlayerInteractEvent, then that's asking for trouble, as well.