Spongeapi: DataHolderEvents

Created on 26 Apr 2015  路  12Comments  路  Source: SpongePowered/SpongeAPI

It would be amazing if we could have an event when a DataHolder has a DataManipulator added or removed or modified. It would be helpful for things like ItemStacks if their DurabilityData is changed for any reason (usually we would have a Cause for these kind of things).

Resolving this would eliminate the need for a ToolDurabilityEvent as suggested in #593.

There are countless applications that can be useful for this, including:

  • A sheep regrowing it's coat
  • Entities becoming non-aggressive
  • A Beacon's potion effects being changed
  • A player renaming an entity
input wanted data event

Most helpful comment

@Zidane I'm going to go ahead and re-open this as an issue for the various sub events with direct actions as there's some discussion I would like on where the events themselves would be located (somewhat partial to them being under the api.event.data package).

Currently, what I have in mind:

  • [ ] Changing dye of a Sheep
  • [ ] Renaming an entity with a NameTag item
  • [ ] Changing a MobSpawner to use a different egg
  • [ ] Perhaps updating a CommandBlock's command?

I'm sure there are more that we'll be thinking of when adding the events and implementing them.

All 12 comments

Sounds great!

I just worry that this could cause a whole lot of events being created on modded servers if DataManipulators are created for ticking machines or pipes. Is there any chance of optimizing what events get signed up for, in order to reduce the amount of event spam?

This would also cover #497

To reduce the spam we should separate/subclass the event for entity/item/block targets.

Item targets also need the containing inventory in the event.

Does ChangeDataHolderEvent resolve this issue or is there still more to add?

@simon816

It does, closing (we'll add sub events for more direct actions)

@Zidane I'm going to go ahead and re-open this as an issue for the various sub events with direct actions as there's some discussion I would like on where the events themselves would be located (somewhat partial to them being under the api.event.data package).

Currently, what I have in mind:

  • [ ] Changing dye of a Sheep
  • [ ] Renaming an entity with a NameTag item
  • [ ] Changing a MobSpawner to use a different egg
  • [ ] Perhaps updating a CommandBlock's command?

I'm sure there are more that we'll be thinking of when adding the events and implementing them.

When an entity catches on fire?
When a player starts crouching?

When a player starts crouching, please :P

Hoping for this. Would help to check food level changes

Related to https://github.com/SpongePowered/SpongeCommon/issues/742. I started working on an implementation some time ago (see that issue), but I'm waiting for some bleeding changes to be (hopefully) merged into what will eventually be API 7. As bleeding is still for API 6, which is solely for Minecraft updates, the PR I need is still on hold.

Going to close this for now due to https://github.com/SpongePowered/SpongeAPI/pull/1728 - If anyone would still like changes or additions, please create a new issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Cybermaxke picture Cybermaxke  路  4Comments

kashike picture kashike  路  3Comments

Favorlock picture Favorlock  路  6Comments

Cybermaxke picture Cybermaxke  路  6Comments

connorhartley picture connorhartley  路  3Comments