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
90 lines
2.2 KiB
C++
90 lines
2.2 KiB
C++
#pragma once
|
|
using namespace std;
|
|
|
|
#include "Entity.h"
|
|
|
|
class Player;
|
|
class Level;
|
|
class CompoundTag;
|
|
class DamageSource;
|
|
|
|
class Boat : public Entity
|
|
{
|
|
public:
|
|
eINSTANCEOF GetType() { return eTYPE_BOAT; };
|
|
static Entity *create(Level *level) { return new Boat(level); }
|
|
|
|
private:
|
|
// 4J - added for common ctor code
|
|
void _init();
|
|
public:
|
|
static const int serialVersionUID = 0;
|
|
|
|
private:
|
|
static const int DATA_ID_HURT = 17;
|
|
static const int DATA_ID_HURTDIR = 18;
|
|
static const int DATA_ID_DAMAGE = 19;
|
|
static const double MAX_SPEED;
|
|
static const double MAX_COLLISION_SPEED;
|
|
static const double MIN_ACCELERATION;
|
|
static const double MAX_ACCELERATION;
|
|
|
|
bool doLerp;
|
|
double acceleration;
|
|
|
|
public:
|
|
Boat(Level *level);
|
|
|
|
protected:
|
|
virtual bool makeStepSound();
|
|
virtual void defineSynchedData();
|
|
|
|
public:
|
|
virtual AABB *getCollideAgainstBox(shared_ptr<Entity> entity);
|
|
virtual AABB *getCollideBox();
|
|
virtual bool isPushable();
|
|
|
|
Boat(Level *level, double x, double y, double z);
|
|
|
|
virtual double getRideHeight();
|
|
virtual bool hurt(DamageSource *source, float damage);
|
|
virtual void animateHurt();
|
|
virtual bool isPickable();
|
|
|
|
private:
|
|
int lSteps;
|
|
double lx, ly, lz, lyr, lxr;
|
|
double lxd, lyd, lzd;
|
|
|
|
public:
|
|
virtual void lerpTo(double x, double y, double z, float yRot, float xRot, int steps);
|
|
virtual void lerpMotion(double xd, double yd, double zd);
|
|
virtual void tick();
|
|
void createSplash(double particleStrengh);
|
|
virtual void positionRider();
|
|
|
|
protected:
|
|
virtual void addAdditonalSaveData(CompoundTag *base);
|
|
virtual void readAdditionalSaveData(CompoundTag *base);
|
|
|
|
public:
|
|
virtual float getShadowHeightOffs();
|
|
wstring getName();
|
|
virtual bool interact(shared_ptr<Player> player);
|
|
|
|
virtual void setDamage(float damage);
|
|
virtual float getDamage();
|
|
virtual void setHurtTime(int hurtTime);
|
|
virtual int getHurtTime();
|
|
virtual void setHurtDir(int hurtDir);
|
|
virtual int getHurtDir();
|
|
|
|
bool getDoLerp();
|
|
void setDoLerp(bool doLerp);
|
|
|
|
virtual int getAttackTooltipId(std::shared_ptr<Player> player);
|
|
virtual int getInteractTooltipId(Level *level,
|
|
std::shared_ptr<Player> player,
|
|
std::shared_ptr<ItemInstance> heldItem);
|
|
};
|