use of org.spongepowered.common.event.tracking.context.transaction.block.AddBlockEventTransaction in project SpongeCommon by SpongePowered.
the class TransactionSink method logBlockEvent.
@SuppressWarnings("ConstantConditions")
default void logBlockEvent(final BlockState state, final TrackedWorldBridge serverWorld, final BlockPos pos, final TrackableBlockEventDataBridge blockEvent) {
final WeakReference<ServerLevel> worldRef = new WeakReference<>((ServerLevel) serverWorld);
final Supplier<ServerLevel> worldSupplier = () -> Objects.requireNonNull(worldRef.get(), "ServerWorld dereferenced");
@Nullable final BlockEntity tileEntity = ((ServerLevel) serverWorld).getBlockEntity(pos);
final SpongeBlockSnapshot original = TrackingUtil.createPooledSnapshot(state, pos, BlockChangeFlags.NONE, Constants.World.DEFAULT_BLOCK_CHANGE_LIMIT, tileEntity, worldSupplier, Optional::empty, Optional::empty);
original.blockChange = BlockChange.MODIFY;
final AddBlockEventTransaction transaction = new AddBlockEventTransaction(original, blockEvent);
this.logTransaction(transaction);
}
Aggregations