Rename CanRepairWithItem to CanRepairWithRawMaterial and rename Size() to Count()
This commit is contained in:
parent
27f95454a9
commit
954b59d6f4
@ -83,7 +83,7 @@ void cEnchantments::AddFromString(const AString & a_StringSpec)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
size_t cEnchantments::Size(void)
|
size_t cEnchantments::Count(void)
|
||||||
{
|
{
|
||||||
return m_Enchantments.size();
|
return m_Enchantments.size();
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ public:
|
|||||||
void AddFromString(const AString & a_StringSpec);
|
void AddFromString(const AString & a_StringSpec);
|
||||||
|
|
||||||
/** Get the count of enchantments */
|
/** Get the count of enchantments */
|
||||||
size_t Size(void);
|
size_t Count(void);
|
||||||
|
|
||||||
/** Serializes all the enchantments into a string */
|
/** Serializes all the enchantments into a string */
|
||||||
AString ToString(void) const;
|
AString ToString(void) const;
|
||||||
|
@ -60,7 +60,7 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool CanRepairWithItem(const cItem & a_Item) override
|
virtual bool CanRepairWithRawMaterial(short a_ItemType) override
|
||||||
{
|
{
|
||||||
switch (m_ItemType)
|
switch (m_ItemType)
|
||||||
{
|
{
|
||||||
@ -69,35 +69,35 @@ public:
|
|||||||
case E_ITEM_CHAIN_HELMET:
|
case E_ITEM_CHAIN_HELMET:
|
||||||
case E_ITEM_CHAIN_LEGGINGS:
|
case E_ITEM_CHAIN_LEGGINGS:
|
||||||
{
|
{
|
||||||
return (a_Item.m_ItemType == E_ITEM_IRON);
|
return (a_ItemType == E_ITEM_IRON);
|
||||||
}
|
}
|
||||||
case E_ITEM_DIAMOND_BOOTS:
|
case E_ITEM_DIAMOND_BOOTS:
|
||||||
case E_ITEM_DIAMOND_CHESTPLATE:
|
case E_ITEM_DIAMOND_CHESTPLATE:
|
||||||
case E_ITEM_DIAMOND_HELMET:
|
case E_ITEM_DIAMOND_HELMET:
|
||||||
case E_ITEM_DIAMOND_LEGGINGS:
|
case E_ITEM_DIAMOND_LEGGINGS:
|
||||||
{
|
{
|
||||||
return (a_Item.m_ItemType == E_ITEM_DIAMOND);
|
return (a_ItemType == E_ITEM_DIAMOND);
|
||||||
}
|
}
|
||||||
case E_ITEM_IRON_BOOTS:
|
case E_ITEM_IRON_BOOTS:
|
||||||
case E_ITEM_IRON_CHESTPLATE:
|
case E_ITEM_IRON_CHESTPLATE:
|
||||||
case E_ITEM_IRON_HELMET:
|
case E_ITEM_IRON_HELMET:
|
||||||
case E_ITEM_IRON_LEGGINGS:
|
case E_ITEM_IRON_LEGGINGS:
|
||||||
{
|
{
|
||||||
return (a_Item.m_ItemType == E_ITEM_IRON);
|
return (a_ItemType == E_ITEM_IRON);
|
||||||
}
|
}
|
||||||
case E_ITEM_GOLD_BOOTS:
|
case E_ITEM_GOLD_BOOTS:
|
||||||
case E_ITEM_GOLD_CHESTPLATE:
|
case E_ITEM_GOLD_CHESTPLATE:
|
||||||
case E_ITEM_GOLD_HELMET:
|
case E_ITEM_GOLD_HELMET:
|
||||||
case E_ITEM_GOLD_LEGGINGS:
|
case E_ITEM_GOLD_LEGGINGS:
|
||||||
{
|
{
|
||||||
return (a_Item.m_ItemType == E_ITEM_GOLD);
|
return (a_ItemType == E_ITEM_GOLD);
|
||||||
}
|
}
|
||||||
case E_ITEM_LEATHER_BOOTS:
|
case E_ITEM_LEATHER_BOOTS:
|
||||||
case E_ITEM_LEATHER_CAP:
|
case E_ITEM_LEATHER_CAP:
|
||||||
case E_ITEM_LEATHER_PANTS:
|
case E_ITEM_LEATHER_PANTS:
|
||||||
case E_ITEM_LEATHER_TUNIC:
|
case E_ITEM_LEATHER_TUNIC:
|
||||||
{
|
{
|
||||||
return (a_Item.m_ItemType == E_ITEM_LEATHER);
|
return (a_ItemType == E_ITEM_LEATHER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -512,7 +512,7 @@ bool cItemHandler::IsPlaceable(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cItemHandler::CanRepairWithItem(const cItem & a_Item)
|
bool cItemHandler::CanRepairWithRawMaterial(short a_ItemType)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ public:
|
|||||||
virtual bool IsPlaceable(void);
|
virtual bool IsPlaceable(void);
|
||||||
|
|
||||||
/** Can the anvil repair this item, when a_Item is the second input? */
|
/** Can the anvil repair this item, when a_Item is the second input? */
|
||||||
virtual bool CanRepairWithItem(const cItem & a_Item);
|
virtual bool CanRepairWithRawMaterial(short a_ItemType);
|
||||||
|
|
||||||
/** Get the repair cost from the item, or 0 if the item hasn't repair cost. */
|
/** Get the repair cost from the item, or 0 if the item hasn't repair cost. */
|
||||||
virtual int GetRepairCost(void);
|
virtual int GetRepairCost(void);
|
||||||
|
@ -86,15 +86,15 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool CanRepairWithItem(const cItem & a_Item) override
|
virtual bool CanRepairWithRawMaterial(short a_ItemType) override
|
||||||
{
|
{
|
||||||
switch (m_ItemType)
|
switch (m_ItemType)
|
||||||
{
|
{
|
||||||
case E_ITEM_WOODEN_PICKAXE: return (a_Item.m_ItemType == E_BLOCK_PLANKS);
|
case E_ITEM_WOODEN_PICKAXE: return (a_ItemType == E_BLOCK_PLANKS);
|
||||||
case E_ITEM_STONE_PICKAXE: return (a_Item.m_ItemType == E_BLOCK_COBBLESTONE);
|
case E_ITEM_STONE_PICKAXE: return (a_ItemType == E_BLOCK_COBBLESTONE);
|
||||||
case E_ITEM_IRON_PICKAXE: return (a_Item.m_ItemType == E_ITEM_IRON);
|
case E_ITEM_IRON_PICKAXE: return (a_ItemType == E_ITEM_IRON);
|
||||||
case E_ITEM_GOLD_PICKAXE: return (a_Item.m_ItemType == E_ITEM_GOLD);
|
case E_ITEM_GOLD_PICKAXE: return (a_ItemType == E_ITEM_GOLD);
|
||||||
case E_ITEM_DIAMOND_PICKAXE: return (a_Item.m_ItemType == E_ITEM_DIAMOND);
|
case E_ITEM_DIAMOND_PICKAXE: return (a_ItemType == E_ITEM_DIAMOND);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -42,15 +42,15 @@ public:
|
|||||||
return (a_BlockType == E_BLOCK_SNOW);
|
return (a_BlockType == E_BLOCK_SNOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool CanRepairWithItem(const cItem & a_Item) override
|
virtual bool CanRepairWithRawMaterial(short a_ItemType) override
|
||||||
{
|
{
|
||||||
switch (m_ItemType)
|
switch (m_ItemType)
|
||||||
{
|
{
|
||||||
case E_ITEM_WOODEN_SHOVEL: return (a_Item.m_ItemType == E_BLOCK_PLANKS);
|
case E_ITEM_WOODEN_SHOVEL: return (a_ItemType == E_BLOCK_PLANKS);
|
||||||
case E_ITEM_STONE_SHOVEL: return (a_Item.m_ItemType == E_BLOCK_COBBLESTONE);
|
case E_ITEM_STONE_SHOVEL: return (a_ItemType == E_BLOCK_COBBLESTONE);
|
||||||
case E_ITEM_IRON_SHOVEL: return (a_Item.m_ItemType == E_ITEM_IRON);
|
case E_ITEM_IRON_SHOVEL: return (a_ItemType == E_ITEM_IRON);
|
||||||
case E_ITEM_GOLD_SHOVEL: return (a_Item.m_ItemType == E_ITEM_GOLD);
|
case E_ITEM_GOLD_SHOVEL: return (a_ItemType == E_ITEM_GOLD);
|
||||||
case E_ITEM_DIAMOND_SHOVEL: return (a_Item.m_ItemType == E_ITEM_DIAMOND);
|
case E_ITEM_DIAMOND_SHOVEL: return (a_ItemType == E_ITEM_DIAMOND);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -24,15 +24,15 @@ public:
|
|||||||
return (a_BlockType == E_BLOCK_COBWEB);
|
return (a_BlockType == E_BLOCK_COBWEB);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool CanRepairWithItem(const cItem & a_Item) override
|
virtual bool CanRepairWithRawMaterial(short a_ItemType) override
|
||||||
{
|
{
|
||||||
switch (m_ItemType)
|
switch (m_ItemType)
|
||||||
{
|
{
|
||||||
case E_ITEM_WOODEN_SWORD: return (a_Item.m_ItemType == E_BLOCK_PLANKS);
|
case E_ITEM_WOODEN_SWORD: return (a_ItemType == E_BLOCK_PLANKS);
|
||||||
case E_ITEM_STONE_SWORD: return (a_Item.m_ItemType == E_BLOCK_COBBLESTONE);
|
case E_ITEM_STONE_SWORD: return (a_ItemType == E_BLOCK_COBBLESTONE);
|
||||||
case E_ITEM_IRON_SWORD: return (a_Item.m_ItemType == E_ITEM_IRON);
|
case E_ITEM_IRON_SWORD: return (a_ItemType == E_ITEM_IRON);
|
||||||
case E_ITEM_GOLD_SWORD: return (a_Item.m_ItemType == E_ITEM_GOLD);
|
case E_ITEM_GOLD_SWORD: return (a_ItemType == E_ITEM_GOLD);
|
||||||
case E_ITEM_DIAMOND_SWORD: return (a_Item.m_ItemType == E_ITEM_DIAMOND);
|
case E_ITEM_DIAMOND_SWORD: return (a_ItemType == E_ITEM_DIAMOND);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -797,7 +797,7 @@ void cSlotAreaAnvil::OnTakeResult(cPlayer & a_Player)
|
|||||||
cFastRandom Random;
|
cFastRandom Random;
|
||||||
if (!a_Player.IsGameModeCreative() && (Block == E_BLOCK_ANVIL) && (Random.NextFloat(1.0F) < 0.12F))
|
if (!a_Player.IsGameModeCreative() && (Block == E_BLOCK_ANVIL) && (Random.NextFloat(1.0F) < 0.12F))
|
||||||
{
|
{
|
||||||
NIBBLETYPE var4 = BlockMeta & 0x3;
|
NIBBLETYPE Orientation = BlockMeta & 0x3;
|
||||||
NIBBLETYPE AnvilDamage = BlockMeta >> 2;
|
NIBBLETYPE AnvilDamage = BlockMeta >> 2;
|
||||||
++AnvilDamage;
|
++AnvilDamage;
|
||||||
|
|
||||||
@ -810,7 +810,7 @@ void cSlotAreaAnvil::OnTakeResult(cPlayer & a_Player)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
a_Player.GetWorld()->SetBlockMeta(PosX, PosY, PosZ, var4 | AnvilDamage << 2);
|
a_Player.GetWorld()->SetBlockMeta(PosX, PosY, PosZ, Orientation | (AnvilDamage << 2));
|
||||||
a_Player.GetWorld()->BroadcastSoundParticleEffect(1021, PosX, PosY, PosZ, 0);
|
a_Player.GetWorld()->BroadcastSoundParticleEffect(1021, PosX, PosY, PosZ, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -832,7 +832,7 @@ bool cSlotAreaAnvil::CanTakeResultItem(cPlayer & a_Player)
|
|||||||
(a_Player.GetXpLevel() >= m_MaximumCost) // or the player have enough exp?
|
(a_Player.GetXpLevel() >= m_MaximumCost) // or the player have enough exp?
|
||||||
) &&
|
) &&
|
||||||
(!GetSlot(2, a_Player)->IsEmpty()) && // Is a item in the result slot?
|
(!GetSlot(2, a_Player)->IsEmpty()) && // Is a item in the result slot?
|
||||||
(m_MaximumCost > 0) // And: Is m_MaximumCost higher than 0?
|
(m_MaximumCost > 0) // When no maximum cost is set, the item isn't set from the UpdateResult() method and can't be a valid enchanting result.
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -871,8 +871,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player)
|
|||||||
if (!SecondInput.IsEmpty())
|
if (!SecondInput.IsEmpty())
|
||||||
{
|
{
|
||||||
RepairCost += cItemHandler::GetItemHandler(SecondInput)->GetRepairCost();
|
RepairCost += cItemHandler::GetItemHandler(SecondInput)->GetRepairCost();
|
||||||
|
if (Input.IsDamageable() && cItemHandler::GetItemHandler(Input)->CanRepairWithRawMaterial(SecondInput.m_ItemType))
|
||||||
if (Input.IsDamageable() && cItemHandler::GetItemHandler(Input)->CanRepairWithItem(SecondInput))
|
|
||||||
{
|
{
|
||||||
// Tool and armor repair with special item (iron / gold / diamond / ...)
|
// Tool and armor repair with special item (iron / gold / diamond / ...)
|
||||||
int DamageDiff = std::min((int)Input.m_ItemDamage, (int)Input.GetMaxDamage() / 4);
|
int DamageDiff = std::min((int)Input.m_ItemDamage, (int)Input.GetMaxDamage() / 4);
|
||||||
@ -889,7 +888,7 @@ void cSlotAreaAnvil::UpdateResult(cPlayer & a_Player)
|
|||||||
while ((DamageDiff > 0) && (x < SecondInput.m_ItemCount))
|
while ((DamageDiff > 0) && (x < SecondInput.m_ItemCount))
|
||||||
{
|
{
|
||||||
Input.m_ItemDamage -= DamageDiff;
|
Input.m_ItemDamage -= DamageDiff;
|
||||||
NeedExp += std::max(1, DamageDiff / 100) + Input.m_Enchantments.Size();
|
NeedExp += std::max(1, DamageDiff / 100) + Input.m_Enchantments.Count();
|
||||||
DamageDiff = std::min((int)Input.m_ItemDamage, (int)Input.GetMaxDamage() / 4);
|
DamageDiff = std::min((int)Input.m_ItemDamage, (int)Input.GetMaxDamage() / 4);
|
||||||
|
|
||||||
++x;
|
++x;
|
||||||
|
Loading…
Reference in New Issue
Block a user