Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SlotProtocol : PacketProtocol {
- public static void SyncSlot( int whose, int slot, Item item ) {
- var protocol = new SlotProtocol( whose, slot, item );
- this.SendToServer( true );
- }
- public const byte InventorySlot = 1;
- public const byte VisualState = 2;
- public ubyte Whose;
- public byte Slot;
- public short ItemNetID;
- public short ItemStack;
- public byte ItemPrefix;
- public SlotProtocol() {}
- private SlotProtocol( int whose, int slot, Item item ) {
- this.Whose = whose;
- this.Slot = slot;
- this.ItemNetID = item.netID;
- this.ItemStack = item.stack;
- this.ItemPrefix = item.prefix;
- }
- public override void ReceiveOnClient() {
- this.HandleReceive();
- }
- public override void ReceiveOnServer() {
- this.HandleReceive();
- }
- private void HandleReceive() {
- var utilityInv = Main.player[ this.Whose ].UtilityInv();
- var item = this.Slot < utilityInv.items.Length
- ? utilityInv.items[ this.Slot ]
- : utilityInv.dyes[ this.Slot - utilityInv.items.Length];
- item.netDefaults( this.ItemNetID );
- item.stack = this.ItemStack;
- item.prefix = this.ItemPrefix;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement