|
26 | 26 | #include <mc/world/actor/player/Player.h>
|
27 | 27 | #include <mc/world/containers/models/LevelContainerModel.h>
|
28 | 28 | #include <mc/world/events/EventResult.h>
|
| 29 | +#include <mc/world/item/BucketItem.h> |
29 | 30 | #include <mc/world/item/CrossbowItem.h>
|
30 | 31 | #include <mc/world/item/ItemInstance.h>
|
31 | 32 | #include <mc/world/item/registry/ItemStack.h>
|
@@ -828,6 +829,84 @@ LL_TYPE_INSTANCE_HOOK(
|
828 | 829 | origin(id, obj);
|
829 | 830 | }
|
830 | 831 |
|
| 832 | +LL_TYPE_INSTANCE_HOOK( |
| 833 | + PlayerUseBucketPlaceHook, |
| 834 | + HookPriority::Normal, |
| 835 | + BucketItem, |
| 836 | + &BucketItem::_emptyBucket, |
| 837 | + bool, |
| 838 | + BlockSource& region, |
| 839 | + Block const& contents, |
| 840 | + BlockPos const& pos, |
| 841 | + Actor* placer, |
| 842 | + ItemStack const& instance, |
| 843 | + uchar face |
| 844 | +) { |
| 845 | + IF_LISTENED(EVENT_TYPES::onUseBucketPlace) { |
| 846 | + CallEventRtnValue( |
| 847 | + EVENT_TYPES::onUseBucketPlace, |
| 848 | + false, |
| 849 | + PlayerClass::newPlayer(static_cast<Player*>(placer)), |
| 850 | + ItemClass::newItem(&const_cast<ItemStack&>(instance), false), |
| 851 | + BlockClass::newBlock(&contents, &pos, ®ion), |
| 852 | + Number::newNumber(face), |
| 853 | + FloatPos::newPos(pos, region.getDimensionId()) |
| 854 | + ); |
| 855 | + } |
| 856 | + IF_LISTENED_END(EVENT_TYPES::onUseBucketPlace); |
| 857 | + return origin(region, contents, pos, placer, instance, face); |
| 858 | +} |
| 859 | + |
| 860 | +LL_TYPE_INSTANCE_HOOK( |
| 861 | + PlayerUseBucketTakeHook1, |
| 862 | + HookPriority::Normal, |
| 863 | + BucketItem, |
| 864 | + &BucketItem::_takeLiquid, |
| 865 | + bool, |
| 866 | + ItemStack& item, |
| 867 | + Actor& entity, |
| 868 | + BlockPos const& pos |
| 869 | +) { |
| 870 | + IF_LISTENED(EVENT_TYPES::onUseBucketTake) { |
| 871 | + CallEventRtnValue( |
| 872 | + EVENT_TYPES::onUseBucketTake, |
| 873 | + false, |
| 874 | + PlayerClass::newPlayer(&static_cast<Player&>(entity)), |
| 875 | + ItemClass::newItem(&item, false), |
| 876 | + BlockClass::newBlock(&pos, entity.getDimensionId()), |
| 877 | + Number::newNumber(-1), |
| 878 | + FloatPos::newPos(pos, entity.getDimensionId()) |
| 879 | + ); |
| 880 | + } |
| 881 | + IF_LISTENED_END(EVENT_TYPES::onUseBucketTake); |
| 882 | + return origin(item, entity, pos); |
| 883 | +} |
| 884 | + |
| 885 | +LL_TYPE_INSTANCE_HOOK( |
| 886 | + PlayerUseBucketTakeHook2, |
| 887 | + HookPriority::Normal, |
| 888 | + BucketItem, |
| 889 | + &BucketItem::_takePowderSnow, |
| 890 | + bool, |
| 891 | + ItemStack& item, |
| 892 | + Actor& entity, |
| 893 | + BlockPos const& pos |
| 894 | +) { |
| 895 | + IF_LISTENED(EVENT_TYPES::onUseBucketTake) { |
| 896 | + CallEventRtnValue( |
| 897 | + EVENT_TYPES::onUseBucketTake, |
| 898 | + false, |
| 899 | + PlayerClass::newPlayer(&static_cast<Player&>(entity)), |
| 900 | + ItemClass::newItem(&item, false), |
| 901 | + BlockClass::newBlock(&pos, entity.getDimensionId()), |
| 902 | + Number::newNumber(-1), |
| 903 | + FloatPos::newPos(pos, entity.getDimensionId()) |
| 904 | + ); |
| 905 | + } |
| 906 | + IF_LISTENED_END(EVENT_TYPES::onUseBucketTake); |
| 907 | + return origin(item, entity, pos); |
| 908 | +} |
| 909 | + |
831 | 910 | void PlayerStartDestroyBlock() { PlayerStartDestroyHook::hook(); }
|
832 | 911 | void PlayerDropItem() { PlayerDropItemHook::hook(); }
|
833 | 912 | void PlayerOpenContainerEvent() { PlayerOpenContainerHook::hook(); }
|
@@ -872,6 +951,11 @@ void PlayerSleepEvent() { PlayerSleepHook::hook(); }
|
872 | 951 | void PlayerOpenInventoryEvent() { PlayerOpenInventoryHook::hook(); }
|
873 | 952 | void PlayerPullFishingHookEvent() { PlayerPullFishingHook::hook(); }
|
874 | 953 | void ScoreChangedEvent() { ScoreChangedHook::hook(); }
|
| 954 | +void PlayerUseBucketPlaceEvent() { PlayerUseBucketPlaceHook::hook(); } |
| 955 | +void PlayerUseBucketTakeEvent() { |
| 956 | + PlayerUseBucketTakeHook1::hook(); |
| 957 | + PlayerUseBucketTakeHook2::hook(); |
| 958 | +} |
875 | 959 |
|
876 | 960 | // NOLINTEND(cppcoreguidelines-pro-type-reinterpret-cast)
|
877 | 961 | // NOLINTEND(cppcoreguidelines-avoid-non-const-global-variables)
|
|
0 commit comments