1.16.5 Get Inventory of Existing StoneCutter.

Discussion in 'Spigot Plugin Development' started by TurtlesAreHot, Feb 28, 2021.

  1. Hello. I have been here today researching on how I can get the inventory of an existing stonecutter. I want to prevent an item with specific nbt data from being able to be used in a stonecutter. I believe the way I want to currently do is basically check the inventory, check if the items in the stonecutter slot have nbt data then set the results to nothing if it does have that nbt data.

    I have not found much online at the moment and there doesn't seem to be any events for this. Is there some other way to achieve this?
  2. It can be kind of painful, but the just is you want to use InventoryClickEvent.
    Check if the inventory is a STONECUTTER, then check if the click results in the item with the NBT tag being placed in the stone cutter (there are many ways to do this, make sure you cover all ClickTypes.
    You can use InventoryClickEvent#getCursor() or InventoryClickEvent#getCurrentItem() to check if the item with the NBT tag is involved in the click.

    I'm sure you can cancel the NBT item from being placed in the stonecutter in the first place. I am not sure (but pretty confident) that you can set the result to nothing when the NBT item is placed in the stonecutter by casting the stonecutter inventory to a StonecutterInventory or something like that.