Пример #1
0
 public Block(SlotItem s)
 {
     if (s == null)
     {
         ID = BlockID.Air;
         return;
     }
     ID = s.ItemID.ToBlock();
     Meta = s.Uses;
     Light = Block.LightLevel((byte)ID);
 }
Пример #2
0
        public static SlotItem Read(EndianBinaryReader r)
        {
            SlotItem i = new SlotItem();
            
            i.ItemID = (BlockID)r.ReadInt16();
            if (i.ItemID < 0)
                return null;
            #if DEBUGPACKET
            if (((int)i.ItemID).ToString() == i.ItemID.ToString())
                throw new NotImplementedException("BlockID: " + (int)i.ItemID);
            #endif

            i.Count = r.ReadByte();
            i.Uses = r.ReadInt16();

            //Metadata   
            i.Data = Tag.ReadTag(r);
            //Debug.WriteLine(i + ": " + i.Data);

            return i;

        }
Пример #3
0
        public static void Write(EndianBinaryWriter w, SlotItem i)
        {
            if (i == null || i.ItemID < 0)
            {
                w.Write((short)-1);
                return;
            }
            w.Write((short)i.ItemID);
            w.Write((byte)i.Count);
            w.Write((short)i.Uses);

            if (i.ItemID == BlockID.BareHands)
                return;

            if (i.Data == null)
            {
                w.Write((byte)0);
                return;
            }
            if (i.Data is TagEnd)
                w.Write((byte)0);
            else
                i.Data.Write(w);
        }
Пример #4
0
 protected virtual bool ImportMeta(int id, SlotItem val)
 {
     return false;
 }
Пример #5
0
 protected virtual bool ImportMeta(int id, SlotItem val)
 {
     return(false);
 }