[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/prismarine](https://jsprismarine.dev/api/@jsprismarine/prismarine/index.md) / [world/chunk/BlockStorage](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/chunk/BlockStorage/index.md) / BlockWriteCounter

# Class: BlockWriteCounter

Defined in: [packages/prismarine/src/world/chunk/BlockStorage.ts:103](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/chunk/BlockStorage.ts#L103)

Counts the block writes and storage swaps under one chunk.

[BlockStorage.writeEpoch](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/chunk/BlockStorage/classes/BlockStorage.md#writeepoch) moves on a write anywhere in the process, so a fluid flowing in
one chunk made every other chunk sum its section revisions again. A chunk hands its counter to
each sub chunk it holds, which hands it to each storage, and reads its own count instead.

## Constructors

### Constructor

> **new BlockWriteCounter**(): `BlockWriteCounter`

#### Returns

`BlockWriteCounter`

## Properties

### count

> **count**: `number` = `0`

Defined in: [packages/prismarine/src/world/chunk/BlockStorage.ts:105](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/chunk/BlockStorage.ts#L105)

Writes and swaps counted so far.

***

### shared

> **shared**: `boolean` = `false`

Defined in: [packages/prismarine/src/world/chunk/BlockStorage.ts:110](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/chunk/BlockStorage.ts#L110)

Set once a sub chunk or storage was handed a second counter. Writes then reach only the
last counter, so neither can vouch for its chunk and both fall back to the revisions.

## Methods

### attach()

> `static` **attach**(`current`, `next`): `BlockWriteCounter`

Defined in: [packages/prismarine/src/world/chunk/BlockStorage.ts:113](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/chunk/BlockStorage.ts#L113)

The counter an object holds after being handed `next`, marking both shared when it held another.

#### Parameters

##### current

`BlockWriteCounter` \| `undefined`

##### next

`BlockWriteCounter`

#### Returns

`BlockWriteCounter`
