Updating block metadata
#11
(01-21-2016, 09:11 PM)NiLSPACE Wrote: Add the check for the right click hook.

Also, I believe you should check if the meta is 15 instead of 16. The meta starts from 0 until 15. For the same reason you should also set the left click to 15 instead of 16 when the meta is 0.

Now it works, thank you.
Although the block is still not prevented from being destroyed if the new meta it sets is not in the texture pack. eg.: if coming from 12 to 11 by left clicking, the meta changes, but the block is destroyed. If coming from 2 to 1, the block stays.

It feels like the SetBlockMeta(BlockX, BlockY, BlockZ, meta) somehow fails (but no log is returned in the terminal) and it prevents the mcBlockRespawn() function from returning true and preventing the block from being deleted.
Reply
Thanks given by:
#12
You'll have to manually save the max meta value depending on the block. An easy place to find the metas is here: https://github.com/cuberite/cuberite/blo...kID.h#L466
Reply
Thanks given by:
#13
(01-21-2016, 10:02 PM)NiLSPACE Wrote: You'll have to manually save the max meta value depending on the block. An easy place to find the metas is here: https://github.com/cuberite/cuberite/blo...kID.h#L466

So the only way is to create a separate list of item id's and their max meta values?
Reply
Thanks given by:
#14
Yeah, something like this:
-- The list
g_MaxMetas = {
   [E_BLOCK_STAINED_GLASS] = 15,
   [E_BLOCK_WOOL] = 15,
   [E_BLOCK_BIG_FLOWER] = 5,
   ...
}

-- How to get the max meta:
local maxMeta = g_MaxMetas[BlockType] or 0

This way you only have to write down the blocks that can have multiple blockmetas.
Reply
Thanks given by:
#15
(01-21-2016, 10:32 PM)NiLSPACE Wrote: Yeah, something like this:
-- The list
g_MaxMetas = {
   [E_BLOCK_STAINED_GLASS] = 15,
   [E_BLOCK_WOOL] = 15,
   [E_BLOCK_BIG_FLOWER] = 5,
   ...
}

-- How to get the max meta:
local maxMeta = g_MaxMetas[BlockType] or 0

This way you only have to write down the blocks that can have multiple blockmetas.

Now what if I have a texture pack that has additional metas? I would have to create a list for all known texturepacks individually. Isn't there a way to just ignore max value, set whatever number to the block and continue executing other functions (mcBlockRespawn - return true) in Cuberite? If Cuberite didn't stop executing the function when an invalid meta is set to the block, all of this would be easy.
Reply
Thanks given by:
#16
Texture packs can't add new blocks or metas to the game. They can only change the block textures, models and sounds.
Reply
Thanks given by:
#17
Nevertheless, I still think that the behaviour should be fixed. The function should just assign said meta and if the given meta for the block does not exist, Cuberite should just assign the highest / lowest possible meta to the block instead of just ending the code.

I would take a look at it, but I am not familiar with C++
Reply
Thanks given by:
#18
I disagree. Allot of the times you are sure that the blocks are valid. Adding a check before actually setting the block would only slow the server down even though it's very simple to fix in the plugin itself.
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)