how would you get the nbt of a block that a item is on

Discussion in 'Plugin Development' started by Cat 700, Mar 11, 2020.

Thread Status:
Not open for further replies.
  1. Offline

    Cat 700

    I want to get the nbt of a block but only if a certain type of item is dropped on that block. the block is a spawner so it does have nbt. also I want to get what it is spawning and nothing else
     
  2. Offline

    Machine Maker

    There are some threads out there talking about getting NBT data from tile entities (blocks don't have NBT data, tile entities do). As for getting the location to check, you can listen to the event when a player drops an item, and get the location of the item.
     
  3. Offline

    Cat 700

    but how would I get the block the item is on would it just be item.getlocation.getY and then -1 and say location.getblock or something like that?
     
  4. Offline

    Machine Maker

    Yeah, that sounds about right. Do item#getLocation()#getBlock()#getRelative(BlockFace.DOWN) to get the block tho. I think that is probably better than subtracting 1 from Y.
     
    Kars likes this.
Thread Status:
Not open for further replies.

Share This Page