Ejemplo n.º 1
0
 public override void Write(BigEndianStream stream)
 {
     stream.Write(EntityId);
     stream.Write(Unknown);
     stream.Write(X);
     stream.Write(Y);
     stream.Write(Z);
 }
Ejemplo n.º 2
0
        public override void Write(BigEndianStream stream)
        {
            stream.Write(X);
            stream.Write(Y);
            stream.Write(Z);
            stream.Write(SizeX);
            stream.Write(SizeY);
            stream.Write(SizeZ);

            int o = 16 * 16 * 128;
            byte[] data = new byte[o * 5 / 2];

            int i = 0;
            for (int x = 0; x < 16; x++)
            {
                for (int z = 0; z < 16; z++)
                {
                    for (int y = 0; y < 128; y++)
                    {
                        int s = ((i + 1) & 1) * 4;
                        int ofst = i;
                        data[ofst] = Chunk[x, y, z];
                        ofst = i / 2 + o * 2 / 2;
                        data[ofst] = unchecked((byte)(data[ofst] | (Chunk.GetData(x, y, z) << s)));
                        ofst = i / 2 + o * 3 / 2;
                        data[ofst] = unchecked((byte)(data[ofst] | (Chunk.GetBlockLight(x, y, z) << s)));
                        ofst = i / 2 + o * 4 / 2;
                        data[ofst] = unchecked((byte)(data[ofst] | (Chunk.GetSkyLight(x, y, z) << s)));
                        i++;
                    }
                }
            }

            byte[] comp = new byte[o * 5];
            int len;

            Deflater deflater = new Deflater(0);
            try
            {
                deflater.setInput(data);
                deflater.finish();
                len = deflater.deflate(comp);
            }
            finally
            {
                deflater.end();
            }

            stream.Write(len);
            stream.Write(comp, 0, len);
        }
Ejemplo n.º 3
0
 internal void Write(BigEndianStream stream)
 {
     stream.Write(Type > 0 ? Type : (short)-1);
     if (Type > 0)
     {
         stream.Write(Count);
         stream.Write(Durability);
     }
 }
Ejemplo n.º 4
0
        internal void Write(BigEndianStream stream)
        {
            stream.Write(Type > 0 ? Type : (short)-1);
            if (Type > 0)
            {
                stream.Write(Count);
                stream.Write(Durability);

                //if (Durability > 0 || IsEnchantable())
                    stream.Write((short)-1);
                // TODO: Remove the two lines above and implement items and enchantments write
                /*
                 * if (Item.CanBeDamaged())
                 * {
                 *      if(_enchantments != null)
                 *          WriteEnchantmentsToNBT(stream);
                 *      else
                 *          stream.Write(-1);
                 * }
                 */
            }
        }
Ejemplo n.º 5
0
 internal void Write(BigEndianStream tx)
 {
     try // I can't work out how it set this from SpawnAnimal.
     {
         foreach (int k in Data.Keys)
         {
             Type type = Data[k].GetType();
             if (type == typeof(byte))
             {
                 tx.WriteByte((byte)k);
                 tx.Write((byte)Data[k]);
             }
             else if (type == typeof(short))
             {
                 tx.WriteByte((byte)(0x20 | k));
                 tx.Write((short)Data[k]);
             }
             else if (type == typeof(int))
             {
                 tx.WriteByte((byte)(0x40 | k));
                 tx.Write((int)Data[k]);
             }
             else if (type == typeof(float))
             {
                 tx.WriteByte((byte)(0x60 | k));
                 tx.Write((float)Data[k]);
             }
             else if (type == typeof(string))
             {
                 tx.WriteByte((byte)(0x80 | k));
                 tx.Write((string)Data[k]);
             }
         }
     }
     catch { }
     finally
     {
         tx.WriteByte(0x7f);
     }
 }
Ejemplo n.º 6
0
 public override void Write(BigEndianStream stream)
 {
     stream.Write(Statistic);
     stream.Write(Amount);
 }