Add Cake #81

Merged
TheBrokenRail merged 22 commits from bigjango13/minecraft-pi-reborn:master into master 2024-02-07 06:47:47 +00:00
14 changed files with 51 additions and 30 deletions
Showing only changes of commit 5e1d718f5a - Show all commits

@ -1 +1 @@
Subproject commit 2390ef024752785e7e6e492feca5fec08014fa06
Subproject commit 8bca4b7ec6aa28ef6fbc894d1f358468bcc4b321

View File

@ -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)
bigjango13 marked this conversation as resolved Outdated

Why did you add this to the v2.5.3 changelog?

Why did you add this to the v2.5.3 changelog?

Should I add it to v2.5.4 or v2.6.0 instead?

Should I add it to v2.5.4 or v2.6.0 instead?

Add it to v3.0.0.

Add it to v3.0.0.
* 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)

View File

@ -1 +1,3 @@
bool buckets_enabled();
#pragma once
bigjango13 marked this conversation as resolved Outdated

Please add a #pragma once.

Also, instead of a fancy method containing a static bool, why not just use an extern bool buckets_enabled, or just have buckets_enabled() check a variable.

bool buckets_enabled() {
    static bool ret = feature_has("Add Buckets", server_enabled);
    return ret;
}

just seems a bit over-complicated.

Please add a `#pragma once`. Also, instead of a fancy method containing a `static bool`, why not just use an `extern bool buckets_enabled`, or just have `buckets_enabled()` check a variable. ```c++ bool buckets_enabled() { static bool ret = feature_has("Add Buckets", server_enabled); return ret; } ``` just seems a bit over-complicated.
extern bool buckets_enabled;

View File

@ -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 *
}
}
bigjango13 marked this conversation as resolved Outdated

This should probably have a comment before it.

This should probably have a comment before it.
// 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

View File

@ -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);
bigjango13 marked this conversation as resolved
Review

feature_has should ideally only run once per feature (to avoid redundant log entries). Maybe bucket could set a variable if it's enabled?

`feature_has` should ideally only run once per feature (to avoid redundant log entries). Maybe `bucket` could set a variable if it's enabled?
if (buckets_enabled()) {
if (buckets_enabled) {
// The recipe needs milk buckets
misc_run_on_recipes_setup(Recipes_injection);
}

View File

@ -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)
bigjango13 marked this conversation as resolved Outdated

So, uh, what does these patches actually do? Does it set an entity ID somewhere? Because that should probably be in the comment.

So, uh, what does these patches actually do? Does it set an entity ID somewhere? Because that should probably be in the comment.
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]"

View File

@ -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;

View File

@ -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;

View File

@ -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<Button *> rendered_buttons = 0x18;
property std::vector<Button *> selectable_buttons = 0x30;
property int width = 0x8;
property int height = 0xc;
property bool passthrough_input = 0x10;
property Minecraft *minecraft = 0x14;
property std::vector<Button *> rendered_buttons = 0x18;
property std::vector<Button *> selectable_buttons = 0x30;
property Font *font = 0x40;

View File

@ -5,3 +5,6 @@ vtable 0x10e7b0;
vtable-size 0x98;
property int nutrition = 0x24;
// Always 0.6
property float unknown_param_1 = 0x28;
property bool meat = 0x2c;

View File

@ -1,4 +1,5 @@
static-method void renderGuiItem_one(Font *font, Textures *textures, ItemInstance *item_instance, float param_1, float param_2, bool param_3) = 0x63e58;
static-method void renderGuiItem_two(Font *font, Textures *textures, ItemInstance *item_instance, float param_1, float param_2, float param_3, float param_4, bool param_5) = 0x63be0;
static-method void renderGuiItemCorrect(Font *font, Textures *textures, ItemInstance *item_instance, int param_1, int param_2) = 0x639a0;
static-method void renderGuiItemDecorations(ItemInstance *item, float x, float y) = 0x63748;
static-method void renderGuiItem_one(Font *font, Textures *textures, ItemInstance *item_instance, float x, float y, bool param_3) = 0x63e58;
static-method void renderGuiItem_two(Font *font, Textures *textures, ItemInstance *item_instance, float x, float y, float w, float h, bool param_5) = 0x63be0;
static-method void renderGuiItemCorrect(Font *font, Textures *textures, ItemInstance *item_instance, int x, int y) = 0x639a0;
static-method void renderGuiItemDecorations(ItemInstance *item, float x, float y) = 0x63748;
static-method void blit(float x, float y, float texture_x, float texture_y, float w, float h) = 0x638c0;

View File

@ -1,6 +1,8 @@
method void begin(int mode) = 0x529d4;
method void draw() = 0x52e08;
method void colorABGR(int color) = 0x52b54;
method void color(int r, int g, int b, int a) = 0x52a48;
method void vertex(float x, float y, float z) = 052bc0;
method void vertexUV(float x, float y, float z, float u, float v) = 0x52d40;
static-property Tesselator instance = 0x137538;

View File

@ -8,6 +8,7 @@ size 0x5c;
method Tile *init() = 0xc34dc;
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;
@ -15,7 +16,7 @@ virtual-method void updateShape(LevelSource *level, int x, int y, int z) = 0x14;
virtual-method void updateDefaultShape() = 0x18;
virtual-method float getBrightness(LevelSource *level, int x, int y, int z) = 0x20;
virtual-method int getTexture1() = 0x28;
virtual-method int getTexture2(int face) = 0x2c;
virtual-method int getTexture2(int face, int data) = 0x2c;
virtual-method int getTexture3(LevelSource *level, int x, int y, int z, int face) = 0x30;
virtual-method AABB *getAABB(Level *level, int x, int y, int z) = 0x34;
virtual-method bool isSolidRender() = 0x40;
@ -27,9 +28,11 @@ virtual-method int getRenderLayer() = 0x94;
virtual-method int use(Level *level, int x, int y, int z, Player *player) = 0x98;
virtual-method void setPlacedBy(Level *level, int x, int y, int z, Mob *placer) = 0xa8;
virtual-method int getColor(LevelSource *level_source, int x, int y, int z) = 0xb8;
virtual-method void entityInside(Level *level, int x, int y, int z, Entity *entity) = 0xcc;
virtual-method std::string getDescriptionId() = 0xdc;
virtual-method Tile *setDescriptionId(std::string *description_id) = 0xe0;
virtual-method Tile *setSoundType(Tile_SoundType *sound_type) = 0xe8;
virtual-method Tile *setLightEmission(float light) = 0xf0;
virtual-method Tile *setExplodeable(float explodeable) = 0xf4;
virtual-method Tile *setDestroyTime(float destroy_time) = 0xf8;
@ -68,3 +71,6 @@ static-property Tile *grass_carried = 0x181dd4;
// Sounds
static-property Tile_SoundType SOUND_STONE = 0x181c80;
// Light
static-property float *lightEmission = 0x181214;

View File

@ -1,3 +1,4 @@
method void tesselateBlockInWorld(Tile *tile, int x, int y, int z) = 0x59e30;
method bool tesselateBlockInWorld(Tile *tile, int x, int y, int z) = 0x59e30;
method bool tesselateInWorld(Tile *tile, int x, int y, int z) = 0x5e80c;
property Level *level = 0x0;