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
93 lines
2.3 KiB
C++
93 lines
2.3 KiB
C++
#pragma once
|
|
|
|
using namespace std;
|
|
|
|
class Random;
|
|
class EatTileGoal;
|
|
class CraftingContainer;
|
|
|
|
#include "Animal.h"
|
|
#include "SharedConstants.h"
|
|
#include "AbstractContainerMenu.h"
|
|
|
|
class Sheep : public Animal
|
|
{
|
|
private:
|
|
class SheepContainer : public AbstractContainerMenu
|
|
{
|
|
bool stillValid(shared_ptr<Player> player) { return false; }
|
|
};
|
|
|
|
shared_ptr<CraftingContainer> container;
|
|
public:
|
|
eINSTANCEOF GetType() { return eTYPE_SHEEP; }
|
|
static Entity *create(Level *level) { return new Sheep(level); }
|
|
|
|
private:
|
|
static const int EAT_ANIMATION_TICKS = SharedConstants::TICKS_PER_SECOND * 2;
|
|
static const int DATA_WOOL_ID = 16;
|
|
|
|
int eatAnimationTick;
|
|
EatTileGoal *eatTileGoal;
|
|
|
|
public:
|
|
static const int COLOR_LENGTH = 16;
|
|
static const float COLOR[COLOR_LENGTH][3];
|
|
|
|
public:
|
|
Sheep(Level *level);
|
|
|
|
protected:
|
|
virtual bool useNewAi();
|
|
virtual void newServerAiStep();
|
|
|
|
public:
|
|
void aiStep();
|
|
|
|
protected:
|
|
virtual void registerAttributes();
|
|
virtual void defineSynchedData();
|
|
|
|
public:
|
|
virtual void dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel);
|
|
virtual int getDeathLoot();
|
|
|
|
public:
|
|
virtual void handleEntityEvent(byte id);
|
|
|
|
public:
|
|
float getHeadEatPositionScale(float a);
|
|
float getHeadEatAngleScale(float a);
|
|
|
|
virtual bool mobInteract(shared_ptr<Player> player);
|
|
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:
|
|
int getColor();
|
|
void setColor(int color);
|
|
bool isSheared();
|
|
void setSheared(bool value);
|
|
|
|
static int getSheepColor(Random *random);
|
|
virtual shared_ptr<AgableMob> getBreedOffspring(shared_ptr<AgableMob> target);
|
|
|
|
virtual void ate();
|
|
|
|
MobGroupData *finalizeMobSpawn(MobGroupData *groupData, int extraData = 0); // 4J Added extraData param
|
|
virtual int getAttackTooltipId(std::shared_ptr<Player> player);
|
|
virtual int getInteractTooltipId(Level *level,
|
|
std::shared_ptr<Player> player,
|
|
std::shared_ptr<ItemInstance> heldItem);
|
|
|
|
private:
|
|
int getOffspringColor(shared_ptr<Animal> animal, shared_ptr<Animal> partner);
|
|
int getDyeColor(shared_ptr<Animal> animal);
|
|
};
|