mojira.dev
MCPE-241274

BlockFilter exclusion doesn't work when a waterlogged block exists in the same sub-chunk.

When using script API version v2.8.0 for @minecraft/server (it also seems to affect previous versions), any waterlogged block that exists in the same sub-chunk [16, 16, 16] area, breaks the functionality of BlockFilter.excludeTypes when used in either Dimension.containsBlock(…) or Dimension.getBlocks(…).

Observed Results

Specifying an excluded block type when a waterlogged block exists in the same sub-chunk either returns the excluded block or detects the excluded block.

The bug stays active even after removing the waterlogged block from the same sub-chunk, either permanently making it bugged or temporarily bugged when re-loading the world.

Expected Results

The excluded block type should not be detected by Dimension.containsBlock(…) or included in the Dimension.getBlocks(…).

Other Tests

Inclusion of block types work properly, however, other exclusion methods haven’t been tested.

containsBlockTestExclusion(origin, from, to, block) {
    const source = getSourceDimension(origin);
    system.run(() => {
        const volume = new BlockVolume(from, to);
        const result = source.containsBlock(volume, { excludeTypes: [block.id] });
        world.sendMessage(`Result From dimension.containsBlock(...): ${result? "§aTrue" : "§cFalse"}`);

        const blockIterator = source.getBlocks(volume, { excludeTypes: [block.id] }).getBlockLocationIterator();
        const detectedBlocks = [];
        for(const block of blockIterator) {
            detectedBlocks.push(source.getBlock(block).typeId);
        }

        world.sendMessage(`Detected Blocks: ${detectedBlocks.join(", ")}`);
    })
    return undefined;
}

function getSourceDimension(origin) {
if(origin.initiator !== undefined) {
    return origin.initiator.dimension;
}
if(origin.sourceEntity !== undefined) {
    return origin.sourceEntity.dimension;
}
if(origin.sourceBlock !== undefined) {
    return origin.sourceBlock.dimension;
}

throw new Error("Unknown source!");

}

Notes

I first found this bug on the windows version of minecraft bedrock v26.33 running on arch linux, so I tested on android just to be sure it affected multiple officially supported devices before submitting this bug.

The included world contains the addon to reproduce the bug.

Attachments

Comments 2

Thank you for helping us improve Minecraft! We saved your files:

[media][media][media]

Update: BlockFilter is completely broken even with inclusion in certain scenarios.

This completely breaks trying to reset critical objective story-based scripting with replayability.
This is one of the many extra affected functions in my use cases currently.

protected async ReplaceBlockPermutationOnLoadAsync(dimension: Dimension, location: Vector3, permutation: BlockPermutation, replace: BlockFilter, token: CancellationToken, loadChunk: boolean = false): Promise<void> {
        let tickingAreaId = undefined;
        try {
            if (!loadChunk) {
                await waitForChunkLoadAsync(dimension, location, token);
            } else if (!dimension.isChunkLoaded(location)) {
                tickingAreaId = await loadChunkAsync(dimension, location, token);
            }

            if (dimension.containsBlock(new BlockVolume(location, location), replace)) {
                dimension.setBlockPermutation(location, permutation);
            }
        } finally {
            unloadChunk(tickingAreaId);
        }
    }

SineVector241

(Unassigned)

Unconfirmed

Multiple

Android 14, 6.18.40-1-cachyos-lts (64-bit)

26.50.22 Preview, 26.33 Hotfix

Retrieved