mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Added slab handling 1.13-1.19.4
This commit is contained in:
parent
4ff7712f20
commit
c7597e8822
5 changed files with 713 additions and 239 deletions
|
|
@ -9,6 +9,7 @@ using Brigadier.NET.Exceptions;
|
|||
using MinecraftClient.ChatBots;
|
||||
using MinecraftClient.CommandHandler;
|
||||
using MinecraftClient.CommandHandler.Patch;
|
||||
using MinecraftClient.Commands;
|
||||
using MinecraftClient.Inventory;
|
||||
using MinecraftClient.Logger;
|
||||
using MinecraftClient.Mapping;
|
||||
|
|
@ -97,6 +98,11 @@ namespace MinecraftClient
|
|||
private int playerLevel;
|
||||
private int playerTotalExperience;
|
||||
private byte CurrentSlot = 0;
|
||||
|
||||
// Sneaking
|
||||
public bool IsSneaking { get; set; } = false;
|
||||
private bool isUnderSlab = false;
|
||||
private DateTime nextSneakingUpdate = DateTime.Now;
|
||||
|
||||
// Entity handling
|
||||
private readonly Dictionary<int, Entity> entities = new();
|
||||
|
|
@ -144,7 +150,9 @@ namespace MinecraftClient
|
|||
Tuple<Thread, CancellationTokenSource>? timeoutdetector = null;
|
||||
|
||||
public ILogger Log;
|
||||
|
||||
|
||||
private static IMinecraftComHandler? instance;
|
||||
public static IMinecraftComHandler? Instance => instance;
|
||||
/// <summary>
|
||||
/// Starts the main chat client, wich will login to the server using the MinecraftCom class.
|
||||
/// </summary>
|
||||
|
|
@ -157,6 +165,8 @@ namespace MinecraftClient
|
|||
public McClient(SessionToken session, PlayerKeyPair? playerKeyPair, string server_ip, ushort port, int protocolversion, ForgeInfo? forgeInfo)
|
||||
{
|
||||
CmdResult.currentHandler = this;
|
||||
instance = this;
|
||||
|
||||
terrainAndMovementsEnabled = Config.Main.Advanced.TerrainAndMovements;
|
||||
inventoryHandlingEnabled = Config.Main.Advanced.InventoryHandling;
|
||||
entityHandlingEnabled = Config.Main.Advanced.EntityHandling;
|
||||
|
|
@ -328,6 +338,25 @@ namespace MinecraftClient
|
|||
}
|
||||
}
|
||||
|
||||
if (nextSneakingUpdate < DateTime.Now)
|
||||
{
|
||||
if (world.GetBlock(new Location(location.X, location.Y + 1, location.Z)).IsTopSlab(protocolversion) && !IsSneaking)
|
||||
{
|
||||
isUnderSlab = true;
|
||||
SendEntityAction(EntityActionType.StartSneaking);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isUnderSlab && !IsSneaking)
|
||||
{
|
||||
isUnderSlab = false;
|
||||
SendEntityAction(EntityActionType.StopSneaking);
|
||||
}
|
||||
}
|
||||
|
||||
nextSneakingUpdate = DateTime.Now.AddMilliseconds(300);
|
||||
}
|
||||
|
||||
lock (chatQueue)
|
||||
{
|
||||
TrySendMessageToServer();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue