Code refactoring (related to #1024)

This commit is contained in:
ORelio 2020-05-25 21:39:24 +02:00
parent d120001d70
commit 23870711a0
11 changed files with 69 additions and 100 deletions

View file

@ -693,7 +693,7 @@ namespace MinecraftClient.Protocol.Handlers
return false; //Currently not implemented
}
public bool SendCreativeInventoryAction(int slot, Item item)
public bool SendCreativeInventoryAction(int slot, ItemType item, int count)
{
return false; //Currently not implemented
}

View file

@ -215,8 +215,6 @@ namespace MinecraftClient.Protocol.Handlers
break;
case PacketIncomingType.JoinGame:
handler.OnGameJoined();
// by reinforce
// get client player EntityID
int playerEntityID = dataTypes.ReadNextInt(packetData);
handler.SetPlayerEntityID(playerEntityID);
dataTypes.ReadNextByte(packetData);
@ -1377,13 +1375,13 @@ namespace MinecraftClient.Protocol.Handlers
catch (ObjectDisposedException) { return false; }
}
public bool SendCreativeInventoryAction(int slot, Item item)
public bool SendCreativeInventoryAction(int slot, ItemType itemType, int count)
{
try
{
List<byte> packet = new List<byte>();
packet.AddRange(dataTypes.GetShort((short)slot));
packet.AddRange(dataTypes.GetItemSlot(item));
packet.AddRange(dataTypes.GetItemSlot(new Item((int)itemType, count, null)));
SendPacket(PacketOutgoingType.CreativeInventoryAction, packet);
return true;

View file

@ -150,11 +150,14 @@ namespace MinecraftClient.Protocol
bool SendWindowAction(int windowId, int slotId, WindowActionType action, Item item);
/// <summary>
/// Send a click window slot packet to the server
/// Request Creative Mode item creation into regular/survival Player Inventory
/// </summary>
/// <param name="slot">Id of inventory slot</param>
/// <param name="item">Id of item </param>
bool SendCreativeInventoryAction(int slot, Item item);
/// <remarks>(obviously) requires to be in creative mode</remarks>
/// <param name="slot">Destination inventory slot</param>
/// <param name="itemType">Item type</param>
/// <param name="count">Item count</param>
/// <returns>TRUE if item given successfully</returns>
bool SendCreativeInventoryAction(int slot, ItemType itemType, int count);
/// <summary>
/// Send a close window packet to the server

View file

@ -137,13 +137,13 @@ namespace MinecraftClient.Protocol
void OnSpawnEntity(Entity entity);
/// <summary>
/// Called when a player has spawned
/// Called when a player spawns or enters the client's render distance
/// </summary>
/// <param name="EntityID">Entity ID</param>
/// <param name="UUID">Entity UUID</param>
/// <param name="entityID">Entity ID</param>
/// <param name="uuid">Entity UUID</param>
/// <param name="location">Entity location</param>
/// <param name="Yaw">Player head yaw</param>
/// <param name="Pitch">Player head pitch</param>
/// <param name="yaw">Player head yaw</param>
/// <param name="pitch">Player head pitch</param>
void OnSpawnPlayer(int entityID, Guid uuid, Location location, byte yaw, byte pitch);
/// <summary>
@ -160,7 +160,7 @@ namespace MinecraftClient.Protocol
/// <param name="Dy">Y offset</param>
/// <param name="Dz">Z offset</param>
/// <param name="onGround">TRUE if on ground</param>
void OnEntityPosition(int entityID, Double dx, Double dy, Double dz,bool onGround);
void OnEntityPosition(int entityID, Double dx, Double dy, Double dz, bool onGround);
/// <summary>
/// Called when an entity moved to fixed coordinates