Improve Creative Restrictions Mod

This commit is contained in:
TheBrokenRail 2024-05-09 19:03:48 -04:00
parent e1f0787e48
commit eeef63d9ef
6 changed files with 49 additions and 23 deletions

View File

@ -16,6 +16,13 @@
* Add `Optimized Chunk Sorting` Feature Flag (Enabled By Default) * Add `Optimized Chunk Sorting` Feature Flag (Enabled By Default)
* Add `Add Cake` Feature Flag (Enabled By Default) * Add `Add Cake` Feature Flag (Enabled By Default)
* Add `Add Reborn Info To Options` Feature Flag (Enabled By Default) * Add `Add Reborn Info To Options` Feature Flag (Enabled By Default)
* Add `Track FPS` Feature Flag (Disabled By Default)
* Split Up `Remove Creative Mode Restrictions` Feature Flag
* `Remove Creative Mode Restrictions` (Disabled By Default)
* `Display Slot Count In Creative Mode` (Disabled By Default)
* `Force Survival Mode Inventory UI` (Disabled By Default)
* `Force Survival Mode Inventory Behavior` (Disabled By Default)
* `Maximize Creative Mode Inventory Stack Size` (Disabled By Default)
* Add Milk Buckets * Add Milk Buckets
* Implement Crafting Remainders * Implement Crafting Remainders
* Improve Death Messages * Improve Death Messages

View File

@ -8,6 +8,10 @@ TRUE Fix Sign Placement
TRUE Show Block Outlines TRUE Show Block Outlines
FALSE Expand Creative Mode Inventory FALSE Expand Creative Mode Inventory
FALSE Remove Creative Mode Restrictions FALSE Remove Creative Mode Restrictions
FALSE Display Slot Count In Creative Mode
FALSE Force Survival Mode Inventory UI
FALSE Force Survival Mode Inventory Behavior
FALSE Maximize Creative Mode Inventory Stack Size
TRUE Animated Water TRUE Animated Water
TRUE Animated Lava TRUE Animated Lava
TRUE Animated Fire TRUE Animated Fire

View File

