diff --git a/libreborn/include/libreborn/util.h b/libreborn/include/libreborn/util.h index b63e86b..707fdf0 100644 --- a/libreborn/include/libreborn/util.h +++ b/libreborn/include/libreborn/util.h @@ -52,7 +52,7 @@ int reborn_is_server(); // Customize VTable #define CUSTOM_VTABLE(name, parent) \ - static void _setup_##name##_vtable(parent##_vtable *vtable); \ + void _setup_##name##_vtable(parent##_vtable *vtable); \ static parent##_vtable *get_##name##_vtable() { \ static parent##_vtable *vtable = NULL; \ /* Allocate VTable */ \ @@ -67,7 +67,7 @@ int reborn_is_server(); return vtable; \ } \ /* User-Defined Setup Code */ \ - static void _setup_##name##_vtable(parent##_vtable *vtable) + void _setup_##name##_vtable(parent##_vtable *vtable) #ifdef __cplusplus } diff --git a/mods/include/mods/text-input-box/TextInputBox.h b/mods/include/mods/text-input-box/TextInputBox.h index 16f62bf..9fcaf18 100644 --- a/mods/include/mods/text-input-box/TextInputBox.h +++ b/mods/include/mods/text-input-box/TextInputBox.h @@ -3,7 +3,7 @@ #include struct TextInputBox { - static TextInputBox *create(const std::string &placeholder = "", const std::string &text = ""); + static TextInputBox *create(const std::string &placeholder = "", const std::string &text = "", const std::vector *history = NULL); GuiComponent super; @@ -21,6 +21,8 @@ struct TextInputBox { bool isFocused(); void setMaxLength(int max_length); + int history_pos; + private: void recalculateScroll(); @@ -38,4 +40,5 @@ private: Font *m_pFont; int m_maxLength; int m_scrollPos; + const std::vector *history; }; diff --git a/mods/src/chat/ui.cpp b/mods/src/chat/ui.cpp index 4aa18c1..bdc2dc2 100644 --- a/mods/src/chat/ui.cpp +++ b/mods/src/chat/ui.cpp @@ -10,6 +10,8 @@ #include #include +std::vector history; + // Structure struct ChatScreen { TextInputScreen super; @@ -24,7 +26,7 @@ CUSTOM_VTABLE(chat_screen, Screen) { original_init(super); ChatScreen *self = (ChatScreen *) super; // Text Input - self->chat = TextInputBox::create(); + self->chat = TextInputBox::create("", "", &history); self->super.m_textInputs->push_back(self->chat); self->chat->init(super->font); self->chat->setFocused(true); @@ -78,7 +80,11 @@ CUSTOM_VTABLE(chat_screen, Screen) { ChatScreen *self = (ChatScreen *) super; if (key == 0x0d && self->chat->isFocused()) { if (self->chat->getText().length() > 0) { - _chat_queue_message(self->chat->getText().c_str()); + std::string text = self->chat->getText(); + if (self->chat->history_pos != int(history.size() - 1)) { + history.push_back(text); + } + _chat_queue_message(text.c_str()); } Minecraft_setScreen(super->minecraft, NULL); } @@ -113,6 +119,7 @@ static Screen *create_chat_screen() { // Init void _init_chat_ui() { + history = {}; misc_run_on_game_key_press([](Minecraft *minecraft, int key) { if (key == 0x54) { if (Minecraft_isLevelGenerated(minecraft) && minecraft->screen == NULL) { diff --git a/mods/src/text-input-box/TextInputBox.cpp b/mods/src/text-input-box/TextInputBox.cpp index 22d0c8e..cfbda59 100644 --- a/mods/src/text-input-box/TextInputBox.cpp +++ b/mods/src/text-input-box/TextInputBox.cpp @@ -2,7 +2,16 @@ #include -TextInputBox *TextInputBox::create(const std::string &placeholder, const std::string &text) { +static int get_vec_size(const std::vector *vec) { + return vec ? vec->size() : 0; +} + +static std::string index_vec(const std::vector *vec, int pos) { + if (vec == NULL || pos == get_vec_size(vec)) return ""; + return vec->at(pos); +} + +TextInputBox *TextInputBox::create(const std::string &placeholder, const std::string &text, const std::vector *history) { // Construct TextInputBox *self = new TextInputBox; GuiComponent_constructor(&self->super); @@ -22,6 +31,8 @@ TextInputBox *TextInputBox::create(const std::string &placeholder, const std::st self->m_pFont = nullptr; self->m_maxLength = -1; self->m_scrollPos = 0; + self->history = history; + self->history_pos = get_vec_size(history); // Return return self; @@ -88,6 +99,16 @@ void TextInputBox::keyPressed(int key) { recalculateScroll(); break; } + case 0x26: { + // Up + int old_pos = history_pos; + history_pos -= 1; + if (history_pos < 0) history_pos = get_vec_size(history); + if (old_pos == history_pos) break; + m_text = index_vec(history, history_pos); + m_insertHead = int(m_text.size()); + break; + } case 0x27: { // Right m_insertHead++; @@ -101,6 +122,16 @@ void TextInputBox::keyPressed(int key) { recalculateScroll(); break; } + case 0x28: { + // Down + int old_pos = history_pos; + history_pos += 1; + if (history_pos > get_vec_size(history)) history_pos = 0; + if (old_pos == history_pos) break; + m_text = index_vec(history, history_pos); + m_insertHead = int(m_text.size()); + break; + } case 0x0d: { // Enter m_bFocused = false; diff --git a/symbols/CMakeLists.txt b/symbols/CMakeLists.txt index cabb173..55be867 100644 --- a/symbols/CMakeLists.txt +++ b/symbols/CMakeLists.txt @@ -66,6 +66,7 @@ set(SRC src/level/container/Container.def src/level/container/ContainerMenu.def src/level/container/Inventory.def + src/level/feature/Feature.def src/level/feature/LargeFeature.def src/level/feature/LargeCaveFeature.def src/level/Material.def @@ -97,6 +98,7 @@ set(SRC src/item/ArmorItem.def src/item/TileItem.def src/item/FoodItem.def + src/item/DiggerItem.def src/api/OffsetPosTranslator.def src/api/CommandServer.def src/api/ConnectedClient.def diff --git a/symbols/src/entity/Entity.def b/symbols/src/entity/Entity.def index ec7a88b..bd5e7ff 100644 --- a/symbols/src/entity/Entity.def +++ b/symbols/src/entity/Entity.def @@ -1,5 +1,6 @@ virtual-method void remove() = 0x10; virtual-method void tick() = 0x34; +virtual-method float getBrightness(float param_1) = 0x64; virtual-method bool interact(Player *with) = 0x6c; virtual-method void playerTouch(Player *player) = 0x70; virtual-method bool isPlayer() = 0x94; @@ -37,3 +38,4 @@ property int fire_timer = 0xa0; property int renderer_id = 0xa8; property bool on_ground = 0xb2; property bool freeze_physics = 0xb9; +property float fall_distance = 0xac; diff --git a/symbols/src/game/GameRenderer.def b/symbols/src/game/GameRenderer.def index 2e149cb..b8795ef 100644 --- a/symbols/src/game/GameRenderer.def +++ b/symbols/src/game/GameRenderer.def @@ -1,3 +1,4 @@ +method void tick(int tick, int max_ticks) = 0x495bc; method void render(float param_1) = 0x4a338; method void setupCamera(float param_1, int param_2) = 0x489f8; diff --git a/symbols/src/game/Minecraft.def b/symbols/src/game/Minecraft.def index 04707c0..35229b9 100644 --- a/symbols/src/game/Minecraft.def +++ b/symbols/src/game/Minecraft.def @@ -4,7 +4,7 @@ method void tickInput() = 0x15ffc; method void setIsCreativeMode(int is_creative) = 0x16ec4; method int isTouchscreen() = 0x1639c; method void setScreen(Screen *screen) = 0x15d6c; -method void tick(int param_1, int param_2) = 0x16934; +method void tick(int tick, int max_ticks) = 0x16934; method void hostMultiplayer(int port) = 0x16664; method char *getProgressMessage() = 0x16e58; method uint isLevelGenerated() = 0x16e6c; @@ -27,21 +27,24 @@ property int screen_width = 0x20; property int screen_height = 0x24; property Options options = 0x3c; property LevelRenderer *levelrenderer = 0x150; +property GameRenderer *gamerenderer = 0x154; property GameMode *game_mode = 0x160; property Textures *textures = 0x164; +property ScreenChooser screen_chooser = 0x168; +property Font *font = 0x16c; property RakNetInstance *rak_net_instance = 0x170; property NetEventCallback *network_handler = 0x174; property Level *level = 0x188; +property LocalPlayer *player = 0x18c; property Mob *camera = 0x194; property Gui gui = 0x198; -property LocalPlayer *player = 0x18c; property Screen *screen = 0xc10; property HitResult hit_result = 0xc38; property int progress = 0xc60; +property int ticks_per_update = 0xc70; +property bool is_creative_mode = 0xcb5; property PerfRenderer *perf_renderer = 0xcbc; property CommandServer *command_server = 0xcc0; -property Font *font = 0x16c; -property ScreenChooser screen_chooser = 0x168; // Smooth Lighting static-property bool useAmbientOcclusion = 0x136b90; diff --git a/symbols/src/item/DiggerItem.def b/symbols/src/item/DiggerItem.def new file mode 100644 index 0000000..7d114e8 --- /dev/null +++ b/symbols/src/item/DiggerItem.def @@ -0,0 +1,3 @@ +extends Item; + +property float speed = 0x24; diff --git a/symbols/src/level/Biome.def b/symbols/src/level/Biome.def index 4b1e307..4b5fa33 100644 --- a/symbols/src/level/Biome.def +++ b/symbols/src/level/Biome.def @@ -1,2 +1,20 @@ +vtable 0x110180; +vtable-size 0x24; + +static-method void initBiomes() = 0xae320; +static-method void recalc() = 0xae010; +static-method Biome *_getBiome(float temp, float humidity) = 0xadf04; + +virtual-method Feature *getTreeFeature(Random *random) = 0x8; +virtual-method Feature *getGrassFeature(Random *random) = 0xc; +virtual-method float adjustScale(float scale) = 0x10; +virtual-method float adjustDepth(float depth) = 0x14; +virtual-method uint getSkyColor(float temp) = 0x18; +//virtual-method ??? *getMobs(MobCategory *category) = 0x1c; +virtual-method float getCreatureProbability() = 0x20; + property int color = 0x2c; property int leaf_color = 0x34; + +// 64x64, Temp x humidity +static-property-array Biome *map = 0x17c970; diff --git a/symbols/src/level/Level.def b/symbols/src/level/Level.def index 14b50f9..c604a9c 100644 --- a/symbols/src/level/Level.def +++ b/symbols/src/level/Level.def @@ -11,17 +11,21 @@ method Entity *getEntity(int id) = 0xa45a4; method bool addEntity(Entity *entity) = 0xa7cbc; method int getBrightness2(LightLayer *layer, int x, int y, int z) = 0xa3c70; method void playSound(Entity *entity, std::string *name, float volume, float pitch) = 0xa42a8; +// Searches aabb for entities, ignores the entity "ignore", overwrites the same vector each time +method std::vector *getEntities(Entity *ignore, AABB *aabb) = 0xa5a4c; // Searches aabb for entities of type type_id, adds then to buff, returns the number of entities added method int getEntitiesOfType(int type_id, AABB *aabb, std::vector *buff) = 0xa612c; // Searches aabb for entities of base type base_type, adds then to buff, returns the number of entities added method int getEntitiesOfClass(int base_type, AABB *aabb, std::vector *buff) = 0xa6240; // This will implicitly make the tile entity if the tile at x, y, z doesn't have one and is an EntityTile method TileEntity *getTileEntity(int x, int y, int z) = 0xa55d4; +method void animateTick(int x, int y, int z) = 0xa5920; virtual-method void tick() = 0x28; virtual-method void updateSleepingPlayerList() = 0x2c; virtual-method ChunkCache *createChunkSource() = 0x30; +property bool done_generating = 0x12; property std::vector entities = 0x20; property std::vector tileentities = 0x50; property std::vector players = 0x60; diff --git a/symbols/src/level/LevelRenderer.def b/symbols/src/level/LevelRenderer.def index 1cb645d..d15a4f4 100644 --- a/symbols/src/level/LevelRenderer.def +++ b/symbols/src/level/LevelRenderer.def @@ -1,3 +1,4 @@ +method void tick() = 0x4da1c; method void render(Mob *mob, int param_1, float delta) = 0x4f710; method void renderDebug(AABB *aabb, float delta) = 0x4d310; method void generateSky() = 0x4d0d4; diff --git a/symbols/src/level/RandomLevelSource.def b/symbols/src/level/RandomLevelSource.def index ea21c11..6d41eea 100644 --- a/symbols/src/level/RandomLevelSource.def +++ b/symbols/src/level/RandomLevelSource.def @@ -5,4 +5,5 @@ vtable 0x110598; method void buildSurface(int chunk_x, int chunk_y, uchar *chunk_data, Biome **biomes) = 0xb32ec; property LargeCaveFeature cave_feature = 0x8; +property Random random = 0x19f8; property Level *level = 0x72c8; diff --git a/symbols/src/level/container/Inventory.def b/symbols/src/level/container/Inventory.def index 7a1158c..6a7441f 100644 --- a/symbols/src/level/container/Inventory.def +++ b/symbols/src/level/container/Inventory.def @@ -6,5 +6,7 @@ method ItemInstance *getSelected() = 0x8d134; // It's just FillingContainer_linkSlot with selectedSlot as linked_slot method bool moveToSelectedSlot(int unlinked_slot, bool push_aside) = 0x8d148; method void setupDefault() = 0x8d164; +method void clearInventoryWithDefault() = 0x8e7c8; +method void clearInventory() = 0x92b84; property int selectedSlot = 0x28; diff --git a/symbols/src/level/feature/Feature.def b/symbols/src/level/feature/Feature.def new file mode 100644 index 0000000..9310d49 --- /dev/null +++ b/symbols/src/level/feature/Feature.def @@ -0,0 +1,7 @@ +vtable 0x10e530; +vtable-size 0x10; + +// Pure virtual +virtual-method bool place(Level *level, Random *random, int x, int y, int z) = 0x8; +// Not sure about args, it doesn't seem to be used at all +virtual-method void init(float x, float y, float z) = 0xc; diff --git a/symbols/src/misc/Mth.def b/symbols/src/misc/Mth.def index 9dd5c78..4133f59 100644 --- a/symbols/src/misc/Mth.def +++ b/symbols/src/misc/Mth.def @@ -5,3 +5,4 @@ static-method float sin(float x) = 0x7775c; static-method float cos(float x) = 0x77728; static-method float abs(float x) = 0x7781c; static-method float min(float a, float b) = 0x7782c; +static-method float invSqrt(float a) = 0x776d4; \ No newline at end of file diff --git a/symbols/src/tile/Tile.def b/symbols/src/tile/Tile.def index 62270ae..18c0ebd 100644 --- a/symbols/src/tile/Tile.def +++ b/symbols/src/tile/Tile.def @@ -73,3 +73,4 @@ static-property Tile *grass_carried = 0x181dd4; // Sounds static-property Tile_SoundType SOUND_STONE = 0x181c80; +static-property Tile_SoundType SOUND_WOOD = 0x181cb4; diff --git a/symbols/src/tile/TileRenderer.def b/symbols/src/tile/TileRenderer.def index e779491..23a3d3d 100644 --- a/symbols/src/tile/TileRenderer.def +++ b/symbols/src/tile/TileRenderer.def @@ -1,4 +1,8 @@ +size 0xb8; + +constructor (Minecraft *minecraft, LevelSource *level) = 0x53e58; + method bool tesselateBlockInWorld(Tile *tile, int x, int y, int z) = 0x59e30; method bool tesselateInWorld(Tile *tile, int x, int y, int z) = 0x5e80c; -property Level *level = 0x0; +property LevelSource *level = 0x0;