Jump to content

Recommended Posts

Posted (edited)

This event would be called something along the lines of ItemTakeEvent, and is fired when the player tries to click on an item to move it to a different slot. It should be cancellable, and should pass the EntityPlayer and the ItemStack. I already made a fork and implemented the feature, but when I made a pull request I was notified that the way I did it would probably hinder with some mods' functions.

Here is an example showing how one might use the new Event:

public class FilterEventHandler {
	@SubscribeEvent
	public void onItemTake(ItemTakeEvent event) {
		// Stop the player from being allowed to acquire TNT through an inventory.
		if (event.getItemStack().getItem().getRegistryName().toString().equals("minecraft:tnt")) {
			event.setCanceled(true);
		}
	}
}

 

The reason I thought of this event because I am currently making a mod called InventoryFilter that allows you to write a list of regular expressions. All items that would go into your inventory are compared against this filter either as a whitelist or blacklist. I already have item pickups filtered, but when trying to filter taking items from inventories, I found out there was no event readily made for that.

Hope this can be implemented!

Edited by titanknox
typo

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.