Add Cake #81
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "bigjango13/minecraft-pi-reborn:master"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds cake, crafting remainders, milk buckets, death messages,
misc_run_on_language_setup
, and a lot more symbols.I messed up the merge, fixing it now.
@ -7,1 +7,4 @@
* Added ``overwrite_calls_within`` Function
* Add ``Add Cake`` Feature Flag (Enabled By Default)
* Add Milk Buckets
* Implement Crafting Remainders
Why did you add this to the v2.5.3 changelog?
Should I add it to v2.5.4 or v2.6.0 instead?
Add it to v3.0.0.
@ -7,3 +7,3 @@
// Items
static Item *bucket = NULL;
static FoodItem *bucket = NULL;
Do we really care about MCPE compatibility that much? IMO, the code might be nicer if the milk bucket was just a separate item. What are your thoughts?
What MCPE compatibility? As far as I know, each type of bucket has it's own id (326 water bucket, 327 lava bucket, and 335 milk bucket). While it might be a little bit nicer without all the aux value checks, it would also be a lot more verbose (even with just splitting off milk buckets), and I think that the current systems is a bit harder to understand the first time, but once it's understood it's a lot easier to read/work with than splitting it off. (It also takes up 1-3 less item ids, but that's a pretty minor bonus.)
@ -119,0 +135,4 @@
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);
Use
FoodItem_useTimeDepleted_non_virtual
rather than de-referencing the address yourself.@ -139,2 +196,3 @@
FoodItem *item = alloc_FoodItem();
ALLOC_CHECK(item);
Item_constructor(item, id);
Item_constructor((Item *) item, id);
Does
FoodItem
not have its own constructor?I think it was inlined, it must have been pretty minor, as I can't find any trace of it in minecraft-pi or libminecraftpe.so
@ -0,0 +5,4 @@
#include <mods/init/init.h>
#include <mods/misc/misc.h>
Tile *cake = NULL;
This should probably be
static
.@ -0,0 +166,4 @@
cake_instance->count = 255;
cake_instance->auxiliary = 0;
cake_instance->id = 92;
(*FillingContainer_addItem)(filling_container, cake_instance);
Remove the
(*
and)
.@ -0,0 +234,4 @@
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)) {
feature_has
should ideally only run once per feature (to avoid redundant log entries). Maybebucket
could set a variable if it's enabled?@ -103,1 +101,4 @@
Item_initItems();
// Run Functions
handle_misc_items_setup(NULL);
Why was the order of
Item_initItems_injection
changed?A few reasons:
@ -548,0 +555,4 @@
if (selected_slot != self->inventory->selectedSlot) {
self->itemBeingUsed.id = 0;
}
Player_stopUsingItem(self);
Rather than all this, why not just make the player stop using the item when the selected slot is changed?
That already happens, however if
itemBeingUsed.id == heldItem.id
,heldItem
'sauxiliary
will be set to that ofitemBeingUsed
. This fixes it by insuring thatitemBeingUsed
'sid
cannot be the same, as empty slots are (almost1) always NULL instead of having an id of 0.There are a few way to obtain an EmptyItemInstance, however it's throught bugs/mods and it almost always crashes within a few seconds of being held. ↩︎
@ -61,0 +71,4 @@
LocalPlayer *player = self->minecraft->player;
if (!player->inventory->vtable->add(player->inventory, craftingRemainingItem)) {
// Drop
player->vtable->drop(player, craftingRemainingItem, false);
How does this work if, for instance, the remaining item is 5 sticks and the player's inventory has space for 3 sticks? Do 3 sticks get added to the inventory and 2 dropped?
Yep!
@ -61,0 +83,4 @@
if (self->craftingRemainingItem != NULL) {
ItemInstance *ret = alloc_ItemInstance();
ret->id = self->craftingRemainingItem->id;
ret->count = item_instance->count;
This feels wrong? Was this added for a specific reason?
Yes, in case anyone decides to use
Item
'scraftingRemainingItem
instead of overwriting it'sItem_getCraftingRemainingItem
. I mentioned it here.@ -0,0 +1,5 @@
method void craftSelectedItem() = 0x2e0e4;
Shouldn't this extend
Screen
?@ -12,0 +12,4 @@
// 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;
This seems wrong. According to Ghidra, this function's signature is
Item::useTimeDepleted(ItemInstance*, Level*, Player*)
(and of course an extraItem *self
).It could be returning a structure, IIRC if a function returns a structure, the caller allocates the structure and passes a pointer to it as the first argument top the function (like how
this
is passed) and then the function writes to that pointer. Check outCommandServer::parse
in Ghidra.Hmm, seems like it. it tripped me up because both Item and ItemInstance have the id at 0x4.
a5e223859c
toc93350a44c
@ -1 +1 @@
Subproject commit 8e6c8d7effc54f8aecd30eda17069588298f4ada
Subproject commit b4c3ef9d0fdf46845f3e81e5d989dab06e71e6c1
Why did you downgrade GLFW?
I have no idea, I just git pulled, and when I git added it was there. How would I undo it?
Figured it out
@ -18,0 +40,4 @@
}
} else if (aux) {
// Throwable with owner
Level *level = player->level;
Shouldn't this check if this was an arrow? What if another entity has aux data?
That's intended, only throwables have aux values:
So if I egg you to death, it still says that I'm the one who did it.
@ -18,0 +45,4 @@
return get_death_message(player, shooter, true);
} else if (80 <= type_id || type_id <= 82) {
// Throwable without owner
message += " was shot under mysterious circumstances";
A lot of these death messages are duplicated. Is there any chance these could be consolidated into fewer if statements?
Done 👍
@ -18,0 +51,4 @@
message += " was blown apart";
} else if (cause->vtable->isHangingEntity(cause)) {
// Painting?
message += " admired too much art";
When would this ever happen?
No idea, I thought it might be useful in case the paintings ever try to take over.
@ -23,2 +86,3 @@
// Death Message Logic
#define Player_actuallyHurt_injection(type) \
#define Player_death_injections(type) \
static void type##Player_die_injection(type##Player *player, Entity *cause) { \
IIRC when originally implementing death message, that hooking
Player::die
caused some issues on servers.Did you test:
kill
console command)That's why I also hooked
actuallyHurt
as it did before. There are quite a few ways to die without callingPlayer::die
, falling into the void is a notable one. If the player dies without callingPlayer::die
, it will just post the usual " has died". As for your question, yes, all of those have been tested.Seems like TNT shirks responsibility for blowing you up, should be an easy patch. Should it be enabled even when death messages aren't? If so, should it be in misc.h?
If it's only used for death messages, I would put the patch with the death message code. Also do Creepers have the correct death message when blowing players up?
Sounds good 👍
Yes "FG6 was killed by a Creeper", the only explosion source other than TNT are beds, but:
Other than that, all death messages work.
@ -0,0 +1 @@
bool buckets_enabled();
Please add a
#pragma once
.Also, instead of a fancy method containing a
static bool
, why not just use anextern bool buckets_enabled
, or just havebuckets_enabled()
check a variable.just seems a bit over-complicated.
@ -264,14 +336,25 @@ static void FurnaceTileEntity_tick_ItemInstance_setNull_injection(ItemInstance *
}
}
static void Language_injection(__attribute__((unused)) void *null) {
This should probably have a comment before it.
@ -60,1 +134,4 @@
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"
So, uh, what does these patches actually do? Does it set an entity ID somewhere? Because that should probably be in the comment.
@ -0,0 +1,7 @@
extends Item;
size 0x30;
FoodItem
is 3 32-bit ints bigger thanItem
, but only one is accounted fornutrition
. What are the others? This is important becauseFoodItem
is constructed manually and therefore anything not set manually will be left uninitialized.Time for the big green button!