This document details how Better Fire+ preserves block orientations (facing directions, stair shapes, slab halves) during material transformations and prevents item duplication when container blocks undergo thermal state changes.
setType(id) ProblemIn Minecraft Bedrock Script API, calling block.setType("minecraft:new_id") overwrites the block type ID and resets all permutation properties to default values.
For directional or shaped blocks (stairs, slabs, doors, trapdoors, logs, chests), calling setType causes rotation and shape distortion:
north or default values.y orientation.To solve this, Better Fire+ computes the intersection of valid state keys between the source block permutation and the target block permutation using BlockPermutation:
export function applyTransform(block, targetTypeId) {
const currentPerm = block.permutation;
const targetPerm = BlockPermutation.resolve(targetTypeId);
let newPerm = targetPerm;
for (const [key, val] of Object.entries(currentPerm.getAllStates())) {
// Skip volatile states that belong specifically to the old block state
if (!VOLATILE_STATES.has(key) && targetPerm.getState(key) !== undefined) {
try {
newPerm = newPerm.withState(key, val);
} catch (e) {
// Ignore incompatible state values
}
}
}
block.setPermutation(newPerm);
}
VOLATILE_STATES)Certain permutation states describe internal progress or block-specific conditions that must not carry over to the target block (e.g. moisture level, growth age, lit state, or bite count).
The blacklist includes:
const VOLATILE_STATES = new Set([
"age", "growth", "lit", "extinguished", "moisture",
"bite_counter", "candles", "composter_fill_level",
"honey_level", "hatch", "cracked", "stage", "dusted"
]);