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

BlockDispenseEvent should have getEntity() and getBlockState() method

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
    • None
    • -
    • Yes

      BlockDispenseEvent only has a method to get the ItemStack that caused this event, but no method to get the "resulting" Entity spawned, which could be an Item, or e.g. a Boat/Minecart, or even a BlockState (e.g. when water is placed).

       

      Is there any reason why this currently does not exist? I've seen a lot of "DispenseBehavior" classes in NMS. I think it'd be nice if they could somehow be exposed to the API, e.g. through two methods being added to BlockDispenseEvent:

       

      /**
      * Gets the entity spawned through this BlockDispenseEvent, or null if there is none
      */
      public @Nullable Entity getEntity();
      
      /**
      * Gets the BlockState that will be created/changed through this BlockDispenseEvent, or null if there is none
      */
      public @Nullable BlockState getNewBlockState();

      Any opinions on this?

       

      EDIT: lynx just reminded me, that the ItemStack being dispensed is changeable, so obviously it's not possible to get the resulting Entity/BlockState in this event yet, however there could maybe a separate BlockDispensedEvent, maybe split up into BlockDispensedEntityEvent and BlockDispensedBlockEvent, that could be used to get the result instead.

            Unassigned Unassigned
            mfnalex mfnalex
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: