From 4a5514f0638f4097a794bf772adeb871f9f1abc5 Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Mon, 22 Jan 2024 01:39:43 -0500 Subject: [PATCH 01/18] A few more symbols --- symbols/CMakeLists.txt | 8 ++++++++ symbols/src/api/CommandServer.def | 3 ++- symbols/src/api/OffsetPosTranslator.def | 4 ++++ symbols/src/entity/Entity.def | 3 +++ symbols/src/entity/player/LocalPlayer.def | 1 + symbols/src/gui/components/IntRectangle.def | 6 ++++++ symbols/src/gui/components/RectangleArea.def | 8 ++++++++ symbols/src/gui/components/ScrollingPane.def | 16 ++++++++++++++++ symbols/src/input/IMoveInput.def | 1 + symbols/src/item/ArmorItem.def | 5 +++++ symbols/src/item/ArmorMaterial.def | 13 +++++++++++++ symbols/src/level/ChunkCache.def | 3 +++ symbols/src/level/ChunkSource.def | 2 ++ symbols/src/level/Level.def | 6 +++++- symbols/src/level/LevelSource.def | 7 ++++++- symbols/src/level/container/FillingContainer.def | 9 ++++++++- symbols/src/level/container/Inventory.def | 3 +++ symbols/src/network/NetEventCallback.def | 1 + symbols/src/network/packet/SignUpdatePacket.def | 7 +++++++ 19 files changed, 102 insertions(+), 4 deletions(-) create mode 100644 symbols/src/gui/components/IntRectangle.def create mode 100644 symbols/src/gui/components/RectangleArea.def create mode 100644 symbols/src/gui/components/ScrollingPane.def create mode 100644 symbols/src/input/IMoveInput.def create mode 100644 symbols/src/item/ArmorItem.def create mode 100644 symbols/src/item/ArmorMaterial.def create mode 100644 symbols/src/level/ChunkCache.def create mode 100644 symbols/src/network/packet/SignUpdatePacket.def diff --git a/symbols/CMakeLists.txt b/symbols/CMakeLists.txt index 7b84c3e..13a127d 100644 --- a/symbols/CMakeLists.txt +++ b/symbols/CMakeLists.txt @@ -23,6 +23,7 @@ set(SRC src/network/ServerSideNetworkHandler.def src/network/packet/LoginPacket.def src/network/packet/PlayerEquipmentPacket.def + src/network/packet/SignUpdatePacket.def src/network/packet/Packet.def src/network/packet/StartGamePacket.def src/network/packet/ChatPacket.def @@ -59,6 +60,7 @@ set(SRC src/level/ExternalFileLevelStorageSource.def src/level/Biome.def src/level/ChunkSource.def + src/level/ChunkCache.def src/level/Level.def src/level/LevelRenderer.def src/level/LevelStorageSource.def @@ -72,6 +74,8 @@ set(SRC src/item/AuxDataTileItem.def src/item/ItemInstance.def src/item/Item.def + src/item/ArmorMaterial.def + src/item/ArmorItem.def src/item/TileItem.def src/api/OffsetPosTranslator.def src/api/CommandServer.def @@ -96,6 +100,9 @@ set(SRC src/gui/components/GuiComponent.def src/gui/components/Button.def src/gui/components/Gui.def + src/gui/components/IntRectangle.def + src/gui/components/RectangleArea.def + src/gui/components/ScrollingPane.def src/app-platform/AppPlatform.def src/app-platform/AppPlatform_linux.def src/app-platform/AppPlatform_readAssetFile_return_value.def @@ -124,6 +131,7 @@ set(SRC src/misc/SoundEngine.def src/misc/Common.def src/misc/Config.def + src/input/IMoveInput.def src/input/IBuildInput.def src/input/MouseBuildInput.def src/input/Mouse.def diff --git a/symbols/src/api/CommandServer.def b/symbols/src/api/CommandServer.def index b975027..950e41a 100644 --- a/symbols/src/api/CommandServer.def +++ b/symbols/src/api/CommandServer.def @@ -1,3 +1,4 @@ method std::string parse(ConnectedClient *client, std::string *command) = 0x6aa8c; -property Minecraft *minecraft = 0x18; \ No newline at end of file +property Minecraft *minecraft = 0x18; +property OffsetPosTranslator pos_translator = 0x1c; diff --git a/symbols/src/api/OffsetPosTranslator.def b/symbols/src/api/OffsetPosTranslator.def index 15d0d43..7278987 100644 --- a/symbols/src/api/OffsetPosTranslator.def +++ b/symbols/src/api/OffsetPosTranslator.def @@ -1 +1,5 @@ method void from(int *x, int *y, int *z) = 0x27c98; + +property float x = 0x4; +property float y = 0x8; +property float z = 0xc; diff --git a/symbols/src/entity/Entity.def b/symbols/src/entity/Entity.def index a004387..def2f3b 100644 --- a/symbols/src/entity/Entity.def +++ b/symbols/src/entity/Entity.def @@ -10,6 +10,9 @@ property int id = 0x1c; property float old_x = 0x28; property float old_y = 0x2c; property float old_z = 0x30; +property float vel_x = 0x34; +property float vel_y = 0x38; +property float vel_z = 0x3c; property float yaw = 0x40; property float pitch = 0x44; property float old_yaw = 0x48; diff --git a/symbols/src/entity/player/LocalPlayer.def b/symbols/src/entity/player/LocalPlayer.def index 4c09db4..b2efcdc 100644 --- a/symbols/src/entity/player/LocalPlayer.def +++ b/symbols/src/entity/player/LocalPlayer.def @@ -2,4 +2,5 @@ extends Player; vtable 0x106230; +property IMoveInput *input = 0xc88; property Minecraft *minecraft = 0xc90; diff --git a/symbols/src/gui/components/IntRectangle.def b/symbols/src/gui/components/IntRectangle.def new file mode 100644 index 0000000..0fbabd4 --- /dev/null +++ b/symbols/src/gui/components/IntRectangle.def @@ -0,0 +1,6 @@ +size 0x10; + +property int x = 0x0; +property int y = 0x4; +property int x_offset = 0x8; +property int y_offset = 0xc; diff --git a/symbols/src/gui/components/RectangleArea.def b/symbols/src/gui/components/RectangleArea.def new file mode 100644 index 0000000..d68dbb7 --- /dev/null +++ b/symbols/src/gui/components/RectangleArea.def @@ -0,0 +1,8 @@ +size 0x18; + +property float x1 = 0x8; +property float x2 = 0xc; +property float y1 = 0x10; +property float y2 = 0x14; + +method bool isInside(float x, float y) = 0x21aa4; diff --git a/symbols/src/gui/components/ScrollingPane.def b/symbols/src/gui/components/ScrollingPane.def new file mode 100644 index 0000000..f1442b8 --- /dev/null +++ b/symbols/src/gui/components/ScrollingPane.def @@ -0,0 +1,16 @@ +extends GuiComponent; + +constructor (int param_2, IntRectangle *bb, IntRectangle *itembb, int columns, int item_count, float scale, IntRectangle *itembb2) = 0x22b44; + +method void setContentOffset(float x, float y) = 0x220a0; +method void render(float param_1, float param_2, float alpha) = 0x22ee4; +method void adjustContentSize() = 0x21aa4; +method bool queryHoldTime(int *item_id, int *pressed_time) = 0x22ab4; + +property float scale = 0x2c; +property RectangleArea area = 0x60; +property Vec3 content_offset = 0xe4; +property float max_y = 0x130; +property float size_y = 0x170; +property float adjust_content_size_y = 0x1ec; + diff --git a/symbols/src/input/IMoveInput.def b/symbols/src/input/IMoveInput.def new file mode 100644 index 0000000..7b24b8b --- /dev/null +++ b/symbols/src/input/IMoveInput.def @@ -0,0 +1 @@ +property bool is_sneaking = 0xe; diff --git a/symbols/src/item/ArmorItem.def b/symbols/src/item/ArmorItem.def new file mode 100644 index 0000000..bc7749a --- /dev/null +++ b/symbols/src/item/ArmorItem.def @@ -0,0 +1,5 @@ +extends Item; + +size 0x34; + +constructor (int id, ArmorMaterial *material, int param_3, int slot) = 0x9362c; diff --git a/symbols/src/item/ArmorMaterial.def b/symbols/src/item/ArmorMaterial.def new file mode 100644 index 0000000..82bfe2a --- /dev/null +++ b/symbols/src/item/ArmorMaterial.def @@ -0,0 +1,13 @@ +size 0x14; + +property int health_for_slot_multiplier = 0x0; +property int feet_protection = 0x4; +property int leg_protection = 0x8; +property int body_protection = 0xc; +property int head_protection = 0x10; + +static-property ArmorMaterial cloth = 0x17a780; +static-property ArmorMaterial chain = 0x17a794; +static-property ArmorMaterial iron = 0x17a7a8; +static-property ArmorMaterial gold = 0x17a7bc; +static-property ArmorMaterial diamond = 0x17a7d0; diff --git a/symbols/src/level/ChunkCache.def b/symbols/src/level/ChunkCache.def new file mode 100644 index 0000000..599ce3f --- /dev/null +++ b/symbols/src/level/ChunkCache.def @@ -0,0 +1,3 @@ +extends ChunkSource; + +vtable 0x10fbc0; diff --git a/symbols/src/level/ChunkSource.def b/symbols/src/level/ChunkSource.def index 4c8f80c..64aa224 100644 --- a/symbols/src/level/ChunkSource.def +++ b/symbols/src/level/ChunkSource.def @@ -1 +1,3 @@ +vtable 0x10fb88; + virtual-method void postProcess(ChunkSource *chunk_source, int chunk_x, int chunk_y) = 0x14; diff --git a/symbols/src/level/Level.def b/symbols/src/level/Level.def index 5923df7..202af9c 100644 --- a/symbols/src/level/Level.def +++ b/symbols/src/level/Level.def @@ -9,5 +9,9 @@ method void addParticle(std::string *particle, float x, float y, float z, float method Entity *getEntity(int id) = 0xa45a4; method bool addEntity(Entity *entity) = 0xa7cbc; -property std::vector players = 0x60; +virtual-method void tick() = 0x28; +virtual-method void updateSleepingPlayerList() = 0x2c; +virtual-method ChunkCache *createChunkSource() = 0x30; + property std::vector entities = 0x20; +property std::vector players = 0x60; diff --git a/symbols/src/level/LevelSource.def b/symbols/src/level/LevelSource.def index ff7a855..e9162c2 100644 --- a/symbols/src/level/LevelSource.def +++ b/symbols/src/level/LevelSource.def @@ -1,3 +1,8 @@ virtual-method int getTile(int x, int y, int z) = 0x8; +virtual-method int isEmptyTile(int x, int y, int z) = 0xc; +virtual-method int getBrightness(int x, int y, int z) = 0x10; +virtual-method int getData(int x, int y, int z) = 0x14; virtual-method Material *getMaterial(int x, int y, int z) = 0x18; -virtual-method Biome *getBiome(int x, int z) = 0x24; \ No newline at end of file +virtual-method bool isSolidRenderTile(int x, int y, int z) = 0x1c; +virtual-method bool isSolidBlockingTile(int x, int y, int z) = 0x20; +virtual-method Biome *getBiome(int x, int z) = 0x24; diff --git a/symbols/src/level/container/FillingContainer.def b/symbols/src/level/container/FillingContainer.def index ed6e0f5..79a69c6 100644 --- a/symbols/src/level/container/FillingContainer.def +++ b/symbols/src/level/container/FillingContainer.def @@ -1,13 +1,20 @@ extends Container; method void addItem(ItemInstance *item_instance) = 0x92aa0; -virtual-method bool add(ItemInstance *item_instance) = 0x30; method void clearSlot(int slot) = 0x922f8; method void release(int slot) = 0x92058; method void compressLinkedSlotList(int slot) = 0x92280; method ItemInstance *getLinked(int slot) = 0x92230; +method bool linkEmptySlot(int slot) = 0x92590; +method int getFreeSlot() = 0x91ffc; +method int getSlot(int id) = 0x91ce0; +method int linkSlot(int linked_slot, int unlinked_slot, bool push_aside) = 0x92188; + virtual-method ItemInstance *getItem(int pos) = 0x8; +virtual-method void setItem(int pos, ItemInstance *item) = 0xc; +virtual-method bool add(ItemInstance *item_instance) = 0x30; property int *linked_slots = 0xc; property int linked_slots_length = 0x14; +property std::vector items = 0x18; property bool is_creative = 0x24; diff --git a/symbols/src/level/container/Inventory.def b/symbols/src/level/container/Inventory.def index 45e1d5c..1108f0b 100644 --- a/symbols/src/level/container/Inventory.def +++ b/symbols/src/level/container/Inventory.def @@ -1,6 +1,9 @@ extends FillingContainer; method void selectSlot(int slot) = 0x8d13c; +// It's just FillingContainer_getLinked but with selectedSlot as slot method ItemInstance *getSelected() = 0x8d134; +// It's just FillingContainer_linkSlot with selectedSlot as linked_slot +method bool moveToSelectedSlot(int unlinked_slot, bool push_aside) = 0x8d148; property int selectedSlot = 0x28; diff --git a/symbols/src/network/NetEventCallback.def b/symbols/src/network/NetEventCallback.def index b5a29c5..c8b7eeb 100644 --- a/symbols/src/network/NetEventCallback.def +++ b/symbols/src/network/NetEventCallback.def @@ -1,2 +1,3 @@ virtual-method void onDisconnect(RakNet_RakNetGUID *guid) = 0x18; +virtual-method void handle_SignUpdatePacket(RakNet_RakNetGUID *guid, SignUpdatePacket *packet) = 0xcc; virtual-method void handle_ChatPacket(RakNet_RakNetGUID *rak_net_guid, uchar *packet) = 0xc8; diff --git a/symbols/src/network/packet/SignUpdatePacket.def b/symbols/src/network/packet/SignUpdatePacket.def new file mode 100644 index 0000000..20665c2 --- /dev/null +++ b/symbols/src/network/packet/SignUpdatePacket.def @@ -0,0 +1,7 @@ +extends Packet; + +property int x = 0xc; +property int y = 0x10; +property int z = 0x14; +// std::string lines[4] +property std::string *lines = 0x18; -- 2.40.1 From 949b9d71594db36b4528133bc575d509ce2041cd Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Mon, 22 Jan 2024 03:13:54 -0500 Subject: [PATCH 02/18] Even more symbols from other projects --- symbols/CMakeLists.txt | 2 ++ symbols/src/entity/CameraEntity.def | 7 +++++++ symbols/src/entity/Entity.def | 2 ++ symbols/src/entity/EntityFactory.def | 1 + symbols/src/entity/Mob.def | 2 ++ symbols/src/game/Minecraft.def | 30 +++++++++++++++------------- symbols/src/level/Level.def | 2 ++ symbols/src/level/LightLayer.def | 2 ++ symbols/src/misc/Tesselator.def | 2 ++ 9 files changed, 36 insertions(+), 14 deletions(-) create mode 100644 symbols/src/entity/CameraEntity.def create mode 100644 symbols/src/level/LightLayer.def diff --git a/symbols/CMakeLists.txt b/symbols/CMakeLists.txt index 13a127d..53b2aff 100644 --- a/symbols/CMakeLists.txt +++ b/symbols/CMakeLists.txt @@ -29,6 +29,7 @@ set(SRC src/network/packet/ChatPacket.def src/entity/EntityFactory.def src/entity/PrimedTnt.def + src/entity/CameraEntity.def src/entity/EntityRenderer.def src/entity/Sheep.def src/entity/PathfinderMob.def @@ -61,6 +62,7 @@ set(SRC src/level/Biome.def src/level/ChunkSource.def src/level/ChunkCache.def + src/level/LightLayer.def src/level/Level.def src/level/LevelRenderer.def src/level/LevelStorageSource.def diff --git a/symbols/src/entity/CameraEntity.def b/symbols/src/entity/CameraEntity.def new file mode 100644 index 0000000..6f560af --- /dev/null +++ b/symbols/src/entity/CameraEntity.def @@ -0,0 +1,7 @@ +extends Entity; + +size 0xbe4; +vtable 0x108898; + +// -1 or an entity id +property int tracking_id = 0xbe0; \ No newline at end of file diff --git a/symbols/src/entity/Entity.def b/symbols/src/entity/Entity.def index def2f3b..e9cb294 100644 --- a/symbols/src/entity/Entity.def +++ b/symbols/src/entity/Entity.def @@ -18,5 +18,7 @@ property float pitch = 0x44; property float old_yaw = 0x48; property float old_pitch = 0x4c; property float head_height = 0x68; +property float hitbox_width = 0x6c; +property float hitbox_height = 0x70; property bool on_ground = 0xb2; property bool freeze_physics = 0xb9; diff --git a/symbols/src/entity/EntityFactory.def b/symbols/src/entity/EntityFactory.def index 2430dcf..b32cfbc 100644 --- a/symbols/src/entity/EntityFactory.def +++ b/symbols/src/entity/EntityFactory.def @@ -1 +1,2 @@ +// https://mcpirevival.miraheze.org/wiki/Minecraft:_Pi_Edition_Complete_Entity_List shows what id should be static-method Entity *CreateEntity(int id, Level *level) = 0x7d794; diff --git a/symbols/src/entity/Mob.def b/symbols/src/entity/Mob.def index 2555e94..c540f84 100644 --- a/symbols/src/entity/Mob.def +++ b/symbols/src/entity/Mob.def @@ -2,6 +2,8 @@ extends Entity; vtable 0x10ad60; +constructor (Level *level) = 0x81b80; + virtual-method void actuallyHurt(int damage) = 0x16c; virtual-method void die(Entity *cause) = 0x130; virtual-method ItemInstance *getCarriedItem() = 0x1ac; diff --git a/symbols/src/game/Minecraft.def b/symbols/src/game/Minecraft.def index 18303f7..b6440d8 100644 --- a/symbols/src/game/Minecraft.def +++ b/symbols/src/game/Minecraft.def @@ -1,12 +1,10 @@ vtable 0x102700; -virtual-method void init() = 0x38; 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; -virtual-method void update() = 0x24; method void hostMultiplayer(int port) = 0x16664; method char *getProgressMessage() = 0x16e58; method uint isLevelGenerated() = 0x16e6c; @@ -14,30 +12,34 @@ method bool isCreativeMode() = 0x17270; method void releaseMouse() = 0x15d30; method void grabMouse() = 0x15d10; method void leaveGame(bool save_remote_level) = 0x15ea0; -virtual-method int handleBack(bool do_nothing) = 0x34; method uchar *getCreator() = 0x17538; method LevelStorageSource *getLevelSource() = 0x16e84; method void handleMouseDown(int param_1, bool can_destroy) = 0x1584c; method void handleBuildAction(uint *build_action_intention) = 0x15920; -virtual-method void selectLevel(std::string *level_dir, std::string *level_name, LevelSettings *settings) = 0x40; method void joinMultiplayer(PingedCompatibleServer *server) = 0x165f4; +virtual-method void update() = 0x24; +virtual-method int handleBack(bool do_nothing) = 0x34; +virtual-method void init() = 0x38; +virtual-method void selectLevel(std::string *level_dir, std::string *level_name, LevelSettings *settings) = 0x40; + property int screen_width = 0x20; property int screen_height = 0x24; -property NetEventCallback *network_handler = 0x174; -property RakNetInstance *rak_net_instance = 0x170; -property Level *level = 0x188; -property Textures *textures = 0x164; -property GameMode *game_mode = 0x160; -property LocalPlayer *player = 0x18c; property Options options = 0x3c; +property LevelRenderer *levelrenderer = 0x150; +property GameMode *game_mode = 0x160; +property Textures *textures = 0x164; +property RakNetInstance *rak_net_instance = 0x170; +property NetEventCallback *network_handler = 0x174; +property Level *level = 0x188; +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 CommandServer *command_server = 0xcc0; -property Screen *screen = 0xc10; -property Gui gui = 0x198; -property Mob *pov = 0x150; property PerfRenderer *perf_renderer = 0xcbc; +property CommandServer *command_server = 0xcc0; // Smooth Lighting static-property bool useAmbientOcclusion = 0x136b90; diff --git a/symbols/src/level/Level.def b/symbols/src/level/Level.def index 202af9c..852ad54 100644 --- a/symbols/src/level/Level.def +++ b/symbols/src/level/Level.def @@ -4,10 +4,12 @@ vtable 0x108de0; method void saveLevelData() = 0xa2e94; 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; 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; virtual-method void tick() = 0x28; virtual-method void updateSleepingPlayerList() = 0x2c; diff --git a/symbols/src/level/LightLayer.def b/symbols/src/level/LightLayer.def new file mode 100644 index 0000000..0368ab1 --- /dev/null +++ b/symbols/src/level/LightLayer.def @@ -0,0 +1,2 @@ +static-property LightLayer *block = 0x17be94; +static-property LightLayer *sky = 0x17be90; diff --git a/symbols/src/misc/Tesselator.def b/symbols/src/misc/Tesselator.def index af9c4f1..b8f8c3a 100644 --- a/symbols/src/misc/Tesselator.def +++ b/symbols/src/misc/Tesselator.def @@ -2,3 +2,5 @@ method void begin(int mode) = 0x529d4; method void colorABGR(int color) = 0x52b54; method void color(int r, int g, int b, int a) = 0x52a48; method void vertexUV(float x, float y, float z, float u, float v) = 0x52d40; + +static-property Tesselator *instance = 0x137538; -- 2.40.1 From bf1dea322a3975ceb4b9e31fbe73ddf60e6c7732 Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Mon, 22 Jan 2024 22:59:38 -0500 Subject: [PATCH 03/18] More symbols --- symbols/CMakeLists.txt | 3 +++ symbols/src/entity/Entity.def | 6 +++++- symbols/src/entity/EntityRenderDispatcher.def | 1 + symbols/src/entity/ItemSpriteRenderer.def | 5 +++++ symbols/src/entity/Throwable.def | 11 +++++++++++ symbols/src/entity/player/Player.def | 1 + symbols/src/item/Item.def | 7 +++++-- symbols/src/level/Level.def | 1 + symbols/src/misc/Random.def | 3 +++ 9 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 symbols/src/entity/ItemSpriteRenderer.def create mode 100644 symbols/src/entity/Throwable.def create mode 100644 symbols/src/misc/Random.def diff --git a/symbols/CMakeLists.txt b/symbols/CMakeLists.txt index 53b2aff..3ddaf4f 100644 --- a/symbols/CMakeLists.txt +++ b/symbols/CMakeLists.txt @@ -31,6 +31,7 @@ set(SRC src/entity/PrimedTnt.def src/entity/CameraEntity.def src/entity/EntityRenderer.def + src/entity/ItemSpriteRenderer.def src/entity/Sheep.def src/entity/PathfinderMob.def src/entity/HumanoidModel.def @@ -50,6 +51,7 @@ set(SRC src/entity/Entity.def src/entity/ItemEntity.def src/entity/Arrow.def + src/entity/Throwable.def src/level/container/FillingContainer.def src/level/container/Container.def src/level/container/ContainerMenu.def @@ -133,6 +135,7 @@ set(SRC src/misc/SoundEngine.def src/misc/Common.def src/misc/Config.def + src/misc/Random.def src/input/IMoveInput.def src/input/IBuildInput.def src/input/MouseBuildInput.def diff --git a/symbols/src/entity/Entity.def b/symbols/src/entity/Entity.def index e9cb294..096752e 100644 --- a/symbols/src/entity/Entity.def +++ b/symbols/src/entity/Entity.def @@ -1,12 +1,15 @@ +virtual-method void remove() = 0x10; virtual-method void tick() = 0x34; virtual-method bool hurt(Entity *attacker, int damage) = 0xa4; virtual-method int getEntityTypeId() = 0xdc; -method void moveTo(float x, float y, float z, float pitch, float yaw) = 0x7a834; + +method void moveTo(float x, float y, float z, float yaw, float pitch) = 0x7a834; property float x = 0x4; property float y = 0x8; property float z = 0xc; property int id = 0x1c; +property Level *level = 0x24; property float old_x = 0x28; property float old_y = 0x2c; property float old_z = 0x30; @@ -20,5 +23,6 @@ property float old_pitch = 0x4c; property float head_height = 0x68; property float hitbox_width = 0x6c; property float hitbox_height = 0x70; +property int renderer_id = 0xa8; property bool on_ground = 0xb2; property bool freeze_physics = 0xb9; diff --git a/symbols/src/entity/EntityRenderDispatcher.def b/symbols/src/entity/EntityRenderDispatcher.def index d811d71..d678fc4 100644 --- a/symbols/src/entity/EntityRenderDispatcher.def +++ b/symbols/src/entity/EntityRenderDispatcher.def @@ -1,2 +1,3 @@ constructor () = 0x6096c; + method void assign(uchar entity_id, EntityRenderer *renderer) = 0x6094c; diff --git a/symbols/src/entity/ItemSpriteRenderer.def b/symbols/src/entity/ItemSpriteRenderer.def new file mode 100644 index 0000000..e01309b --- /dev/null +++ b/symbols/src/entity/ItemSpriteRenderer.def @@ -0,0 +1,5 @@ +extends EntityRenderer; + +size 0x10; + +constructor (int texture) = 0x64078; diff --git a/symbols/src/entity/Throwable.def b/symbols/src/entity/Throwable.def new file mode 100644 index 0000000..a234f54 --- /dev/null +++ b/symbols/src/entity/Throwable.def @@ -0,0 +1,11 @@ +extends Entity; + +size 0xf4; +vtable 0x10dcb8; +vtable-size 0x13c; + +constructor (Level *level, Entity *thrower) = 0x8ccf0; + +virtual-method void onHit(HitResult *res) = 0x138; + +property int thrower_id = 0xd8; diff --git a/symbols/src/entity/player/Player.def b/symbols/src/entity/player/Player.def index 60cfb6d..87cc8a4 100644 --- a/symbols/src/entity/player/Player.def +++ b/symbols/src/entity/player/Player.def @@ -10,3 +10,4 @@ method ItemInstance *getArmor(int slot) = 0x8fda4; property std::string username = 0xbf4; property Inventory *inventory = 0xbe0; +property bool infinite_items = 0xbff; diff --git a/symbols/src/item/Item.def b/symbols/src/item/Item.def index aff1010..6c70872 100644 --- a/symbols/src/item/Item.def +++ b/symbols/src/item/Item.def @@ -14,10 +14,13 @@ virtual-method void setDescriptionId(std::string *name) = 0x6c; virtual-method std::string getDescriptionId(ItemInstance *item_instance) = 0x7c; property int id = 0x4; -property bool is_stacked_by_data = 0x19; -property int category = 0x10; property int max_damage = 0x8; +property int texture = 0xc; +property int category = 0x10; property int max_stack_size = 0x14; +property bool equipped = 0x18; +property bool is_stacked_by_data = 0x19; +property std::string description_id = 0x20; // Globals static-property-array Item *items = 0x17b250; diff --git a/symbols/src/level/Level.def b/symbols/src/level/Level.def index 852ad54..0411c97 100644 --- a/symbols/src/level/Level.def +++ b/symbols/src/level/Level.def @@ -10,6 +10,7 @@ method void addParticle(std::string *particle, float x, float y, float z, float 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; virtual-method void tick() = 0x28; virtual-method void updateSleepingPlayerList() = 0x2c; diff --git a/symbols/src/misc/Random.def b/symbols/src/misc/Random.def new file mode 100644 index 0000000..5ceca14 --- /dev/null +++ b/symbols/src/misc/Random.def @@ -0,0 +1,3 @@ +method int genrand_int32() = 0x42cf8; + +static-property Random random = 0x17a87c; -- 2.40.1 From 2c2543f387b2628409b11345cf93cdba6a68d143 Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Tue, 23 Jan 2024 20:35:57 -0500 Subject: [PATCH 04/18] Add packet related symbols --- mods/src/misc/misc.c | 2 +- symbols/CMakeLists.txt | 1 + symbols/src/network/packet/Packet.def | 8 +++++++- symbols/src/network/raknet/RakNet_BitStream.def | 4 ++++ 4 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 symbols/src/network/raknet/RakNet_BitStream.def diff --git a/mods/src/misc/misc.c b/mods/src/misc/misc.c index 9fc1eba..0063997 100644 --- a/mods/src/misc/misc.c +++ b/mods/src/misc/misc.c @@ -161,7 +161,7 @@ static void Screen_render_injection(Screen *screen, int32_t param_1, int32_t par // Sanitize Username #define MAX_USERNAME_LENGTH 16 -static void LoginPacket_read_injection(LoginPacket *packet, unsigned char *bit_stream) { +static void LoginPacket_read_injection(LoginPacket *packet, RakNet_BitStream *bit_stream) { // Call Original Method LoginPacket_read_non_virtual(packet, bit_stream); diff --git a/symbols/CMakeLists.txt b/symbols/CMakeLists.txt index 3ddaf4f..75341d0 100644 --- a/symbols/CMakeLists.txt +++ b/symbols/CMakeLists.txt @@ -20,6 +20,7 @@ set(SRC src/network/raknet/RakNet_StartupResult.h src/network/raknet/RakNet_RakNetGUID.def src/network/raknet/RakNet_RakPeer.def + src/network/raknet/RakNet_BitStream.def src/network/ServerSideNetworkHandler.def src/network/packet/LoginPacket.def src/network/packet/PlayerEquipmentPacket.def diff --git a/symbols/src/network/packet/Packet.def b/symbols/src/network/packet/Packet.def index abfa163..bcc587c 100644 --- a/symbols/src/network/packet/Packet.def +++ b/symbols/src/network/packet/Packet.def @@ -1,2 +1,8 @@ constructor () = 0x6fc18; -virtual-method void read(uchar *bit_stream) = 0xc; +size 0x10; +vtable 0x1024d8; +vtable-size 0x14; + +virtual-method void write(RakNet_BitStream *bit_stream) = 0x8; +virtual-method void read(RakNet_BitStream *bit_stream) = 0xc; +virtual-method void handle(RakNet_RakNetGUID *guid, NetEventCallback *callback) = 0x10; diff --git a/symbols/src/network/raknet/RakNet_BitStream.def b/symbols/src/network/raknet/RakNet_BitStream.def new file mode 100644 index 0000000..570c3be --- /dev/null +++ b/symbols/src/network/raknet/RakNet_BitStream.def @@ -0,0 +1,4 @@ +method void Write_uchar(uchar *i) = 0x18448; +method void Write_int(int *i) = 0x18454; + +method void Read_int(int *i) = 0x184ec; -- 2.40.1 From 6c5d647a7f771ff1ffb61de2c4f184665cde07fe Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Tue, 23 Jan 2024 20:38:41 -0500 Subject: [PATCH 05/18] Fix Tesselator instance symbols --- symbols/src/misc/Tesselator.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/symbols/src/misc/Tesselator.def b/symbols/src/misc/Tesselator.def index b8f8c3a..dbe8612 100644 --- a/symbols/src/misc/Tesselator.def +++ b/symbols/src/misc/Tesselator.def @@ -3,4 +3,4 @@ method void colorABGR(int color) = 0x52b54; method void color(int r, int g, int b, int a) = 0x52a48; method void vertexUV(float x, float y, float z, float u, float v) = 0x52d40; -static-property Tesselator *instance = 0x137538; +static-property Tesselator instance = 0x137538; -- 2.40.1 From f78a4e47aced1c9c4703fc2edad262f2cbdd999a Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Sat, 27 Jan 2024 16:00:44 -0500 Subject: [PATCH 06/18] Add buckets of milk - Milk Buckets can be obtained by using an empty bucket on a cow - They can be drunk, but they don't heal you - Adds the `misc_run_on_language_setup` function - Changes `misc_run_on_tile_setup` and `misc_run_on_item_setup` to run after the original function is called - Fix used items transferring durability - Add more symbols --- dependencies/symbol-processor/src | 2 +- mods/include/mods/misc/misc.h | 1 + mods/src/bucket/bucket.cpp | 127 +++++++++++++----- mods/src/misc/api.cpp | 26 +++- mods/src/misc/misc.c | 17 +++ symbols/CMakeLists.txt | 7 +- symbols/src/entity/Entity.def | 1 + symbols/src/entity/{ => animal}/AgableMob.def | 0 symbols/src/entity/{ => animal}/Animal.def | 0 symbols/src/entity/animal/Cow.def | 3 + symbols/src/entity/player/Player.def | 12 +- symbols/src/item/FoodItem.def | 7 + symbols/src/item/Item.def | 12 +- symbols/src/misc/I18n.def | 3 + .../src/network/raknet/RakNet_BitStream.def | 11 ++ 15 files changed, 186 insertions(+), 43 deletions(-) rename symbols/src/entity/{ => animal}/AgableMob.def (100%) rename symbols/src/entity/{ => animal}/Animal.def (100%) create mode 100644 symbols/src/entity/animal/Cow.def create mode 100644 symbols/src/item/FoodItem.def create mode 100644 symbols/src/misc/I18n.def diff --git a/dependencies/symbol-processor/src b/dependencies/symbol-processor/src index 0b696bd..ea31be1 160000 --- a/dependencies/symbol-processor/src +++ b/dependencies/symbol-processor/src @@ -1 +1 @@ -Subproject commit 0b696bd55b31416929d0a29d84ad50ab5ba0ceae +Subproject commit ea31be1cb2b43decb9c906215f80ff20efd2b479 diff --git a/mods/include/mods/misc/misc.h b/mods/include/mods/misc/misc.h index 291384b..6fe20c1 100644 --- a/mods/include/mods/misc/misc.h +++ b/mods/include/mods/misc/misc.h @@ -22,6 +22,7 @@ void misc_run_on_creative_inventory_setup(misc_update_function_FillingContainer_ typedef void (*misc_update_function_void_t)(void *obj); void misc_run_on_tiles_setup(misc_update_function_void_t function); // obj == NULL void misc_run_on_items_setup(misc_update_function_void_t function); // obj == NULL +void misc_run_on_language_setup(misc_update_function_void_t function); // obj == NULL void Level_saveLevelData_injection(Level *level); diff --git a/mods/src/bucket/bucket.cpp b/mods/src/bucket/bucket.cpp index 1645bad..0c0cf33 100644 --- a/mods/src/bucket/bucket.cpp +++ b/mods/src/bucket/bucket.cpp @@ -6,31 +6,57 @@ #include // Items -Item *bucket = NULL; +FoodItem *bucket = NULL; // Description And Texture -static std::string BucketItem_getDescriptionId(__attribute__((unused)) Item *item, ItemInstance *item_instance) { +static std::string BucketItem_getDescriptionId(__attribute__((unused)) FoodItem *item, ItemInstance *item_instance) { if (item_instance->auxiliary == Tile_water->id) { return "item.bucketWater"; } else if (item_instance->auxiliary == Tile_lava->id) { return "item.bucketLava"; + } else if (item_instance->auxiliary == 1) { + return "item.bucketMilk"; } else { return "item.bucket"; } } -static int32_t BucketItem_getIcon(__attribute__((unused)) Item *item, int32_t auxiliary) { +static int32_t BucketItem_getIcon(__attribute__((unused)) FoodItem *item, int32_t auxiliary) { if (auxiliary == Tile_water->id) { return 75; } else if (auxiliary == Tile_lava->id) { return 76; + } else if (auxiliary == 1) { + return 77; } else { return 74; } } +// Filling +static bool fill_bucket(ItemInstance *item_instance, Player *player, int new_auxiliary) { + bool success = false; + if (item_instance->count == 1) { + item_instance->auxiliary = new_auxiliary; + success = true; + } else { + ItemInstance new_item; + new_item.id = bucket->id; + new_item.count = 1; + new_item.auxiliary = new_auxiliary; + Inventory *inventory = player->inventory; + if (inventory->vtable->add(inventory, &new_item)) { + // Added To Inventory + success = true; + item_instance->count -= 1; + } + } + return success; +} + + // Use Bucket -static int32_t BucketItem_useOn(__attribute__((unused)) Item *item, ItemInstance *item_instance, Player *player, Level *level, int32_t x, int32_t y, int32_t z, int32_t hit_side, __attribute__((unused)) float hit_x, __attribute__((unused)) float hit_y, __attribute__((unused)) float hit_z) { - if (item_instance->count < 1) { +static int32_t BucketItem_useOn(__attribute__((unused)) FoodItem *item, ItemInstance *item_instance, Player *player, Level *level, int32_t x, int32_t y, int32_t z, int32_t hit_side, __attribute__((unused)) float hit_x, __attribute__((unused)) float hit_y, __attribute__((unused)) float hit_z) { + if (item_instance->count < 1 || item_instance->auxiliary == 1) { return 0; } else if (item_instance->auxiliary == 0) { // Empty Bucket @@ -43,23 +69,7 @@ static int32_t BucketItem_useOn(__attribute__((unused)) Item *item, ItemInstance } if (new_auxiliary != 0) { // Valid - bool success = false; - if (item_instance->count == 1) { - item_instance->auxiliary = new_auxiliary; - success = true; - } else { - ItemInstance new_item; - new_item.id = bucket->id; - new_item.count = 1; - new_item.auxiliary = new_auxiliary; - Inventory *inventory = player->inventory; - if (inventory->vtable->add(inventory, &new_item)) { - // Added To Inventory - success = true; - item_instance->count -= 1; - } - } - if (success) { + if (fill_bucket(item_instance, player, new_auxiliary)) { Level_setTileAndData(level, x, y, z, 0, 0); return 1; } else { @@ -116,28 +126,64 @@ static int32_t BucketItem_useOn(__attribute__((unused)) Item *item, ItemInstance } } +static int BucketItem_getUseDuration(__attribute__((unused)) FoodItem *item, ItemInstance *item_instance) { + if (item_instance->auxiliary == 1) { + return 0x20; + } + return 0; +} + +static void BucketItem_useTimeDepleted(FoodItem *item, uchar *param_1, ItemInstance *item_instance, Level *level, Player *player) { + if (item_instance->auxiliary == 1) { + (*FoodItem_useTimeDepleted_vtable_addr)(item, param_1, item_instance, level, player); + // Set it to a empty bucket + item_instance->auxiliary = 0; + item_instance->count = 1; + } +} + +static int BucketItem_getUseAnimation(__attribute__((unused)) FoodItem *item) { + return 2; +} + +static bool BucketItem_isFood(__attribute__((unused)) FoodItem *item) { + return true; +} + +static ItemInstance *BucketItem_use(FoodItem *item, ItemInstance *item_instance, __attribute__((unused)) Level *level, Player *player) { + if (item_instance->auxiliary == 1) { + return (*FoodItem_use_vtable_addr)(item, item_instance, level, player); + } + return item_instance; +} + // Bucket VTable -static Item_vtable *get_bucket_vtable() { - static Item_vtable *vtable = NULL; +static FoodItem_vtable *get_bucket_vtable() { + static FoodItem_vtable *vtable = NULL; if (vtable == NULL) { // Init - vtable = dup_Item_vtable(Item_vtable_base); + vtable = dup_FoodItem_vtable(FoodItem_vtable_base); ALLOC_CHECK(vtable); // Modify vtable->getDescriptionId = BucketItem_getDescriptionId; vtable->getIcon = BucketItem_getIcon; vtable->useOn = BucketItem_useOn; + vtable->getUseDuration = BucketItem_getUseDuration; + vtable->useTimeDepleted = BucketItem_useTimeDepleted; + vtable->getUseAnimation = BucketItem_getUseAnimation; + vtable->isFood = BucketItem_isFood; + vtable->use = BucketItem_use; } return vtable; } // Create Items -static Item *create_bucket(int32_t id, int32_t texture_x, int32_t texture_y, std::string name) { +static FoodItem *create_bucket(int32_t id, int32_t texture_x, int32_t texture_y, std::string name) { // Construct - Item *item = alloc_Item(); + FoodItem *item = alloc_FoodItem(); ALLOC_CHECK(item); - Item_constructor(item, id); + Item_constructor((Item *) item, id); // Set VTable item->vtable = get_bucket_vtable(); @@ -149,6 +195,7 @@ static Item *create_bucket(int32_t id, int32_t texture_x, int32_t texture_y, std item->category = 2; item->max_damage = 0; item->max_stack_size = 1; + item->nutrition = 0; // Return return item; @@ -168,17 +215,29 @@ static int32_t ItemInstance_getMaxStackSize_injection(ItemInstance *item_instanc } } +// Milking +bool Cow_interact_injection(Cow *self, Player *player) { + ItemInstance *item = Inventory_getSelected(player->inventory); + if (item && item->id == bucket->id && item->auxiliary == 0) { + // Fill with milk + fill_bucket(item, player, 1); + return true; + } + return Cow_interact_non_virtual(self, player); +} + // Creative Inventory -static void inventory_add_item(FillingContainer *inventory, Item *item, int32_t auxiliary) { +static void inventory_add_item(FillingContainer *inventory, FoodItem *item, int32_t auxiliary) { ItemInstance *item_instance = new ItemInstance; ALLOC_CHECK(item_instance); - item_instance = ItemInstance_constructor_item_extra(item_instance, item, 1, auxiliary); + item_instance = ItemInstance_constructor_item_extra(item_instance, (Item *) item, 1, auxiliary); FillingContainer_addItem(inventory, item_instance); } static void Inventory_setupDefault_FillingContainer_addItem_call_injection(FillingContainer *filling_container) { inventory_add_item(filling_container, bucket, 0); inventory_add_item(filling_container, bucket, Tile_water->id); inventory_add_item(filling_container, bucket, Tile_lava->id); + inventory_add_item(filling_container, bucket, 1); } // Make Liquids Selectable @@ -273,6 +332,10 @@ static void FurnaceTileEntity_tick_ItemInstance_setNull_injection(ItemInstance * } } +static void Language_injection(__attribute__((unused)) void *null) { + I18n__strings.insert(std::make_pair("item.bucketMilk.name", "Milk Bucket")); +} + // Init void init_bucket() { // Add Buckets @@ -281,6 +344,8 @@ void init_bucket() { misc_run_on_items_setup(Item_initItems_injection); // Change Max Stack Size Based On Auxiliary overwrite_calls((void *) ItemInstance_getMaxStackSize, (void *) ItemInstance_getMaxStackSize_injection); + // Enable milking + patch_address((void *) Cow_interact_vtable_addr, (void *) Cow_interact_injection); // Creative Inventory misc_run_on_creative_inventory_setup(Inventory_setupDefault_FillingContainer_addItem_call_injection); // Make Liquids Selectable @@ -293,5 +358,7 @@ void init_bucket() { // Custom Furnace Fuel overwrite_calls((void *) FurnaceTileEntity_getBurnDuration, (void *) FurnaceTileEntity_getBurnDuration_injection); overwrite_call((void *) 0xd351c, (void *) FurnaceTileEntity_tick_ItemInstance_setNull_injection); + // Language for milk + misc_run_on_language_setup(Language_injection); } } diff --git a/mods/src/misc/api.cpp b/mods/src/misc/api.cpp index d8ec95a..6e5a7b7 100644 --- a/mods/src/misc/api.cpp +++ b/mods/src/misc/api.cpp @@ -77,6 +77,7 @@ SETUP_CALLBACK(creative_inventory_setup, FillingContainer); static void Inventory_setupDefault_FillingContainer_addItem_call_injection(FillingContainer *filling_container, ItemInstance *item_instance) { // Call Original Method FillingContainer_addItem(filling_container, item_instance); + // Run Functions handle_misc_creative_inventory_setup(filling_container); } @@ -85,22 +86,33 @@ static void Inventory_setupDefault_FillingContainer_addItem_call_injection(Filli SETUP_CALLBACK(tiles_setup, void); // Handle Custom Tiles Setup Behavior static void Tile_initTiles_injection() { - // Run Functions - handle_misc_tiles_setup(NULL); - // Call Original Method Tile_initTiles(); + + // Run Functions + handle_misc_tiles_setup(NULL); } // Run Functions On Items Setup SETUP_CALLBACK(items_setup, void); // Handle Custom Items Setup Behavior static void Item_initItems_injection() { - // Run Functions - handle_misc_items_setup(NULL); - // Call Original Method Item_initItems(); + + // Run Functions + handle_misc_items_setup(NULL); +} + +// Run Functions On Language Setup +SETUP_CALLBACK(language_setup, void); +// Handle Custom Items Setup Behavior +static void I18n_loadLanguage_injection(AppPlatform *app, std::string language_name) { + // Call Original Method + I18n_loadLanguage(app, language_name); + + // Run Functions + handle_misc_language_setup(NULL); } // Init @@ -117,4 +129,6 @@ void _init_misc_api() { // Handle Custom Item/Tile Init Behavior overwrite_calls((void *) Tile_initTiles, (void *) Tile_initTiles_injection); overwrite_calls((void *) Item_initItems, (void *) Item_initItems_injection); + // Handle Custom Language Entries + overwrite_calls((void *) I18n_loadLanguage, (void *) I18n_loadLanguage_injection); } diff --git a/mods/src/misc/misc.c b/mods/src/misc/misc.c index 0063997..9bf5ff9 100644 --- a/mods/src/misc/misc.c +++ b/mods/src/misc/misc.c @@ -545,6 +545,19 @@ static int FurnaceTileEntity_getLitProgress_injection(FurnaceTileEntity *furnace return ret; } +// Fix used items transferring durability +static int selected_slot = -1; +static void Player_startUsingItem_injection(Player *self, ItemInstance *item_instance, int time) { + selected_slot = self->inventory->selectedSlot; + Player_startUsingItem(self, item_instance, time); +} +static void Player_stopUsingItem_injection(Player *self) { + if (selected_slot != self->inventory->selectedSlot) { + self->itemBeingUsed.id = 0; + } + Player_stopUsingItem(self); +} + // Init static void nop() { } @@ -731,6 +744,10 @@ void init_misc() { unsigned char mov_r3_ff[4] = {0xff, 0x30, 0xa0, 0xe3}; // "mov r3, #0xff" patch((void *) 0x7178c, mov_r3_ff); + // Fix used items transferring durability + overwrite_calls((void *) Player_startUsingItem, (void *) Player_startUsingItem_injection); + overwrite_calls((void *) Player_stopUsingItem, (void *) Player_stopUsingItem_injection); + // Init C++ And Logging _init_misc_cpp(); _init_misc_logging(); diff --git a/symbols/CMakeLists.txt b/symbols/CMakeLists.txt index 75341d0..7715ed9 100644 --- a/symbols/CMakeLists.txt +++ b/symbols/CMakeLists.txt @@ -40,8 +40,9 @@ set(SRC src/entity/MobFactory.def src/entity/EntityRenderDispatcher.def src/entity/MobRenderer.def - src/entity/AgableMob.def - src/entity/Animal.def + src/entity/animal/AgableMob.def + src/entity/animal/Animal.def + src/entity/animal/Cow.def src/entity/Mob.def src/entity/player/ServerPlayer.def src/entity/player/Player.def @@ -82,6 +83,7 @@ set(SRC src/item/ArmorMaterial.def src/item/ArmorItem.def src/item/TileItem.def + src/item/FoodItem.def src/api/OffsetPosTranslator.def src/api/CommandServer.def src/api/ConnectedClient.def @@ -125,6 +127,7 @@ set(SRC src/tile/GrassTile.def src/tile/HeavyTile.def src/misc/Strings.def + src/misc/I18n.def src/entity/ModelPart.def src/misc/Tesselator.def src/misc/AABB.def diff --git a/symbols/src/entity/Entity.def b/symbols/src/entity/Entity.def index 096752e..3c57c4b 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 bool interact(Player *with) = 0x6c; virtual-method bool hurt(Entity *attacker, int damage) = 0xa4; virtual-method int getEntityTypeId() = 0xdc; diff --git a/symbols/src/entity/AgableMob.def b/symbols/src/entity/animal/AgableMob.def similarity index 100% rename from symbols/src/entity/AgableMob.def rename to symbols/src/entity/animal/AgableMob.def diff --git a/symbols/src/entity/Animal.def b/symbols/src/entity/animal/Animal.def similarity index 100% rename from symbols/src/entity/Animal.def rename to symbols/src/entity/animal/Animal.def diff --git a/symbols/src/entity/animal/Cow.def b/symbols/src/entity/animal/Cow.def new file mode 100644 index 0000000..f18dd75 --- /dev/null +++ b/symbols/src/entity/animal/Cow.def @@ -0,0 +1,3 @@ +extends Animal; + +vtable 0x10ba38; diff --git a/symbols/src/entity/player/Player.def b/symbols/src/entity/player/Player.def index 87cc8a4..a63a002 100644 --- a/symbols/src/entity/player/Player.def +++ b/symbols/src/entity/player/Player.def @@ -2,12 +2,18 @@ extends Mob; vtable 0x10de70; -method int isUsingItem() = 0x8f15c; virtual-method void drop(ItemInstance *item_instance, bool is_death) = 0x208; virtual-method void stopSleepInBed(bool param_1, bool param_2, bool param_3) = 0x228; virtual-method void openTextEdit(TileEntity *sign) = 0x230; -method ItemInstance *getArmor(int slot) = 0x8fda4; -property std::string username = 0xbf4; +method int isUsingItem() = 0x8f15c; +method void stopUsingItem() = 0x8f514; +method void startUsingItem(ItemInstance *item_instance, int use_duration) = 0x8f4b8; +method ItemInstance *getArmor(int slot) = 0x8fda4; +method bool isHurt() = 0x8fb44; + property Inventory *inventory = 0xbe0; +property std::string username = 0xbf4; +property bool immortal = 0xbfc; property bool infinite_items = 0xbff; +property ItemInstance itemBeingUsed = 0xc34; diff --git a/symbols/src/item/FoodItem.def b/symbols/src/item/FoodItem.def new file mode 100644 index 0000000..5c1c159 --- /dev/null +++ b/symbols/src/item/FoodItem.def @@ -0,0 +1,7 @@ +extends Item; + +size 0x30; +vtable 0x10e7b0; +vtable-size 0x98; + +property int nutrition = 0x24; diff --git a/symbols/src/item/Item.def b/symbols/src/item/Item.def index 6c70872..c1e72e4 100644 --- a/symbols/src/item/Item.def +++ b/symbols/src/item/Item.def @@ -6,12 +6,22 @@ vtable 0x10f128; size 0x24; constructor (int id) = 0x99488; -virtual-method void setIcon(int texture_x, int texture_y) = 0x18; virtual-method int getIcon(int auxiliary) = 0x14; +virtual-method void setIcon(int texture_x, int texture_y) = 0x18; virtual-method int useOn(ItemInstance *item_instance, Player *player, Level *level, int x, int y, int z, int hit_side, float hit_x, float hit_y, float hit_z) = 0x20; +// Normally returns 0 +virtual-method int getUseDuration(ItemInstance *item_instance) = 0x24; +// I don't know much about param_1, it might be some partially initialized ItemInstance* +virtual-method void useTimeDepleted(uchar *param_1, ItemInstance *item_instance, Level *level, Player *player) = 0x28; +virtual-method int getDestorySpeed(ItemInstance *item_instance, Tile *tile) = 0x2c; virtual-method ItemInstance *use(ItemInstance *item_instance, Level *level, Player *player) = 0x30; +virtual-method bool mineBlock(ItemInstance *instance, int tile_id, int x, int y, int z) = 0x48; +virtual-method bool isFood() = 0x64; +virtual-method bool isArmor() = 0x68; virtual-method void setDescriptionId(std::string *name) = 0x6c; virtual-method std::string getDescriptionId(ItemInstance *item_instance) = 0x7c; +// Swing = 0, eating = 1, drinking = 2, bow = 4, anything else is nothing +virtual-method int getUseAnimation() = 0x94; property int id = 0x4; property int max_damage = 0x8; diff --git a/symbols/src/misc/I18n.def b/symbols/src/misc/I18n.def new file mode 100644 index 0000000..e35e2bb --- /dev/null +++ b/symbols/src/misc/I18n.def @@ -0,0 +1,3 @@ +static-method void loadLanguage(AppPlatform *app, std::string language_name) = 0x680d0; + +static-property std::map _strings = 0x137d98; diff --git a/symbols/src/network/raknet/RakNet_BitStream.def b/symbols/src/network/raknet/RakNet_BitStream.def index 570c3be..586e4d1 100644 --- a/symbols/src/network/raknet/RakNet_BitStream.def +++ b/symbols/src/network/raknet/RakNet_BitStream.def @@ -1,4 +1,15 @@ method void Write_uchar(uchar *i) = 0x18448; method void Write_int(int *i) = 0x18454; +method void Write_ushort(ushort *i) = 0x45a68; +method void Write_short(short *i) = 0x71918; +// right_aligned should be true +method void WriteBits(uchar *buff, uint bits, bool right_aligned) = 0xd41b4; +method void Read_uchar(uchar *i) = 0x45ab0; method void Read_int(int *i) = 0x184ec; +method void Read_ushort(ushort *i) = 0x45acc; +method void Read_short(short *i) = 0x72070; +// right_aligned should be true +method void ReadBits(uchar *buff, uint bits, bool right_aligned) = 0xd3e18; + +property uint readOffset = 0x8; -- 2.40.1 From 9de256e6c74b77098f323862b58a6324d16bb2e0 Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Sun, 28 Jan 2024 14:18:22 -0500 Subject: [PATCH 07/18] Add Cake And Crafting Remainders - Revert `misc_run_on_tile_setup` running after the original function is called, as it broke custom tiles. - More symbols --- docs/CHANGELOG.md | 3 + launcher/src/client/available-feature-flags | 1 + mods/CMakeLists.txt | 7 +- mods/include/mods/init/init.h | 1 + mods/src/bucket/bucket.cpp | 12 + mods/src/cake/README.md | 3 + mods/src/cake/cake.cpp | 242 ++++++++++++++++++ mods/src/init/init.c | 1 + mods/src/misc/README.md | 1 + mods/src/misc/api.cpp | 6 +- mods/src/misc/misc.cpp | 36 +++ symbols/CMakeLists.txt | 4 + symbols/src/entity/player/Player.def | 1 + .../src/gui/screens/PaneCraftingScreen.def | 5 + symbols/src/item/Item.def | 3 + symbols/src/level/Material.def | 5 +- symbols/src/misc/SimpleFoodData.def | 5 + symbols/src/recipes/CItem.def | 3 + symbols/src/recipes/ReqItem.def | 3 + symbols/src/tile/Tile.def | 28 +- 20 files changed, 359 insertions(+), 11 deletions(-) create mode 100644 mods/src/cake/README.md create mode 100644 mods/src/cake/cake.cpp create mode 100644 symbols/src/gui/screens/PaneCraftingScreen.def create mode 100644 symbols/src/misc/SimpleFoodData.def create mode 100644 symbols/src/recipes/CItem.def create mode 100644 symbols/src/recipes/ReqItem.def diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index a06335b..35af98a 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -5,6 +5,9 @@ * By Default, The Outline Width Is Set Using The GUI Scale * This Can Be Overridden Using The ``MCPI_BLOCK_OUTLINE_WIDTH`` Environmental Variable * Added ``overwrite_calls_within`` Function +* Add ``Add Cake`` Feature Flag (Enabled By Default) +* Add Milk Buckets +* Implement Crafting Remainders **2.5.2** * Add ``3D Chest Model`` Feature Flag (Enabled By Default) diff --git a/launcher/src/client/available-feature-flags b/launcher/src/client/available-feature-flags index a8436a3..b6f75d1 100644 --- a/launcher/src/client/available-feature-flags +++ b/launcher/src/client/available-feature-flags @@ -51,3 +51,4 @@ TRUE Disable Hostile AI In Creative Mode TRUE Load Custom Skins TRUE 3D Chest Model TRUE Replace Block Highlight With Outline +TRUE Add Cake diff --git a/mods/CMakeLists.txt b/mods/CMakeLists.txt index b9dac35..6a6c05d 100644 --- a/mods/CMakeLists.txt +++ b/mods/CMakeLists.txt @@ -109,6 +109,9 @@ target_link_libraries(options mods-headers reborn-patch symbols feature home) add_library(bucket SHARED src/bucket/bucket.cpp) target_link_libraries(bucket mods-headers reborn-patch symbols feature misc) +add_library(cake SHARED src/cake/cake.cpp) +target_link_libraries(cake mods-headers reborn-patch symbols feature misc) + add_library(home SHARED src/home/home.c) target_link_libraries(home mods-headers reborn-patch symbols) @@ -116,7 +119,7 @@ add_library(test SHARED src/test/test.c) target_link_libraries(test mods-headers reborn-patch home) add_library(init SHARED src/init/init.c) -target_link_libraries(init symbols mods-headers reborn-util compat game-mode misc death options chat creative bucket textures home version test media-layer-core) +target_link_libraries(init symbols mods-headers reborn-util compat game-mode misc death options chat creative bucket cake textures home version test media-layer-core) if(MCPI_SERVER_MODE) target_link_libraries(init server) else() @@ -127,7 +130,7 @@ if(NOT MCPI_HEADLESS_MODE) endif() ## Install Mods -set(MODS_TO_INSTALL init compat readdir feature game-mode misc override death options chat creative bucket textures home version test) +set(MODS_TO_INSTALL init compat readdir feature game-mode misc override death options chat creative bucket cake textures home version test) if(MCPI_SERVER_MODE) list(APPEND MODS_TO_INSTALL server) else() diff --git a/mods/include/mods/init/init.h b/mods/include/mods/init/init.h index ea7b952..5f9d3b7 100644 --- a/mods/include/mods/init/init.h +++ b/mods/include/mods/init/init.h @@ -33,6 +33,7 @@ void init_death(); void init_options(); void init_chat(); void init_bucket(); +void init_cake(); void init_home(); #ifdef __cplusplus diff --git a/mods/src/bucket/bucket.cpp b/mods/src/bucket/bucket.cpp index 0c0cf33..1e95ddc 100644 --- a/mods/src/bucket/bucket.cpp +++ b/mods/src/bucket/bucket.cpp @@ -157,6 +157,17 @@ static ItemInstance *BucketItem_use(FoodItem *item, ItemInstance *item_instance, return item_instance; } +static ItemInstance *BucketItem_getCraftingRemainingItem(FoodItem *item, ItemInstance *item_instance) { + if (item_instance->auxiliary == 0) { + return NULL; + } + ItemInstance *ret = alloc_ItemInstance(); + ret->id = item->id; + ret->count = item_instance->count; + ret->auxiliary = 0; + return ret; +} + // Bucket VTable static FoodItem_vtable *get_bucket_vtable() { static FoodItem_vtable *vtable = NULL; @@ -174,6 +185,7 @@ static FoodItem_vtable *get_bucket_vtable() { vtable->getUseAnimation = BucketItem_getUseAnimation; vtable->isFood = BucketItem_isFood; vtable->use = BucketItem_use; + vtable->getCraftingRemainingItem = BucketItem_getCraftingRemainingItem; } return vtable; } diff --git a/mods/src/cake/README.md b/mods/src/cake/README.md new file mode 100644 index 0000000..7ce1b4e --- /dev/null +++ b/mods/src/cake/README.md @@ -0,0 +1,3 @@ +# ``cake`` Mod + +This mod adds cake. diff --git a/mods/src/cake/cake.cpp b/mods/src/cake/cake.cpp new file mode 100644 index 0000000..cb38dd4 --- /dev/null +++ b/mods/src/cake/cake.cpp @@ -0,0 +1,242 @@ +#include +#include + +#include +#include +#include + +Tile *cake = NULL; + +#define CAKE_LEN 0.0625F + +// Description +static std::string Cake_getDescriptionId(__attribute__((unused)) Tile *tile) { + return "tile.cake"; +} + +// Textures +static int Cake_getTexture2(__attribute__((unused)) Tile *tile, int face) { + if (face == 1) { + // Top texture + return 121; + } else if (face == 0) { + // Bottom texture + return 124; + } + // Side texture + return 122; +} + +static int Cake_getTexture3(__attribute__((unused)) Tile *tile, Level *level, int x, int y, int z, int face) { + // Eaten face + if (face == 3) { + int data = level->vtable->getData(level, x, y, z); + if (data != 0 && data < 6) { + // Sliced texture + return 123; + } + } + // Normal + return Cake_getTexture2(tile, face); +} + +// Rendering +static bool Cake_isSolidRender(__attribute__((unused)) Tile *tile) { + // Stop it from turning other blocks invisable + return 0; +} + +static int Cake_getRenderLayer(__attribute__((unused)) Tile *tile) { + // Stop weird transparency issues + return 1; +} + +static bool Cake_isCubeShaped(__attribute__((unused)) Tile *tile) { + return false; +} + +// Size +static void Cake_updateDefaultShape(Tile *tile) { + // Set the default shape + tile->vtable->setShape( + tile, + CAKE_LEN, 0.0, CAKE_LEN, + 1.0 - CAKE_LEN, 0.5, 1.0 - CAKE_LEN + ); +} + +static AABB *Cake_getAABB(Tile *tile, Level *level, int x, int y, int z) { + // Get the size of the slices + int data = level->vtable->getData(level, x, y, z); + if (data >= 6) data = 0; + float slice_size = (1.0 / 7.0) * (float) data; + + // Corner 1 + AABB *aabb = &tile->aabb; + aabb->x1 = (float) x + CAKE_LEN; + aabb->y1 = (float) y; + aabb->z1 = (float) z + CAKE_LEN; + + // Corner 2 + aabb->x2 = (float) x + (1.0 - CAKE_LEN); + aabb->y2 = (float) y + 0.5; + aabb->z2 = (float) z + (1.0 - CAKE_LEN) - slice_size; + + return aabb; +} + +static void Cake_updateShape(Tile *tile, Level *level, int x, int y, int z) { + // Set cake + int data = level->vtable->getData(level, x, y, z); + if (data >= 6) data = 0; + // Get slice amount + float slice_size = (1.0 / 7.0) * (float) data; + tile->vtable->setShape( + tile, + CAKE_LEN, 0.0, CAKE_LEN, + 1.0 - CAKE_LEN, 0.5, (1.0 - CAKE_LEN) - slice_size + ); +} + +// Eating +static int Cake_use(__attribute__((unused)) Tile *tile, Level *level, int x, int y, int z, Player *player) { + // Eat + SimpleFoodData_eat(&player->foodData, 3); + // Set the new tile + int data = level->vtable->getData(level, x, y, z); + if (data >= 5) { + // Remove the cake, it has been completely gobbled up + Level_setTileAndData(level, x, y, z, 0, 0); + } else { + // Remove a slice + Level_setTileAndData(level, x, y, z, 92, data + 1); + } + return 1; +} + +// Makes the cakes +static void make_cake() { + // Construct + cake = alloc_Tile(); + ALLOC_CHECK(cake); + int texture = 122; + Tile_constructor(cake, 92, texture, Material_dirt); + cake->texture = texture; + + // Set VTable + cake->vtable = dup_Tile_vtable(Tile_vtable_base); + ALLOC_CHECK(cake->vtable); + + // Set shape + cake->vtable->setShape( + cake, + CAKE_LEN, 0.0, CAKE_LEN, + 1.0 - CAKE_LEN, 0.5, 1.0 - CAKE_LEN + ); + + // Modify functions + cake->vtable->getDescriptionId = Cake_getDescriptionId; + cake->vtable->getTexture3 = Cake_getTexture3; + cake->vtable->getTexture2 = Cake_getTexture2; + cake->vtable->isSolidRender = Cake_isSolidRender; + cake->vtable->getRenderLayer = Cake_getRenderLayer; + cake->vtable->isCubeShaped = Cake_isCubeShaped; + cake->vtable->updateShape = Cake_updateShape; + cake->vtable->updateDefaultShape = Cake_updateDefaultShape; + cake->vtable->getAABB = Cake_getAABB; + cake->vtable->use = Cake_use; + + // Init + Tile_init(cake); + cake->vtable->setDestroyTime(cake, 1.0f); + cake->vtable->setExplodeable(cake, 20.0f); + cake->category = 4; + std::string name = "Cake"; + cake->vtable->setDescriptionId(cake, &name); +} + +static void Tile_initTiles_injection(__attribute__((unused)) void *null) { + make_cake(); +} + +// Add cake to creative inventory +static void Inventory_setupDefault_FillingContainer_addItem_call_injection(FillingContainer *filling_container) { + ItemInstance *cake_instance = new ItemInstance; + ALLOC_CHECK(cake_instance); + cake_instance->count = 255; + cake_instance->auxiliary = 0; + cake_instance->id = 92; + (*FillingContainer_addItem)(filling_container, cake_instance); +} + +// Recipe (only when buckets are enabled) +static void Recipes_injection(Recipes *recipes) { + // Sugar + Recipes_Type sugar = { + .item = 0, + .tile = 0, + .instance = { + .count = 1, + .id = 353, + .auxiliary = 0 + }, + .letter = 's' + }; + // Wheat + Recipes_Type wheat = { + .item = 0, + .tile = 0, + .instance = { + .count = 1, + .id = 296, + .auxiliary = 0 + }, + .letter = 'w' + }; + // Eggs + Recipes_Type eggs = { + .item = 0, + .tile = 0, + .instance = { + .count = 1, + .id = 344, + .auxiliary = 0 + }, + .letter = 'e' + }; + // Milk + Recipes_Type milk = { + .item = 0, + .tile = 0, + .instance = { + .count = 1, + .id = 325, + .auxiliary = 1 + }, + .letter = 'm' + }; + // Cake + ItemInstance cake_item = { + .count = 1, + .id = 92, + .auxiliary = 0 + }; + // Add + std::string line1 = "mmm"; + std::string line2 = "ses"; + std::string line3 = "www"; + std::vector ingredients = {milk, sugar, wheat, eggs}; + Recipes_addShapedRecipe_3(recipes, &cake_item, &line1, &line2, &line3, &ingredients); +} + +void init_cake() { + // Add cakes + if (feature_has("Add Cake", server_enabled)) { + misc_run_on_tiles_setup(Tile_initTiles_injection); + misc_run_on_creative_inventory_setup(Inventory_setupDefault_FillingContainer_addItem_call_injection); + if (feature_has("Add Buckets", server_enabled)) { + // The recipe needs milk buckets + misc_run_on_recipes_setup(Recipes_injection); + } + } +} diff --git a/mods/src/init/init.c b/mods/src/init/init.c index 5823111..041fc90 100644 --- a/mods/src/init/init.c +++ b/mods/src/init/init.c @@ -32,6 +32,7 @@ __attribute__((constructor)) static void init() { init_options(); init_chat(); init_bucket(); + init_cake(); init_home(); #ifndef MCPI_SERVER_MODE init_benchmark(); diff --git a/mods/src/misc/README.md b/mods/src/misc/README.md index 3b1231b..882a7b6 100644 --- a/mods/src/misc/README.md +++ b/mods/src/misc/README.md @@ -5,3 +5,4 @@ This mod has several miscellaneous mods that are too small to be their own mod, * Removing the red background from unobtainable items in the inventory. * Loading the bundled language file. * Printing chat messages to the log. +* Implementing crafting remainders. diff --git a/mods/src/misc/api.cpp b/mods/src/misc/api.cpp index 6e5a7b7..c3022d0 100644 --- a/mods/src/misc/api.cpp +++ b/mods/src/misc/api.cpp @@ -86,11 +86,11 @@ static void Inventory_setupDefault_FillingContainer_addItem_call_injection(Filli SETUP_CALLBACK(tiles_setup, void); // Handle Custom Tiles Setup Behavior static void Tile_initTiles_injection() { - // Call Original Method - Tile_initTiles(); - // Run Functions handle_misc_tiles_setup(NULL); + + // Call Original Method + Tile_initTiles(); } // Run Functions On Items Setup diff --git a/mods/src/misc/misc.cpp b/mods/src/misc/misc.cpp index 6e34cbe..410760e 100644 --- a/mods/src/misc/misc.cpp +++ b/mods/src/misc/misc.cpp @@ -58,6 +58,38 @@ static void PauseScreen_init_injection(PauseScreen *screen) { } } +// Implement crafting remainders +void PaneCraftingScreen_craftSelectedItem_PaneCraftingScreen_recheckRecipes_injection(PaneCraftingScreen *self) { + // Check for crafting remainders + CItem *item = self->item; + for (size_t i = 0; i < item->ingredients.size(); i++) { + ItemInstance requested_item_instance = item->ingredients[i].requested_item; + Item *requested_item = Item_items[requested_item_instance.id]; + ItemInstance *craftingRemainingItem = requested_item->vtable->getCraftingRemainingItem(requested_item, &requested_item_instance); + if (craftingRemainingItem != NULL) { + // Add or drop remainder + LocalPlayer *player = self->minecraft->player; + if (!player->inventory->vtable->add(player->inventory, craftingRemainingItem)) { + // Drop + player->vtable->drop(player, craftingRemainingItem, false); + } + } + } + // Call Original Method + PaneCraftingScreen_recheckRecipes(self); +} + +ItemInstance *Item_getCraftingRemainingItem_injection(Item *self, ItemInstance *item_instance) { + if (self->craftingRemainingItem != NULL) { + ItemInstance *ret = alloc_ItemInstance(); + ret->id = self->craftingRemainingItem->id; + ret->count = item_instance->count; + ret->auxiliary = 0; + return ret; + } + return NULL; +} + // Init void _init_misc_cpp() { // Implement AppPlatform::readAssetFile So Translations Work @@ -70,4 +102,8 @@ void _init_misc_cpp() { // Add Missing Buttons To Pause Menu patch_address(PauseScreen_init_vtable_addr, (void *) PauseScreen_init_injection); } + + // Implement crafting remainders + overwrite_call((void *) 0x2e230, (void *) PaneCraftingScreen_craftSelectedItem_PaneCraftingScreen_recheckRecipes_injection); + overwrite((void *) Item_getCraftingRemainingItem_non_virtual, (void *) Item_getCraftingRemainingItem_injection); } diff --git a/symbols/CMakeLists.txt b/symbols/CMakeLists.txt index 7715ed9..6b2ff44 100644 --- a/symbols/CMakeLists.txt +++ b/symbols/CMakeLists.txt @@ -100,6 +100,7 @@ set(SRC src/gui/screens/StartMenuScreen.def src/gui/screens/ProgressScreen.def src/gui/screens/Touch_SelectWorldScreen.def + src/gui/screens/PaneCraftingScreen.def src/gui/Font.def src/gui/components/ImageButton.def src/gui/components/OptionButton.def @@ -128,6 +129,7 @@ set(SRC src/tile/HeavyTile.def src/misc/Strings.def src/misc/I18n.def + src/misc/SimpleFoodData.def src/entity/ModelPart.def src/misc/Tesselator.def src/misc/AABB.def @@ -147,6 +149,8 @@ set(SRC src/recipes/FurnaceRecipes.def src/recipes/Recipes.def src/recipes/Recipes_Type.def + src/recipes/ReqItem.def + src/recipes/CItem.def ) # Resolve Definition Files set(RESOLVED_SRC "") diff --git a/symbols/src/entity/player/Player.def b/symbols/src/entity/player/Player.def index a63a002..f82458a 100644 --- a/symbols/src/entity/player/Player.def +++ b/symbols/src/entity/player/Player.def @@ -17,3 +17,4 @@ property std::string username = 0xbf4; property bool immortal = 0xbfc; property bool infinite_items = 0xbff; property ItemInstance itemBeingUsed = 0xc34; +property SimpleFoodData foodData = 0xc00; diff --git a/symbols/src/gui/screens/PaneCraftingScreen.def b/symbols/src/gui/screens/PaneCraftingScreen.def new file mode 100644 index 0000000..b561ce8 --- /dev/null +++ b/symbols/src/gui/screens/PaneCraftingScreen.def @@ -0,0 +1,5 @@ +method void craftSelectedItem() = 0x2e0e4; +method void recheckRecipes() = 0x2dc98; + +property Minecraft *minecraft = 0x14; +property CItem *item = 0x74; diff --git a/symbols/src/item/Item.def b/symbols/src/item/Item.def index c1e72e4..656c977 100644 --- a/symbols/src/item/Item.def +++ b/symbols/src/item/Item.def @@ -20,6 +20,8 @@ virtual-method bool isFood() = 0x64; virtual-method bool isArmor() = 0x68; virtual-method void setDescriptionId(std::string *name) = 0x6c; virtual-method std::string getDescriptionId(ItemInstance *item_instance) = 0x7c; +// This returns an Item*, but it's never called normally so it doesn't matter if we invent a better system over top of it +virtual-method ItemInstance *getCraftingRemainingItem(ItemInstance *item_instance) = 0x84; // Swing = 0, eating = 1, drinking = 2, bow = 4, anything else is nothing virtual-method int getUseAnimation() = 0x94; @@ -30,6 +32,7 @@ property int category = 0x10; property int max_stack_size = 0x14; property bool equipped = 0x18; property bool is_stacked_by_data = 0x19; +property Item *craftingRemainingItem = 0x1c; property std::string description_id = 0x20; // Globals diff --git a/symbols/src/level/Material.def b/symbols/src/level/Material.def index 9d54f76..fb420b0 100644 --- a/symbols/src/level/Material.def +++ b/symbols/src/level/Material.def @@ -1,4 +1,7 @@ virtual-method bool isSolid() = 0x8; // Globals -static-property Material *Material_stone = 0x180a9c; \ No newline at end of file +static-property Material *dirt = 0x180a94; +static-property Material *stone = 0x180a9c; +static-property Material *metal = 0x180aa0; +static-property Material *glass = 0x180acc; diff --git a/symbols/src/misc/SimpleFoodData.def b/symbols/src/misc/SimpleFoodData.def new file mode 100644 index 0000000..880dc2a --- /dev/null +++ b/symbols/src/misc/SimpleFoodData.def @@ -0,0 +1,5 @@ +size 0x4; + +method void eat(int amount) = 0x91470; + +property int health = 0x0; diff --git a/symbols/src/recipes/CItem.def b/symbols/src/recipes/CItem.def new file mode 100644 index 0000000..e555ae6 --- /dev/null +++ b/symbols/src/recipes/CItem.def @@ -0,0 +1,3 @@ +property ItemInstance item = 0x0; +property std::vector ingredients = 0x20; +property bool craftable = 0x2c; diff --git a/symbols/src/recipes/ReqItem.def b/symbols/src/recipes/ReqItem.def new file mode 100644 index 0000000..a01fe2a --- /dev/null +++ b/symbols/src/recipes/ReqItem.def @@ -0,0 +1,3 @@ +size 0x10; + +property ItemInstance requested_item = 0x0; diff --git a/symbols/src/tile/Tile.def b/symbols/src/tile/Tile.def index fe01648..91e12e2 100644 --- a/symbols/src/tile/Tile.def +++ b/symbols/src/tile/Tile.def @@ -3,20 +3,38 @@ static-method void initTiles() = 0xc358c; vtable 0x115670; vtable-size 0x104; -constructor (int id, int texture, void *material) = 0xc33a0; +constructor (int id, int texture, Material *material) = 0xc33a0; size 0x5c; method Tile *init() = 0xc34dc; -virtual-method Tile *setDestroyTime(float destroy_time) = 0xf8; -virtual-method Tile *setExplodeable(float explodeable) = 0xf4; -virtual-method Tile *setSoundType(Tile_SoundType *sound_type) = 0xe8; + +virtual-method bool isCubeShaped() = 0x8; +virtual-method int getRenderShape() = 0xc; +virtual-method void setShape(float x1, float y1, float z1, float x2, float y2, float z2) = 0x10; +virtual-method void updateShape(Level *level, int x, int y, int z) = 0x14; +virtual-method void updateDefaultShape() = 0x18; +virtual-method int getTexture1() = 0x28; +virtual-method int getTexture2(int face) = 0x2c; +virtual-method int getTexture3(Level *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 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; +virtual-method int getRenderLayer() = 0x94; virtual-method int use(Level *level, int x, int y, int z, Player *player) = 0x98; virtual-method int getColor(LevelSource *level_source, int x, int y, int z) = 0xb8; -virtual-method int getRenderShape() = 0xc; +virtual-method std::string getDescriptionId() = 0xdc; virtual-method Tile *setDescriptionId(std::string *description_id) = 0xe0; +virtual-method Tile *setSoundType(Tile_SoundType *sound_type) = 0xe8; +virtual-method Tile *setExplodeable(float explodeable) = 0xf4; +virtual-method Tile *setDestroyTime(float destroy_time) = 0xf8; +property int texture = 0x4; property int id = 0x8; property int category = 0x3c; +property AABB aabb = 0x40; // Globals static-property-array Tile *tiles = 0x180e08; -- 2.40.1 From 3b596061515a7d2c9a25b1aed75bbdc5784a3f8a Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Sun, 28 Jan 2024 15:04:40 -0500 Subject: [PATCH 08/18] Fix CMakeLists --- mods/CMakeLists.txt | 54 +++++++++++---------------------------------- 1 file changed, 13 insertions(+), 41 deletions(-) diff --git a/mods/CMakeLists.txt b/mods/CMakeLists.txt index cc0d337..24bee06 100644 --- a/mods/CMakeLists.txt +++ b/mods/CMakeLists.txt @@ -103,51 +103,23 @@ endif() # Build add_library(mods SHARED ${SRC}) -==== BASE ==== -add_library(death SHARED src/death/death.cpp) -target_link_libraries(death mods-headers reborn-patch symbols feature) +# Install +install(TARGETS mods DESTINATION "${MCPI_INSTALL_DIR}/mods") +# SDK +install(TARGETS mods EXPORT sdk DESTINATION "${MCPI_SDK_LIB_DIR}") -add_library(misc SHARED src/misc/misc.c src/misc/misc.cpp src/misc/logging.cpp src/misc/api.cpp) -target_link_libraries(misc mods-headers reborn-patch symbols media-layer-core feature) - -add_library(options SHARED src/options/options.c src/options/options.cpp) -target_link_libraries(options mods-headers reborn-patch symbols feature home) - -add_library(bucket SHARED src/bucket/bucket.cpp) -target_link_libraries(bucket mods-headers reborn-patch symbols feature misc) - -add_library(home SHARED src/home/home.c) -target_link_libraries(home mods-headers reborn-patch symbols) - -add_library(test SHARED src/test/test.c) -target_link_libraries(test mods-headers reborn-patch home) -==== BASE ==== - -==== BASE ==== -add_library(init SHARED src/init/init.c) -target_link_libraries(init symbols mods-headers reborn-util compat game-mode misc death options chat creative bucket textures home version test media-layer-core) -if(MCPI_SERVER_MODE) - target_link_libraries(init server) -else() - target_link_libraries(init multiplayer benchmark) -endif() -==== BASE ==== +# Dependencies +target_link_libraries(mods symbols reborn-patch media-layer-core dl pthread) if(NOT MCPI_HEADLESS_MODE) target_link_libraries(mods stb_image) endif() -==== BASE ==== -## Install Mods -set(MODS_TO_INSTALL init compat readdir feature game-mode misc override death options chat creative bucket textures home version test) -if(MCPI_SERVER_MODE) - list(APPEND MODS_TO_INSTALL server) -else() - list(APPEND MODS_TO_INSTALL multiplayer benchmark) -endif() -if(NOT MCPI_HEADLESS_MODE) - list(APPEND MODS_TO_INSTALL sound camera input sign touch atlas title-screen skin screenshot) -endif() -install(TARGETS ${MODS_TO_INSTALL} DESTINATION "${MCPI_INSTALL_DIR}/mods") -==== BASE ==== +# Headers +target_include_directories( + mods + PUBLIC + "$" + "$" +) # SDK install(DIRECTORY "include/" DESTINATION "${MCPI_SDK_INCLUDE_DIR}/mods") -- 2.40.1 From c93350a44c317cf7bfb31de30e6701a34d1e750a Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Sun, 28 Jan 2024 19:31:18 -0500 Subject: [PATCH 09/18] Fix things --- mods/include/mods/bucket/bucket.h | 1 + mods/src/bucket/bucket.cpp | 12 +++++++++--- mods/src/cake/cake.cpp | 7 ++++--- symbols/src/gui/screens/PaneCraftingScreen.def | 3 ++- symbols/src/item/Item.def | 3 +-- 5 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 mods/include/mods/bucket/bucket.h diff --git a/mods/include/mods/bucket/bucket.h b/mods/include/mods/bucket/bucket.h new file mode 100644 index 0000000..de355c4 --- /dev/null +++ b/mods/include/mods/bucket/bucket.h @@ -0,0 +1 @@ +bool buckets_enabled(); diff --git a/mods/src/bucket/bucket.cpp b/mods/src/bucket/bucket.cpp index c91197e..504a525 100644 --- a/mods/src/bucket/bucket.cpp +++ b/mods/src/bucket/bucket.cpp @@ -133,13 +133,14 @@ static int BucketItem_getUseDuration(__attribute__((unused)) FoodItem *item, Ite return 0; } -static void BucketItem_useTimeDepleted(FoodItem *item, uchar *param_1, ItemInstance *item_instance, Level *level, Player *player) { +static ItemInstance BucketItem_useTimeDepleted(FoodItem *item, ItemInstance *item_instance, Level *level, Player *player) { if (item_instance->auxiliary == 1) { - (*FoodItem_useTimeDepleted_vtable_addr)(item, param_1, item_instance, level, player); + *item_instance = FoodItem_useTimeDepleted_non_virtual(item, item_instance, level, player); // Set it to a empty bucket item_instance->auxiliary = 0; item_instance->count = 1; } + return *item_instance; } static int BucketItem_getUseAnimation(__attribute__((unused)) FoodItem *item) { @@ -349,9 +350,14 @@ static void Language_injection(__attribute__((unused)) void *null) { } // Init +bool buckets_enabled() { + static bool ret = feature_has("Add Buckets", server_enabled); + return ret; +} + void init_bucket() { // Add Buckets - if (feature_has("Add Buckets", server_enabled)) { + if (buckets_enabled()) { // Add Items misc_run_on_items_setup(Item_initItems_injection); // Change Max Stack Size Based On Auxiliary diff --git a/mods/src/cake/cake.cpp b/mods/src/cake/cake.cpp index cb38dd4..8461c8a 100644 --- a/mods/src/cake/cake.cpp +++ b/mods/src/cake/cake.cpp @@ -4,8 +4,9 @@ #include #include #include +#include -Tile *cake = NULL; +static Tile *cake = NULL; #define CAKE_LEN 0.0625F @@ -166,7 +167,7 @@ static void Inventory_setupDefault_FillingContainer_addItem_call_injection(Filli cake_instance->count = 255; cake_instance->auxiliary = 0; cake_instance->id = 92; - (*FillingContainer_addItem)(filling_container, cake_instance); + FillingContainer_addItem(filling_container, cake_instance); } // Recipe (only when buckets are enabled) @@ -234,7 +235,7 @@ void init_cake() { if (feature_has("Add Cake", server_enabled)) { misc_run_on_tiles_setup(Tile_initTiles_injection); misc_run_on_creative_inventory_setup(Inventory_setupDefault_FillingContainer_addItem_call_injection); - if (feature_has("Add Buckets", server_enabled)) { + if (buckets_enabled()) { // The recipe needs milk buckets misc_run_on_recipes_setup(Recipes_injection); } diff --git a/symbols/src/gui/screens/PaneCraftingScreen.def b/symbols/src/gui/screens/PaneCraftingScreen.def index b561ce8..6ef4fda 100644 --- a/symbols/src/gui/screens/PaneCraftingScreen.def +++ b/symbols/src/gui/screens/PaneCraftingScreen.def @@ -1,5 +1,6 @@ +extends Screen; + method void craftSelectedItem() = 0x2e0e4; method void recheckRecipes() = 0x2dc98; -property Minecraft *minecraft = 0x14; property CItem *item = 0x74; diff --git a/symbols/src/item/Item.def b/symbols/src/item/Item.def index 656c977..289b010 100644 --- a/symbols/src/item/Item.def +++ b/symbols/src/item/Item.def @@ -11,8 +11,7 @@ virtual-method void setIcon(int texture_x, int texture_y) = 0x18; virtual-method int useOn(ItemInstance *item_instance, Player *player, Level *level, int x, int y, int z, int hit_side, float hit_x, float hit_y, float hit_z) = 0x20; // Normally returns 0 virtual-method int getUseDuration(ItemInstance *item_instance) = 0x24; -// I don't know much about param_1, it might be some partially initialized ItemInstance* -virtual-method void useTimeDepleted(uchar *param_1, ItemInstance *item_instance, Level *level, Player *player) = 0x28; +virtual-method ItemInstance useTimeDepleted(ItemInstance *item_instance, Level *level, Player *player) = 0x28; virtual-method int getDestorySpeed(ItemInstance *item_instance, Tile *tile) = 0x2c; virtual-method ItemInstance *use(ItemInstance *item_instance, Level *level, Player *player) = 0x30; virtual-method bool mineBlock(ItemInstance *instance, int tile_id, int x, int y, int z) = 0x48; -- 2.40.1 From 6060fdd4e18fac94bdda38aba397068fbc9e4109 Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Mon, 29 Jan 2024 22:44:09 -0500 Subject: [PATCH 10/18] Add Death Messages --- dependencies/glfw/src | 2 +- mods/src/death/death.cpp | 113 +++++++++++++++++++++++++++++----- symbols/src/entity/Entity.def | 9 +++ 3 files changed, 109 insertions(+), 15 deletions(-) diff --git a/dependencies/glfw/src b/dependencies/glfw/src index 8e6c8d7..b4c3ef9 160000 --- a/dependencies/glfw/src +++ b/dependencies/glfw/src @@ -1 +1 @@ -Subproject commit 8e6c8d7effc54f8aecd30eda17069588298f4ada +Subproject commit b4c3ef9d0fdf46845f3e81e5d989dab06e71e6c1 diff --git a/mods/src/death/death.cpp b/mods/src/death/death.cpp index 995829a..8ea2faa 100644 --- a/mods/src/death/death.cpp +++ b/mods/src/death/death.cpp @@ -7,55 +7,140 @@ #include // Death Messages -static std::string get_death_message(Player *player) { - // Get Username - std::string *username = &player->username; - +static const char *monster_names[] = {"Zombie", "Creeper", "Skeleton", "Spider", "Zombie Pigman"}; +static std::string get_death_message(Player *player, Entity *cause, bool was_shot = false) { // Prepare Death Message - std::string message; - message.append(username->c_str()); - message.append(" has died"); + std::string message = player->username; + + // The cause + if (cause) { + // Entity cause + int type_id = cause->vtable->getEntityTypeId(cause); + int aux = cause->vtable->getAuxData(cause); + if (cause->vtable->isPlayer(cause)) { + // Another player + if (was_shot) { + message += " was shot by "; + } else { + message += " was killed by "; + } + message += ((Player *) cause)->username; + } else if (cause->vtable->getCreatureBaseType(cause) == 1) { + // Killed by a monster + if (was_shot) { + message += " was shot by a "; + } else { + message += " was killed by a "; + } + if (32 <= type_id && type_id <= 36) { + message += monster_names[type_id - 32]; + } else { + // Unknown monster + message += "Mysterious Beast"; + } + } else if (aux) { + // Throwable with owner + Level *level = player->level; + Entity *shooter = Level_getEntity(level, aux); + return get_death_message(player, shooter, true); + } else if (80 <= type_id || type_id <= 82) { + // Throwable without owner + message += " was shot under mysterious circumstances"; + } else if (type_id == 65) { + // TNT + message += " was blown apart"; + } else if (cause->vtable->isHangingEntity(cause)) { + // Painting? + message += " admired too much art"; + } else { + if (was_shot) { + message += " was shot under mysterious circumstances"; + } else { + message += " was killed under mysterious circumstances"; + } + } + } else { + // Non-entity cause + if (was_shot) { + // Throwable with invalid owner + message += " was shot under mysterious circumstances"; + } else { + // Anything else + message += " has died"; + } + } // Return return message; } +static bool is_hurt = false; +static bool Mob_hurt_injection(Mob *mob, Entity *source, int dmg) { + // Call Original Method + is_hurt = true; + bool ret = Mob_hurt_non_virtual(mob, source, dmg); + is_hurt = false; + return ret; +} + // Death Message Logic -#define Player_actuallyHurt_injection(type) \ +#define Player_death_injections(type) \ + static void type##Player_die_injection(type##Player *player, Entity *cause) { \ + /* Call Original Method */ \ + type##Player_die_non_virtual(player, cause); \ + \ + /* Get Variable */ \ + RakNetInstance *rak_net_instance = player->minecraft->rak_net_instance; \ + /* Only Run On Server-Side */ \ + if (rak_net_instance->vtable->isServer(rak_net_instance)) { \ + /* Get Death Message */ \ + std::string message = get_death_message((Player *) player, cause); \ + \ + /* Post Death Message */ \ + ServerSideNetworkHandler *server_side_network_handler = (ServerSideNetworkHandler *) player->minecraft->network_handler; \ + ServerSideNetworkHandler_displayGameMessage(server_side_network_handler, &message); \ + } \ + } \ + \ static void type##Player_actuallyHurt_injection(type##Player *player, int32_t damage) { \ /* Store Old Health */ \ int32_t old_health = player->health; \ \ /* Call Original Method */ \ type##Player_actuallyHurt_non_virtual(player, damage); \ + if (is_hurt == true) return; \ \ /* Store New Health */ \ int32_t new_health = player->health; \ \ /* Get Variables */ \ - Minecraft *minecraft = player->minecraft; \ - RakNetInstance *rak_net_instance = minecraft->rak_net_instance; \ + RakNetInstance *rak_net_instance = player->minecraft->rak_net_instance; \ /* Only Run On Server-Side */ \ if (rak_net_instance->vtable->isServer(rak_net_instance)) { \ /* Check Health */ \ if (new_health < 1 && old_health >= 1) { \ /* Get Death Message */ \ - std::string message = get_death_message((Player *) player); \ + std::string message = get_death_message((Player *) player, NULL); \ \ /* Post Death Message */ \ - ServerSideNetworkHandler *server_side_network_handler = (ServerSideNetworkHandler *) minecraft->network_handler; \ + ServerSideNetworkHandler *server_side_network_handler = (ServerSideNetworkHandler *) player->minecraft->network_handler; \ ServerSideNetworkHandler_displayGameMessage(server_side_network_handler, &message); \ } \ } \ } -Player_actuallyHurt_injection(Local) -Player_actuallyHurt_injection(Server) + +Player_death_injections(Local); +Player_death_injections(Server); // Init void init_death() { // Death Messages if (feature_has("Implement Death Messages", server_auto)) { + patch_address(ServerPlayer_die_vtable_addr, (void *) ServerPlayer_die_injection); + patch_address(LocalPlayer_die_vtable_addr, (void *) LocalPlayer_die_injection); patch_address(ServerPlayer_actuallyHurt_vtable_addr, (void *) ServerPlayer_actuallyHurt_injection); patch_address(LocalPlayer_actuallyHurt_vtable_addr, (void *) LocalPlayer_actuallyHurt_injection); + patch_address(Mob_hurt_vtable_addr, (void *) Mob_hurt_injection); + overwrite_calls((void *) Mob_hurt_non_virtual, (void *) Mob_hurt_injection); } } diff --git a/symbols/src/entity/Entity.def b/symbols/src/entity/Entity.def index 3c57c4b..44aae8d 100644 --- a/symbols/src/entity/Entity.def +++ b/symbols/src/entity/Entity.def @@ -1,8 +1,17 @@ virtual-method void remove() = 0x10; virtual-method void tick() = 0x34; virtual-method bool interact(Player *with) = 0x6c; +virtual-method bool isPlayer() = 0x94; virtual-method bool hurt(Entity *attacker, int damage) = 0xa4; +// See https://mcpirevival.miraheze.org/wiki/Minecraft:_Pi_Edition_Complete_Entity_List for these two virtual-method int getEntityTypeId() = 0xdc; +virtual-method int getCreatureBaseType() = 0xe0; +virtual-method bool isMob() = 0xe8; +virtual-method bool isItemEntity() = 0xec; +// HangingEntity is a painting +virtual-method bool isHangingEntity() = 0xf0; +// The owner entity id for arrows/throwables, else 0 +virtual-method int getAuxData() = 0xf4; method void moveTo(float x, float y, float z, float yaw, float pitch) = 0x7a834; -- 2.40.1 From ba266db0075b9ad1c769832b8d4431c082f747b5 Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Mon, 29 Jan 2024 23:15:44 -0500 Subject: [PATCH 11/18] Undo glfw changes --- dependencies/glfw/src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies/glfw/src b/dependencies/glfw/src index b4c3ef9..8e6c8d7 160000 --- a/dependencies/glfw/src +++ b/dependencies/glfw/src @@ -1 +1 @@ -Subproject commit b4c3ef9d0fdf46845f3e81e5d989dab06e71e6c1 +Subproject commit 8e6c8d7effc54f8aecd30eda17069588298f4ada -- 2.40.1 From 19dd4b1d79201b1daefbcf83de5a9c73ff2d8f9e Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Tue, 30 Jan 2024 00:47:07 -0500 Subject: [PATCH 12/18] Clean up death messages --- mods/src/death/death.cpp | 62 +++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 36 deletions(-) diff --git a/mods/src/death/death.cpp b/mods/src/death/death.cpp index 8ea2faa..e74be5b 100644 --- a/mods/src/death/death.cpp +++ b/mods/src/death/death.cpp @@ -11,63 +11,53 @@ static const char *monster_names[] = {"Zombie", "Creeper", "Skeleton", "Spider", static std::string get_death_message(Player *player, Entity *cause, bool was_shot = false) { // Prepare Death Message std::string message = player->username; - - // The cause if (cause) { // Entity cause int type_id = cause->vtable->getEntityTypeId(cause); int aux = cause->vtable->getAuxData(cause); - if (cause->vtable->isPlayer(cause)) { - // Another player + bool is_player = cause->vtable->isPlayer(cause); + if (cause->vtable->getCreatureBaseType(cause) != 0 || is_player) { + // Killed by a creature if (was_shot) { message += " was shot by "; } else { message += " was killed by "; } - message += ((Player *) cause)->username; - } else if (cause->vtable->getCreatureBaseType(cause) == 1) { - // Killed by a monster - if (was_shot) { - message += " was shot by a "; - } else { - message += " was killed by a "; - } - if (32 <= type_id && type_id <= 36) { + if (is_player) { + // Killed by a player + message += ((Player *) cause)->username; + } else if (32 <= type_id && type_id <= 36) { + // Normal monster + message += "a "; message += monster_names[type_id - 32]; } else { - // Unknown monster - message += "Mysterious Beast"; + // Unknown creature + message += "a Mysterious Beast"; } + return message; } else if (aux) { - // Throwable with owner + // Killed by a throwable with owner Level *level = player->level; Entity *shooter = Level_getEntity(level, aux); return get_death_message(player, shooter, true); - } else if (80 <= type_id || type_id <= 82) { - // Throwable without owner - message += " was shot under mysterious circumstances"; } else if (type_id == 65) { - // TNT - message += " was blown apart"; + // Blown up by TNT + return message + " was blown apart"; } else if (cause->vtable->isHangingEntity(cause)) { // Painting? - message += " admired too much art"; - } else { - if (was_shot) { - message += " was shot under mysterious circumstances"; - } else { - message += " was killed under mysterious circumstances"; - } + return message + " admired too much art"; } + } + + if (was_shot) { + // Throwable with invalid owner + return message + " was shot under mysterious circumstances"; + } else if (cause) { + // Unknown entity + return message + " was killed"; } else { - // Non-entity cause - if (was_shot) { - // Throwable with invalid owner - message += " was shot under mysterious circumstances"; - } else { - // Anything else - message += " has died"; - } + // Anything else + return message + " has died"; } // Return -- 2.40.1 From 98b1b9b1da3da51cabfd73aeb946a7a6d12eef75 Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Tue, 30 Jan 2024 11:08:57 -0500 Subject: [PATCH 13/18] Fix TNT --- mods/src/death/death.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mods/src/death/death.cpp b/mods/src/death/death.cpp index e74be5b..16d653e 100644 --- a/mods/src/death/death.cpp +++ b/mods/src/death/death.cpp @@ -133,4 +133,9 @@ void init_death() { patch_address(Mob_hurt_vtable_addr, (void *) Mob_hurt_injection); overwrite_calls((void *) Mob_hurt_non_virtual, (void *) Mob_hurt_injection); } + // Fix TNT + unsigned char cpy_r1_r0_patch[4] = {0x00, 0x10, 0xa0, 0xe1}; // "cpy r1,r0" + patch((void *) 0x87998, cpy_r1_r0_patch); + unsigned char ldr_r0_24_patch[4] = {0x24, 0x00, 0x90, 0xe5}; // "ldr r0,[r0,#0x24]" + patch((void *) 0x8799c, ldr_r0_24_patch); } -- 2.40.1 From 739d21b835b0467f966fdefdedc07e2c6225631f Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Tue, 30 Jan 2024 19:44:07 -0500 Subject: [PATCH 14/18] Fix load_symbol ignoring source when a previous source has already been loaded --- media-layer/core/src/audio/file.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/media-layer/core/src/audio/file.cpp b/media-layer/core/src/audio/file.cpp index 34de48c..0992548 100644 --- a/media-layer/core/src/audio/file.cpp +++ b/media-layer/core/src/audio/file.cpp @@ -13,10 +13,12 @@ // Load Symbol From ELF File static void load_symbol(const char *source, const char *name, std::function callback) { - static std::unique_ptr binary = NULL; - if (binary == NULL) { - binary = LIEF::ELF::Parser::parse(source); + static std::unordered_map> sources = {}; + auto pos = sources.find(std::string(source)); + if (pos == sources.end()) { + sources[std::string(source)] = LIEF::ELF::Parser::parse(source); } + std::unique_ptr &binary = sources[std::string(source)]; const LIEF::ELF::Symbol *symbol = binary->get_dynamic_symbol(name); if (symbol != NULL) { LIEF::span data = binary->get_content_from_virtual_address(symbol->value(), symbol->size(), LIEF::Binary::VA_TYPES::VA); -- 2.40.1 From 67de39d23a80ddb72956bff58dd0db1de5731f34 Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Thu, 1 Feb 2024 19:20:29 -0500 Subject: [PATCH 15/18] Merge symbol-processor changes too --- dependencies/symbol-processor/src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies/symbol-processor/src b/dependencies/symbol-processor/src index 39e1d17..2390ef0 160000 --- a/dependencies/symbol-processor/src +++ b/dependencies/symbol-processor/src @@ -1 +1 @@ -Subproject commit 39e1d17f93fb2253be3692858241aab62104d05f +Subproject commit 2390ef024752785e7e6e492feca5fec08014fa06 -- 2.40.1 From 60b1219a7d3ad0ab71a4d330410c749c7f8fd942 Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Thu, 1 Feb 2024 19:22:13 -0500 Subject: [PATCH 16/18] Remove a commit I left in by mistake from a diffrent PR --- media-layer/core/src/audio/file.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/media-layer/core/src/audio/file.cpp b/media-layer/core/src/audio/file.cpp index 0992548..34de48c 100644 --- a/media-layer/core/src/audio/file.cpp +++ b/media-layer/core/src/audio/file.cpp @@ -13,12 +13,10 @@ // Load Symbol From ELF File static void load_symbol(const char *source, const char *name, std::function callback) { - static std::unordered_map> sources = {}; - auto pos = sources.find(std::string(source)); - if (pos == sources.end()) { - sources[std::string(source)] = LIEF::ELF::Parser::parse(source); + static std::unique_ptr binary = NULL; + if (binary == NULL) { + binary = LIEF::ELF::Parser::parse(source); } - std::unique_ptr &binary = sources[std::string(source)]; const LIEF::ELF::Symbol *symbol = binary->get_dynamic_symbol(name); if (symbol != NULL) { LIEF::span data = binary->get_content_from_virtual_address(symbol->value(), symbol->size(), LIEF::Binary::VA_TYPES::VA); -- 2.40.1 From 82ba813b7205b46fd0baedbd200f94f4c74a2ec3 Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Thu, 1 Feb 2024 19:26:06 -0500 Subject: [PATCH 17/18] Restore GLFW, again... --- dependencies/glfw/src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies/glfw/src b/dependencies/glfw/src index b4c3ef9..8e6c8d7 160000 --- a/dependencies/glfw/src +++ b/dependencies/glfw/src @@ -1 +1 @@ -Subproject commit b4c3ef9d0fdf46845f3e81e5d989dab06e71e6c1 +Subproject commit 8e6c8d7effc54f8aecd30eda17069588298f4ada -- 2.40.1 From 5e1d718f5a5576cbe7ee94ddba20d62854755657 Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Tue, 6 Feb 2024 20:04:00 -0500 Subject: [PATCH 18/18] More fixes --- dependencies/symbol-processor/src | 2 +- docs/CHANGELOG.md | 9 ++++++--- mods/include/mods/bucket/bucket.h | 4 +++- mods/src/bucket/bucket.cpp | 12 ++++++------ mods/src/cake/cake.cpp | 6 +++--- mods/src/death/death.cpp | 1 + symbols/src/gui/Gui.def | 1 + symbols/src/gui/components/GuiComponent.def | 1 + symbols/src/gui/screens/Screen.def | 20 ++++++++++---------- symbols/src/item/FoodItem.def | 3 +++ symbols/src/item/ItemRenderer.def | 9 +++++---- symbols/src/misc/Tesselator.def | 2 ++ symbols/src/tile/Tile.def | 8 +++++++- symbols/src/tile/TileRenderer.def | 3 ++- 14 files changed, 51 insertions(+), 30 deletions(-) diff --git a/dependencies/symbol-processor/src b/dependencies/symbol-processor/src index 2390ef0..8bca4b7 160000 --- a/dependencies/symbol-processor/src +++ b/dependencies/symbol-processor/src @@ -1 +1 @@ -Subproject commit 2390ef024752785e7e6e492feca5fec08014fa06 +Subproject commit 8bca4b7ec6aa28ef6fbc894d1f358468bcc4b321 diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index f4b0f8a..ef1feb5 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,13 +1,16 @@ # Changelog +**3.0.0** +* Add ``Add Cake`` Feature Flag (Enabled By Default) +* Add Milk Buckets +* Implement Crafting Remainders +* Add Death Messages + **2.5.3** * Add `Replace Block Highlight With Outline` Feature Flag (Enabled By Default) * By Default, The Outline Width Is Set Using The GUI Scale * This Can Be Overridden Using The ``MCPI_BLOCK_OUTLINE_WIDTH`` Environmental Variable * Added ``overwrite_calls_within`` Function -* Add ``Add Cake`` Feature Flag (Enabled By Default) -* Add Milk Buckets -* Implement Crafting Remainders **2.5.2** * Add `3D Chest Model` Feature Flag (Enabled By Default) diff --git a/mods/include/mods/bucket/bucket.h b/mods/include/mods/bucket/bucket.h index de355c4..2547d63 100644 --- a/mods/include/mods/bucket/bucket.h +++ b/mods/include/mods/bucket/bucket.h @@ -1 +1,3 @@ -bool buckets_enabled(); +#pragma once + +extern bool buckets_enabled; diff --git a/mods/src/bucket/bucket.cpp b/mods/src/bucket/bucket.cpp index 0f7c90e..22af894 100644 --- a/mods/src/bucket/bucket.cpp +++ b/mods/src/bucket/bucket.cpp @@ -200,6 +200,8 @@ static FoodItem *create_bucket(int32_t id, int32_t texture_x, int32_t texture_y, item->max_damage = 0; item->max_stack_size = 1; item->nutrition = 0; + item->unknown_param_1 = 0.6; + item->meat = false; // Return return item; @@ -336,19 +338,17 @@ static void FurnaceTileEntity_tick_ItemInstance_setNull_injection(ItemInstance * } } +// Add the bucket name to the language file static void Language_injection(__attribute__((unused)) void *null) { I18n__strings.insert(std::make_pair("item.bucketMilk.name", "Milk Bucket")); } // Init -bool buckets_enabled() { - static bool ret = feature_has("Add Buckets", server_enabled); - return ret; -} - +bool buckets_enabled = false; void init_bucket() { // Add Buckets - if (buckets_enabled()) { + buckets_enabled = feature_has("Add Buckets", server_enabled); + if (buckets_enabled) { // Add Items misc_run_on_items_setup(Item_initItems_injection); // Change Max Stack Size Based On Auxiliary diff --git a/mods/src/cake/cake.cpp b/mods/src/cake/cake.cpp index e922975..c9c0034 100644 --- a/mods/src/cake/cake.cpp +++ b/mods/src/cake/cake.cpp @@ -16,7 +16,7 @@ static std::string Cake_getDescriptionId(__attribute__((unused)) Tile *tile) { } // Textures -static int Cake_getTexture2(__attribute__((unused)) Tile *tile, int face) { +static int Cake_getTexture2(__attribute__((unused)) Tile *tile, int face, __attribute__((unused)) int data) { if (face == 1) { // Top texture return 121; @@ -38,7 +38,7 @@ static int Cake_getTexture3(__attribute__((unused)) Tile *tile, LevelSource *lev } } // Normal - return Cake_getTexture2(tile, face); + return Cake_getTexture2(tile, face, 0); } // Rendering @@ -235,7 +235,7 @@ void init_cake() { if (feature_has("Add Cake", server_enabled)) { misc_run_on_tiles_setup(Tile_initTiles_injection); misc_run_on_creative_inventory_setup(Inventory_setupDefault_FillingContainer_addItem_call_injection); - if (buckets_enabled()) { + if (buckets_enabled) { // The recipe needs milk buckets misc_run_on_recipes_setup(Recipes_injection); } diff --git a/mods/src/death/death.cpp b/mods/src/death/death.cpp index 16d653e..606ece2 100644 --- a/mods/src/death/death.cpp +++ b/mods/src/death/death.cpp @@ -134,6 +134,7 @@ void init_death() { overwrite_calls((void *) Mob_hurt_non_virtual, (void *) Mob_hurt_injection); } // Fix TNT + // This changes PrimedTnt_explode from Level_explode(NULL, x, y, z, 3.1f) to Level_explode(this, x, y, z, 3.1f) unsigned char cpy_r1_r0_patch[4] = {0x00, 0x10, 0xa0, 0xe1}; // "cpy r1,r0" patch((void *) 0x87998, cpy_r1_r0_patch); unsigned char ldr_r0_24_patch[4] = {0x24, 0x00, 0x90, 0xe5}; // "ldr r0,[r0,#0x24]" diff --git a/symbols/src/gui/Gui.def b/symbols/src/gui/Gui.def index fc7595a..dc477cd 100644 --- a/symbols/src/gui/Gui.def +++ b/symbols/src/gui/Gui.def @@ -12,6 +12,7 @@ method void addMessage(std::string *text) = 0x27820; method void getSlotPos(int slot, int *x, int *y) = 0x25548; method void renderSlot(int slot, int x, int y, float alpha) = 0x25cc0; method void renderSlotText(ItemInstance *item, float x, float y, bool finite, bool shadow) = 0x25df8; +method void renderHearts() = 0x2641c; property Minecraft *minecraft = 0x9f4; property float selected_item_text_timer = 0x9fc; diff --git a/symbols/src/gui/components/GuiComponent.def b/symbols/src/gui/components/GuiComponent.def index 93a801c..4a14dc1 100644 --- a/symbols/src/gui/components/GuiComponent.def +++ b/symbols/src/gui/components/GuiComponent.def @@ -7,3 +7,4 @@ method void blit(int x_dest, int y_dest, int x_src, int y_src, int width_dest, i method void drawCenteredString(Font *font, std::string *text, int x, int y, int color) = 0x2821c; method void drawString(Font *font, std::string *text, int x, int y, int color) = 0x28284; method void fill(int x1, int y1, int x2, int y2, uint color) = 0x285f0; +method void fillGradient(int x1, int y1, int x2, int y2, int color1, int color2) = 0x287c0; \ No newline at end of file diff --git a/symbols/src/gui/screens/Screen.def b/symbols/src/gui/screens/Screen.def index 79c3818..8f2ecff 100644 --- a/symbols/src/gui/screens/Screen.def +++ b/symbols/src/gui/screens/Screen.def @@ -6,23 +6,23 @@ constructor () = 0x29028; vtable-size 0x74; vtable 0x1039d8; -virtual-method void updateEvents() = 0x14; -virtual-method void keyboardNewChar(char key) = 0x70; -virtual-method void keyPressed(int key) = 0x6c; +virtual-method void init() = 0xc; virtual-method void render(int x, int y, float param_1) = 0x8; +virtual-method void setupPositions() = 0x10; +virtual-method void updateEvents() = 0x14; virtual-method bool handleBackEvent(bool param_1) = 0x24; virtual-method void tick() = 0x28; -virtual-method void buttonClicked(Button *button) = 0x60; -virtual-method void init() = 0xc; -virtual-method void mouseClicked(int x, int y, int param_1) = 0x64; virtual-method void removed() = 0x2c; virtual-method void renderBackground() = 0x30; -virtual-method void setupPositions() = 0x10; +virtual-method void buttonClicked(Button *button) = 0x60; +virtual-method void mouseClicked(int x, int y, int param_1) = 0x64; +virtual-method void keyPressed(int key) = 0x6c; +virtual-method void keyboardNewChar(char key) = 0x70; -property Minecraft *minecraft = 0x14; -property std::vector