Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-991

Ticket SPIGOT-764 broke BlockPlaceEvent trigger logic

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
    • None

      The way ticket SPIGOT-764 was implemented has not only made it possible to cancle monster egg usage via the useItemInHand flag of the PlayerInteractEvent, but also changed the behavior of when a BlockPlaceEvent gets triggered.

      I found this out after having to crawl through the latest commits and spigot source code and debugging one of my plugins which relied on the old behavior.

      Previously one could deny item usage (to prevent usage of 'special' items like lighters, throwable projectiles, dyes, bone meal, buckets, ... etc.) and still got the BlockPlaceEvent for normal placeable blocks.
      This allowed handling of block placement separately from item usage, with the advantage that one would be able to detect if and how a block would normally going to be placed by minecraft (one would get a BlockPlaceEvent if minecraft would place a block, and one would have all the information provided by the BlockPlaceEvent, like replaced block, etc.).

      Now, if you want to deny usage of those special items but still want to allow, detect or otherwise handle block placements, you have to figure this out yourself inside the interact event already, so that you don't accidently deny item usage there already for those placeable blocks.

      First I thought this might not be a big deal: checking if the Material of the item in hand in the PlayerInteractEvent isBlock() and then not deny item usage. However there are a bunch of other, non-block items which are placeable (which trigger BlockPlaceEvents), like the flower pot item, various doors, etc. etc.
      So now it becomes more difficulty to figure out whether an item is placeable or not, in a way which doesn't require updating of the plugins everytime new placeable items are added to minecraft.

      So I suggest to either revert the change from ticket 764 and solve that differently: maybe by having a special case for monster eggs, because they seem to be the only case (I currently know of) which need to also handle part of their item usage inside the item placement logic.

      Or another solution would maybe be to add something like Material#isPlaceable() to the API.

      Though I would prefer the first solution (reverting 764 and solving that differently), as that would mean that old plugins, which rely on the old behavior, wouldn't need to depend on the very latest spigot build because of that api addition only being available there.

            Unassigned Unassigned
            blablubbabc blablubbabc
            Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: