Blockception / BC-Minecraft-Bedrock-Diagnoser

A typescript package library that provides diagnostics for Minecraft bedrock projects
https://www.npmjs.com/package/bc-minecraft-bedrock-diagnoser
BSD 3-Clause "New" or "Revised" License
2 stars 2 forks source link

Check if valid block and item being used #206

Open Xterionix opened 5 months ago

Xterionix commented 5 months ago

For entity components that reference items and blocks, it should check if they're valid. Happy to do this myself if you could point me in the direction as I believe it's already setup to check for valid blocks and items just not within the entity components

DaanV2 commented 5 months ago

You can register component diagnostics here:

https://github.com/Blockception/BC-Minecraft-Bedrock-Diagnoser/blob/main/src/Lib/Diagnostics/BehaviorPack/Entity/components/diagnose.ts

To check if an item exists: you can use: behaviorpack_item_diagnose or behaviorpack_check_blockid

Xterionix commented 5 months ago

I'm not sure what the input would be for the block check function

export function check_if_block_exists(name: string, component: any, context: Context, diagnoser: DiagnosticsBuilder): void { 
  if (component === undefined) return;
  if (component.target_blocks !== undefined && component.target_blocks instanceof Array) component.target_blocks.forEach((block: string) => behaviorpack_check_blockid(/**?**/ ,diagnoser) )
DaanV2 commented 4 months ago

Aah the Types.OffsetWord is an object that stores the text of the data found, and the offset in the file where it is located.

Here you can see any example:

https://github.com/Blockception/BC-Minecraft-Bedrock-Diagnoser/blob/34732a139a2b252ff0fd17fd16401f618c5e71ce/src/Lib/Diagnostics/BehaviorPack/Loot%20Table/entry.ts#L21

For the diagnosed (and vscode) to place the error in a document it needs to known a location

Xterionix commented 4 months ago

Even for checking the block Id I should get the item?

DaanV2 commented 4 months ago

No, I think we are going to need a equivalent for block on that function, don't think it exists yet.

Xterionix commented 4 months ago

Ah, well let me know when that's been adeded