Description:
A custom block that uses the minecraft:redstone_producer
component with block state permutations fails to update its redstone output when toggled.
The attached sample add-on defines a custom switch block with a powered state. A script toggles this state when the block is right-clicked. However, when the permutation changes from unpowered to powered, the redstone signal is not updated in the world.
This behavior differs from vanilla redstone components (e.g., levers, buttons), which immediately update their redstone output when toggled.
Steps to Reproduce:
Install the attached sample add-on.
Create a new world with the add-on active.
Place the custom switch block next to redstone dust or another redstone component.
Right-click the switch block to toggle its state.
Observed Results:
The custom switch block visually toggles state, but the redstone signal is not updated.
Expected Results:
When toggled to the powered state, the custom switch block should update its redstone output and power adjacent redstone components, consistent with vanilla redstone behavior.
A Workaround for the creators:
Creators can force an update by temporarily replacing the block with another type (e.g., minecraft:air
) and then setting the powered switch permutation block within the same tick. This forces the game to update the redstone state:
import { BlockPermutation, system } from '@minecraft/server'
system.beforeEvents.startup.subscribe(init => {
init.blockComponentRegistry.registerCustomComponent("bug_sample:switch", {
onPlayerInteract: event => {
const block = event.block;
const permutation = block.permutation; // Store the last switch block permutation
// Force update by briefly replacing with another block type
block.setPermutation(BlockPermutation.resolve("minecraft:stone"));
// Then set the block with the switch toggled powered
block.setPermutation(permutation.withState("bug_sample:powered", !permutation.getState("bug_sample:powered")))
}
})
})
Linked issues
is duplicated by 1
Attachments
Comments 0
No comments.