PrismarineJS/prismarine-viewer

Map Block Names to IDs #71

tgb20 posted onGitHub

Block IDs used by the standalone viewer do not match the deprecated id numbers or their position in the block list. For instance oak saplings have an id of 6, and they are the 19th block in the block list, but the ID in prismarine is 21. Ideally you should be able to use their names, as that is their only official identifiers, "oak_sapling".


The ids can be retrieved from mcData:

mcData.blocksByName['oak_sapling'].id
posted by Karang over 4 years ago

This leads to the same problem, perhaps the ids are misaligned. mcData.blocksByName['oak_sapling'].id returns 19, as it should, but when you call viewer.world.setBlockStateId(new Vec3(0, 1, 0), mcData.blocksByName['oak_sapling'].id); a acacia plank appears.

posted by tgb20 over 4 years ago

ah yeah, sorry the generator function returns a stateId not a type, so mcData.blocksByName['oak_sapling'].minStateId

posted by Karang over 4 years ago

Yes, this appears to be working, thanks! I can make another issue about this if you want but is there a way to access the three.js scene from the standalone viewer? For instance if I wanted to add new models or edit the controls? Without needing to modify the original package.

posted by tgb20 over 4 years ago

No it is not possible at the moment without modifying the packages. Some people have made it work by copying bits of the code in their project, but thats not a good long term solution. There is an open issue related to this https://github.com/PrismarineJS/prismarine-viewer/issues/69

posted by Karang over 4 years ago

Fund this Issue

$0.00
Funded

Pull requests