Jump to content

Container ItemAdd and ItemRemove Events


claymore1977

Recommended Posts

Greetings all.  First off, I apologize in advance if this has been answered elsewhere, but after a good bit of searching I cannot find what I am looking for.  I suspect this is because of a massive failure to understand a key concept on my part.

What I am looking to do is be able to execute custom code when an item is either added or removed from a container.  I have been searching for the equivalent of ItemAdd and ItemRemove events to try to hook, but haven't found much.

UseCase 1: As the owner of a chest, I want to allow another player to open the chest and view the contents, but be unable to remove the contents.
UseCase 2: As the owner of a chest, I want to be notified via chat when another player places an item in the chest.

Not looking for an end to end solution, just for someone to put me onto the right path.  It's obvious I am missing something.

Thanks in advance everyone.

Edited by claymore1977
Link to comment
Share on other sites

1. You would need to store the owner of the block in the tile entity instance and make slots accessible based on that comparison flag.

2. A lot of custom container screen handling to make this happen. There is no difference between placing an item and removing it as it just simply is swapping an empty item stack on the cursor for the item stack in the container. So, you will need to define this specific action yourself.

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.