mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-05-16 20:13:51 +00:00
blockstate, more block events, command preprocess event.
This commit is contained in:
parent
21b5accc69
commit
18a673bd46
34 changed files with 1359 additions and 58 deletions
|
|
@ -95,6 +95,14 @@ typedef void(__stdcall *fn_set_entity_callbacks)(void *setSneaking, void *setVel
|
|||
typedef void(__stdcall *fn_set_experience_callbacks)(void *setLevel, void *setExp, void *giveExp, void *giveExpLevels, void *setFoodLevel, void *setSaturation, void *setExhaustion);
|
||||
typedef void(__stdcall *fn_set_particle_callbacks)(void *spawnParticle);
|
||||
typedef void(__stdcall *fn_set_vehicle_callbacks)(void *setPassenger, void *leaveVehicle, void *eject, void *getVehicleId, void *getPassengerId, void *getEntityInfo);
|
||||
typedef int(__stdcall *fn_fire_block_grow)(int dimId, int x, int y, int z, int newTileId, int newTileData);
|
||||
typedef int(__stdcall *fn_fire_block_form)(int dimId, int x, int y, int z, int newTileId, int newTileData);
|
||||
typedef int(__stdcall *fn_fire_block_burn)(int dimId, int x, int y, int z);
|
||||
typedef int(__stdcall *fn_fire_block_spread)(int dimId, int x, int y, int z, int srcX, int srcY, int srcZ, int newTileId, int newTileData);
|
||||
typedef int(__stdcall *fn_fire_piston_extend)(int dimId, int x, int y, int z, int direction, int length);
|
||||
typedef int(__stdcall *fn_fire_piston_retract)(int dimId, int x, int y, int z, int direction);
|
||||
typedef int(__stdcall *fn_fire_command_preprocess)(int entityId, const char *cmdUtf8, int cmdByteLen, char *outBuf, int outBufSize, int *outLen);
|
||||
typedef int(__stdcall *fn_fire_block_from_to)(int dimId, int fromX, int fromY, int fromZ, int toX, int toY, int toZ, int face);
|
||||
|
||||
struct OpenContainerInfo
|
||||
{
|
||||
|
|
@ -144,6 +152,14 @@ static fn_set_entity_callbacks s_managedSetEntityCallbacks = nullptr;
|
|||
static fn_set_experience_callbacks s_managedSetExperienceCallbacks = nullptr;
|
||||
static fn_set_particle_callbacks s_managedSetParticleCallbacks = nullptr;
|
||||
static fn_set_vehicle_callbacks s_managedSetVehicleCallbacks = nullptr;
|
||||
static fn_fire_block_grow s_managedFireBlockGrow = nullptr;
|
||||
static fn_fire_block_form s_managedFireBlockForm = nullptr;
|
||||
static fn_fire_block_burn s_managedFireBlockBurn = nullptr;
|
||||
static fn_fire_block_spread s_managedFireBlockSpread = nullptr;
|
||||
static fn_fire_piston_extend s_managedFirePistonExtend = nullptr;
|
||||
static fn_fire_piston_retract s_managedFirePistonRetract = nullptr;
|
||||
static fn_fire_command_preprocess s_managedFireCommandPreprocess = nullptr;
|
||||
static fn_fire_block_from_to s_managedFireBlockFromTo = nullptr;
|
||||
|
||||
static bool s_initialized = false;
|
||||
|
||||
|
|
@ -214,6 +230,14 @@ void Initialize()
|
|||
{L"SetExperienceCallbacks", (void **)&s_managedSetExperienceCallbacks},
|
||||
{L"SetParticleCallbacks", (void **)&s_managedSetParticleCallbacks},
|
||||
{L"SetVehicleCallbacks", (void **)&s_managedSetVehicleCallbacks},
|
||||
{L"FireBlockGrow", (void **)&s_managedFireBlockGrow},
|
||||
{L"FireBlockForm", (void **)&s_managedFireBlockForm},
|
||||
{L"FireBlockBurn", (void **)&s_managedFireBlockBurn},
|
||||
{L"FireBlockSpread", (void **)&s_managedFireBlockSpread},
|
||||
{L"FirePistonExtend", (void **)&s_managedFirePistonExtend},
|
||||
{L"FirePistonRetract", (void **)&s_managedFirePistonRetract},
|
||||
{L"FireCommandPreprocess", (void **)&s_managedFireCommandPreprocess},
|
||||
{L"FireBlockFromTo", (void **)&s_managedFireBlockFromTo},
|
||||
};
|
||||
|
||||
bool ok = true;
|
||||
|
|
@ -902,4 +926,88 @@ void FireBedLeave(int entityId, int dimId, int bedX, int bedY, int bedZ)
|
|||
return;
|
||||
s_managedFireBedLeave(entityId, dimId, bedX, bedY, bedZ);
|
||||
}
|
||||
|
||||
bool FireBlockGrow(int dimId, int x, int y, int z, int newTileId, int newTileData)
|
||||
{
|
||||
if (!s_initialized || !s_managedFireBlockGrow)
|
||||
return false;
|
||||
return s_managedFireBlockGrow(dimId, x, y, z, newTileId, newTileData) != 0;
|
||||
}
|
||||
|
||||
bool FireBlockForm(int dimId, int x, int y, int z, int newTileId, int newTileData)
|
||||
{
|
||||
if (!s_initialized || !s_managedFireBlockForm)
|
||||
return false;
|
||||
return s_managedFireBlockForm(dimId, x, y, z, newTileId, newTileData) != 0;
|
||||
}
|
||||
|
||||
bool FireBlockBurn(int dimId, int x, int y, int z)
|
||||
{
|
||||
if (!s_initialized || !s_managedFireBlockBurn)
|
||||
return false;
|
||||
return s_managedFireBlockBurn(dimId, x, y, z) != 0;
|
||||
}
|
||||
|
||||
bool FireBlockSpread(int dimId, int x, int y, int z, int srcX, int srcY, int srcZ, int newTileId, int newTileData)
|
||||
{
|
||||
if (!s_initialized || !s_managedFireBlockSpread)
|
||||
return false;
|
||||
return s_managedFireBlockSpread(dimId, x, y, z, srcX, srcY, srcZ, newTileId, newTileData) != 0;
|
||||
}
|
||||
|
||||
bool FirePistonExtend(int dimId, int x, int y, int z, int direction, int length)
|
||||
{
|
||||
if (!s_initialized || !s_managedFirePistonExtend)
|
||||
return false;
|
||||
return s_managedFirePistonExtend(dimId, x, y, z, direction, length) != 0;
|
||||
}
|
||||
|
||||
bool FirePistonRetract(int dimId, int x, int y, int z, int direction)
|
||||
{
|
||||
if (!s_initialized || !s_managedFirePistonRetract)
|
||||
return false;
|
||||
return s_managedFirePistonRetract(dimId, x, y, z, direction) != 0;
|
||||
}
|
||||
|
||||
bool FireCommandPreprocess(int entityId, const std::wstring &commandLine, std::wstring &outCommand)
|
||||
{
|
||||
if (!s_initialized || !s_managedFireCommandPreprocess)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string cmdUtf8 = ServerRuntime::StringUtils::WideToUtf8(commandLine);
|
||||
|
||||
const int kBufSize = 2048;
|
||||
char outBuf[kBufSize] = {};
|
||||
int outLen = 0;
|
||||
|
||||
int cancelled = s_managedFireCommandPreprocess(entityId,
|
||||
cmdUtf8.empty() ? "" : cmdUtf8.data(), (int)cmdUtf8.size(),
|
||||
outBuf, kBufSize, &outLen);
|
||||
|
||||
if (cancelled != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (outLen > 0 && outLen < kBufSize)
|
||||
{
|
||||
std::string resultUtf8(outBuf, outLen);
|
||||
outCommand = ServerRuntime::StringUtils::Utf8ToWide(resultUtf8);
|
||||
}
|
||||
else
|
||||
{
|
||||
outCommand = commandLine;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FireBlockFromTo(int dimId, int fromX, int fromY, int fromZ, int toX, int toY, int toZ, int face)
|
||||
{
|
||||
if (!s_initialized || !s_managedFireBlockFromTo)
|
||||
return false;
|
||||
return s_managedFireBlockFromTo(dimId, fromX, fromY, fromZ, toX, toY, toZ, face) != 0;
|
||||
}
|
||||
} // namespace FourKitBridge
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue