所以我试图创建一个循环,每次循环时我都会创建一个对象的新实例:像这样。
Client client = new Client(session);
client.Connect(server);
while (true) {
client.SendPacket(new Craft.Net.CreativeInventoryActionPacket(-1, new Craft.Net.ItemStack((short)19, (sbyte)1)));
client.Disconnect ("Generic");
System.Threading.Thread.Sleep(3000);
//obviously I cannot do this, because there is already an object named client.
Client client = new Client(session);
client.Connect(server);
}
我该怎么做呢?我需要创建一个新的 MinecraftClient 实例,在执行 client.Disconnect 后我无法重用旧实例。