public MapBlock getBlock(int x, int y, int z) { int index = x + (z * 16) + (y * 16 * 16); MapBlock thisBlock = new MapBlock((int)blocks[index], x, y, z, (int)Math.Floor(decimal.Divide(x, 16)), (int)Math.Floor(decimal.Divide(z, 16))); return thisBlock; }
public MapBlock getBlock(int x, int y, int z) { int index = x + (z * 16) + (y * 16 * 16); MapBlock thisBlock = new MapBlock((int)blocks[index], x, y, z, (int)Math.Floor(decimal.Divide(x, 16)), (int)Math.Floor(decimal.Divide(z, 16))); return(thisBlock); }
void findBlock(string[] args) { // Attempt on an alternitive block lookup method, for speed's sake.. functions lookup = new functions(); if (!lookup.isNumeric(args[2])) { return; } if (!lookup.isNumeric(args[3])) { return; } if (!lookup.isNumeric(args[4])) { return; } int blockX = int.Parse(args[2]); int blockY = int.Parse(args[3]); int blockZ = int.Parse(args[4]); decimal ChunkX = decimal.Divide(blockX, 16); decimal ChunkZ = decimal.Divide(blockZ, 16); ChunkX = Math.Floor(ChunkX); ChunkZ = Math.Floor(ChunkZ); Classes.Chunk thisChunk = null; Classes.MapBlock thisblock = null; foreach (Classes.Chunk b in Mainform.Chunks) { if (b.x == ChunkX & b.z == ChunkZ) { thisChunk = b; break; } } thisblock = thisChunk.getBlock(blockX, blockY, blockZ); if (thisblock != null) { Packets.chatMessage cm = new Packets.chatMessage(Socket, Mainform, "FOUND IT. " + thisblock.Name, true); } else { Packets.chatMessage cm = new Packets.chatMessage(Socket, Mainform, "Fail :(", true); } }
void parseChunk(Chunk toparse, Form1 thisform) { // Get all of the blocks, and load them into memory. for (byte i = 0; i < 16; i++) { if (Convert.ToBoolean(toparse.pbitmap & (1 << i))) { for (int f= 0; f < 4096; f++) { int blockX = (toparse.x * 16) + (f & 0x0F); // f & 0x0f int blockY = (i * 16) + (blockX >> 8); // i*16 + (f >> 8) int blockZ = (toparse.z * 16) + (f & 0xF0) >> 4; // (f & F0) >> 4 int blockID = toparse.blocks[f]; MapBlock myBlock = new MapBlock(blockID, blockX, blockY, blockZ); if (thisform.blocks == null) thisform.blocks = new MapBlock[] { myBlock }; else { MapBlock[] temp = thisform.blocks; thisform.blocks = new MapBlock[temp.Length + 1]; Array.Copy(temp, thisform.blocks, temp.Length); thisform.blocks[temp.Length] = myBlock; } } } } }