Cuberite Forum
Enchanting - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html)
+--- Forum: Development (https://forum.cuberite.org/forum-13.html)
+--- Thread: Enchanting (/thread-1321.html)

Pages: 1 2 3 4 5 6 7 8 9 10 11


RE: Enchanting - LO1ZB - 04-12-2014

(04-12-2014, 11:06 PM)daniel0916 Wrote: But the ID's aren't right. 137 = command block. But there isn't a command block.

I think you try to check the wrong area, i made 2 Screenshorts what i think that
the first screnn is what i think what your code ic checking, the second what it schould check.
http://1drv.ms/1kSJta2

the tables are only for relativ posittion to the checked area


RE: Enchanting - daniel0916 - 04-12-2014

I haven't any knowing about cBlockArea. Maybe you are right but i don't know how can i check then the bookshelves..


RE: Enchanting - LO1ZB - 04-12-2014

I havent worked with the MCServer code at all, but please try:
cBlockArea Area;
		Area.Read(a_Player.GetWorld(), PosX - 2, PosX + 2, PosY, PosY + 1, PosZ - 2, PosZ + 2);

		for (int x = 0; x < 6; x++)
		{
			for (int y = 0; y < 3; y++)
			{
				for (int z = 0; z < 6; z++)
				{
					LOG("%i", Area.GetRelBlockType(x, y, z));

					if (Area.GetRelBlockType(x, y, z) == E_BLOCK_BOOKCASE)
					{
						LOG("BookShelf");
					}
				}
			}
		}
And:
cBlockArea Area;
		Area.Read(a_Player.GetWorld(), PosX - 2, PosX + 2, PosY, PosY + 1, PosZ - 2, PosZ + 2);

		for (int x = 0; x < 6; x++)
		{
			for (int y = 0; y < 3; y++)
			{
				for (int z = 0; z < 6; z++)
				{
					LOG("%i", Area.GetBlockType(x, y, z));

					if (Area.GetBlockType(x, y, z) == E_BLOCK_BOOKCASE)
					{
						LOG("BookShelf");
					}
				}
			}
		}



RE: Enchanting - daniel0916 - 04-12-2014

The first one is working. The second not.
But a Bookshelf also need to be one block away from the Enchantment Table..


RE: Enchanting - LO1ZB - 04-13-2014

(04-12-2014, 11:59 PM)daniel0916 Wrote: The first one is working. The second not.
But a Bookshelf also need to be one block away from the Enchantment Table..
Try to think about what blocks need to be checkt and make an algorithm that ckects them without even thinking of the BlockArea.
the block has to be
x = lenght; z = with; y = hight
((((x == 0) || (x == 5)) || ((z == 0) || (z == 5))) && ((y == 0) || y == 1)))
dont know if it works, also the block between the table an the bookshelf has to be air..


RE: Enchanting - daniel0916 - 04-13-2014

So i should test every position where a bookshelf should be and not use cBlockArea?
I will try to make it...


RE: Enchanting - LO1ZB - 04-13-2014

(04-13-2014, 12:28 AM)daniel0916 Wrote: So i should test every position where a bookshelf should be and not use cBlockArea?
I will try to make it...

You have to check inside the loop if the "selected" block can be a bookshelf

cBlockArea Area;
		Area.Read(a_Player.GetWorld(), PosX - 2, PosX + 2, PosY, PosY + 1, PosZ - 2, PosZ + 2);
 
		for (int x = 0; x < 6; x++)
		{
			for (int y = 0; y < 3; y++)
			{
				for (int z = 0; z < 6; z++)
				{
					if((((x == 0) || (x == 5)) || ((z == 0) || (z == 5))) && ((y == 0) || y == 1))
					{
						LOG("%i", Area.GetRelBlockType(x, y, z));
 
						if (Area.GetRelBlockType(x, y, z) == E_BLOCK_BOOKCASE)
						{
							LOG("BookShelf");
						}
					}
				}
			}
		}



RE: Enchanting - daniel0916 - 04-13-2014

It's working. But sometimes more Bookshelves would be found than there are.


RE: Enchanting - LO1ZB - 04-13-2014

Could you give me the source? I want to try to debug it. Smile


RE: Enchanting - daniel0916 - 04-13-2014

https://github.com/daniel0916/MCServer/tree/Enchanting

I also pushed your newest code..