use of org.spongepowered.api.event.item.inventory.container.InteractContainerEvent in project SpongeCommon by SpongePowered.
the class SpongeEventManager method preparePost.
protected final NoExceptionClosable preparePost(final Event event) {
if (event instanceof InteractContainerEvent) {
// Track usage of Containers
final ContainerBridge bridge = ((ContainerBridge) ((InteractContainerEvent) event).container());
bridge.bridge$setInUse(true);
return new ContainerInUseClosable(bridge);
}
return SpongeEventManager.NULL_CLOSABLE;
}
use of org.spongepowered.api.event.item.inventory.container.InteractContainerEvent in project SpongeCommon by SpongePowered.
the class CloseMenuTransaction method generateEvent.
@Override
public Optional<InteractContainerEvent> generateEvent(final PhaseContext<@NonNull ?> context, @Nullable final GameTransaction<@NonNull ?> parent, final ImmutableList<GameTransaction<InteractContainerEvent>> gameTransactions, final Cause currentCause) {
final ItemStackSnapshot resultingCursor = ItemStackUtil.snapshotOf(this.player.inventory.getCarried());
final Transaction<ItemStackSnapshot> cursorTransaction = new Transaction<>(this.cursor, resultingCursor);
final InteractContainerEvent.Close event = SpongeEventFactory.createInteractContainerEventClose(currentCause, (Container) this.menu, cursorTransaction, (Container) this.menu, this.slotTransactions == null ? Collections.emptyList() : this.slotTransactions);
return Optional.of(event);
}
use of org.spongepowered.api.event.item.inventory.container.InteractContainerEvent in project SpongeCommon by SpongePowered.
the class OpenMenuTransaction method generateEvent.
@Override
public Optional<InteractContainerEvent> generateEvent(final PhaseContext<@NonNull ?> context, @Nullable final GameTransaction<@NonNull ?> parent, final ImmutableList<GameTransaction<InteractContainerEvent>> gameTransactions, final Cause currentCause) {
final ItemStackSnapshot resultingCursor = ItemStackUtil.snapshotOf(this.player.inventory.getCarried());
final Transaction<ItemStackSnapshot> cursorTransaction = new Transaction<>(this.cursor, resultingCursor);
final InteractContainerEvent.Open event = SpongeEventFactory.createInteractContainerEventOpen(currentCause, (Container) this.menu, cursorTransaction);
return Optional.of(event);
}
Aggregations