Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check valid block types in block operations #26

Open
madmaxoft opened this issue Feb 26, 2014 · 3 comments
Open

Check valid block types in block operations #26

madmaxoft opened this issue Feb 26, 2014 · 3 comments

Comments

@madmaxoft
Copy link
Member

Block operations that take a blocktype parameter from the user (such as //set) should check that the provided blocktype is really a block and not an item. Otherwise weird behavior will occur: //set gold sets the selection to gold blocks, but //set diamond sets the selection to water.

@NiLSPACE
Copy link
Member

This could be done in the GetBlockTypeMeta function

@NiLSPACE
Copy link
Member

After a talk with @Seadragon91 he said we need to check for metas as well. I don't think we should prevent people from using invalid meta's, since some metas in Minecraft aren't officially registered as a different block, but give a different texture nonetheless. Instead we should change the default meta. Currently every time somebody didn't give a meta value it gives 0 in return. This isn't always valid. For example chests don't have a 0 meta value.

If we change this line to

-- g_DefaultMetas doesn't exist yet though
return BlockID, g_DefaultMetas[BlockID] or 0, true

it should fix //set 54 (chest) but it wouldn't fix //set chest.

That should be fixed here. By checking if :%d+$ matches on the blockname. If it doesn't match you give the default meta in return.

@madmaxoft
Copy link
Member Author

That is something not exactly related to this issue. This issue was about trying to use items instead of blocks - //set diamond is actually a request to set the blocks to type E_ITEM_DIAMOND, while the user's intent was more likely //set diamondore or //set diamondblock. I think WE would be right to report an error and refuse the set in the invalid case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants