KubeJS-Mods / KubeJS

https://kubejs.com
GNU Lesser General Public License v3.0
310 stars 91 forks source link

BlockStateComponent is not reversable #743

Closed Notenoughmail closed 11 months ago

Notenoughmail commented 12 months ago

Minecraft Version

1.20

KubeJS Version

2001.6.3-build.89

Rhino Version

2001.2.2-build.11

Architectury Version

9.1.12

Forge/Fabric Version

Forge 47.1.3

Describe your issue

BlockStateComponent#write relies on the block state's toString() method to write its value, unfortunately this does not produce a string which UtilsJS#parseBlockState nor vanilla's own block state parser can handle. This is due to the block state relying on the base block's toString() method which wraps its id in Block{}.

Recreation

final BlockState testState = Blocks.ACACIA_STAIRS.defaultBlockState();
final BlockState processedState = BlockStateComponent.BLOCK.read(null, BlockStateComponent.BLOCK.write(null, testState));

Put this code somewhere and get an exception similar to the crash attached, where I put it in my mod's constructor

Crash report/logs

https://mclo.gs/BqXJNWo

MaxNeedsSnacks commented 11 months ago

Fixed in the newest release, thanks for the report!