本文整理汇总了C#中MiNET.Player.SendPackage方法的典型用法代码示例。如果您正苦于以下问题:C# Player.SendPackage方法的具体用法?C# Player.SendPackage怎么用?C# Player.SendPackage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MiNET.Player
的用法示例。
在下文中一共展示了Player.SendPackage方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToggleDownfall
public void ToggleDownfall(Player player)
{
ThreadPool.QueueUserWorkItem(delegate(object state)
{
for (int i = 0; i < short.MaxValue; i = i+2000)
{
var data = i;
{
McpeLevelEvent levelEvent = new McpeLevelEvent();
levelEvent.eventId = 3001;
levelEvent.data = data;
player.SendPackage(levelEvent);
}
//{
// McpeLevelEvent levelEvent = new McpeLevelEvent();
// levelEvent.eventId = 3002;
// levelEvent.data = i;
// player.SendPackage(levelEvent);
//}
player.SendMessage("Downfall " + data, type: MessageType.Raw);
Thread.Sleep(5000);
}
for (int i = short.MaxValue; i >= 0; i = i - 2000)
{
{
McpeLevelEvent levelEvent = new McpeLevelEvent();
levelEvent.eventId = 3001;
levelEvent.data = i;
player.SendPackage(levelEvent);
}
//{
// McpeLevelEvent levelEvent = new McpeLevelEvent();
// levelEvent.eventId = 3002;
// levelEvent.data = i;
// player.SendPackage(levelEvent);
//}
player.SendMessage("Downfall " + i, type: MessageType.Raw);
Thread.Sleep(5000);
}
});
//{
// McpeLevelEvent levelEvent = new McpeLevelEvent();
// levelEvent.eventId = 3001;
// levelEvent.data = 100000;
// player.SendPackage(levelEvent);
//}
//{
// McpeLevelEvent levelEvent = new McpeLevelEvent();
// levelEvent.eventId = 3002;
// levelEvent.data = 36625;
// player.SendPackage(levelEvent);
//}
player.SendMessage("Toggled downfall", type: MessageType.Raw);
}
示例2: ChangeDimension
public void ChangeDimension(Player player)
{
McpeChangeDimension change = McpeChangeDimension.CreateObject();
change.dimension = 1;
change.unknown = 0;
player.SendPackage(change);
}
示例3: GameMode
public void GameMode(Player player, int gameMode)
{
player.SendPackage(new McpeStartGame
{
seed = -1,
generator = 1,
gamemode = gameMode,
entityId = player.EntityId,
spawnX = player.Level.SpawnPoint.X,
spawnY = player.Level.SpawnPoint.Y,
spawnZ = player.Level.SpawnPoint.Z,
x = player.KnownPosition.X,
y = player.KnownPosition.Y,
z = player.KnownPosition.Z
});
}
示例4: AddPlayer
public override void AddPlayer(Player newPlayer, string broadcastText = null, bool spawn = true)
{
base.AddPlayer(newPlayer, broadcastText, false);
Mob entity = new Mob(new Random().Next(10, 16), this) // Passive mobs
//Mob entity = new Mob(new Random().Next(32, 39), this) // Hostile mobs
{
KnownPosition = newPlayer.KnownPosition,
//Data = -(blockId | 0 << 0x10)
};
entity.SpawnEntity();
// Despawn the new entity from the player himeself
newPlayer.SendPackage(new McpeRemoveEntity()
{
entityId = entity.EntityId,
});
_playerEntities.Add(newPlayer, entity);
}
示例5: Kit
public void Kit(Player player, int kitId)
{
var armor = player.Inventory.Armor;
var slots = player.Inventory.Slots;
switch (kitId)
{
case 0:
// Kit leather tier
armor[0] = new MetadataSlot(new ItemStack(298)); // Helmet
armor[1] = new MetadataSlot(new ItemStack(299)); // Chest
armor[2] = new MetadataSlot(new ItemStack(300)); // Leggings
armor[3] = new MetadataSlot(new ItemStack(301)); // Boots
break;
case 1:
// Kit gold tier
armor[0] = new MetadataSlot(new ItemStack(314)); // Helmet
armor[1] = new MetadataSlot(new ItemStack(315)); // Chest
armor[2] = new MetadataSlot(new ItemStack(316)); // Leggings
armor[3] = new MetadataSlot(new ItemStack(317)); // Boots
break;
case 2:
// Kit chain tier
armor[0] = new MetadataSlot(new ItemStack(302)); // Helmet
armor[1] = new MetadataSlot(new ItemStack(303)); // Chest
armor[2] = new MetadataSlot(new ItemStack(304)); // Leggings
armor[3] = new MetadataSlot(new ItemStack(305)); // Boots
break;
case 3:
// Kit iron tier
armor[0] = new MetadataSlot(new ItemStack(306)); // Helmet
armor[1] = new MetadataSlot(new ItemStack(307)); // Chest
armor[2] = new MetadataSlot(new ItemStack(308)); // Leggings
armor[3] = new MetadataSlot(new ItemStack(309)); // Boots
break;
case 4:
// Kit diamond tier
armor[0] = new MetadataSlot(new ItemStack(310)); // Helmet
armor[1] = new MetadataSlot(new ItemStack(311)); // Chest
armor[2] = new MetadataSlot(new ItemStack(312)); // Leggings
armor[3] = new MetadataSlot(new ItemStack(313)); // Boots
break;
}
byte c = 0;
slots[c++] = new MetadataSlot(new ItemStack(268, 1)); // Wooden Sword
slots[c++] = new MetadataSlot(new ItemStack(283, 1)); // Golden Sword
slots[c++] = new MetadataSlot(new ItemStack(272, 1)); // Stone Sword
slots[c++] = new MetadataSlot(new ItemStack(267, 1)); // Iron Sword
slots[c++] = new MetadataSlot(new ItemStack(276, 1)); // Diamond Sword
slots[c++] = new MetadataSlot(new ItemStack(261, 1)); // Bow
slots[c++] = new MetadataSlot(new ItemStack(262, 64)); // Arrows
slots[c++] = new MetadataSlot(new ItemStack(344, 64)); // Eggs
slots[c++] = new MetadataSlot(new ItemStack(332, 64)); // Snowballs
player.SendPackage(new McpeContainerSetContent
{
windowId = 0,
slotData = player.Inventory.Slots,
hotbarData = player.Inventory.ItemHotbar
});
player.SendPackage(new McpeContainerSetContent
{
windowId = 0x78, // Armor windows ID
slotData = player.Inventory.Armor,
hotbarData = null
});
SendEquipmentForPlayer(player);
SendArmorForPlayer(player);
player.Level.BroadcastTextMessage(string.Format("Player {0} changed kit.", player.Username), type: MessageType.Raw);
}
示例6: GameMode
public void GameMode(Player player, int gameMode)
{
player.GameMode = (GameMode) gameMode;
player.SendPackage(new McpeStartGame
{
seed = -1,
generator = 1,
gamemode = gameMode,
entityId = player.EntityId,
spawnX = player.Level.SpawnPoint.X,
spawnY = player.Level.SpawnPoint.Y,
spawnZ = player.Level.SpawnPoint.Z,
x = player.KnownPosition.X,
y = player.KnownPosition.Y,
z = player.KnownPosition.Z
});
player.Level.BroadcastTextMessage(string.Format("{0} changed to game mode {1}.", player.Username, gameMode), type: MessageType.Raw);
}
示例7: Fly
public void Fly(Player player)
{
player.SendPackage(new McpeAdventureSettings {flags = 0x80});
player.Level.BroadcastTextMessage(string.Format("Player {0} enabled flying.", player.Username), type: MessageType.Raw);
}
示例8: Effect
public void Effect(Player player, int effectId, int amplifier = 1, int duration = 20)
{
player.SendPackage(new McpeMobEffect
{
entityId = player.EntityId,
eventId = 1, // Add
effectId = (byte) effectId,
duration = 20*duration,
amplifier = (byte) amplifier,
particles = 0,
});
player.Level.BroadcastTextMessage(string.Format("{0} added effect {1} with strenght {2}", player.Username, effectId, amplifier), type: MessageType.Raw);
}
示例9: Hide
public void Hide(Player player, string type)
{
EntityType mobType;
try
{
mobType = (EntityType) Enum.Parse(typeof (EntityType), type, true);
}
catch (ArgumentException e)
{
return;
}
Level level = player.Level;
HidePlayer(player, true);
Mob entity = new Mob(mobType, level)
{
KnownPosition = player.KnownPosition,
HealthManager = player.HealthManager,
NameTag = player.NameTag,
};
entity.SpawnEntity();
var remove = McpeRemoveEntity.CreateObject();
remove.entityId = entity.EntityId;
player.SendPackage(remove);
_playerEntities[player] = entity;
level.BroadcastMessage($"Player {player.Username} spawned as {mobType}.", type: MessageType.Raw);
}
示例10: Hide
public void Hide(Player player, byte id)
{
Level level = player.Level;
level.HidePlayer(player, true);
Mob entity = new Mob(id, level)
{
KnownPosition = player.KnownPosition,
//Data = -(blockId | 0 << 0x10)
};
entity.SpawnEntity();
player.SendPackage(new McpeRemoveEntity()
{
entityId = entity.EntityId,
});
_playerEntities[player] = entity;
level.BroadcastTextMessage(string.Format("Player {0} spawned as other entity.", player.Username));
}
示例11: GameMode
public void GameMode(Player player, int gameMode)
{
if (gameMode == 1)
{
player.Inventory.Slots.Clear();
player.Inventory.Slots.AddRange(InventoryUtils.CreativeInventoryItems);
}
//player.GameMode = (GameMode) gameMode;
player.SendPackage(new McpeStartGame
{
seed = -1,
generator = 1,
gamemode = gameMode,
entityId = player.EntityId,
spawnX = (int)player.Level.SpawnPoint.X,
spawnY = (int)player.Level.SpawnPoint.Y,
spawnZ = (int)player.Level.SpawnPoint.Z,
x = player.KnownPosition.X,
y = player.KnownPosition.Y,
z = player.KnownPosition.Z
});
{
McpeContainerSetContent creativeContent = McpeContainerSetContent.CreateObject();
creativeContent.windowId = (byte)0x79;
creativeContent.slotData = player.Inventory.GetSlots();
creativeContent.hotbarData = player.Inventory.GetHotbar();
player.SendPackage(creativeContent);
}
player.Level.BroadcastMessage(string.Format("{0} changed to game mode {1}.", player.Username, gameMode), type: MessageType.Raw);
}
示例12: RespawnHandler
public Package RespawnHandler(McpeRespawn packet, Player player)
{
McpeMobEffect speedEffect = McpeMobEffect.CreateObject();
speedEffect.entityId = 0;
speedEffect.eventId = 1;
speedEffect.effectId = 1;
speedEffect.duration = 0x7fffffff;
speedEffect.amplifier = 2;
speedEffect.particles = 1;
player.SendPackage(speedEffect);
McpeMobEffect jumpEffect = McpeMobEffect.CreateObject();
jumpEffect.entityId = 0;
jumpEffect.eventId = 1;
jumpEffect.effectId = 8;
jumpEffect.duration = 0x7fffffff;
jumpEffect.amplifier = 2;
jumpEffect.particles = 1;
player.SendPackage(jumpEffect);
if (player.Level.LevelId.Equals("Default"))
{
player.Level.CurrentWorldTime = 10000;
player.Level.IsWorldTimeStarted = false;
}
player.SendSetTime();
return packet;
}