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
42 lines
1.3 KiB
C++
42 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include "HangingEntity.h"
|
|
|
|
class LeashFenceKnotEntity : public HangingEntity
|
|
{
|
|
|
|
public:
|
|
eINSTANCEOF GetType() { return eTYPE_LEASHFENCEKNOT; };
|
|
static Entity *create(Level *level) { return new LeashFenceKnotEntity(level); }
|
|
|
|
private:
|
|
|
|
void _init();
|
|
|
|
public:
|
|
LeashFenceKnotEntity(Level *level);
|
|
LeashFenceKnotEntity(Level *level, int xTile, int yTile, int zTile);
|
|
|
|
protected:
|
|
void defineSynchedData();
|
|
|
|
public:
|
|
void setDir(int dir);
|
|
int getWidth();
|
|
int getHeight();
|
|
bool shouldRenderAtSqrDistance(double distance);
|
|
void dropItem(shared_ptr<Entity> causedBy);
|
|
bool save(CompoundTag *entityTag);
|
|
void addAdditonalSaveData(CompoundTag *tag);
|
|
void readAdditionalSaveData(CompoundTag *tag);
|
|
bool interact(shared_ptr<Player> player);
|
|
virtual bool hurt(DamageSource *source, float damage);
|
|
virtual bool survives();
|
|
static shared_ptr<LeashFenceKnotEntity> createAndAddKnot(Level *level, int x, int y, int z);
|
|
static shared_ptr<LeashFenceKnotEntity> findKnotAt(Level *level, int x, int y, int z);
|
|
virtual int getAttackTooltipId(std::shared_ptr<Player> player);
|
|
virtual int getInteractTooltipId(Level *level,
|
|
std::shared_ptr<Player> player,
|
|
std::shared_ptr<ItemInstance> heldItem);
|
|
};
|