Fixed some Errors (not all)
This commit is contained in:
parent
f9343a8490
commit
0086fcfef1
@ -2735,7 +2735,9 @@ void cClientHandle::HandleEnchantItem(Byte & WindowID, Byte & Enchantment)
|
|||||||
cItem Item = *Window->m_SlotArea->GetSlot(0, *m_Player);
|
cItem Item = *Window->m_SlotArea->GetSlot(0, *m_Player);
|
||||||
int BaseEnchantmentLevel = Window->GetPropertyValue(Enchantment);
|
int BaseEnchantmentLevel = Window->GetPropertyValue(Enchantment);
|
||||||
|
|
||||||
if (Item.EnchantByXPLevels(BaseEnchantmentLevel, *m_Player, true, true))
|
if (Item.EnchantByXPLevels(BaseEnchantmentLevel))
|
||||||
|
{
|
||||||
|
if (m_Player->IsGameModeCreative() | m_Player->DeltaExperience(-m_Player->XpForLevel(BaseEnchantmentLevel)) >= 0)
|
||||||
{
|
{
|
||||||
Window->m_SlotArea->SetSlot(0, *m_Player, Item);
|
Window->m_SlotArea->SetSlot(0, *m_Player, Item);
|
||||||
Window->SendSlot(*m_Player, Window->m_SlotArea, 0);
|
Window->SendSlot(*m_Player, Window->m_SlotArea, 0);
|
||||||
@ -2745,6 +2747,7 @@ void cClientHandle::HandleEnchantItem(Byte & WindowID, Byte & Enchantment)
|
|||||||
Window->SetProperty(1, 0, *m_Player);
|
Window->SetProperty(1, 0, *m_Player);
|
||||||
Window->SetProperty(2, 0, *m_Player);
|
Window->SetProperty(2, 0, *m_Player);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,6 +20,11 @@ class cFastNBTWriter;
|
|||||||
class cParsedNBT;
|
class cParsedNBT;
|
||||||
|
|
||||||
|
|
||||||
|
// fwd:
|
||||||
|
struct cWeightedEnchantment;
|
||||||
|
|
||||||
|
typedef std::vector<cWeightedEnchantment> cWeightedEnchantments;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -112,7 +117,6 @@ public:
|
|||||||
/** Gets random enchantment from Vector and returns it */
|
/** Gets random enchantment from Vector and returns it */
|
||||||
static cEnchantments GetRandomEnchantmentFromVector(cWeightedEnchantments & a_Enchantments);
|
static cEnchantments GetRandomEnchantmentFromVector(cWeightedEnchantments & a_Enchantments);
|
||||||
|
|
||||||
|
|
||||||
/// Returns true if a_Other doesn't contain exactly the same enchantments and levels
|
/// Returns true if a_Other doesn't contain exactly the same enchantments and levels
|
||||||
bool operator !=(const cEnchantments & a_Other) const;
|
bool operator !=(const cEnchantments & a_Other) const;
|
||||||
|
|
||||||
@ -131,15 +135,14 @@ protected:
|
|||||||
} ; // tolua_export
|
} ; // tolua_export
|
||||||
|
|
||||||
|
|
||||||
/** Things below for the Enchanting System */
|
|
||||||
|
|
||||||
|
// Define the cWeightedEnchantment struct:
|
||||||
struct cWeightedEnchantment
|
struct cWeightedEnchantment
|
||||||
{
|
{
|
||||||
int m_Weight;
|
int m_Weight;
|
||||||
cEnchantments m_Enchantments;
|
cEnchantments m_Enchantments;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<cWeightedEnchantment> cWeightedEnchantments;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ int cItem::GetEnchantability()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cItem::EnchantByXPLevels(int a_NumXPLevels, cPlayer & a_Player, bool a_BlockConflictingEnchantments, bool a_DeleteLevelFromPlayer)
|
bool cItem::EnchantByXPLevels(int a_NumXPLevels)
|
||||||
{
|
{
|
||||||
if (!cItem::IsEnchantable(m_ItemType) && m_ItemType != E_ITEM_BOOK)
|
if (!cItem::IsEnchantable(m_ItemType) && m_ItemType != E_ITEM_BOOK)
|
||||||
{
|
{
|
||||||
@ -338,12 +338,7 @@ bool cItem::EnchantByXPLevels(int a_NumXPLevels, cPlayer & a_Player, bool a_Bloc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a_Player.DeltaExperience(-a_Player.XpForLevel(a_NumXPLevels)) >= 0 || a_Player.IsGameModeCreative())
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ public:
|
|||||||
|
|
||||||
/** Enchants the item using the specified number of XP levels.
|
/** Enchants the item using the specified number of XP levels.
|
||||||
Returns true if item enchanted, false if not. */
|
Returns true if item enchanted, false if not. */
|
||||||
bool EnchantByXPLevels(int a_NumXPLevels, cPlayer & a_Player, bool a_BlockConflictingEnchantments, bool a_DeleteLevelFromPlayer); // tolua_export
|
bool EnchantByXPLevels(int a_NumXPLevels); // tolua_export
|
||||||
|
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user