@ -22,7 +22,6 @@ void _overwrite_call(const char *file, int line, void *start, void *target);
} }
#define _setup_fancy_overwrite(start, name, target) \ #define _setup_fancy_overwrite(start, name, target) \
_check_if_method_is_new(name); \
static name##_t _original_for_##target = start; \ static name##_t _original_for_##target = start; \
static name##_t _helper_for_##target = __overwrite_helper_for_##name(target, _original_for_##target) static name##_t _helper_for_##target = __overwrite_helper_for_##name(target, _original_for_##target)
@ -38,6 +37,7 @@ void *_overwrite_calls(const char *file, int line, void *start, void *target);
// Replace All Calls To Virtual Method start With target // Replace All Calls To Virtual Method start With target
#define overwrite_virtual_calls(start, target) \ #define overwrite_virtual_calls(start, target) \
{ \ { \
_check_if_method_is_new(start); \
_setup_fancy_overwrite(*start##_vtable_addr, start, target); \ _setup_fancy_overwrite(*start##_vtable_addr, start, target); \
overwrite_calls_manual((void *) *start##_vtable_addr, (void *) _helper_for_##target); \ overwrite_calls_manual((void *) *start##_vtable_addr, (void *) _helper_for_##target); \
} }

View File

@ -127,38 +127,49 @@ void init_creative() {
} }
// Remove Creative Mode Restrictions (Opening Chests, Crafting, Etc) // Remove Creative Mode Restrictions (Opening Chests, Crafting, Etc)
if (feature_has("Remove Creative Mode Restrictions", server_enabled)) {
unsigned char nop_patch[4] = {0x00, 0xf0, 0x20, 0xe3}; // "nop" unsigned char nop_patch[4] = {0x00, 0xf0, 0x20, 0xe3}; // "nop"
if (feature_has("Remove Creative Mode Restrictions", server_enabled)) {
// Remove Restrictions // Remove Restrictions
patch((void *) 0x43ee8, nop_patch); patch((void *) 0x43ee8, nop_patch);
patch((void *) 0x43f3c, nop_patch); patch((void *) 0x43f3c, nop_patch);
patch((void *) 0x43f8c, nop_patch); patch((void *) 0x43f8c, nop_patch);
patch((void *) 0x43fd8, nop_patch); patch((void *) 0x43fd8, nop_patch);
patch((void *) 0x99010, nop_patch); patch((void *) 0x99010, nop_patch);
// Fix UI
patch((void *) 0x341c0, nop_patch);
patch((void *) 0x3adb4, nop_patch);
patch((void *) 0x3b374, nop_patch);
// Fix Inventory
patch((void *) 0x8d080, nop_patch);
patch((void *) 0x8d090, nop_patch);
patch((void *) 0x91d48, nop_patch);
patch((void *) 0x92098, nop_patch);
unsigned char inv_creative_check_r3_patch[4] = {0x03, 0x00, 0x53, 0xe1}; // "cmp r3, r3"
patch((void *) 0x923c0, inv_creative_check_r3_patch);
patch((void *) 0x92828, nop_patch);
patch((void *) 0x92830, nop_patch);
// Display Slot Count
patch((void *) 0x1e3f4, nop_patch);
unsigned char slot_count_patch[4] = {0x18, 0x00, 0x00, 0xea}; // "b 0x27110"
patch((void *) 0x270a8, slot_count_patch);
patch((void *) 0x33954, nop_patch);
// Maximize Creative Inventory Stack Size
unsigned char maximize_stack_patch[4] = {0xff, 0xc0, 0xa0, 0xe3}; // "mov r12, 0xff"
patch((void *) 0x8e104, maximize_stack_patch);
// Allow Nether Reactor // Allow Nether Reactor
patch((void *) 0xc0290, nop_patch); patch((void *) 0xc0290, nop_patch);
// Disable Other Restrictions // Disable Other Restrictions
is_restricted = 0; is_restricted = 0;
} }
// Inventory Behavior
if (feature_has("Force Survival Mode Inventory Behavior", server_enabled)) {
patch((void *) 0x8d080, nop_patch); // Inventory::add
patch((void *) 0x92828, nop_patch); // FillingContainer::add
patch((void *) 0x91d48, nop_patch); // FillingContainer::hasResource
patch((void *) 0x92098, nop_patch); // FillingContainer::removeResource(int)
unsigned char inv_creative_check_r3_patch[4] = {0x03, 0x00, 0x53, 0xe1}; // "cmp r3, r3"
patch((void *) 0x923c0, inv_creative_check_r3_patch); // FillingContainer::removeResource(ItemInstance const&, bool)
}
// "Craft" And "Armor" Buttons
if (feature_has("Force Survival Mode Inventory UI", server_enabled)) {
patch((void *) 0x341c0, nop_patch); // Add "Armor" Button To Classic Inventory
unsigned char inv_creative_check_r5_patch[4] = {0x05, 0x00, 0x55, 0xe1}; // "cmp r5, r5"
patch((void *) 0x3adb0, inv_creative_check_r5_patch); // Reposition "Select blocks" In Touch Inventory
patch((void *) 0x3b374, nop_patch); // Add "Armor" And "Craft" Buttons To Touch Inventory
}
// Display Slot Count
if (feature_has("Display Slot Count In Creative Mode", server_enabled)) {
patch((void *) 0x1e3f4, nop_patch);
unsigned char slot_count_patch[4] = {0x18, 0x00, 0x00, 0xea}; // "b 0x27110"
patch((void *) 0x270a8, slot_count_patch);
patch((void *) 0x33954, nop_patch);
}
// Maximize Creative Inventory Stack Size
if (feature_has("Maximize Creative Mode Inventory Stack Size", server_enabled)) {
unsigned char maximize_stack_patch[4] = {0xff, 0xc0, 0xa0, 0xe3}; // "mov r12, 0xff"
patch((void *) 0x8e104, maximize_stack_patch);
}
} }

View File

@ -1,5 +1,7 @@
extends Container; extends Container;
vtable 0x10e250;
method void addItem(ItemInstance *item_instance) = 0x92aa0; method void addItem(ItemInstance *item_instance) = 0x92aa0;
method void clearSlot(int slot) = 0x922f8; method void clearSlot(int slot) = 0x922f8;
method void release(int slot) = 0x92058; method void release(int slot) = 0x92058;

View File

@ -1,5 +1,7 @@
extends FillingContainer; extends FillingContainer;
vtable 0x10de18;
method void selectSlot(int slot) = 0x8d13c; method void selectSlot(int slot) = 0x8d13c;
// It's just FillingContainer_getLinked but with selectedSlot as slot // It's just FillingContainer_getLinked but with selectedSlot as slot
method ItemInstance *getSelected() = 0x8d134; method ItemInstance *getSelected() = 0x8d134;