本文整理汇总了C#中MinecraftServer类的典型用法代码示例。如果您正苦于以下问题:C# MinecraftServer类的具体用法?C# MinecraftServer怎么用?C# MinecraftServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MinecraftServer类属于命名空间,在下文中一共展示了MinecraftServer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SendPacket
public override void SendPacket(MinecraftServer server, MinecraftClient client)
{
client.SendData(CreateBuffer(
DataUtility.CreateInt32(EntityId),
DataUtility.CreateInt16(SlotIndex),
Item.GetData()));
}
开发者ID:Imperceptus,项目名称:Craft.Net,代码行数:7,代码来源:EntityEquipmentPacket.cs
示例2: HandlePacket
public override void HandlePacket(MinecraftServer Server, ref MinecraftClient Client)
{
if (!Client.ReadyToSpawn)
return;
Client.Entity.Pitch = Pitch;
Client.Entity.Yaw = Yaw;
}
开发者ID:keneo,项目名称:Craft.Net,代码行数:7,代码来源:PlayerLookPacket.cs
示例3: SendPacket
public override void SendPacket(MinecraftServer server, MinecraftClient client)
{
byte[] payload = new byte[] { PacketId, (byte)EntityIds.Length };
foreach (int id in EntityIds)
payload = payload.Concat(DataUtility.CreateInt32(id)).ToArray();
client.SendData(payload);
}
开发者ID:pdelvo,项目名称:Craft.Net,代码行数:7,代码来源:DestroyEntityPacket.cs
示例4: EntityAction
public static void EntityAction(MinecraftClient client, MinecraftServer server, IPacket _packet)
{
var packet = (EntityActionPacket)_packet;
switch (packet.Action)
{
case EntityActionPacket.EntityAction.Crouch:
client.Entity.IsCrouching = true;
break;
case EntityActionPacket.EntityAction.Uncrouch:
client.Entity.IsCrouching = false;
break;
case EntityActionPacket.EntityAction.StartSprinting:
client.Entity.IsSprinting = true;
break;
case EntityActionPacket.EntityAction.StopSprinting:
client.Entity.IsSprinting = false;
break;
case EntityActionPacket.EntityAction.LeaveBed:
client.Entity.LeaveBed();
break;
}
if (packet.Action != EntityActionPacket.EntityAction.LeaveBed) // NOTE: Does this matter?
{
// TODO ?
}
}
开发者ID:ammaraskar,项目名称:Craft.Net,代码行数:26,代码来源:PlayerMovementHandlers.cs
示例5: ThreadSleepForever
private MinecraftServer mc; /* synthetic field */
#endregion Fields
#region Constructors
public ThreadSleepForever(MinecraftServer minecraftserver)
{
mc = minecraftserver;
//
setDaemon(true);
start();
}
开发者ID:riverar,项目名称:Crafty,代码行数:13,代码来源:ThreadSleepForever.cs
示例6: Handshake
public static void Handshake(MinecraftClient client, MinecraftServer server, IPacket _packet)
{
var packet = (HandshakePacket)_packet;
if (packet.ProtocolVersion < PacketReader.ProtocolVersion)
{
client.SendPacket(new DisconnectPacket("Outdated client!"));
return;
}
if (packet.ProtocolVersion > PacketReader.ProtocolVersion)
{
client.SendPacket(new DisconnectPacket("Outdated server!"));
return;
}
if (server.Clients.Any(c => c.Username == packet.Username))
{
client.SendPacket(new DisconnectPacket(""));
return;
}
client.Username = packet.Username;
client.Hostname = packet.ServerHostname + ":" + packet.ServerPort;
if (server.Settings.OnlineMode)
client.AuthenticationHash = CreateHash();
else
client.AuthenticationHash = "-";
if (server.Settings.EnableEncryption)
client.SendPacket(CreateEncryptionRequest(client, server));
else
server.LogInPlayer(client);
}
开发者ID:cpancake,项目名称:Craft.Net,代码行数:29,代码来源:LoginHandlers.cs
示例7: KeepAlive
public static void KeepAlive(MinecraftClient client, MinecraftServer server, IPacket _packet)
{
var packet = (KeepAlivePacket)_packet;
// TODO: Confirm value validity
client.LastKeepAlive = DateTime.Now;
client.Ping = (short)(client.LastKeepAlive - client.LastKeepAliveSent).TotalMilliseconds;
}
开发者ID:skirmish,项目名称:Craft.Net,代码行数:7,代码来源:PacketHandlers.cs
示例8: GetPingValue
private static string GetPingValue(MinecraftServer server)
{
return "§1\0" + PacketReader.ProtocolVersion + "\0" +
PacketReader.FriendlyVersion + "\0" +
server.Settings.MotD + "\0" + server.Clients.Count(c => c.IsLoggedIn) +
"\0" + server.Settings.MaxPlayers;
}
开发者ID:nevercast,项目名称:Craft.Net,代码行数:7,代码来源:PacketHandlers.cs
示例9: ClientStatus
public static void ClientStatus(MinecraftClient client, MinecraftServer server, IPacket _packet)
{
var packet = (ClientStatusPacket)_packet;
if (packet.Status == ClientStatusPacket.ClientStatus.InitialSpawn)
{
// Create a hash for session verification
SHA1 sha1 = SHA1.Create();
AsnKeyBuilder.AsnMessage encodedKey = AsnKeyBuilder.PublicKeyToX509(server.ServerKey);
byte[] shaData = Encoding.UTF8.GetBytes(client.AuthenticationHash)
.Concat(client.SharedKey)
.Concat(encodedKey.GetBytes()).ToArray();
string hash = Cryptography.JavaHexDigest(shaData);
// Talk to session.minecraft.net
if (server.Settings.OnlineMode)
{
var webClient = new WebClient();
var webReader = new StreamReader(webClient.OpenRead(
new Uri(string.Format(sessionCheckUri, client.Username, hash))));
string response = webReader.ReadToEnd();
webReader.Close();
if (response != "YES")
{
client.SendPacket(new DisconnectPacket("Failed to verify username!"));
return;
}
}
server.LogInPlayer(client);
}
else if (packet.Status == ClientStatusPacket.ClientStatus.Respawn)
{
// TODO
}
}
开发者ID:ammaraskar,项目名称:Craft.Net,代码行数:35,代码来源:LoginHandlers.cs
示例10: SendPacket
public override void SendPacket(MinecraftServer server, MinecraftClient client)
{
// TODO: Refactor like mad
var buffer = new List<byte>();
buffer.Add(PacketId);
buffer.AddRange(DataUtility.CreateInt32(Item.Id));
if (Item.Item.Empty)
buffer.AddRange(DataUtility.CreateInt16(-1));
else
{
buffer.AddRange(DataUtility.CreateInt16((short)Item.Item.Id)); // TODO: Make slots use signed shorts
buffer.Add(Item.Item.Count);
buffer.AddRange(DataUtility.CreateInt16((short)Item.Item.Metadata));
buffer.AddRange(DataUtility.CreateInt16(-1)); // TODO: Nbt appears to be sent here
}
buffer.AddRange(DataUtility.CreateAbsoluteInteger(Item.Position.X));
buffer.AddRange(DataUtility.CreateAbsoluteInteger(Item.Position.Y));
buffer.AddRange(DataUtility.CreateAbsoluteInteger(Item.Position.Z));
buffer.AddRange(DataUtility.CreatePackedByte(Item.Pitch));
buffer.AddRange(DataUtility.CreatePackedByte(Item.Pitch));
buffer.AddRange(DataUtility.CreatePackedByte(Item.Yaw));
client.SendData(buffer.ToArray());
}
开发者ID:Imperceptus,项目名称:Craft.Net,代码行数:25,代码来源:SpawnDroppedItemPacket.cs
示例11: SendPacket
public override void SendPacket(MinecraftServer server, MinecraftClient client)
{
client.SendData(CreateBuffer(
DataUtility.CreateInt32((int)SpawnPosition.X),
DataUtility.CreateInt32((int)SpawnPosition.Y),
DataUtility.CreateInt32((int)SpawnPosition.Z)));
}
开发者ID:Imperceptus,项目名称:Craft.Net,代码行数:7,代码来源:SpawnPositionPacket.cs
示例12: RegisterHandlers
public static void RegisterHandlers(MinecraftServer server)
{
server.RegisterPacketHandler(typeof(HandshakePacket), LoginHandlers.Handshake);
server.RegisterPacketHandler(typeof(LoginStartPacket), LoginHandlers.LoginStart);
server.RegisterPacketHandler(typeof(EncryptionKeyResponsePacket), LoginHandlers.EncryptionKeyResponse);
server.RegisterPacketHandler(typeof(ClientStatusPacket), LoginHandlers.ClientStatus);
server.RegisterPacketHandler(typeof(ClientSettingsPacket), LoginHandlers.ClientSettings);
server.RegisterPacketHandler(typeof(PlayerPacket), PlayerMovementHandlers.Player);
server.RegisterPacketHandler(typeof(PlayerPositionPacket), PlayerMovementHandlers.PlayerPosition);
server.RegisterPacketHandler(typeof(PlayerLookPacket), PlayerMovementHandlers.PlayerLook);
server.RegisterPacketHandler(typeof(PlayerPositionAndLookPacket), PlayerMovementHandlers.PlayerPositionAndLook);
server.RegisterPacketHandler(typeof(AnimationPacket), PlayerMovementHandlers.Animation);
server.RegisterPacketHandler(typeof(EntityActionPacket), PlayerMovementHandlers.EntityAction);
server.RegisterPacketHandler(typeof(PlayerAbilitiesPacket), PlayerMovementHandlers.PlayerAbilities);
server.RegisterPacketHandler(typeof(CreativeInventoryActionPacket), InventoryHandlers.CreativeInventoryAction);
server.RegisterPacketHandler(typeof(ClickWindowPacket), InventoryHandlers.ClickWindow);
server.RegisterPacketHandler(typeof(CloseWindowPacket), InventoryHandlers.CloseWindow);
server.RegisterPacketHandler(typeof(HeldItemPacket), InventoryHandlers.HeldItemChange);
server.RegisterPacketHandler(typeof(PlayerBlockActionPacket), InteractionHandlers.PlayerDigging);
server.RegisterPacketHandler(typeof(RightClickPacket), InteractionHandlers.RightClick);
server.RegisterPacketHandler(typeof(StatusRequestPacket), StatusRequest);
server.RegisterPacketHandler(typeof(StatusPingPacket), StatusPing);
server.RegisterPacketHandler(typeof(ChatMessagePacket), ChatMessage);
server.RegisterPacketHandler(typeof(KeepAlivePacket), KeepAlive);
}
开发者ID:kaltinril,项目名称:Craft.Net,代码行数:29,代码来源:PacketHandlers.cs
示例13: SendPacket
public override void SendPacket(MinecraftServer server, MinecraftClient client)
{
client.SendData(CreateBuffer(
DataUtility.CreateString(PlayerName),
DataUtility.CreateBoolean(Online),
DataUtility.CreateInt16(Ping)));
}
开发者ID:Imperceptus,项目名称:Craft.Net,代码行数:7,代码来源:PlayerListItemPacket.cs
示例14: HandlePacket
public override void HandlePacket(MinecraftServer server, MinecraftClient client)
{
if (!client.ReadyToSpawn)
return;
client.Entity.Pitch = Pitch;
client.Entity.Yaw = Yaw;
}
开发者ID:Imperceptus,项目名称:Craft.Net,代码行数:7,代码来源:PlayerLookPacket.cs
示例15: SendPacket
public override void SendPacket(MinecraftServer server, MinecraftClient client)
{
byte[] data = new byte[] {PacketId}
.Concat(DataUtility.CreateInt32(EntityId))
.Concat(new byte[] {(byte)Animation}).ToArray();
client.SendData(data);
}
开发者ID:pdelvo,项目名称:Craft.Net,代码行数:7,代码来源:AnimationPacket.cs
示例16: RegisterHandlers
public static void RegisterHandlers(MinecraftServer server)
{
server.RegisterPacketHandler(HandshakePacket.PacketId, LoginHandlers.Handshake);
server.RegisterPacketHandler(EncryptionKeyResponsePacket.PacketId, LoginHandlers.EncryptionKeyResponse);
server.RegisterPacketHandler(ClientStatusPacket.PacketId, LoginHandlers.ClientStatus);
server.RegisterPacketHandler(ClientSettingsPacket.PacketId, LoginHandlers.ClientSettings);
server.RegisterPacketHandler(PlayerPacket.PacketId, PlayerMovementHandlers.Player);
server.RegisterPacketHandler(PlayerPositionPacket.PacketId, PlayerMovementHandlers.PlayerPosition);
server.RegisterPacketHandler(PlayerLookPacket.PacketId, PlayerMovementHandlers.PlayerLook);
server.RegisterPacketHandler(PlayerPositionAndLookPacket.PacketId, PlayerMovementHandlers.PlayerPositionAndLook);
server.RegisterPacketHandler(AnimationPacket.PacketId, PlayerMovementHandlers.Animation);
server.RegisterPacketHandler(EntityActionPacket.PacketId, PlayerMovementHandlers.EntityAction);
server.RegisterPacketHandler(PlayerAbilitiesPacket.PacketId, PlayerMovementHandlers.PlayerAbilities);
server.RegisterPacketHandler(CreativeInventoryActionPacket.PacketId, InventoryHandlers.CreativeInventoryAction);
server.RegisterPacketHandler(ClickWindowPacket.PacketId, InventoryHandlers.ClickWindow);
server.RegisterPacketHandler(CloseWindowPacket.PacketId, InventoryHandlers.CloseWindow);
server.RegisterPacketHandler(HeldItemChangePacket.PacketId, InventoryHandlers.HeldItemChange);
server.RegisterPacketHandler(PlayerDiggingPacket.PacketId, InteractionHandlers.PlayerDigging);
server.RegisterPacketHandler(RightClickPacket.PacketId, InteractionHandlers.RightClick);
server.RegisterPacketHandler(ServerListPingPacket.PacketId, ServerListPing);
server.RegisterPacketHandler(ChatMessagePacket.PacketId, ChatMessage);
server.RegisterPacketHandler(KeepAlivePacket.PacketId, KeepAlive);
}
开发者ID:nevercast,项目名称:Craft.Net,代码行数:27,代码来源:PacketHandlers.cs
示例17: HandlePacket
public override void HandlePacket(MinecraftServer server, MinecraftClient client)
{
var target = server.EntityManager.GetEntity(TargetId);
if (target == null ||
server.EntityManager.GetEntityWorld(target) != server.EntityManager.GetEntityWorld(client.Entity) ||
target.Position.DistanceTo(client.Entity.Position) > client.Reach)
return;
if (target is LivingEntity)
{
// Do damage
if (LeftClick)
{
var livingEntity = target as LivingEntity;
if (livingEntity.Invulnerable)
return;
var item = client.Entity.SelectedItem.Item;
if (item == null)
item = new AirBlock();
client.Entity.FoodExhaustion += 0.3f;
livingEntity.Damage(item.AttackDamage);
livingEntity.Velocity /*+*/= DataUtility.RotateY(new Vector3(0, 0, client.Entity.IsSprinting ? 10 : 3),
// TODO: Knockback enchantment
DataUtility.DegreesToRadians(client.Entity.Yaw));
if (livingEntity is PlayerEntity)
{
(livingEntity as PlayerEntity).LastDamageType = DamageType.Combat;
(livingEntity as PlayerEntity).LastAttackingEntity = client.Entity;
}
// TODO: Physics
}
}
}
开发者ID:Imperceptus,项目名称:Craft.Net,代码行数:34,代码来源:UseEntityPacket.cs
示例18: EntityTracker
public EntityTracker(MinecraftServer minecraftserver)
{
trackedEntitySet = new HashSet();
trackedEntityHashTable = new MCHashTable();
mcServer = minecraftserver;
maxTrackingDistanceThreshold = minecraftserver.configManager.func_640_a();
}
开发者ID:riverar,项目名称:Crafty,代码行数:7,代码来源:EntityTracker.cs
示例19: SendPacket
public override void SendPacket(MinecraftServer server, MinecraftClient client)
{
client.SendData(CreateBuffer(
DataUtility.CreateInt16(Health),
DataUtility.CreateInt16(Food),
DataUtility.CreateFloat(FoodSaturation)));
}
开发者ID:Imperceptus,项目名称:Craft.Net,代码行数:7,代码来源:UpdateHealthPacket.cs
示例20: HandlePacket
public override void HandlePacket(MinecraftServer server, MinecraftClient client)
{
switch (Action)
{
case EntityAction.Crouch:
client.IsCrouching = true;
break;
case EntityAction.Uncrouch:
client.IsCrouching = false;
break;
case EntityAction.StartSprinting:
client.IsSprinting = true;
break;
case EntityAction.StopSprinting:
client.IsSprinting = false;
break;
case EntityAction.LeaveBed:
client.Entity.LeaveBed();
break;
}
if (Action != EntityAction.LeaveBed) // NOTE: Does this matter?
{
// TODO ?
}
}
开发者ID:pdelvo,项目名称:Craft.Net,代码行数:25,代码来源:EntityActionPacket.cs
注:本文中的MinecraftServer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论