I made mod

Hi I made mod, it does this:

When you drop an Item, it will send you a system message saying, You Dropped an Item.

Where to distribute to

1 Like

Also, how would I get the object that is being dropped in the DropItemEvent? I want to maybe extend to maybe item possibility break when drop?

Its good template or server mod thank.

How to extend the plugin to get the object being dropped & transform it to another item/stack? Only related object I have access is the “causer” of the item drop, player.

There are several subinterfaces of DropItemEvent that represent different events.
The one you’d be most interested in is DropItemEvent.Dispense, this is fired when something dispenses an item (e.g a player dropping something).
There is a method on this event called getEntities(), this returns a list of all entities in the event.
You can use this to get the Item entity that was dropped.

Thanks so awesome program so cool :slight_smile: ok so do I do the subevent item like so: public void onDropItemEvent(DropItemEvent.Dispense e, @First Player src){} ?

Yes, that is correct

Ok I only changed DropItemEvent to DropItemEvent.Dispense, and now nothing happens when I drop item from player. Seems to immediately fix when changed back.

Edit: I think maybe was looking for this - Interface DropItemEvent.Pre - trying

Ok now when I drop item it responds with [SpongeItemStackSnapshot(itemType=ItemMultiTexture(Name=dirt), count=1)]

I think this is what I was looking for :slight_smile: What kind of object is this, is this a “SpongeItemStackSnapshot” object and how do I access only the name?

Depends on the code, which you haven’t posted. However, yes. It gives you the ItemStackSnapshot. You can then call snapshot.getType() to get the ItemType, and if this is turned directly into a Text, it will have the correct name when displayed to players.