Sponge 8.0 InteractContainerEvent.Open not trigger

please help me.

InteractContainerEvent.Open not trigger.

and p.openInventory() <— get opening inventory, the inventory type is alway null. like it not changed.

2 problem.

please help me, How can I handle on Inventory Open, and How can I get opening Inventory ?.

Inventory Close Event is trigger well, but Inventory Open Event not trigger

I want to handle when Player press E to open thier inventory.

PlayerInventory.

The player inventory being opened (none container essentially) is handled completely on the client. So cant grab the event.

It used to get sent to the server, so thats why it worked on api 1 and 2 but was removed.

Only way to detect if a player has that open is listening when a inventory change happens and no open inventory

1 Like

Could you please send me an example code to detect that.

Sure. Something like

public void onInventoryChange(AffectItemStackEvent event, @First ServerPlayer player){
  if(player.openInventory().isPresent()){
    //Player is interacting with a open inventory
    return;
  }
  //The player is interacting with a inventory without one open .... Default states it must be the player inventory
}
1 Like

Thank for you care!