Moved the whole logic to a new file (TooltipManager.cpp), and rewrote most of the logic to profit from object oriented programming. The side-effect is that the changes are scattered across entities, tiles and items because moving everything to OOP requires to add the tooltip to every .cpp file for every tile/item/entities (or their class, on plants for example which all use the tooltip IDS_TOOLTIPS_PLANT)
The issue with the default tooltips loop written by 4J is that:
Its running in the main Minecraft::tick loop and is more than a thousand lines long, polluting the function.
Not using C++'s full potential with object oriented programming, 4J decided to use a big switch case (probably because it could run better on hardware without branch prediction like the WiiU or Xbox 360 ?)
And seems to be better off in its own file than in the main Minecraft.cpp file
70 lines
1.7 KiB
C++
70 lines
1.7 KiB
C++
#pragma once
|
|
|
|
using namespace std;
|
|
|
|
#include "Animal.h"
|
|
|
|
class Player;
|
|
class LightningBolt;
|
|
class ControlledByPlayerGoal;
|
|
|
|
class Pig : public Animal
|
|
{
|
|
public:
|
|
eINSTANCEOF GetType() { return eTYPE_PIG; }
|
|
static Entity *create(Level *level) { return new Pig(level); }
|
|
private:
|
|
static const int DATA_SADDLE_ID = 16;
|
|
ControlledByPlayerGoal *controlGoal;
|
|
|
|
public:
|
|
Pig(Level *level);
|
|
|
|
virtual bool useNewAi();
|
|
|
|
protected:
|
|
virtual bool removeWhenFarAway();
|
|
virtual void registerAttributes();
|
|
virtual void newServerAiStep();
|
|
|
|
public:
|
|
virtual bool canBeControlledByRider();
|
|
|
|
protected:
|
|
virtual void defineSynchedData();
|
|
|
|
public:
|
|
virtual void addAdditonalSaveData(CompoundTag *tag);
|
|
virtual void readAdditionalSaveData(CompoundTag *tag);
|
|
|
|
protected:
|
|
virtual int getAmbientSound();
|
|
virtual int getHurtSound();
|
|
virtual int getDeathSound();
|
|
virtual void playStepSound(int xt, int yt, int zt, int t);
|
|
|
|
public:
|
|
virtual bool mobInteract(shared_ptr<Player> player);
|
|
|
|
protected:
|
|
virtual int getDeathLoot();
|
|
// virtual void dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel);
|
|
|
|
public:
|
|
bool hasSaddle();
|
|
void setSaddle(bool value);
|
|
virtual void thunderHit(const LightningBolt *lightningBolt);
|
|
|
|
protected:
|
|
virtual void causeFallDamage(float distance);
|
|
|
|
public:
|
|
virtual shared_ptr<AgableMob> getBreedOffspring(shared_ptr<AgableMob> target);
|
|
bool isFood(shared_ptr<ItemInstance> itemInstance);
|
|
ControlledByPlayerGoal *getControlGoal();
|
|
virtual int getAttackTooltipId(std::shared_ptr<Player> player);
|
|
virtual int getInteractTooltipId(Level *level,
|
|
std::shared_ptr<Player> player,
|
|
std::shared_ptr<ItemInstance> heldItem);
|
|
};
|