Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. class SlotProtocol : PacketProtocol {
  2. public static void SyncSlot( int whose, int slot, Item item ) {
  3. var protocol = new SlotProtocol( whose, slot, item );
  4. this.SendToServer( true );
  5. }
  6.  
  7.  
  8.  
  9. public const byte InventorySlot = 1;
  10. public const byte VisualState = 2;
  11.  
  12. public ubyte Whose;
  13. public byte Slot;
  14. public short ItemNetID;
  15. public short ItemStack;
  16. public byte ItemPrefix;
  17.  
  18.  
  19. public SlotProtocol() {}
  20.  
  21. private SlotProtocol( int whose, int slot, Item item ) {
  22. this.Whose = whose;
  23. this.Slot = slot;
  24. this.ItemNetID = item.netID;
  25. this.ItemStack = item.stack;
  26. this.ItemPrefix = item.prefix;
  27. }
  28.  
  29.  
  30. public override void ReceiveOnClient() {
  31. this.HandleReceive();
  32. }
  33.  
  34. public override void ReceiveOnServer() {
  35. this.HandleReceive();
  36. }
  37.  
  38.  
  39. private void HandleReceive() {
  40. var utilityInv = Main.player[ this.Whose ].UtilityInv();
  41. var item = this.Slot < utilityInv.items.Length
  42. ? utilityInv.items[ this.Slot ]
  43. : utilityInv.dyes[ this.Slot - utilityInv.items.Length];
  44.  
  45. item.netDefaults( this.ItemNetID );
  46. item.stack = this.ItemStack;
  47. item.prefix = this.ItemPrefix;
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement