mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-07-17 02:08:33 +00:00
refactor: unglob std::shared_ptr
This commit is contained in:
@@ -70,9 +70,9 @@ ItemInstance::ItemInstance(int id, int count, int damage)
|
||||
_init(id,count,damage);
|
||||
}
|
||||
|
||||
shared_ptr<ItemInstance> ItemInstance::fromTag(CompoundTag *itemTag)
|
||||
std::shared_ptr<ItemInstance> ItemInstance::fromTag(CompoundTag *itemTag)
|
||||
{
|
||||
shared_ptr<ItemInstance> itemInstance = shared_ptr<ItemInstance>(new ItemInstance());
|
||||
std::shared_ptr<ItemInstance> itemInstance = std::shared_ptr<ItemInstance>(new ItemInstance());
|
||||
itemInstance->load(itemTag);
|
||||
return itemInstance->getItem() != NULL ? itemInstance : nullptr;
|
||||
}
|
||||
@@ -82,9 +82,9 @@ ItemInstance::~ItemInstance()
|
||||
if(tag != NULL) delete tag;
|
||||
}
|
||||
|
||||
shared_ptr<ItemInstance> ItemInstance::remove(int count)
|
||||
std::shared_ptr<ItemInstance> ItemInstance::remove(int count)
|
||||
{
|
||||
shared_ptr<ItemInstance> ii = shared_ptr<ItemInstance>( new ItemInstance(id, count, auxValue) );
|
||||
std::shared_ptr<ItemInstance> ii = std::shared_ptr<ItemInstance>( new ItemInstance(id, count, auxValue) );
|
||||
if (tag != NULL) ii->tag = (CompoundTag *) tag->copy();
|
||||
this->count -= count;
|
||||
|
||||
@@ -111,7 +111,7 @@ int ItemInstance::getIconType()
|
||||
return getItem()->getIconType();
|
||||
}
|
||||
|
||||
bool ItemInstance::useOn(shared_ptr<Player> player, Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly)
|
||||
bool ItemInstance::useOn(std::shared_ptr<Player> player, Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly)
|
||||
{
|
||||
return getItem()->useOn(shared_from_this(), player, level, x, y, z, face, clickX, clickY, clickZ, bTestUseOnOnly);
|
||||
}
|
||||
@@ -121,17 +121,17 @@ float ItemInstance::getDestroySpeed(Tile *tile)
|
||||
return getItem()->getDestroySpeed(shared_from_this(), tile);
|
||||
}
|
||||
|
||||
bool ItemInstance::TestUse(Level *level, shared_ptr<Player> player)
|
||||
bool ItemInstance::TestUse(Level *level, std::shared_ptr<Player> player)
|
||||
{
|
||||
return getItem()->TestUse( level, player);
|
||||
}
|
||||
|
||||
shared_ptr<ItemInstance> ItemInstance::use(Level *level, shared_ptr<Player> player)
|
||||
std::shared_ptr<ItemInstance> ItemInstance::use(Level *level, std::shared_ptr<Player> player)
|
||||
{
|
||||
return getItem()->use(shared_from_this(), level, player);
|
||||
}
|
||||
|
||||
shared_ptr<ItemInstance> ItemInstance::useTimeDepleted(Level *level, shared_ptr<Player> player)
|
||||
std::shared_ptr<ItemInstance> ItemInstance::useTimeDepleted(Level *level, std::shared_ptr<Player> player)
|
||||
{
|
||||
return getItem()->useTimeDepleted(shared_from_this(), level, player);
|
||||
}
|
||||
@@ -209,14 +209,14 @@ int ItemInstance::getMaxDamage()
|
||||
return Item::items[id]->getMaxDamage();
|
||||
}
|
||||
|
||||
void ItemInstance::hurt(int i, shared_ptr<Mob> owner)
|
||||
void ItemInstance::hurt(int i, std::shared_ptr<Mob> owner)
|
||||
{
|
||||
if (!isDamageableItem())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
shared_ptr<Player> player = dynamic_pointer_cast<Player>(owner);
|
||||
std::shared_ptr<Player> player = dynamic_pointer_cast<Player>(owner);
|
||||
if (i > 0 && player != NULL)
|
||||
{
|
||||
int enchanted = EnchantmentHelper::getDigDurability(player->inventory);
|
||||
@@ -242,19 +242,19 @@ void ItemInstance::hurt(int i, shared_ptr<Mob> owner)
|
||||
}
|
||||
}
|
||||
|
||||
void ItemInstance::hurtEnemy(shared_ptr<Mob> mob, shared_ptr<Player> attacker)
|
||||
void ItemInstance::hurtEnemy(std::shared_ptr<Mob> mob, std::shared_ptr<Player> attacker)
|
||||
{
|
||||
//bool used =
|
||||
Item::items[id]->hurtEnemy(shared_from_this(), mob, attacker);
|
||||
}
|
||||
|
||||
void ItemInstance::mineBlock(Level *level, int tile, int x, int y, int z, shared_ptr<Player> owner)
|
||||
void ItemInstance::mineBlock(Level *level, int tile, int x, int y, int z, std::shared_ptr<Player> owner)
|
||||
{
|
||||
//bool used =
|
||||
Item::items[id]->mineBlock( shared_from_this(), level, tile, x, y, z, owner);
|
||||
}
|
||||
|
||||
int ItemInstance::getAttackDamage(shared_ptr<Entity> entity)
|
||||
int ItemInstance::getAttackDamage(std::shared_ptr<Entity> entity)
|
||||
{
|
||||
return Item::items[id]->getAttackDamage(entity);
|
||||
}
|
||||
@@ -264,14 +264,14 @@ bool ItemInstance::canDestroySpecial(Tile *tile)
|
||||
return Item::items[id]->canDestroySpecial(tile);
|
||||
}
|
||||
|
||||
bool ItemInstance::interactEnemy(shared_ptr<Mob> mob)
|
||||
bool ItemInstance::interactEnemy(std::shared_ptr<Mob> mob)
|
||||
{
|
||||
return Item::items[id]->interactEnemy(shared_from_this(), mob);
|
||||
}
|
||||
|
||||
shared_ptr<ItemInstance> ItemInstance::copy() const
|
||||
std::shared_ptr<ItemInstance> ItemInstance::copy() const
|
||||
{
|
||||
shared_ptr<ItemInstance> copy = shared_ptr<ItemInstance>( new ItemInstance(id, count, auxValue) );
|
||||
std::shared_ptr<ItemInstance> copy = std::shared_ptr<ItemInstance>( new ItemInstance(id, count, auxValue) );
|
||||
if (tag != NULL)
|
||||
{
|
||||
copy->tag = (CompoundTag *) tag->copy();
|
||||
@@ -295,7 +295,7 @@ ItemInstance *ItemInstance::copy_not_shared() const
|
||||
}
|
||||
|
||||
// 4J Brought forward from 1.2
|
||||
bool ItemInstance::tagMatches(shared_ptr<ItemInstance> a, shared_ptr<ItemInstance> b)
|
||||
bool ItemInstance::tagMatches(std::shared_ptr<ItemInstance> a, std::shared_ptr<ItemInstance> b)
|
||||
{
|
||||
if (a == NULL && b == NULL) return true;
|
||||
if (a == NULL || b == NULL) return false;
|
||||
@@ -311,14 +311,14 @@ bool ItemInstance::tagMatches(shared_ptr<ItemInstance> a, shared_ptr<ItemInstanc
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ItemInstance::matches(shared_ptr<ItemInstance> a, shared_ptr<ItemInstance> b)
|
||||
bool ItemInstance::matches(std::shared_ptr<ItemInstance> a, std::shared_ptr<ItemInstance> b)
|
||||
{
|
||||
if (a == NULL && b == NULL) return true;
|
||||
if (a == NULL || b == NULL) return false;
|
||||
return a->matches(b);
|
||||
}
|
||||
|
||||
bool ItemInstance::matches(shared_ptr<ItemInstance> b)
|
||||
bool ItemInstance::matches(std::shared_ptr<ItemInstance> b)
|
||||
{
|
||||
if (count != b->count) return false;
|
||||
if (id != b->id) return false;
|
||||
@@ -341,12 +341,12 @@ bool ItemInstance::matches(shared_ptr<ItemInstance> b)
|
||||
* @param b
|
||||
* @return
|
||||
*/
|
||||
bool ItemInstance::sameItem(shared_ptr<ItemInstance> b)
|
||||
bool ItemInstance::sameItem(std::shared_ptr<ItemInstance> b)
|
||||
{
|
||||
return id == b->id && auxValue == b->auxValue;
|
||||
}
|
||||
|
||||
bool ItemInstance::sameItemWithTags(shared_ptr<ItemInstance> b)
|
||||
bool ItemInstance::sameItemWithTags(std::shared_ptr<ItemInstance> b)
|
||||
{
|
||||
if (id != b->id) return false;
|
||||
if (auxValue != b->auxValue) return false;
|
||||
@@ -384,7 +384,7 @@ ItemInstance *ItemInstance::setDescriptionId(unsigned int id)
|
||||
return this;
|
||||
}
|
||||
|
||||
shared_ptr<ItemInstance> ItemInstance::clone(shared_ptr<ItemInstance> item)
|
||||
std::shared_ptr<ItemInstance> ItemInstance::clone(std::shared_ptr<ItemInstance> item)
|
||||
{
|
||||
return item == NULL ? nullptr : item->copy();
|
||||
}
|
||||
@@ -406,13 +406,13 @@ wstring ItemInstance::toString()
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
void ItemInstance::inventoryTick(Level *level, shared_ptr<Entity> owner, int slot, bool selected)
|
||||
void ItemInstance::inventoryTick(Level *level, std::shared_ptr<Entity> owner, int slot, bool selected)
|
||||
{
|
||||
if (popTime > 0) popTime--;
|
||||
Item::items[id]->inventoryTick(shared_from_this(), level, owner, slot, selected);
|
||||
}
|
||||
|
||||
void ItemInstance::onCraftedBy(Level *level, shared_ptr<Player> player, int craftCount)
|
||||
void ItemInstance::onCraftedBy(Level *level, std::shared_ptr<Player> player, int craftCount)
|
||||
{
|
||||
// 4J Stu Added for tutorial callback
|
||||
player->onCrafted(shared_from_this());
|
||||
@@ -425,7 +425,7 @@ void ItemInstance::onCraftedBy(Level *level, shared_ptr<Player> player, int craf
|
||||
Item::items[id]->onCraftedBy(shared_from_this(), level, player);
|
||||
}
|
||||
|
||||
bool ItemInstance::equals(shared_ptr<ItemInstance> ii)
|
||||
bool ItemInstance::equals(std::shared_ptr<ItemInstance> ii)
|
||||
{
|
||||
return id == ii->id && count == ii->count && auxValue == ii->auxValue;
|
||||
}
|
||||
@@ -440,7 +440,7 @@ UseAnim ItemInstance::getUseAnimation()
|
||||
return getItem()->getUseAnimation(shared_from_this());
|
||||
}
|
||||
|
||||
void ItemInstance::releaseUsing(Level *level, shared_ptr<Player> player, int durationLeft)
|
||||
void ItemInstance::releaseUsing(Level *level, std::shared_ptr<Player> player, int durationLeft)
|
||||
{
|
||||
getItem()->releaseUsing(shared_from_this(), level, player, durationLeft);
|
||||
}
|
||||
@@ -501,7 +501,7 @@ bool ItemInstance::hasCustomHoverName()
|
||||
return tag->getCompound(L"display")->contains(L"Name");
|
||||
}
|
||||
|
||||
vector<wstring> *ItemInstance::getHoverText(shared_ptr<Player> player, bool advanced, vector<wstring> &unformattedStrings)
|
||||
vector<wstring> *ItemInstance::getHoverText(std::shared_ptr<Player> player, bool advanced, vector<wstring> &unformattedStrings)
|
||||
{
|
||||
vector<wstring> *lines = new vector<wstring>();
|
||||
Item *item = Item::items[id];
|
||||
@@ -568,7 +568,7 @@ vector<wstring> *ItemInstance::getHoverText(shared_ptr<Player> player, bool adva
|
||||
}
|
||||
|
||||
// 4J Added
|
||||
vector<wstring> *ItemInstance::getHoverTextOnly(shared_ptr<Player> player, bool advanced, vector<wstring> &unformattedStrings)
|
||||
vector<wstring> *ItemInstance::getHoverTextOnly(std::shared_ptr<Player> player, bool advanced, vector<wstring> &unformattedStrings)
|
||||
{
|
||||
vector<wstring> *lines = new vector<wstring>();
|
||||
Item *item = Item::items[id];
|
||||
@@ -698,12 +698,12 @@ bool ItemInstance::isFramed()
|
||||
return frame != NULL;
|
||||
}
|
||||
|
||||
void ItemInstance::setFramed(shared_ptr<ItemFrame> frame)
|
||||
void ItemInstance::setFramed(std::shared_ptr<ItemFrame> frame)
|
||||
{
|
||||
this->frame = frame;
|
||||
}
|
||||
|
||||
shared_ptr<ItemFrame> ItemInstance::getFrame()
|
||||
std::shared_ptr<ItemFrame> ItemInstance::getFrame()
|
||||
{
|
||||
return frame;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user