mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/LCE-Revelations.git
synced 2026-07-07 03:58:06 +00:00
feat: add FourKit plugin host with dual server build
Adds the FourKit .NET 10 plugin host as a second dedicated server
build flavour alongside the existing vanilla server. Both flavours
build from the same source tree, with FourKit gated by the
MINECRAFT_SERVER_FOURKIT_BUILD preprocessor define.
Build layout:
Minecraft.Server vanilla, no plugin support, no .NET dep
Minecraft.Server.FourKit FourKit-enabled, ships with bundled
.NET 10 self-contained runtime in runtime/
and an empty plugins/ folder
Both produce a Minecraft.Server.exe in their own per-target output
dir. The variant identity lives in the directory name, not the
binary name, so either flavour can be shipped as a drop-in.
Native bridge (Minecraft.Server/FourKit*.{cpp,h}):
* FourKitRuntime: hosts CoreCLR via hostfxr's command-line init API
(the runtime-config API does not support self-contained components)
* FourKitBridge: ~50 Fire* event entry points, with inline no-op
stubs for the standalone build so gameplay code can call them
unconditionally
* FourKitNatives: ~80 native callbacks the managed side invokes
for player/world/inventory mutations
* FourKitMappers: type and enum mapping helpers
Managed plugin host (Minecraft.Server.FourKit/):
* Bukkit-style API: Player, World, Block, Inventory, Command,
Listener, EventHandler attribute, ~54 event classes
* PluginLoader with per-plugin AssemblyLoadContext
* FourKitHost as the [UnmanagedCallersOnly] entry point table
* Runtime resolves plugins relative to the host process so they
always live next to Minecraft.Server.exe regardless of where the
managed assembly itself is loaded from
Engine hooks (Minecraft.Client/, Minecraft.World/):
* Player lifecycle (PreLogin, Login, Join, Quit, Kick, Move,
Teleport, Portal, Death) wired into PendingConnection and
PlayerConnection without disturbing the cipher handshake or
identity-token security flow
* Inventory open/click/drop hooks across every container menu type
* Block place/break/grow/burn/spread/from-to hooks across the
full tile family
* Bed enter/leave, sign change, entity damage/death, ender pearl
teleport hooks
Regression fixes preserved while applying donor diffs:
* ServerPlayer::die() retains the LCE-Revelations hardcore branch
(setGameMode(ADVENTURE) + banPlayerForHardcoreDeath) in both the
FourKit and non-FourKit code paths
* ServerLevel::entityAdded() retains the sub-entity ID reassignment
loop required by the client's handleAddMob offset, fixing Ender
Dragon and Wither boss multi-part hit detection
* LivingEntity::travel() retains the raw Player* cast and the
cached frictionTile, both Revelations perf wins that the donor
silently reverted
* ServerLogger.cpp keeps the file-logging code donor stripped
* PlayerList.cpp end portal transition fix and UIScene_EndPoem
bounds-check are intact
Build system:
* Top-level CMakeLists.txt adds the Minecraft.Server.FourKit
subdirectory and pulls in the new shared cmake/ServerTarget.cmake
helper
* Minecraft.Server/cmake/sources/Common.cmake is now location
independent (uses CMAKE_CURRENT_LIST_DIR) so the source list
can be consumed from either server target's CMakeLists.txt
* The seven FourKit*.cpp/h files live in their own
_MINECRAFT_SERVER_COMMON_SERVER_FOURKIT variable so the
standalone target omits them
* configure-time .NET 10 SDK check fails fast with a clear
download link if the SDK is missing
* global.json pins the SDK to 10.0.100 with latestFeature
rollforward
Sample plugin (samples/HelloPlugin/) demonstrates the loader and
the PlayerJoinEvent listener pattern.
CI:
* nightly.yml builds both server flavours, ships
LCE-Revelations-Server-Win64.zip and
LCE-Revelations-Server-Win64-FourKit.zip, attests both, and
updates release notes for the dual-flavour layout
* pull-request.yml pulls in actions/setup-dotnet so the FourKit
publish step works in PR validation
* All zip artifacts and the client zip are renamed from
LCREWindows64 to LCE-Revelations-{Client,Server}-Win64
Documentation:
* COMPILE.md gets a VS 2022 quick start, .NET 10 prereq section,
server flavours explanation, and a troubleshooting section
* docs/FOURKIT_PORT_RECON.md captures the file-by-file recon that
drove the port
* docs/FOURKIT_PARITY.md is the canonical reference for which
events FourKit fires
Docker:
* docker-compose.dedicated-server.yml MC_RUNTIME_DIR default points
at the vanilla CMake output. The FourKit Docker image is
intentionally NOT shipped yet because hosting .NET 10 self
contained inside Wine has not been smoke-tested
This commit is contained in:
@@ -33,6 +33,154 @@
|
||||
#include "..\Minecraft.World\LevelChunk.h"
|
||||
#include "LevelRenderer.h"
|
||||
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
#include "..\Minecraft.Server\FourKitBridge.h"
|
||||
#include "..\Minecraft.World\ChatPacket.h"
|
||||
|
||||
static std::wstring FormatDeathMessage(const shared_ptr<ChatPacket>& packet)
|
||||
{
|
||||
if (!packet) return L"";
|
||||
|
||||
std::wstring message;
|
||||
bool replacePlayer = false;
|
||||
bool replaceEntitySource = false;
|
||||
bool replaceItem = false;
|
||||
// coug chough
|
||||
// de hättn echt an gscheidern string konverter für de todesmeldungen macha soin
|
||||
// a globaler helfer waar wahrscheinlich ganz bärig gwen
|
||||
// waaaah
|
||||
|
||||
switch (packet->m_messageType)
|
||||
{
|
||||
case ChatPacket::e_ChatCustom:
|
||||
return packet->m_stringArgs.size() > 0 ? packet->m_stringArgs[0] : L"";
|
||||
case ChatPacket::e_ChatDeathInFire:
|
||||
message = app.GetString(IDS_DEATH_INFIRE); replacePlayer = true; break;
|
||||
case ChatPacket::e_ChatDeathOnFire:
|
||||
message = app.GetString(IDS_DEATH_ONFIRE); replacePlayer = true; break;
|
||||
case ChatPacket::e_ChatDeathLava:
|
||||
message = app.GetString(IDS_DEATH_LAVA); replacePlayer = true; break;
|
||||
case ChatPacket::e_ChatDeathInWall:
|
||||
message = app.GetString(IDS_DEATH_INWALL); replacePlayer = true; break;
|
||||
case ChatPacket::e_ChatDeathDrown:
|
||||
message = app.GetString(IDS_DEATH_DROWN); replacePlayer = true; break;
|
||||
case ChatPacket::e_ChatDeathStarve:
|
||||
message = app.GetString(IDS_DEATH_STARVE); replacePlayer = true; break;
|
||||
case ChatPacket::e_ChatDeathCactus:
|
||||
message = app.GetString(IDS_DEATH_CACTUS); replacePlayer = true; break;
|
||||
case ChatPacket::e_ChatDeathFall:
|
||||
message = app.GetString(IDS_DEATH_FALL); replacePlayer = true; break;
|
||||
case ChatPacket::e_ChatDeathOutOfWorld:
|
||||
message = app.GetString(IDS_DEATH_OUTOFWORLD); replacePlayer = true; break;
|
||||
case ChatPacket::e_ChatDeathGeneric:
|
||||
message = app.GetString(IDS_DEATH_GENERIC); replacePlayer = true; break;
|
||||
case ChatPacket::e_ChatDeathExplosion:
|
||||
message = app.GetString(IDS_DEATH_EXPLOSION); replacePlayer = true; break;
|
||||
case ChatPacket::e_ChatDeathMagic:
|
||||
message = app.GetString(IDS_DEATH_MAGIC); replacePlayer = true; break;
|
||||
case ChatPacket::e_ChatDeathWither:
|
||||
message = app.GetString(IDS_DEATH_WITHER); replacePlayer = true; break;
|
||||
case ChatPacket::e_ChatDeathDragonBreath:
|
||||
message = app.GetString(IDS_DEATH_DRAGON_BREATH); replacePlayer = true; break;
|
||||
case ChatPacket::e_ChatDeathAnvil:
|
||||
message = app.GetString(IDS_DEATH_FALLING_ANVIL); replacePlayer = true; break;
|
||||
case ChatPacket::e_ChatDeathFallingBlock:
|
||||
message = app.GetString(IDS_DEATH_FALLING_TILE); replacePlayer = true; break;
|
||||
case ChatPacket::e_ChatDeathFellAccidentLadder:
|
||||
message = app.GetString(IDS_DEATH_FELL_ACCIDENT_LADDER); replacePlayer = true; break;
|
||||
case ChatPacket::e_ChatDeathFellAccidentVines:
|
||||
message = app.GetString(IDS_DEATH_FELL_ACCIDENT_VINES); replacePlayer = true; break;
|
||||
case ChatPacket::e_ChatDeathFellAccidentWater:
|
||||
message = app.GetString(IDS_DEATH_FELL_ACCIDENT_WATER); replacePlayer = true; break;
|
||||
case ChatPacket::e_ChatDeathFellAccidentGeneric:
|
||||
message = app.GetString(IDS_DEATH_FELL_ACCIDENT_GENERIC); replacePlayer = true; break;
|
||||
case ChatPacket::e_ChatDeathFellKiller:
|
||||
message = app.GetString(IDS_DEATH_FALL); replacePlayer = true; break;
|
||||
case ChatPacket::e_ChatDeathMob:
|
||||
message = app.GetString(IDS_DEATH_MOB); replacePlayer = true; replaceEntitySource = true; break;
|
||||
case ChatPacket::e_ChatDeathPlayer:
|
||||
message = app.GetString(IDS_DEATH_PLAYER); replacePlayer = true; replaceEntitySource = true; break;
|
||||
case ChatPacket::e_ChatDeathArrow:
|
||||
message = app.GetString(IDS_DEATH_ARROW); replacePlayer = true; replaceEntitySource = true; break;
|
||||
case ChatPacket::e_ChatDeathFireball:
|
||||
message = app.GetString(IDS_DEATH_FIREBALL); replacePlayer = true; replaceEntitySource = true; break;
|
||||
case ChatPacket::e_ChatDeathThrown:
|
||||
message = app.GetString(IDS_DEATH_THROWN); replacePlayer = true; replaceEntitySource = true; break;
|
||||
case ChatPacket::e_ChatDeathIndirectMagic:
|
||||
message = app.GetString(IDS_DEATH_INDIRECT_MAGIC); replacePlayer = true; replaceEntitySource = true; break;
|
||||
case ChatPacket::e_ChatDeathThorns:
|
||||
message = app.GetString(IDS_DEATH_THORNS); replacePlayer = true; replaceEntitySource = true; break;
|
||||
case ChatPacket::e_ChatDeathExplosionPlayer:
|
||||
message = app.GetString(IDS_DEATH_EXPLOSION_PLAYER); replacePlayer = true; replaceEntitySource = true; break;
|
||||
case ChatPacket::e_ChatDeathInFirePlayer:
|
||||
message = app.GetString(IDS_DEATH_INFIRE_PLAYER); replacePlayer = true; replaceEntitySource = true; break;
|
||||
case ChatPacket::e_ChatDeathOnFirePlayer:
|
||||
message = app.GetString(IDS_DEATH_ONFIRE_PLAYER); replacePlayer = true; replaceEntitySource = true; break;
|
||||
case ChatPacket::e_ChatDeathLavaPlayer:
|
||||
message = app.GetString(IDS_DEATH_LAVA_PLAYER); replacePlayer = true; replaceEntitySource = true; break;
|
||||
case ChatPacket::e_ChatDeathDrownPlayer:
|
||||
message = app.GetString(IDS_DEATH_DROWN_PLAYER); replacePlayer = true; replaceEntitySource = true; break;
|
||||
case ChatPacket::e_ChatDeathCactusPlayer:
|
||||
message = app.GetString(IDS_DEATH_CACTUS_PLAYER); replacePlayer = true; replaceEntitySource = true; break;
|
||||
case ChatPacket::e_ChatDeathFellAssist:
|
||||
message = app.GetString(IDS_DEATH_FELL_ASSIST); replacePlayer = true; replaceEntitySource = true; break;
|
||||
case ChatPacket::e_ChatDeathFellFinish:
|
||||
message = app.GetString(IDS_DEATH_FELL_FINISH); replacePlayer = true; replaceEntitySource = true; break;
|
||||
case ChatPacket::e_ChatDeathPlayerItem:
|
||||
message = app.GetString(IDS_DEATH_PLAYER_ITEM); replacePlayer = true; replaceEntitySource = true; replaceItem = true; break;
|
||||
case ChatPacket::e_ChatDeathArrowItem:
|
||||
message = app.GetString(IDS_DEATH_ARROW_ITEM); replacePlayer = true; replaceEntitySource = true; replaceItem = true; break;
|
||||
case ChatPacket::e_ChatDeathFireballItem:
|
||||
message = app.GetString(IDS_DEATH_FIREBALL_ITEM); replacePlayer = true; replaceEntitySource = true; replaceItem = true; break;
|
||||
case ChatPacket::e_ChatDeathThrownItem:
|
||||
message = app.GetString(IDS_DEATH_THROWN_ITEM); replacePlayer = true; replaceEntitySource = true; replaceItem = true; break;
|
||||
case ChatPacket::e_ChatDeathIndirectMagicItem:
|
||||
message = app.GetString(IDS_DEATH_INDIRECT_MAGIC_ITEM); replacePlayer = true; replaceEntitySource = true; replaceItem = true; break;
|
||||
case ChatPacket::e_ChatDeathFellAssistItem:
|
||||
message = app.GetString(IDS_DEATH_FELL_ASSIST_ITEM); replacePlayer = true; replaceEntitySource = true; replaceItem = true; break;
|
||||
case ChatPacket::e_ChatDeathFellFinishItem:
|
||||
message = app.GetString(IDS_DEATH_FELL_FINISH_ITEM); replacePlayer = true; replaceEntitySource = true; replaceItem = true; break;
|
||||
default:
|
||||
message = app.GetString(IDS_DEATH_GENERIC); replacePlayer = true; break;
|
||||
}
|
||||
|
||||
if (replacePlayer)
|
||||
{
|
||||
std::wstring playerName = packet->m_stringArgs.size() > 0 ? packet->m_stringArgs[0] : L"";
|
||||
message = replaceAll(message, L"{*PLAYER*}", playerName);
|
||||
}
|
||||
|
||||
if (replaceEntitySource)
|
||||
{
|
||||
std::wstring sourceName;
|
||||
if (!packet->m_intArgs.empty() && packet->m_intArgs[0] == eTYPE_SERVERPLAYER)
|
||||
{
|
||||
sourceName = packet->m_stringArgs.size() > 1 ? packet->m_stringArgs[1] : L"";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (packet->m_stringArgs.size() > 1 && !packet->m_stringArgs[1].empty())
|
||||
{
|
||||
sourceName = packet->m_stringArgs[1];
|
||||
}
|
||||
else if (!packet->m_intArgs.empty())
|
||||
{
|
||||
sourceName = app.getEntityName((eINSTANCEOF)packet->m_intArgs[0]);
|
||||
}
|
||||
}
|
||||
message = replaceAll(message, L"{*SOURCE*}", sourceName);
|
||||
}
|
||||
|
||||
if (replaceItem)
|
||||
{
|
||||
std::wstring itemName = packet->m_stringArgs.size() > 2 ? packet->m_stringArgs[2] : L"";
|
||||
message = replaceAll(message, L"{*ITEM*}", itemName);
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
ServerPlayer::ServerPlayer(MinecraftServer *server, Level *level, const wstring& name, ServerPlayerGameMode *gameMode) : Player(level, name)
|
||||
{
|
||||
@@ -567,6 +715,45 @@ shared_ptr<ItemInstance> ServerPlayer::getCarried(int slot)
|
||||
|
||||
void ServerPlayer::die(DamageSource *source)
|
||||
{
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
shared_ptr<ChatPacket> deathPacket = getCombatTracker()->getDeathMessagePacket();
|
||||
std::wstring deathMsg = FormatDeathMessage(deathPacket);
|
||||
|
||||
int exp = getExperienceReward(nullptr);
|
||||
std::wstring outDeathMsg;
|
||||
int keepInventory = 0;
|
||||
int outNewExp = 0, outNewLevel = 0, outKeepLevel = 0;
|
||||
int outExp = FourKitBridge::FirePlayerDeath(entityId, deathMsg, exp, outDeathMsg, &keepInventory,
|
||||
&outNewExp, &outNewLevel, &outKeepLevel);
|
||||
|
||||
fk_hasDeathState = true;
|
||||
fk_deathKeepInventory = (keepInventory != 0);
|
||||
fk_deathKeepLevel = (outKeepLevel != 0);
|
||||
fk_deathNewExp = outNewExp;
|
||||
fk_deathNewLevel = outNewLevel;
|
||||
|
||||
if (!outDeathMsg.empty())
|
||||
server->getPlayers()->broadcastAll(std::make_shared<ChatPacket>(outDeathMsg));
|
||||
|
||||
// LCE-Revelations: Hardcore mode enforcement. Donor's FourKit-aware die()
|
||||
// rewrite dropped this branch; we restore it AFTER FirePlayerDeath so
|
||||
// plugins still see the death event before the player is banned and
|
||||
// switched to Adventure mode.
|
||||
if (level->getLevelData()->isHardcore())
|
||||
{
|
||||
setGameMode(GameType::ADVENTURE);
|
||||
// Ban this player's XUID and queue disconnect.
|
||||
// The force-save is triggered inside banPlayerForHardcoreDeath after
|
||||
// the disconnect is queued, so the client doesn't get stuck on a save
|
||||
// screen.
|
||||
server->getPlayers()->banPlayerForHardcoreDeath(this);
|
||||
}
|
||||
|
||||
if (keepInventory == 0 && !level->getGameRules()->getBoolean(GameRules::RULE_KEEPINVENTORY))
|
||||
{
|
||||
inventory->dropAll();
|
||||
}
|
||||
#else
|
||||
server->getPlayers()->broadcastAll(getCombatTracker()->getDeathMessagePacket());
|
||||
|
||||
// 4J Added: Hardcore mode — switch to Adventure mode on death (can look but not break/place blocks)
|
||||
@@ -584,6 +771,7 @@ void ServerPlayer::die(DamageSource *source)
|
||||
{
|
||||
inventory->dropAll();
|
||||
}
|
||||
#endif
|
||||
|
||||
vector<Objective *> *objectives = level->getScoreboard()->findObjectiveFor(ObjectiveCriteria::DEATH_COUNT);
|
||||
if(objectives)
|
||||
@@ -776,6 +964,10 @@ void ServerPlayer::changeDimension(int i)
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
bool portalDestModified = false;
|
||||
double portalOutX = 0, portalOutY = 0, portalOutZ = 0;
|
||||
#endif
|
||||
if (dimension == 0 && i == 1)
|
||||
{
|
||||
awardStat(GenericStats::theEnd(), GenericStats::param_theEnd());
|
||||
@@ -783,7 +975,24 @@ void ServerPlayer::changeDimension(int i)
|
||||
Pos *pos = server->getLevel(i)->getDimensionSpecificSpawn();
|
||||
if (pos != nullptr)
|
||||
{
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
{
|
||||
double outX, outY, outZ;
|
||||
bool cancelled = FourKitBridge::FirePlayerPortal(entityId,
|
||||
x, y, z, dimension,
|
||||
pos->x, pos->y, pos->z, i,
|
||||
4,
|
||||
&outX, &outY, &outZ);
|
||||
if (cancelled)
|
||||
{
|
||||
delete pos;
|
||||
return;
|
||||
}
|
||||
connection->teleport(outX, outY, outZ, 0, 0);
|
||||
}
|
||||
#else
|
||||
connection->teleport(pos->x, pos->y, pos->z, 0, 0);
|
||||
#endif
|
||||
delete pos;
|
||||
}
|
||||
|
||||
@@ -791,10 +1000,48 @@ void ServerPlayer::changeDimension(int i)
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
{
|
||||
double scale = server->getLevel(i)->getLevelData()->getHellScale();
|
||||
double toX = x, toY = y, toZ = z;
|
||||
if (i == -1)
|
||||
{
|
||||
toX = x / scale;
|
||||
toZ = z / scale;
|
||||
}
|
||||
else if (dimension == -1 && i == 0)
|
||||
{
|
||||
toX = x * scale;
|
||||
toZ = z * scale;
|
||||
}
|
||||
|
||||
double outX, outY, outZ;
|
||||
bool cancelled = FourKitBridge::FirePlayerPortal(entityId,
|
||||
x, y, z, dimension,
|
||||
toX, toY, toZ, i,
|
||||
3,
|
||||
&outX, &outY, &outZ);
|
||||
if (cancelled)
|
||||
return;
|
||||
if (outX != toX || outY != toY || outZ != toZ)
|
||||
{
|
||||
portalDestModified = true;
|
||||
portalOutX = outX;
|
||||
portalOutY = outY;
|
||||
portalOutZ = outZ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// 4J: Removed on the advice of the mighty King of Achievments (JV)
|
||||
// awardStat(GenericStats::portal(), GenericStats::param_portal());
|
||||
}
|
||||
server->getPlayers()->toggleDimension( dynamic_pointer_cast<ServerPlayer>(shared_from_this()), i);
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
if (portalDestModified)
|
||||
{
|
||||
connection->teleport(portalOutX, portalOutY, portalOutZ, yRot, xRot);
|
||||
}
|
||||
#endif
|
||||
lastSentExp = -1;
|
||||
lastSentHealth = -1;
|
||||
lastSentFood = -1;
|
||||
@@ -824,6 +1071,10 @@ void ServerPlayer::take(shared_ptr<Entity> e, int orgCount)
|
||||
|
||||
Player::BedSleepingResult ServerPlayer::startSleepInBed(int x, int y, int z, bool bTestUse)
|
||||
{
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
if (!bTestUse && FourKitBridge::FireBedEnter(entityId, dimension, x, y, z))
|
||||
return OTHER_PROBLEM;
|
||||
#endif
|
||||
BedSleepingResult result = Player::startSleepInBed(x, y, z, bTestUse);
|
||||
if (result == OK)
|
||||
{
|
||||
@@ -837,12 +1088,22 @@ Player::BedSleepingResult ServerPlayer::startSleepInBed(int x, int y, int z, boo
|
||||
|
||||
void ServerPlayer::stopSleepInBed(bool forcefulWakeUp, bool updateLevelList, bool saveRespawnPoint)
|
||||
{
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
int bedX = bedPosition ? bedPosition->x : 0;
|
||||
int bedY = bedPosition ? bedPosition->y : 0;
|
||||
int bedZ = bedPosition ? bedPosition->z : 0;
|
||||
bool wasSleeping = isSleeping();
|
||||
#endif
|
||||
if (isSleeping())
|
||||
{
|
||||
getLevel()->getTracker()->broadcastAndSend(shared_from_this(), std::make_shared<AnimatePacket>(shared_from_this(), AnimatePacket::WAKE_UP));
|
||||
}
|
||||
Player::stopSleepInBed(forcefulWakeUp, updateLevelList, saveRespawnPoint);
|
||||
if (connection != nullptr) connection->teleport(x, y, z, yRot, xRot);
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
if (wasSleeping)
|
||||
FourKitBridge::FireBedLeave(entityId, dimension, bedX, bedY, bedZ);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ServerPlayer::ride(shared_ptr<Entity> e)
|
||||
@@ -885,10 +1146,18 @@ bool ServerPlayer::startCrafting(int x, int y, int z)
|
||||
if(containerMenu == inventoryMenu)
|
||||
{
|
||||
nextContainerCounter();
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, ContainerOpenPacket::WORKBENCH, L"", 9, false));
|
||||
containerMenu = new CraftingMenu(inventory, level, x, y, z);
|
||||
containerMenu->containerId = containerCounter;
|
||||
containerMenu->addSlotListener(this);
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
if (FourKitBridge::FireInventoryOpen(entityId, ContainerOpenPacket::WORKBENCH, L"", 9))
|
||||
{
|
||||
doCloseContainer();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, ContainerOpenPacket::WORKBENCH, L"", 9, false));
|
||||
refreshContainer(containerMenu);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -903,20 +1172,36 @@ bool ServerPlayer::openFireworks(int x, int y, int z)
|
||||
if(containerMenu == inventoryMenu)
|
||||
{
|
||||
nextContainerCounter();
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, ContainerOpenPacket::FIREWORKS, L"", 9, false));
|
||||
containerMenu = new FireworksMenu(inventory, level, x, y, z);
|
||||
containerMenu->containerId = containerCounter;
|
||||
containerMenu->addSlotListener(this);
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
if (FourKitBridge::FireInventoryOpen(entityId, ContainerOpenPacket::FIREWORKS, L"", 9))
|
||||
{
|
||||
doCloseContainer();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, ContainerOpenPacket::FIREWORKS, L"", 9, false));
|
||||
refreshContainer(containerMenu);
|
||||
}
|
||||
else if(dynamic_cast<CraftingMenu *>(containerMenu) != nullptr)
|
||||
{
|
||||
closeContainer();
|
||||
|
||||
nextContainerCounter();
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, ContainerOpenPacket::FIREWORKS, L"", 9, false));
|
||||
containerMenu = new FireworksMenu(inventory, level, x, y, z);
|
||||
containerMenu->containerId = containerCounter;
|
||||
containerMenu->addSlotListener(this);
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
if (FourKitBridge::FireInventoryOpen(entityId, ContainerOpenPacket::FIREWORKS, L"", 9))
|
||||
{
|
||||
doCloseContainer();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, ContainerOpenPacket::FIREWORKS, L"", 9, false));
|
||||
refreshContainer(containerMenu);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -931,10 +1216,18 @@ bool ServerPlayer::startEnchanting(int x, int y, int z, const wstring &name)
|
||||
if(containerMenu == inventoryMenu)
|
||||
{
|
||||
nextContainerCounter();
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, ContainerOpenPacket::ENCHANTMENT, name.empty() ? L"" : name, 9, !name.empty()));
|
||||
containerMenu = new EnchantmentMenu(inventory, level, x, y, z);
|
||||
containerMenu->containerId = containerCounter;
|
||||
containerMenu->addSlotListener(this);
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
if (FourKitBridge::FireInventoryOpen(entityId, ContainerOpenPacket::ENCHANTMENT, name.empty() ? L"" : name, 9))
|
||||
{
|
||||
doCloseContainer();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, ContainerOpenPacket::ENCHANTMENT, name.empty() ? L"" : name, 9, !name.empty()));
|
||||
refreshContainer(containerMenu);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -949,10 +1242,18 @@ bool ServerPlayer::startRepairing(int x, int y, int z)
|
||||
if(containerMenu == inventoryMenu)
|
||||
{
|
||||
nextContainerCounter();
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, ContainerOpenPacket::REPAIR_TABLE, L"", 9, false));
|
||||
containerMenu = new AnvilMenu(inventory, level, x, y, z, dynamic_pointer_cast<Player>(shared_from_this()));
|
||||
containerMenu->containerId = containerCounter;
|
||||
containerMenu->addSlotListener(this);
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
if (FourKitBridge::FireInventoryOpen(entityId, ContainerOpenPacket::REPAIR_TABLE, L"", 9))
|
||||
{
|
||||
doCloseContainer();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, ContainerOpenPacket::REPAIR_TABLE, L"", 9, false));
|
||||
refreshContainer(containerMenu);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -972,11 +1273,18 @@ bool ServerPlayer::openContainer(shared_ptr<Container> container)
|
||||
int containerType = container->getContainerType();
|
||||
assert(containerType >= 0);
|
||||
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, containerType, container->getCustomName(), container->getContainerSize(), container->hasCustomName()));
|
||||
|
||||
containerMenu = new ContainerMenu(inventory, container);
|
||||
containerMenu->containerId = containerCounter;
|
||||
containerMenu->addSlotListener(this);
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
if (FourKitBridge::FireInventoryOpen(entityId, containerType, container->getCustomName(), container->getContainerSize()))
|
||||
{
|
||||
doCloseContainer();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, containerType, container->getCustomName(), container->getContainerSize(), container->hasCustomName()));
|
||||
refreshContainer(containerMenu);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -991,10 +1299,18 @@ bool ServerPlayer::openHopper(shared_ptr<HopperTileEntity> container)
|
||||
if(containerMenu == inventoryMenu)
|
||||
{
|
||||
nextContainerCounter();
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, ContainerOpenPacket::HOPPER, container->getCustomName(), container->getContainerSize(), container->hasCustomName()));
|
||||
containerMenu = new HopperMenu(inventory, container);
|
||||
containerMenu->containerId = containerCounter;
|
||||
containerMenu->addSlotListener(this);
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
if (FourKitBridge::FireInventoryOpen(entityId, ContainerOpenPacket::HOPPER, container->getCustomName(), container->getContainerSize()))
|
||||
{
|
||||
doCloseContainer();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, ContainerOpenPacket::HOPPER, container->getCustomName(), container->getContainerSize(), container->hasCustomName()));
|
||||
refreshContainer(containerMenu);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1009,10 +1325,18 @@ bool ServerPlayer::openHopper(shared_ptr<MinecartHopper> container)
|
||||
if(containerMenu == inventoryMenu)
|
||||
{
|
||||
nextContainerCounter();
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, ContainerOpenPacket::HOPPER, container->getCustomName(), container->getContainerSize(), container->hasCustomName()));
|
||||
containerMenu = new HopperMenu(inventory, container);
|
||||
containerMenu->containerId = containerCounter;
|
||||
containerMenu->addSlotListener(this);
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
if (FourKitBridge::FireInventoryOpen(entityId, ContainerOpenPacket::HOPPER, container->getCustomName(), container->getContainerSize()))
|
||||
{
|
||||
doCloseContainer();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, ContainerOpenPacket::HOPPER, container->getCustomName(), container->getContainerSize(), container->hasCustomName()));
|
||||
refreshContainer(containerMenu);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1027,10 +1351,18 @@ bool ServerPlayer::openFurnace(shared_ptr<FurnaceTileEntity> furnace)
|
||||
if(containerMenu == inventoryMenu)
|
||||
{
|
||||
nextContainerCounter();
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, ContainerOpenPacket::FURNACE, furnace->getCustomName(), furnace->getContainerSize(), furnace->hasCustomName()));
|
||||
containerMenu = new FurnaceMenu(inventory, furnace);
|
||||
containerMenu->containerId = containerCounter;
|
||||
containerMenu->addSlotListener(this);
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
if (FourKitBridge::FireInventoryOpen(entityId, ContainerOpenPacket::FURNACE, furnace->getCustomName(), furnace->getContainerSize()))
|
||||
{
|
||||
doCloseContainer();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, ContainerOpenPacket::FURNACE, furnace->getCustomName(), furnace->getContainerSize(), furnace->hasCustomName()));
|
||||
refreshContainer(containerMenu);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1045,10 +1377,18 @@ bool ServerPlayer::openTrap(shared_ptr<DispenserTileEntity> trap)
|
||||
if(containerMenu == inventoryMenu)
|
||||
{
|
||||
nextContainerCounter();
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, trap->GetType() == eTYPE_DROPPERTILEENTITY ? ContainerOpenPacket::DROPPER : ContainerOpenPacket::TRAP, trap->getCustomName(), trap->getContainerSize(), trap->hasCustomName()));
|
||||
containerMenu = new TrapMenu(inventory, trap);
|
||||
containerMenu->containerId = containerCounter;
|
||||
containerMenu->addSlotListener(this);
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
if (FourKitBridge::FireInventoryOpen(entityId, trap->GetType() == eTYPE_DROPPERTILEENTITY ? ContainerOpenPacket::DROPPER : ContainerOpenPacket::TRAP, trap->getCustomName(), trap->getContainerSize()))
|
||||
{
|
||||
doCloseContainer();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, trap->GetType() == eTYPE_DROPPERTILEENTITY ? ContainerOpenPacket::DROPPER : ContainerOpenPacket::TRAP, trap->getCustomName(), trap->getContainerSize(), trap->hasCustomName()));
|
||||
refreshContainer(containerMenu);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1063,10 +1403,18 @@ bool ServerPlayer::openBrewingStand(shared_ptr<BrewingStandTileEntity> brewingSt
|
||||
if(containerMenu == inventoryMenu)
|
||||
{
|
||||
nextContainerCounter();
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, ContainerOpenPacket::BREWING_STAND, brewingStand->getCustomName(), brewingStand->getContainerSize(), brewingStand->hasCustomName()));
|
||||
containerMenu = new BrewingStandMenu(inventory, brewingStand);
|
||||
containerMenu->containerId = containerCounter;
|
||||
containerMenu->addSlotListener(this);
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
if (FourKitBridge::FireInventoryOpen(entityId, ContainerOpenPacket::BREWING_STAND, brewingStand->getCustomName(), brewingStand->getContainerSize()))
|
||||
{
|
||||
doCloseContainer();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, ContainerOpenPacket::BREWING_STAND, brewingStand->getCustomName(), brewingStand->getContainerSize(), brewingStand->hasCustomName()));
|
||||
refreshContainer(containerMenu);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1081,10 +1429,18 @@ bool ServerPlayer::openBeacon(shared_ptr<BeaconTileEntity> beacon)
|
||||
if(containerMenu == inventoryMenu)
|
||||
{
|
||||
nextContainerCounter();
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, ContainerOpenPacket::BEACON, beacon->getCustomName(), beacon->getContainerSize(), beacon->hasCustomName()));
|
||||
containerMenu = new BeaconMenu(inventory, beacon);
|
||||
containerMenu->containerId = containerCounter;
|
||||
containerMenu->addSlotListener(this);
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
if (FourKitBridge::FireInventoryOpen(entityId, ContainerOpenPacket::BEACON, beacon->getCustomName(), beacon->getContainerSize()))
|
||||
{
|
||||
doCloseContainer();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, ContainerOpenPacket::BEACON, beacon->getCustomName(), beacon->getContainerSize(), beacon->hasCustomName()));
|
||||
refreshContainer(containerMenu);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1104,7 +1460,15 @@ bool ServerPlayer::openTrading(shared_ptr<Merchant> traderTarget, const wstring
|
||||
containerMenu->addSlotListener(this);
|
||||
shared_ptr<Container> container = static_cast<MerchantMenu *>(containerMenu)->getTradeContainer();
|
||||
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
if (FourKitBridge::FireInventoryOpen(entityId, ContainerOpenPacket::TRADER_NPC, name.empty() ? L"" : name, container->getContainerSize()))
|
||||
{
|
||||
doCloseContainer();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, ContainerOpenPacket::TRADER_NPC, name.empty() ? L"" : name, container->getContainerSize(), !name.empty()));
|
||||
refreshContainer(containerMenu);
|
||||
|
||||
MerchantRecipeList *offers = traderTarget->getOffers(dynamic_pointer_cast<Player>(shared_from_this()));
|
||||
if (offers != nullptr)
|
||||
@@ -1134,10 +1498,18 @@ bool ServerPlayer::openHorseInventory(shared_ptr<EntityHorse> horse, shared_ptr<
|
||||
closeContainer();
|
||||
}
|
||||
nextContainerCounter();
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, ContainerOpenPacket::HORSE, horse->getCustomName(), container->getContainerSize(), container->hasCustomName(), horse->entityId));
|
||||
containerMenu = new HorseInventoryMenu(inventory, container, horse);
|
||||
containerMenu->containerId = containerCounter;
|
||||
containerMenu->addSlotListener(this);
|
||||
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
|
||||
if (FourKitBridge::FireInventoryOpen(entityId, ContainerOpenPacket::HORSE, horse->getCustomName(), container->getContainerSize()))
|
||||
{
|
||||
doCloseContainer();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
connection->send(std::make_shared<ContainerOpenPacket>(containerCounter, ContainerOpenPacket::HORSE, horse->getCustomName(), container->getContainerSize(), container->hasCustomName(), horse->entityId));
|
||||
refreshContainer(containerMenu);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1620,9 +1992,9 @@ bool ServerPlayer::hasPermission(EGameCommand command)
|
||||
//
|
||||
// // 4J - Don't need
|
||||
// //if (server.isSingleplayer() && server.getSingleplayerName().equals(name))
|
||||
/// //{
|
||||
// //{
|
||||
// // server.setDifficulty(packet.getDifficulty());
|
||||
/// //}
|
||||
// //}
|
||||
//}
|
||||
|
||||
int ServerPlayer::getViewDistance()
|
||||
|
||||
Reference in New Issue
Block a user