Sponge: Inventory Event Implementation Progress

Created on 18 Jun 2017  路  10Comments  路  Source: SpongePowered/Sponge

<Zidane> Faithcaio, we should focus more on making sure the inventory events are being fired
<Zidane> and the lookup methods are all working
<Zidane> (So we can put Inventory behind us for the most part, lol!)_

? extends TargetInventoryEvent

  • [x] org.spongepowered.api.event.item.inventory.TargetInventoryEvent
  • [x] org.spongepowered.api.event.entity.ChangeEntityEquipmentEvent
  • [x] org.spongepowered.api.event.entity.ChangeEntityEquipmentEvent.TargetLiving
  • [x] org.spongepowered.api.event.entity.ChangeEntityEquipmentEvent.TargetHumanoid
  • [x] org.spongepowered.api.event.entity.ChangeEntityEquipmentEvent.TargetPlayer
  • [x] org.spongepowered.api.event.item.inventory.ChangeInventoryEvent.Equipment
    equipmentslot-clicks/equip item in hand/equip by dispenser(this last one fires item-pickup)
  • [x] org.spongepowered.api.event.item.inventory.ChangeInventoryEvent
  • [x] org.spongepowered.api.event.item.inventory.ClickInventoryEvent
  • [x] org.spongepowered.api.event.item.inventory.ClickInventoryEvent.Creative
    maybe detect if its not in the creative menu?
  • [x] org.spongepowered.api.event.item.inventory.ClickInventoryEvent.Drag
  • [x] org.spongepowered.api.event.item.inventory.ClickInventoryEvent.Drag.Primary
  • [x] org.spongepowered.api.event.item.inventory.ClickInventoryEvent.Drag.Secondary
  • [x] org.spongepowered.api.event.item.inventory.ClickInventoryEvent.Drop
  • [x] org.spongepowered.api.event.item.inventory.ClickInventoryEvent.Drop.Full
  • [x] org.spongepowered.api.event.item.inventory.ClickInventoryEvent.Drop.Single
    drop Full/Single with Q/ctrl+Q is not fired when inventory is closed (active hotbar item)
  • [x] org.spongepowered.api.event.item.inventory.ClickInventoryEvent.Drop.Outside
    Outside events dont fire when in creative instead only .Creative (actually we can't know better)
  • [x] org.spongepowered.api.event.item.inventory.ClickInventoryEvent.Drop.Primary in Outside
  • [x] org.spongepowered.api.event.item.inventory.ClickInventoryEvent.Drop.Secondary in Outside
  • [x] org.spongepowered.api.event.item.inventory.ClickInventoryEvent.Middle
    clone stack in Creative?
    Unable to find InventoryPacketState handler for click window packet: CPacketClickWindow{windowId=0, slotId=23, usedButton=0, actionNumber=82, clickedItem=1xtile.air@0, mode=CLONE}
  • [x] org.spongepowered.api.event.item.inventory.ClickInventoryEvent.NumberPress
  • [x] org.spongepowered.api.event.item.inventory.ClickInventoryEvent.Primary
  • [x] org.spongepowered.api.event.item.inventory.ClickInventoryEvent.Double
  • [x] org.spongepowered.api.event.item.inventory.ClickInventoryEvent.Shift.Primary
  • [x] org.spongepowered.api.event.item.inventory.ClickInventoryEvent.Secondary
  • [x] org.spongepowered.api.event.item.inventory.ClickInventoryEvent.Shift.Secondary
  • [x] org.spongepowered.api.event.item.inventory.ClickInventoryEvent.Shift
  • [x] org.spongepowered.api.event.item.inventory.ChangeInventoryEvent.Held
  • [x] org.spongepowered.api.event.item.inventory.ChangeInventoryEvent.Pickup
    Fires too soon to be able to know the affected slots and the actual change. Split up in 2 events? EntityItem#onCollideWithPlayer before (current) and after addItemStackToInventory
  • [x] org.spongepowered.api.event.item.inventory.ChangeInventoryEvent.Transfer
  • [x] what about hoppers picking up items in the world?
  • [x] org.spongepowered.api.event.item.inventory.TargetContainerEvent
  • [x] org.spongepowered.api.event.item.inventory.InteractInventoryEvent
  • [x] org.spongepowered.api.event.item.inventory.InteractInventoryEvent.Close
  • [x] org.spongepowered.api.event.item.inventory.InteractInventoryEvent.Open
    missing on PlayerContainer - can we know this?

    • [x] org.spongepowered.api.event.item.inventory.DropItemEvent.Pre

    • getDroppedItems List is not handled properly. Adding/Replacing in the list does nothing. Removing everything actually cancels the event causing the item to remain in the inventory.


related Events:

DropItemEvent


Related Issues:
https://github.com/SpongePowered/SpongeAPI/issues/1558 EventFilter for single Transaction
https://github.com/SpongePowered/SpongeAPI/issues/1051 Hopper Event
https://github.com/SpongePowered/SpongeCommon/issues/1309 Event for /give
https://github.com/SpongePowered/SpongeCommon/issues/1363 DropItemEvent.Pre cancel (check if done)
https://github.com/SpongePowered/SpongeCommon/issues/1037 DropItemEvent.Pre not fired in some cases (done)
https://github.com/SpongePowered/SpongeCommon/issues/1019 ClickInventoryEvent.Drop subclasses not fired (done)


Listener for Testing:
https://gist.github.com/anonymous/b120b44dae28f8d874b85821cc093577

event inventory

All 10 comments

My testing had pretty much the same results.

I did have one issue though: org.spongepowered.api.event.item.inventory.ChangeInventoryEvent.Held needs some work I think or at least more clarification on the documentation. Maybe I am just misunderstanding it though.

At the moment it states "Fired when a Living changes it's held ItemStack", which makes it seem like it would occur anytime what they are holding changes. But when they pick up something into the slot it does not fire, nor when they move something from an inventory into that hotbar slot. It only fires when they change what slot they have selected.

This can be handled with other events, so maybe just the documentation should change.

For the equipment events to be implemented properly, the EquipmentInventoryAdapter needs to be implemented. I tried starting to do so, but it's quite confusing...

Just needed to add Slots with EquipmentSlotType to the EquimentInventoryLens and then use query to get the slots.
It only works if you query for the exact EquipmentType. so e.g. EquipmentTypes.ANY will return nothing.

@Faithcaio You should also add an event for toggling on and off dualwielding

https://github.com/prism/Prism/issues/11

Looks almost close enough to start getting this into prism?

Guessing this https://github.com/SpongePowered/SpongeAPI/issues/1282 is also another related issue, and can be represented with the current/planned inventory API events.

Per the request of @Faithcaio, I'd like to add that it would be useful if events were added when an enchantment is applied to an item in an enchanting table and when items are repaired/renamed in an anvil.

@Zerthick I am handling enchanting along with some other enchant events/changes.

The recently merged ChangeEntityEquipmentEvent was the last missing one.

For Enchant Event there is another issue: https://github.com/SpongePowered/SpongeAPI/issues/1303

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nikosgram picture nikosgram  路  3Comments

XakepSDK picture XakepSDK  路  5Comments

ImMorpheus picture ImMorpheus  路  4Comments

SjsolisZXA picture SjsolisZXA  路  3Comments

gabizou picture gabizou  路  5Comments