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
50 lines
2.1 KiB
C++
50 lines
2.1 KiB
C++
#pragma once
|
|
|
|
#include "BaseEntityTile.h"
|
|
|
|
class FlowerPotTile : public BaseEntityTile
|
|
{
|
|
public:
|
|
static const int TYPE_FLOWER_RED = 1;
|
|
static const int TYPE_FLOWER_YELLOW = 2;
|
|
static const int TYPE_SAPLING_DEFAULT = 3;
|
|
static const int TYPE_SAPLING_EVERGREEN = 4;
|
|
static const int TYPE_SAPLING_BIRCH = 5;
|
|
static const int TYPE_SAPLING_JUNGLE = 6;
|
|
static const int TYPE_MUSHROOM_RED = 7;
|
|
static const int TYPE_MUSHROOM_BROWN = 8;
|
|
static const int TYPE_CACTUS = 9;
|
|
static const int TYPE_DEAD_BUSH = 10;
|
|
static const int TYPE_FERN = 11;
|
|
static const int TYPE_FLOWER_BLUE_ORCHID = 12;
|
|
static const int TYPE_FLOWER_ALLIUM = 13;
|
|
static const int TYPE_FLOWER_AZURE_BLUET = 14;
|
|
static const int TYPE_FLOWER_OXEYE_DAISY = 15;
|
|
|
|
FlowerPotTile(int id);
|
|
shared_ptr<TileEntity> newTileEntity(Level *level);
|
|
virtual void createBlockStateDefinition() override;
|
|
virtual int defaultBlockState() override;
|
|
virtual int convertBlockStateToLegacyData(BlockState *state) override;
|
|
virtual Tile::BlockState getBlockState(LevelSource *level, int x, int y, int z) override;
|
|
virtual Tile::BlockState getBlockState(int data);
|
|
|
|
void updateDefaultShape();
|
|
bool isSolidRender(bool isServerLevel = false);
|
|
int getRenderShape();
|
|
bool isCubeShaped();
|
|
bool use(Level *level, int x, int y, int z, shared_ptr<Player> player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly = false);
|
|
int cloneTileId(Level *level, int x, int y, int z);
|
|
int cloneTileData(Level *level, int x, int y, int z);
|
|
bool useOwnCloneData();
|
|
bool mayPlace(Level *level, int x, int y, int z);
|
|
void neighborChanged(Level *level, int x, int y, int z, int type);
|
|
void onRemove(Level *level, int x, int y, int z, int id, int data);
|
|
using Tile::spawnResources;
|
|
void spawnResources(Level *level, int x, int y, int z, int data, float odds, int playerBonusLevel);
|
|
int getResource(int data, Random *random, int playerBonusLevel);
|
|
static shared_ptr<ItemInstance> getItemFromType(int type);
|
|
static int getTypeFromItem(shared_ptr<ItemInstance> item);
|
|
|
|
virtual int getInteractTooltipId(Level* level, int x, int y, int z, std::shared_ptr<Player> player, bool bUseItemOn) const override;
|
|
}; |