playsound, sleep ignoring

This commit is contained in:
sylvessa 2026-03-23 17:25:46 -05:00
parent a5e39efa04
commit a0be612f48
7 changed files with 294 additions and 9 deletions

View file

@ -36,6 +36,7 @@
#include "..\Minecraft.World\Player.h"
#include "..\Minecraft.World\PlayerAbilitiesPacket.h"
#include "..\Minecraft.World\SetCarriedItemPacket.h"
#include "..\Minecraft.World\LevelSoundPacket.h"
#include "..\Minecraft.World\SimpleContainer.h"
#include "..\Minecraft.World\Slot.h"
#include "..\Minecraft.World\Tile.h"
@ -175,7 +176,7 @@ typedef int(__stdcall *fn_fire_inventory_click)(int entityId,
const char *titleUtf8, int titleByteLen);
typedef int(__stdcall *fn_fire_bed_enter)(int entityId, int dimId, int bedX, int bedY, int bedZ);
typedef void(__stdcall *fn_fire_bed_leave)(int entityId, int dimId, int bedX, int bedY, int bedZ);
typedef void(__stdcall *fn_set_entity_callbacks)(void *setSneaking, void *setVelocity, void *setAllowFlight);
typedef void(__stdcall *fn_set_entity_callbacks)(void *setSneaking, void *setVelocity, void *setAllowFlight, void *playSound, void *setSleepingIgnored);
struct OpenContainerInfo
{
@ -328,13 +329,13 @@ static void __cdecl NativeSetFallDistance(int entityId, float distance)
}
}
// double[20] = { x, y, z, health, maxHealth, fallDistance, gameMode, walkSpeed, yaw, pitch, dimension, isSleeping, sleepTimer, sneaking, sprinting, onGround, velocityX, velocityY, velocityZ, allowFlight }
// double[21] = { x, y, z, health, maxHealth, fallDistance, gameMode, walkSpeed, yaw, pitch, dimension, isSleeping, sleepTimer, sneaking, sprinting, onGround, velocityX, velocityY, velocityZ, allowFlight, sleepingIgnored }
static void __cdecl NativeGetPlayerSnapshot(int entityId, double *outData)
{
auto player = FindPlayer(entityId);
if (!player)
{
memset(outData, 0, 20 * sizeof(double));
memset(outData, 0, 21 * sizeof(double));
outData[3] = 20.0;
outData[4] = 20.0;
outData[7] = 0.1;
@ -361,6 +362,7 @@ static void __cdecl NativeGetPlayerSnapshot(int entityId, double *outData)
outData[17] = player->yd;
outData[18] = player->zd;
outData[19] = player->abilities.mayfly ? 1.0 : 0.0;
outData[20] = player->fk_sleepingIgnored ? 1.0 : 0.0;
}
static void __cdecl NativeBroadcastMessage(const char *utf8, int len)
@ -1332,6 +1334,24 @@ static void __cdecl NativeSetAllowFlight(int entityId, int allowFlight)
}
}
static void __cdecl NativePlaySound(int entityId, int soundId, double x, double y, double z, float volume, float pitch)
{
auto player = FindPlayer(entityId);
if (player && player->connection)
{
player->connection->send(std::make_shared<LevelSoundPacket>(soundId, x, y, z, volume, pitch));
}
}
static void __cdecl NativeSetSleepingIgnored(int entityId, int ignored)
{
auto player = FindPlayer(entityId);
if (player)
{
player->fk_sleepingIgnored = (ignored != 0);
}
}
static std::wstring FindNet10SystemRoot()
{
// overengineered
@ -1634,7 +1654,9 @@ void Initialize()
s_managedSetEntityCallbacks(
(void *)&NativeSetSneaking,
(void *)&NativeSetVelocity,
(void *)&NativeSetAllowFlight);
(void *)&NativeSetAllowFlight,
(void *)&NativePlaySound,
(void *)&NativeSetSleepingIgnored);
LogInfo("fourkit", "FourKit initialized successfully.");
}