public override void HandlePacket(BinaryReader reader, int whoAmI) { var type = (PacketType)reader.ReadByte(); if (Main.netMode == NetmodeID.Server) { ModPacket pak = GetPacket(); pak.Write((byte)type); ShaderID.Write(pak, ShaderID.Read(reader)); if (type == PacketType.NPC) { pak.Write(reader.ReadInt32()); } else if (type == PacketType.PROJ) { pak.Write(reader.ReadInt32()); pak.Write(reader.ReadByte()); } else { pak.Write(whoAmI); } pak.Send(ignoreClient: whoAmI); } else { ShaderID shader = ShaderID.Read(reader); switch (type) { case PacketType.AMMO: ammoShaders[reader.ReadInt32()] = shader; break; case PacketType.NPC: Main.npc[reader.ReadInt32()].Customizer().shaderID = shader.ID; break; case PacketType.PROJ: // read in reverse order because why ??? // none of this actually works anyway // if GlobalItem had a net sync function that'd be great int identity = reader.ReadInt32(); byte owner = reader.ReadByte(); //int idx = Projectile.GetByUUID(owner, identity); int num84 = 1000; for (int num85 = 0; num85 < 1000; num85++) { if (Main.projectile[num85].owner == owner && Main.projectile[num85].identity == identity && Main.projectile[num85].active) { num84 = num85; break; } } if (num84 == 1000) { for (int num86 = 0; num86 < 1000; num86++) { if (!Main.projectile[num86].active) { num84 = num86; break; } } } Main.NewText("Received projectile packet: " + owner + " " + identity + " " + num84 + " " + shader.ID); if (num84 != -1 && num84 != Main.maxProjectiles) { var proj = Main.projectile[num84]; //if(proj.Customizer() is CustomizerProjInfo customizer) //customizer.shaderID = shader.ID; proj.Customizer().shaderID = shader.ID; } else { Main.NewText("Invalid projectile identity"); } break; } } }
public override void NetReceive(Item item, BinaryReader reader) { itemName = reader.ReadString(); shaderID = ShaderID.Read(reader); item.SafeNameOverride(itemName); }