-
Bug
-
Resolution: Fixed
-
1.19.70, 1.19.71, 1.19.72, 1.19.73, 1.19.80, 1.19.81 Hotfix
-
Unconfirmed
-
Multiple
The BlockPermutation.matches() and blockPermutation.withProperty() methods do not work with custom blocks, they only work with vanilla blocks.
For example, if I try to use the '.matches()' method it will always return false no matter if I'm comparing it to its exact same properties, it only works if I leave the properties as undefined and only match the block name.
Now, if I use the '.withProperty()' method, it will always throw an error if I try to get the 'BlockPermutation' with the specified properties, this doesn't happen with vanilla blocks.
import { world } from "@minecraft/server" world.events.itemUseOn.subscribe(i => { const block = i.source.dimension.getBlock(i.getBlockLocation()) if (i.item.typeId === 'minecraft:stick') { const permutation = block.permutation world.sendMessage(`§acustom_block 1 - ${permutation.matches('test:custom_block', { 'block:test': 0 } )}`) world.sendMessage(`§ccustom_block 2 - ${permutation.matches('test:custom_block', permutation.getAllProperties() )}`) world.sendMessage(`§estone_slab - ${permutation.matches('minecraft:stone_slab', { stone_slab_type: 'stone_brick', top_slot_bit: false })}`) //block.setPermutation(block.permutation.withProperty('top_slot_bit', true )) block.setPermutation(block.permutation.withProperty('block:test', 1 )) } })
custom_block.json:
{ "format_version": "1.19.70", "minecraft:block": { "description": { "identifier": "test:custom_block", "menu_category": { "category": "Construction" }, "properties": { "block:test": [ 0, 1 ] } }, "components": { "minecraft:material_instances": { "*": { "texture": "custom_block" } }, "minecraft:on_interact": { "event": "test" } }, "events": { "test": { "sequence": [ { "condition": "!q.block_property('block:test')", "run_command": { "command": "say block_property = 0" } }, { "condition": "q.block_property('block:test')", "run_command": { "command": "say block_property = 1" } } ] } } } }
I will leave the world where I took the test so they can review it.
Well, to execute the error you must enter the world that I sent in the attached files, in the world you will find a script file and a custom block that when you right click or interact on it you will see a "/say" in the chat that will indicate if its "block:test" property is set to 0 or 1.
In the script you will find:
world.events.itemUseOn.subscribe(i => { const block = i.source.dimension.getBlock(i.getBlockLocation()) if (i.item.typeId === 'minecraft:stick') { ... } }
With this, right-clicking or interacting with a stick in the player's hand on a block will execute the code inside the if
{...} on the block.Now inside the if {...}
you will find four tests I made to execute the error, first in the:
world.sendMessage(`${permutation.matches('test:custom_block', { 'block:test': 0 } )}`)
it is checked if "test:custom_block" has the property "block:test" equal to 0, this will always return false regardless of whether it is true.
In the second test I ran getAllProperties() to make sure I wasn't misspelling the name 'block:test':
world.sendMessage(`${permutation.matches('test:custom_block', permutation.getAllProperties() )}`)
but it always returns false.
In the third test I decided to do it with a vanilla block, in this case with a stone slab:
world.sendMessage(`${permutation.matches('minecraft:stone_slab', { stone_slab_type: 'stone_brick', top_slot_bit: false })}`)
When doing so, it returned true if it was compared correctly, that is, it works correctly with vanilla blocks.
In the fourth test I decided to use setPermutation(withProperty()) to change the property of the custom block:
block.setPermutation(block.permutation.withProperty('block:test', 1 ))
This will always give an error in the content log history:
[Scripting][error] -Error: Failed to set property 'block:test' on block 'test:custom_block'
I also did the test with the stone slab and it works correctly.
All of this makes me suspect that it doesn't support properties with namespaces.
- duplicates
-
MCPE-167941 BlockPermutation.resolve doesn't support properties with namespaces
- Resolved