Esempio n. 1
0
 public override bool ParseBytesAndExecute(byte[] data)
 {
     if (data.Length < 4 + 4)
     {
         SysConsole.Output(OutputType.WARNING, "Invalid packet len: " + data.Length);
         return false;
     }
     int spot = Utilities.BytesToInt(Utilities.BytesPartial(data, 0, 4));
     if (spot < 0 || spot > TheClient.Items.Count)
     {
         SysConsole.Output(OutputType.WARNING, "Bad spot:" + spot);
         return false;
     }
     byte[] dat = Utilities.BytesPartial(data, 4, data.Length - 4);
     try
     {
         ItemStack item = new ItemStack(TheClient, dat);
         TheClient.Items.Insert(spot, item);
         TheClient.UpdateInventoryMenu();
         return true;
     }
     catch (Exception ex)
     {
         SysConsole.Output("Spawning item", ex);
         return false;
     }
 }
Esempio n. 2
0
 public override bool ParseBytesAndExecute(byte[] data)
 {
     if (data.Length < 4 + 4)
     {
         return false;
     }
     int spot = Utilities.BytesToInt(Utilities.BytesPartial(data, 0, 4));
     if (spot < 0 || spot > TheClient.Items.Count)
     {
         return false;
     }
     byte[] dat = Utilities.BytesPartial(data, 4, data.Length - 4);
     try
     {
         ItemStack item = new ItemStack(TheClient, dat);
         TheClient.Items[spot] = item;
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
Esempio n. 3
0
 public void InventorySelectItem(int slot)
 {
     ItemStack item = GetItemForSlot(slot);
     InvCurrent = item;
     UI_Inv_Displayname.Text = "^B" + item.DisplayName;
     UI_Inv_Description.Text = "^r^7" + item.Name + (item.SecondaryName != null && item.SecondaryName.Length > 0 ? " [" + item.SecondaryName + "]" : "") + "\n>^B" + item.Description;
     UI_Inv_Detail.Text = "^BCount: " + item.Count + ", Color: " + item.DrawColor + ", Texture: " + (item.Tex != null ? item.Tex.Name: "{NULL}")
         + ", Model: " + (item.Mod != null ? item.Mod.Name : "{NULL}") + ", Shared attributes: "+  item.SharedStr();
 }
Esempio n. 4
0
 /// <summary>
 /// Renders an item on the 2D screen.
 /// </summary>
 /// <param name="item">The item to render.</param>
 /// <param name="pos">Where to render it.</param>
 /// <param name="size">How big to render it, in pixels.</param>
 public void RenderItem(ItemStack item, Location pos, int size, bool sub3d)
 {
     if (sub3d)
     {
         IsOrtho = true;
         item.Render3D(pos + new Location(size * 0.5f), (float)GlobalTickTimeLocal * 0.5f, new Location(size * 0.75));
         IsOrtho = false;
         return;
     }
     ItemFrame.Bind();
     Rendering.SetColor(Color4.White);
     Rendering.RenderRectangle((int)pos.X - 1, (int)pos.Y - 1, (int)(pos.X + size) + 1, (int)(pos.Y + size) + 1);
     item.Render(pos, new Location(size, size, 0));
     if (item.Count > 0)
     {
         FontSets.SlightlyBigger.DrawColoredText("^!^e^7^S" + item.Count, new Location(pos.X + 5, pos.Y + size - FontSets.SlightlyBigger.font_default.Height / 2f - 5, 0));
     }
 }