mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
parent
084668b621
commit
5b28179444
3 changed files with 47 additions and 6 deletions
|
|
@ -33,7 +33,9 @@ namespace MinecraftClient
|
||||||
|
|
||||||
private bool terrainAndMovementsEnabled;
|
private bool terrainAndMovementsEnabled;
|
||||||
private bool terrainAndMovementsRequested = false;
|
private bool terrainAndMovementsRequested = false;
|
||||||
private bool inventoryHandling;
|
private bool inventoryHandlingEnabled;
|
||||||
|
private bool inventoryHandlingRequested = false;
|
||||||
|
|
||||||
private object locationLock = new object();
|
private object locationLock = new object();
|
||||||
private bool locationReceived = false;
|
private bool locationReceived = false;
|
||||||
private World world = new World();
|
private World world = new World();
|
||||||
|
|
@ -106,7 +108,7 @@ namespace MinecraftClient
|
||||||
private void StartClient(string user, string uuid, string sessionID, string server_ip, ushort port, int protocolversion, ForgeInfo forgeInfo, bool singlecommand, string command)
|
private void StartClient(string user, string uuid, string sessionID, string server_ip, ushort port, int protocolversion, ForgeInfo forgeInfo, bool singlecommand, string command)
|
||||||
{
|
{
|
||||||
terrainAndMovementsEnabled = Settings.TerrainAndMovements;
|
terrainAndMovementsEnabled = Settings.TerrainAndMovements;
|
||||||
inventoryHandling = Settings.InventoryHandling;
|
inventoryHandlingEnabled = Settings.InventoryHandling;
|
||||||
|
|
||||||
bool retry = false;
|
bool retry = false;
|
||||||
this.sessionid = sessionID;
|
this.sessionid = sessionID;
|
||||||
|
|
@ -393,6 +395,12 @@ namespace MinecraftClient
|
||||||
Settings.MCSettings_MainHand);
|
Settings.MCSettings_MainHand);
|
||||||
foreach (ChatBot bot in bots)
|
foreach (ChatBot bot in bots)
|
||||||
bot.AfterGameJoined();
|
bot.AfterGameJoined();
|
||||||
|
if (inventoryHandlingRequested)
|
||||||
|
{
|
||||||
|
inventoryHandlingRequested = false;
|
||||||
|
inventoryHandlingEnabled = true;
|
||||||
|
ConsoleIO.WriteLogLine("Inventory handling is now enabled.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -426,7 +434,7 @@ namespace MinecraftClient
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool GetInventoryEnabled()
|
public bool GetInventoryEnabled()
|
||||||
{
|
{
|
||||||
return inventoryHandling;
|
return inventoryHandlingEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -455,6 +463,32 @@ namespace MinecraftClient
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enable or disable Inventories.
|
||||||
|
/// Please note that Enabling will be deferred until next relog.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="enabled">Enabled</param>
|
||||||
|
/// <returns>TRUE if the setting was applied immediately, FALSE if delayed.</returns>
|
||||||
|
public bool SetInventoryEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
if (!inventoryHandlingEnabled)
|
||||||
|
{
|
||||||
|
inventoryHandlingRequested = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inventoryHandlingEnabled = false;
|
||||||
|
inventoryHandlingRequested = false;
|
||||||
|
inventories.Clear();
|
||||||
|
playerInventory = null;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when the server sends a new player location,
|
/// Called when the server sends a new player location,
|
||||||
/// or if a ChatBot whishes to update the player's location.
|
/// or if a ChatBot whishes to update the player's location.
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,12 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
handler.SetTerrainEnabled(false);
|
handler.SetTerrainEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (handler.GetInventoryEnabled() && protocolversion > MC114Version)
|
||||||
|
{
|
||||||
|
ConsoleIO.WriteLineFormatted("§8Inventories are currently not handled for that MC version.");
|
||||||
|
handler.SetInventoryEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
if (protocolversion >= MC113Version)
|
if (protocolversion >= MC113Version)
|
||||||
{
|
{
|
||||||
if (protocolVersion > MC1142Version && handler.GetTerrainEnabled())
|
if (protocolVersion > MC1142Version && handler.GetTerrainEnabled())
|
||||||
|
|
@ -465,7 +471,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
compression_treshold = dataTypes.ReadNextVarInt(packetData);
|
compression_treshold = dataTypes.ReadNextVarInt(packetData);
|
||||||
break;
|
break;
|
||||||
case PacketIncomingType.OpenWindow:
|
case PacketIncomingType.OpenWindow:
|
||||||
if (protocolversion < MC1141Version && handler.GetInventoryEnabled())
|
if (handler.GetInventoryEnabled())
|
||||||
{
|
{
|
||||||
byte windowID = dataTypes.ReadNextByte(packetData);
|
byte windowID = dataTypes.ReadNextByte(packetData);
|
||||||
string type = dataTypes.ReadNextString(packetData).Replace("minecraft:", "").ToUpper();
|
string type = dataTypes.ReadNextString(packetData).Replace("minecraft:", "").ToUpper();
|
||||||
|
|
@ -478,7 +484,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketIncomingType.CloseWindow:
|
case PacketIncomingType.CloseWindow:
|
||||||
if (protocolversion < MC1141Version && handler.GetInventoryEnabled())
|
if (handler.GetInventoryEnabled())
|
||||||
{
|
{
|
||||||
byte windowID = dataTypes.ReadNextByte(packetData);
|
byte windowID = dataTypes.ReadNextByte(packetData);
|
||||||
|
|
||||||
|
|
@ -486,7 +492,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketIncomingType.WindowItems:
|
case PacketIncomingType.WindowItems:
|
||||||
if (protocolversion < MC1141Version && handler.GetInventoryEnabled())
|
if (handler.GetInventoryEnabled())
|
||||||
{
|
{
|
||||||
byte id = dataTypes.ReadNextByte(packetData);
|
byte id = dataTypes.ReadNextByte(packetData);
|
||||||
short elements = dataTypes.ReadNextShort(packetData);
|
short elements = dataTypes.ReadNextShort(packetData);
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ namespace MinecraftClient.Protocol
|
||||||
bool GetTerrainEnabled();
|
bool GetTerrainEnabled();
|
||||||
bool SetTerrainEnabled(bool enabled);
|
bool SetTerrainEnabled(bool enabled);
|
||||||
bool GetInventoryEnabled();
|
bool GetInventoryEnabled();
|
||||||
|
bool SetInventoryEnabled(bool enabled);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when a server was successfully joined
|
/// Called when a server was successfully joined
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue