1
0

Enchanting table shows detail on hover. Enchanting is deterministic. (#4937)

* Use lapis for enchanting, subtract correct number of levels, ClientHandle now selects from pregenerated list.

Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
This commit is contained in:
KingCol13
2020-10-02 00:33:32 +03:00
committed by GitHub
parent be841b4769
commit 8947147c25
13 changed files with 219 additions and 115 deletions

View File

@@ -151,6 +151,8 @@ cPlayer::cPlayer(const cClientHandlePtr & a_Client, const AString & a_PlayerName
SetWorld(World); // Use default world
m_EnchantmentSeed = GetRandomProvider().RandInt<unsigned int>(); // Use a random number to seed the enchantment generator
FLOGD("Player \"{0}\" is connecting for the first time, spawning at default world spawn {1:.2f}",
a_PlayerName, GetPosition()
);
@@ -1861,6 +1863,25 @@ void cPlayer::SetVisible(bool a_bVisible)
MTRand cPlayer::GetEnchantmentRandomProvider()
{
return m_EnchantmentSeed;
}
void cPlayer::PermuteEnchantmentSeed()
{
// Get a new random integer and save that as the seed:
m_EnchantmentSeed = GetRandomProvider().RandInt<unsigned int>();
}
bool cPlayer::HasPermission(const AString & a_Permission)
{
if (a_Permission.empty())
@@ -2277,6 +2298,7 @@ bool cPlayer::LoadFromFile(const AString & a_FileName, cWorldPtr & a_World)
m_LifetimeTotalXp = root.get("xpTotal", 0).asInt();
m_CurrentXp = root.get("xpCurrent", 0).asInt();
m_IsFlying = root.get("isflying", 0).asBool();
m_EnchantmentSeed = root.get("enchantmentSeed", GetRandomProvider().RandInt<unsigned int>()).asUInt();
Json::Value & JSON_KnownItems = root["knownItems"];
for (UInt32 i = 0; i < JSON_KnownItems.size(); i++)
@@ -2439,6 +2461,7 @@ bool cPlayer::SaveToDisk()
root["SpawnY"] = GetLastBedPos().y;
root["SpawnZ"] = GetLastBedPos().z;
root["SpawnWorld"] = m_SpawnWorld->GetName();
root["enchantmentSeed"] = m_EnchantmentSeed;
if (m_World != nullptr)
{