public CameraMan(Camera camera, MinecraftLibrary.Client client)
 {
     mCamera = camera;
     mClient = client;
 }
Example #2
0
 public void packetHandler(object sender,Client.packetReceivedEventArgs e)
 {
     switch (e.ID)
     {
         case 0x0D:
             Packet_PlayerPosAndLook p = (Packet_PlayerPosAndLook)e.packet;
             moveCamera((float)p.x, (float)p.y+3f, (float)p.z);
             break;
         case 8:
             Packet_UpdateHealth h = (Packet_UpdateHealth)e.packet;
             Console.WriteLine("Health Update: {0} {1}", h.health, h.food);
             if (h.health <= 0)
             {
                 Packet_Respawn r = new Packet_Respawn();
                 r.dim = 0;
                 r.difficulty = 1;
                 r.creative = 0;
                 r.levelType = "default";
                 r.worldHeight = 256;
                 mc.sendPacket(r);
             }
             break;
         case 0x32:
             Packet_PreChunk c = (Packet_PreChunk)e.packet;
             if (c.mode)
             {
                 if (!chunks.ContainsKey(c.x + "_" + c.z))
                     chunks.Add(c.x + "_" + c.z, new Chunk());
             }
             else
                 if (chunks.ContainsKey(c.x + "_" + c.z))
                     chunks.Remove(c.x + "_" + c.z);
             break;
         case 0x33:
             Packet_MapChunk mch = (Packet_MapChunk)e.packet;
             int cx, cz;
             cx = mch.x;
             cz = mch.z;
             string key = cx + "_" + cz;
             //output("Chunk: " + key, true);
             if (!chunks.ContainsKey(key))
             {
                 chunks.Add(key, new Chunk());
                 //output("Chunk had to be added! " + key, true);
             }
             chunks[key].update(mch);
             QueueChunk(chunks[key]);
             break;
         case 0x34:
             Packet_MultiBlockChange mb = (Packet_MultiBlockChange)e.packet;
             chunks[mb.x + "_" + mb.z].update(mb);
             QueueChunk(chunks[mb.x + "_" + mb.z]);
             break;
     }
 }
Example #3
0
 public CameraMan(Camera camera,MinecraftLibrary.Client client)
 {
     mCamera = camera;
     mClient = client;
 }
Example #4
0
 public void packetHandler(object sender,Client.packetReceivedEventArgs e)
 {
     switch ((byte)e.Type)
     {
         case 0x0D:
             Packet_PlayerPosAndLook p = (Packet_PlayerPosAndLook)e.packet;
             moveCamera((float)p.X, (float)p.Y+3f, (float)p.Z);
             break;
         case 8:
             Packet_UpdateHealth h = (Packet_UpdateHealth)e.packet;
             Console.WriteLine("Health Update: {0} {1}", h.Health, h.Food);
             if (h.Health <= 0)
             {
                 Packet_Respawn r = new Packet_Respawn();
                 r.Dimension = 0;
                 r.Difficulty = 1;
                 r.Gamemode = 0;
                 r.LevelType = "default";
                 r.WorldHeight = 256;
                 mc.sendPacket(r);
             }
             break;
        /* case 0x32:
             Packet_PreChunk c = (Packet_PreChunk)e.packet;
             if (c.Mode)
             {
                 if (!chunks.ContainsKey(c.X + "_" + c.Z))
                     chunks.Add(c.X + "_" + c.Z, new Chunk());
             }
             else
                 if (chunks.ContainsKey(c.X + "_" + c.Z))
                     chunks.Remove(c.X + "_" + c.Z);
             break; */
         case 0x33:
             Packet_MapChunk mch = (Packet_MapChunk)e.packet;
             int cx, cz;
             cx = mch.X;
             cz = mch.Z;
             string key = cx + "_" + cz;
             //output("Chunk: " + key, true);
             if (!chunks.ContainsKey(key))
             {
                 chunks.Add(key, new Chunk());
                 //output("Chunk had to be added! " + key, true);
             }
             chunks[key].update(mch);
             QueueChunk(chunks[key]);
             break;
         case 0x34:
             Packet_MultiBlockChange mb = (Packet_MultiBlockChange)e.packet;
             chunks[mb.X + "_" + mb.Z].update(mb);
             QueueChunk(chunks[mb.X + "_" + mb.Z]);
             break;
     }
 }