From 7074f35e4ba831e358117842b99ee35b87f85ae5 Mon Sep 17 00:00:00 2001 From: void_17 Date: Mon, 2 Mar 2026 15:58:20 +0700 Subject: shared_ptr -> std::shared_ptr This is one of the first commits in a plan to remove all `using namespace std;` lines in the entire codebase as it is considered anti-pattern today. --- Minecraft.World/Player.h | 96 ++++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 48 deletions(-) (limited to 'Minecraft.World/Player.h') diff --git a/Minecraft.World/Player.h b/Minecraft.World/Player.h index 185a70a7..68088fc1 100644 --- a/Minecraft.World/Player.h +++ b/Minecraft.World/Player.h @@ -50,10 +50,10 @@ private: static const int DATA_PLAYER_RUNNING_ID = 17; public: - shared_ptr inventory; + std::shared_ptr inventory; private: - shared_ptr enderChestInventory; + std::shared_ptr enderChestInventory; public: AbstractContainerMenu *inventoryMenu; @@ -124,7 +124,7 @@ public: // 4J Stu - Made protected so that we can access it from MultiPlayerLocalPlayer protected: - shared_ptr useItem; + std::shared_ptr useItem; int useItemDuration; protected: @@ -146,7 +146,7 @@ protected: virtual void defineSynchedData(); public: - shared_ptr getUseItem(); + std::shared_ptr getUseItem(); int getUseItemDuration(); bool isUsingItem(); int getTicksUsingItem(); void releaseUsingItem(); @@ -156,7 +156,7 @@ public: virtual void tick(); protected: - void spawnEatParticles(shared_ptr useItem, int count); + void spawnEatParticles(std::shared_ptr useItem, int count); virtual void completeUsingItem(); public: @@ -167,7 +167,7 @@ protected: virtual void closeContainer(); public: - virtual void ride(shared_ptr e); + virtual void ride(std::shared_ptr e); void prepareCustomTextures(); virtual void rideTick(); virtual void resetPos(); @@ -182,13 +182,13 @@ public: virtual void aiStep(); private: - virtual void touch(shared_ptr entity); + virtual void touch(std::shared_ptr entity); public: //bool addResource(int resource); // 4J - Removed 1.0.1 int getScore(); virtual void die(DamageSource *source); - void awardKillScore(shared_ptr victim, int score); + void awardKillScore(std::shared_ptr victim, int score); protected: virtual int decreaseAirSupply(int currentSupply); @@ -196,12 +196,12 @@ protected: public: virtual bool isShootable(); bool isCreativeModeAllowed(); - virtual shared_ptr drop(); - shared_ptr drop(shared_ptr item); - shared_ptr drop(shared_ptr item, bool randomly); + virtual std::shared_ptr drop(); + std::shared_ptr drop(std::shared_ptr item); + std::shared_ptr drop(std::shared_ptr item, bool randomly); protected: - virtual void reallyDrop(shared_ptr thrownItem); + virtual void reallyDrop(std::shared_ptr thrownItem); public: float getDestroySpeed(Tile *tile); @@ -209,11 +209,11 @@ public: virtual void readAdditionalSaveData(CompoundTag *entityTag); virtual void addAdditonalSaveData(CompoundTag *entityTag); static Pos *getRespawnPosition(Level *level, CompoundTag *entityTag); - virtual bool openContainer(shared_ptr container); // 4J - added bool return + virtual bool openContainer(std::shared_ptr container); // 4J - added bool return virtual bool startEnchanting(int x, int y, int z); // 4J - added bool return virtual bool startRepairing(int x, int y, int z); // 4J - added bool return virtual bool startCrafting(int x, int y, int z); // 4J - added boo return - virtual void take(shared_ptr e, int orgCount); + virtual void take(std::shared_ptr e, int orgCount); virtual float getHeadHeight(); // 4J-PB - added to keep the code happy with the change to make the third person view per player @@ -224,14 +224,14 @@ protected: virtual void setDefaultHeadHeight(); public: - shared_ptr fishing; + std::shared_ptr fishing; virtual bool hurt(DamageSource *source, int dmg); protected: virtual int getDamageAfterMagicAbsorb(DamageSource *damageSource, int damage); virtual bool isPlayerVersusPlayer(); - void directAllTameWolvesOnTarget(shared_ptr target, bool skipSitting); + void directAllTameWolvesOnTarget(std::shared_ptr target, bool skipSitting); virtual void hurtArmor(int damage); public: @@ -244,24 +244,24 @@ protected: public: using Entity::interact; - virtual bool openFurnace(shared_ptr container); // 4J - added bool return - virtual bool openTrap(shared_ptr container); // 4J - added bool return - virtual void openTextEdit(shared_ptr sign); - virtual bool openBrewingStand(shared_ptr brewingStand); // 4J - added bool return - virtual bool openTrading(shared_ptr traderTarget); // 4J - added bool return - virtual void openItemInstanceGui(shared_ptr itemInstance); - virtual bool interact(shared_ptr entity); - virtual shared_ptr getSelectedItem(); + virtual bool openFurnace(std::shared_ptr container); // 4J - added bool return + virtual bool openTrap(std::shared_ptr container); // 4J - added bool return + virtual void openTextEdit(std::shared_ptr sign); + virtual bool openBrewingStand(std::shared_ptr brewingStand); // 4J - added bool return + virtual bool openTrading(std::shared_ptr traderTarget); // 4J - added bool return + virtual void openItemInstanceGui(std::shared_ptr itemInstance); + virtual bool interact(std::shared_ptr entity); + virtual std::shared_ptr getSelectedItem(); void removeSelectedItem(); virtual double getRidingHeight(); virtual void swing(); - virtual void attack(shared_ptr entity); - virtual void crit(shared_ptr entity); - virtual void magicCrit(shared_ptr entity); + virtual void attack(std::shared_ptr entity); + virtual void crit(std::shared_ptr entity); + virtual void magicCrit(std::shared_ptr entity); virtual void respawn(); protected: - static void animateRespawn(shared_ptr player, Level *level); + static void animateRespawn(std::shared_ptr player, Level *level); public: Slot *getInventorySlot(int slotId); @@ -281,7 +281,7 @@ private: public: /** - * + * * @param forcefulWakeUp * If the player has been forced to wake up. When this happens, * the client will skip the wake-up animation. For example, when @@ -336,9 +336,9 @@ protected: virtual void causeFallDamage(float distance); public: - virtual void killed(shared_ptr mob); - virtual Icon *getItemInHandIcon(shared_ptr item, int layer); - virtual shared_ptr getArmor(int pos); + virtual void killed(std::shared_ptr mob); + virtual Icon *getItemInHandIcon(std::shared_ptr item, int layer); + virtual std::shared_ptr getArmor(int pos); virtual void handleInsidePortal(); void increaseXp(int i); @@ -353,18 +353,18 @@ public: FoodData *getFoodData(); bool canEat(bool magicalItem); bool isHurt(); - virtual void startUsingItem(shared_ptr instance, int duration); + virtual void startUsingItem(std::shared_ptr instance, int duration); bool mayBuild(int x, int y, int z); protected: - virtual int getExperienceReward(shared_ptr killedBy); + virtual int getExperienceReward(std::shared_ptr killedBy); virtual bool isAlwaysExperienceDropper(); public: virtual wstring getAName(); virtual void changeDimension(int i); - virtual void restoreFrom(shared_ptr oldPlayer, bool restoreAll); + virtual void restoreFrom(std::shared_ptr oldPlayer, bool restoreAll); protected: bool makeStepSound(); @@ -378,19 +378,19 @@ public: //Language getLanguage() { return Language.getInstance(); } //String localize(String key, Object... args) { return getLanguage().getElement(key, args); } - shared_ptr getEnderChestInventory(); + std::shared_ptr getEnderChestInventory(); public: - virtual shared_ptr getCarriedItem(); + virtual std::shared_ptr getCarriedItem(); - virtual bool isInvisibleTo(shared_ptr player); + virtual bool isInvisibleTo(std::shared_ptr player); - static int hash_fnct(const shared_ptr k); - static bool eq_test(const shared_ptr x, const shared_ptr y); + static int hash_fnct(const std::shared_ptr k); + static bool eq_test(const std::shared_ptr x, const std::shared_ptr y); // 4J Stu - Added to allow callback to tutorial to stay within Minecraft.Client // Overidden in LocalPlayer - virtual void onCrafted(shared_ptr item) {} + virtual void onCrafted(std::shared_ptr item) {} // 4J Overriding this so that we can have some different default skins virtual int getTexture(); // 4J changed from wstring to int @@ -421,7 +421,7 @@ public: void setShowOnMaps(bool bVal) { m_bShownOnMaps = bVal; } bool canShowOnMaps() { return m_bShownOnMaps && !getPlayerGamePrivilege(ePlayerGamePrivilege_Invisible); } - + virtual void sendMessage(const wstring& message, ChatPacket::EChatPacketMessage type = ChatPacket::e_ChatCustom, int customData = -1, const wstring& additionalMessage = L"") { } private: PlayerUID m_xuid; @@ -493,12 +493,12 @@ public: static void setPlayerGamePrivilege(unsigned int &uiGamePrivileges, EPlayerGamePrivileges privilege, unsigned int value); bool isAllowedToUse(Tile *tile); - bool isAllowedToUse(shared_ptr item); - bool isAllowedToInteract(shared_ptr target); + bool isAllowedToUse(std::shared_ptr item); + bool isAllowedToInteract(std::shared_ptr target); bool isAllowedToMine(); bool isAllowedToAttackPlayers(); bool isAllowedToAttackAnimals(); - bool isAllowedToHurtEntity(shared_ptr target); + bool isAllowedToHurtEntity(std::shared_ptr target); bool isAllowedToFly(); bool isAllowedToIgnoreExhaustion(); bool isAllowedToTeleport(); @@ -513,7 +513,7 @@ public: public: // 4J Stu - Added hooks for the game rules - virtual void handleCollectItem(shared_ptr item) {} + virtual void handleCollectItem(std::shared_ptr item) {} vector *GetAdditionalModelParts(); void SetAdditionalModelParts(vector *ppAdditionalModelParts); @@ -541,13 +541,13 @@ private: struct PlayerKeyHash { - inline int operator() (const shared_ptr k) const + inline int operator() (const std::shared_ptr k) const { return Player::hash_fnct (k); } }; struct PlayerKeyEq { - inline bool operator() (const shared_ptr x, const shared_ptr y) const + inline bool operator() (const std::shared_ptr x, const std::shared_ptr y) const { return Player::eq_test (x, y); } }; -- cgit v1.2.3