From 8de638eb1a6d140305b06e40ca7dd0420b266e85 Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Mon, 18 Mar 2024 19:44:17 -0400 Subject: [PATCH] Make chat history edits saved temporarily --- mods/include/mods/title-screen/title-screen.h | 2 + mods/src/chat/chat.cpp | 8 +-- mods/src/chat/ui.cpp | 64 ++++++++++--------- symbols/src/entity/Entity.def | 1 + symbols/src/entity/EntityRenderDispatcher.def | 2 + symbols/src/item/ItemInHandRenderer.def | 4 +- symbols/src/level/Level.def | 18 +++++- symbols/src/level/Material.def | 3 +- symbols/src/level/ServerLevel.def | 1 + symbols/src/level/feature/Feature.def | 2 + symbols/src/misc/CompoundTag.def | 3 + symbols/src/network/packet/ChatPacket.def | 2 +- symbols/src/network/packet/Packet.def | 3 +- symbols/src/tile/EntityTile.def | 1 + symbols/src/tile/Tile.def | 22 ++++++- 15 files changed, 93 insertions(+), 43 deletions(-) diff --git a/mods/include/mods/title-screen/title-screen.h b/mods/include/mods/title-screen/title-screen.h index bbe30a4..cf6330d 100644 --- a/mods/include/mods/title-screen/title-screen.h +++ b/mods/include/mods/title-screen/title-screen.h @@ -3,4 +3,6 @@ #include #include +extern "C" { void title_screen_load_splashes(std::vector &splashes); +} diff --git a/mods/src/chat/chat.cpp b/mods/src/chat/chat.cpp index 563d670..857e1eb 100644 --- a/mods/src/chat/chat.cpp +++ b/mods/src/chat/chat.cpp @@ -60,9 +60,9 @@ void chat_handle_packet_send(Minecraft *minecraft, ChatPacket *packet) { RakNetInstance *rak_net_instance = minecraft->rak_net_instance; if (rak_net_instance->vtable->isServer(rak_net_instance)) { // Hosting Multiplayer - char *message = packet->message; + const char *message = packet->message.c_str(); ServerSideNetworkHandler *server_side_network_handler = (ServerSideNetworkHandler *) minecraft->network_handler; - chat_send_message(server_side_network_handler, Strings_default_username, message); + chat_send_message(server_side_network_handler, Strings_default_username, (char *) message); } else { // Client rak_net_instance->vtable->send(rak_net_instance, (Packet *) packet); @@ -82,8 +82,8 @@ static void ServerSideNetworkHandler_handle_ChatPacket_injection(ServerSideNetwo Player *player = ServerSideNetworkHandler_getPlayer(server_side_network_handler, rak_net_guid); if (player != NULL) { const char *username = player->username.c_str(); - char *message = chat_packet->message; - chat_send_message(server_side_network_handler, (char *) username, message); + const char *message = chat_packet->message.c_str(); + chat_send_message(server_side_network_handler, (char *) username, (char *) message); } } diff --git a/mods/src/chat/ui.cpp b/mods/src/chat/ui.cpp index b0fa8a0..50cd2ef 100644 --- a/mods/src/chat/ui.cpp +++ b/mods/src/chat/ui.cpp @@ -15,10 +15,6 @@ static std::vector &get_history() { return history; } -static std::string index_vec(const std::vector &vec, int pos) { - return pos == int(vec.size()) ? "" : vec.at(pos); -} - // Structure struct ChatScreen { TextInputScreen super; @@ -29,6 +25,7 @@ struct ChatScreen { CUSTOM_VTABLE(chat_screen, Screen) { TextInputScreen::setup(vtable); // Init + static std::vector local_history = {}; static Screen_init_t original_init = vtable->init; vtable->init = [](Screen *super) { original_init(super); @@ -39,6 +36,8 @@ CUSTOM_VTABLE(chat_screen, Screen) { self->chat->init(super->font); self->chat->setFocused(true); self->history_pos = get_history().size(); + local_history = get_history(); + local_history.push_back(""); // Determine Max Length std::string prefix = _chat_get_prefix(Strings_default_username); int max_length = MAX_CHAT_MESSAGE_LENGTH - prefix.length(); @@ -87,34 +86,39 @@ CUSTOM_VTABLE(chat_screen, Screen) { vtable->keyPressed = [](Screen *super, int key) { // Handle Enter ChatScreen *self = (ChatScreen *) super; - if (key == 0x0d && self->chat->isFocused()) { - if (self->chat->getText().length() > 0) { - std::string text = self->chat->getText(); - std::vector &history = get_history(); - if (history.size() == 0 || text != history.back()) { - history.push_back(text); + if (self->chat->isFocused()) { + if (key == 0x0d) { + if (self->chat->getText().length() > 0) { + std::string text = self->chat->getText(); + if (get_history().size() == 0 || text != get_history().back()) { + get_history().push_back(text); + } + _chat_queue_message(text.c_str()); } - _chat_queue_message(text.c_str()); + Minecraft_setScreen(super->minecraft, NULL); + } else if (key == 0x26) { + // Up + local_history.at(self->history_pos) = self->chat->getText(); + // Change + int old_pos = self->history_pos; + self->history_pos -= 1; + if (self->history_pos < 0) self->history_pos = local_history.size() - 1; + if (old_pos != self->history_pos) { + self->chat->setText(local_history.at(self->history_pos)); + } + return; + } else if (key == 0x28) { + // Down + local_history.at(self->history_pos) = self->chat->getText(); + // Change + int old_pos = self->history_pos; + self->history_pos += 1; + if (self->history_pos > int(local_history.size()) - 1) self->history_pos = 0; + if (old_pos != self->history_pos) { + self->chat->setText(local_history.at(self->history_pos)); + } + return; } - Minecraft_setScreen(super->minecraft, NULL); - } else if (key == 0x26 && self->chat->isFocused()) { - // Up - int old_pos = self->history_pos; - self->history_pos -= 1; - if (self->history_pos < 0) self->history_pos = get_history().size(); - if (old_pos != self->history_pos) { - self->chat->setText(index_vec(get_history(), self->history_pos)); - } - return; - } else if (key == 0x28 && self->chat->isFocused()) { - // Down - int old_pos = self->history_pos; - self->history_pos += 1; - if (self->history_pos > int(get_history().size())) self->history_pos = 0; - if (old_pos != self->history_pos) { - self->chat->setText(index_vec(get_history(), self->history_pos)); - } - return; } // Call Original Method original_keyPressed(super, key); diff --git a/symbols/src/entity/Entity.def b/symbols/src/entity/Entity.def index bd5e7ff..3405fe0 100644 --- a/symbols/src/entity/Entity.def +++ b/symbols/src/entity/Entity.def @@ -37,5 +37,6 @@ property float height_offset = 0x68; property int fire_timer = 0xa0; property int renderer_id = 0xa8; property bool on_ground = 0xb2; +property bool pending_removal = 0xb8; property bool freeze_physics = 0xb9; property float fall_distance = 0xac; diff --git a/symbols/src/entity/EntityRenderDispatcher.def b/symbols/src/entity/EntityRenderDispatcher.def index 355dc45..7ba54d4 100644 --- a/symbols/src/entity/EntityRenderDispatcher.def +++ b/symbols/src/entity/EntityRenderDispatcher.def @@ -3,3 +3,5 @@ constructor () = 0x6096c; method void assign(uchar entity_id, EntityRenderer *renderer) = 0x6094c; method void render(Entity *entity, float x, float y, float z, float rot, float unknown) = 0x60674; static-method EntityRenderDispatcher *getInstance() = 0x60e90; + +property ItemInHandRenderer *item_renderer = 0x0; diff --git a/symbols/src/item/ItemInHandRenderer.def b/symbols/src/item/ItemInHandRenderer.def index 1c239b9..56fd212 100644 --- a/symbols/src/item/ItemInHandRenderer.def +++ b/symbols/src/item/ItemInHandRenderer.def @@ -4,6 +4,4 @@ property ItemInstance item = 0xc; property Minecraft *mc = 0x18; method void renderItem(Mob *mob, ItemInstance *item) = 0x4b824; -method void render(float param_1) = 0x4bfcc; - -static-property ItemInHandRenderer **instance = 0x137bc0; \ No newline at end of file +method void render(float param_1) = 0x4bfcc; \ No newline at end of file diff --git a/symbols/src/level/Level.def b/symbols/src/level/Level.def index c604a9c..03f8ebd 100644 --- a/symbols/src/level/Level.def +++ b/symbols/src/level/Level.def @@ -3,13 +3,20 @@ extends LevelSource; vtable 0x10fcf0; method void saveLevelData() = 0xa2e94; +method void setTile(int x, int y, int z, int id) = 0xa3904; method void setTileAndData(int x, int y, int z, int id, int data) = 0xa38b4; method void setTileAndDataNoUpdate(int x, int y, int z, int id, int data) = 0xa33d0; -method HitResult clip(uchar *param_1, uchar *param_2, bool clip_liquids, bool param_3) = 0xa3db0; +// clip_liquids and clip_hitboxes default to true +// If clip_hitboxes is true it will ignore blocks that have their getAABB return NULL +method HitResult clip(uchar *param_1, uchar *param_2, bool clip_liquids, bool clip_hitboxes) = 0xa3db0; +// Valid particles are crit, flame, lava, smoke, largesmoke, reddust, snowballpoof, and explode +// There is also bubble which only works under water and ironcrack which will crash the game method void addParticle(std::string *particle, float x, float y, float z, float deltaX, float deltaY, float deltaZ, int count) = 0xa449c; 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 int getRawBrightness(int x, int y, int z) = 0xa3b70; +// See mods/src/sound/repository.cpp for a list of sounds 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; @@ -19,7 +26,16 @@ method int getEntitiesOfType(int type_id, AABB *aabb, std::vector *buff 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 removeTileEntity(int x, int y, int z) = 0xa7aac; method void animateTick(int x, int y, int z) = 0xa5920; +// Called by trapdoors, doors, and tnt +method bool hasNeighborSignal(int x, int y, int z) = 0xa5f08; +// Called by hasNeighborSignal +method bool getSignal(int x, int y, int z, int direction) = 0xa5e6c; +// Called by getSignal +method bool hasDirectSignal(int x, int y, int z) = 0xa5d88; +// Called by hasDirectSignal +method bool getDirectSignal(int x, int y, int z, int direction) = 0xa5d2c; virtual-method void tick() = 0x28; virtual-method void updateSleepingPlayerList() = 0x2c; diff --git a/symbols/src/level/Material.def b/symbols/src/level/Material.def index fb420b0..bfde2e0 100644 --- a/symbols/src/level/Material.def +++ b/symbols/src/level/Material.def @@ -1,7 +1,8 @@ virtual-method bool isSolid() = 0x8; // Globals -static-property Material *dirt = 0x180a94; +static-property Material *dirt = 0x180a94; static-property Material *stone = 0x180a9c; static-property Material *metal = 0x180aa0; +static-property Material *plant = 0x180ab0; static-property Material *glass = 0x180acc; diff --git a/symbols/src/level/ServerLevel.def b/symbols/src/level/ServerLevel.def index 5416505..c562b23 100644 --- a/symbols/src/level/ServerLevel.def +++ b/symbols/src/level/ServerLevel.def @@ -1,5 +1,6 @@ extends Level; +vtable 0x109da0; size 0xb80; constructor (uchar *storage, uchar *name, LevelSettings *settings, int param_4, Dimension *dimension) = 0x7692c; diff --git a/symbols/src/level/feature/Feature.def b/symbols/src/level/feature/Feature.def index 9310d49..65cb5a9 100644 --- a/symbols/src/level/feature/Feature.def +++ b/symbols/src/level/feature/Feature.def @@ -1,3 +1,5 @@ + +constructor () = 0xb64a0; vtable 0x10e530; vtable-size 0x10; diff --git a/symbols/src/misc/CompoundTag.def b/symbols/src/misc/CompoundTag.def index bd3a465..ebc4dda 100644 --- a/symbols/src/misc/CompoundTag.def +++ b/symbols/src/misc/CompoundTag.def @@ -5,6 +5,9 @@ size 0x24; constructor (std::string name) = 0x69740; method bool getBoolean(std::string *name) = 0xd1b28; +method char getByte(std::string *name) = 0x7f00c; +method void putByte(std::string *name, char i) = 0x7d6d0; method short getShort(std::string *name) = 0x459c0; +method void putShort(std::string *name, short i) = 0x7d60c; method bool contains(std::string *name, int type) = 0x7d130; method void put(std::string *name, Tag *tag) = 0x6a040; diff --git a/symbols/src/network/packet/ChatPacket.def b/symbols/src/network/packet/ChatPacket.def index 35b8833..518acb1 100644 --- a/symbols/src/network/packet/ChatPacket.def +++ b/symbols/src/network/packet/ChatPacket.def @@ -2,4 +2,4 @@ extends Packet; vtable 0x108a98; -property char *message = 0xc; +property std::string message = 0xc; diff --git a/symbols/src/network/packet/Packet.def b/symbols/src/network/packet/Packet.def index bcc587c..80c6ac4 100644 --- a/symbols/src/network/packet/Packet.def +++ b/symbols/src/network/packet/Packet.def @@ -1,5 +1,6 @@ constructor () = 0x6fc18; -size 0x10; + +size 0x8; vtable 0x1024d8; vtable-size 0x14; diff --git a/symbols/src/tile/EntityTile.def b/symbols/src/tile/EntityTile.def index 2d0fec2..bc1e59e 100644 --- a/symbols/src/tile/EntityTile.def +++ b/symbols/src/tile/EntityTile.def @@ -4,4 +4,5 @@ vtable 0x111348; vtable-size 0x108; size 0x5c; +// Pure virtual virtual-method TileEntity *newTileEntity() = 0x104; diff --git a/symbols/src/tile/Tile.def b/symbols/src/tile/Tile.def index 7d7471c..b147e08 100644 --- a/symbols/src/tile/Tile.def +++ b/symbols/src/tile/Tile.def @@ -19,17 +19,32 @@ virtual-method int getTexture2(int face, int data) = 0x2c; virtual-method int getTexture3(LevelSource *level, int x, int y, int z, int face) = 0x30; virtual-method AABB *getAABB(Level *level, int x, int y, int z) = 0x34; virtual-method bool isSolidRender() = 0x40; +virtual-method bool mayPlace(Level *level, int x, int y, int z, uchar face) = 0x4c; +virtual-method bool mayPlace2(Level *level, int x, int y, int z) = 0x50; virtual-method void tick(Level *level, int x, int y, int z) = 0x58; virtual-method void neighborChanged(Level *level, int x, int y, int z, int neighborId) = 0x64; virtual-method void onPlace(Level *level, int x, int y, int z) = 0x68; virtual-method void onRemove(Level *level, int x, int y, int z) = 0x6c; +// Resource is the dropped item virtual-method int getResource(int data, Random *random) = 0x70; virtual-method int getResourceCount(Random *random) = 0x74; +// Returns 1 (default, not transparent), 2 (transparent when the texture is, like bushes), or 3 (semi-transparent, like water) virtual-method int getRenderLayer() = 0x94; virtual-method int use(Level *level, int x, int y, int z, Player *player) = 0x98; virtual-method void setPlacedBy(Level *level, int x, int y, int z, Mob *placer) = 0xa8; virtual-method void handleEntityInside(Level *level, int x, int y, int z, Entity *entity, Vec3 *speed) = 0xb4; +// Note that this may be ignored depending on the value of getRenderShape virtual-method int getColor(LevelSource *level_source, int x, int y, int z) = 0xb8; +// This doesn't mean that it *is* producing a signal, rather that it might be +// Called by trapdoors, doors, and tnt. Never overridden (always returns false) +virtual-method bool isSignalSource() = 0xbc; +// Doesn't seem to be used, but it's hard to tell with virtual methods +// Yes, this IS a bool and not a char. +virtual-method bool getSignal(LevelSource *level, int x, int y, int z) = 0xc0; +// Called at the end of Level_getSignal +virtual-method bool getSignal2(LevelSource *level, int x, int y, int z, int direction) = 0xc4; +// Called by Level_hasDirectSignal +virtual-method bool getDirectSignal(Level *level, int x, int y, int z, int direction) = 0xc8; virtual-method void entityInside(Level *level, int x, int y, int z, Entity *entity) = 0xcc; virtual-method std::string getDescriptionId() = 0xdc; virtual-method Tile *setDescriptionId(std::string *description_id) = 0xe0; @@ -46,6 +61,8 @@ property float z1 = 0x14; property float x2 = 0x18; property float y2 = 0x1c; property float z2 = 0x20; +property float destroyTime = 0x34; +property float explodeable = 0x38; property int category = 0x3c; property AABB aabb = 0x40; @@ -55,6 +72,8 @@ static-property-array float lightEmission = 0x181214; static-property-array bool isEntityTile = 0x181f20; // Tiles +static-property Tile *grass = 0x181b14; +static-property Tile *leaves = 0x18120c; static-property Tile *chest = 0x181d60; static-property Tile *water = 0x181b3c; static-property Tile *lava = 0x181cc8; @@ -74,11 +93,10 @@ static-property Tile *stoneSlab = 0x181b44; static-property Tile *fire = 0x181de0; // "Carried" Tiles -static-property Tile *leaves = 0x18120c; static-property Tile *leaves_carried = 0x181dd8; -static-property Tile *grass = 0x181b14; static-property Tile *grass_carried = 0x181dd4; // Sounds static-property Tile_SoundType SOUND_STONE = 0x181c80; static-property Tile_SoundType SOUND_WOOD = 0x181cb4; +static-property Tile_SoundType SOUND_GRASS = 0x181c94;