Search in sources :

Example 1 with NotificationTicket

use of org.spongepowered.api.block.transaction.NotificationTicket in project SpongeCommon by SpongePowered.

the class NeighborNotification method markCancelledTransactions.

@Override
public boolean markCancelledTransactions(final NotifyNeighborBlockEvent event, final ImmutableList<? extends GameTransaction<NotifyNeighborBlockEvent>> blockTransactions) {
    boolean cancelledAny = false;
    for (final NotificationTicket transaction : event.tickets()) {
        if (!transaction.valid()) {
            cancelledAny = true;
            for (final GameTransaction<NotifyNeighborBlockEvent> gameTransaction : blockTransactions) {
                final NeighborNotification blockTransaction = (NeighborNotification) gameTransaction;
                final Vector3i position = transaction.targetPosition();
                final BlockPos affectedPosition = blockTransaction.affectedPosition;
                if (position.x() == affectedPosition.getX() && position.y() == affectedPosition.getY() && position.z() == affectedPosition.getZ()) {
                    gameTransaction.markCancelled();
                }
            }
        }
    }
    return cancelledAny;
}
Also used : NotifyNeighborBlockEvent(org.spongepowered.api.event.block.NotifyNeighborBlockEvent) Vector3i(org.spongepowered.math.vector.Vector3i) SpongeNotificationTicket(org.spongepowered.common.block.SpongeNotificationTicket) NotificationTicket(org.spongepowered.api.block.transaction.NotificationTicket) BlockPos(net.minecraft.core.BlockPos)

Aggregations

BlockPos (net.minecraft.core.BlockPos)1 NotificationTicket (org.spongepowered.api.block.transaction.NotificationTicket)1 NotifyNeighborBlockEvent (org.spongepowered.api.event.block.NotifyNeighborBlockEvent)1 SpongeNotificationTicket (org.spongepowered.common.block.SpongeNotificationTicket)1 Vector3i (org.spongepowered.math.vector.Vector3i)1