4jcraft/targets/minecraft/world/item/MilkBucketItem.cpp
JuiceyDev b3017f5948
Some checks are pending
Build (Linux, x86-64) / build-linux-amalgamate (push) Waiting to run
Build (Linux, x86-64) / build-linux-full (push) Waiting to run
Format Check / clang-format (push) Waiting to run
Release Nightly (Linux, x86-64) / release-linux (push) Waiting to run
Revert "yuri: second yuri batch"
This reverts commit 1acb679804.
2026-04-07 13:06:37 +02:00

43 lines
1.2 KiB
C++

#include "MilkBucketItem.h"
#include <memory>
#include "minecraft/world/entity/player/Abilities.h"
#include "minecraft/world/entity/player/Player.h"
#include "minecraft/world/item/Item.h"
#include "minecraft/world/item/ItemInstance.h"
#include "minecraft/world/level/Level.h"
MilkBucketItem::MilkBucketItem(int id) : Item(id) { setMaxStackSize(1); }
std::shared_ptr<ItemInstance> MilkBucketItem::useTimeDepleted(
std::shared_ptr<ItemInstance> instance, Level* level,
std::shared_ptr<Player> player) {
if (!player->abilities.instabuild) instance->count--;
if (!level->isClientSide) {
player->removeAllEffects();
}
if (instance->count <= 0) {
return std::shared_ptr<ItemInstance>(
new ItemInstance(Item::bucket_empty));
}
return instance;
}
int MilkBucketItem::getUseDuration(std::shared_ptr<ItemInstance> itemInstance) {
return DRINK_DURATION;
}
UseAnim MilkBucketItem::getUseAnimation(
std::shared_ptr<ItemInstance> itemInstance) {
return UseAnim_drink;
}
std::shared_ptr<ItemInstance> MilkBucketItem::use(
std::shared_ptr<ItemInstance> instance, Level* level,
std::shared_ptr<Player> player) {
player->startUsingItem(instance, getUseDuration(instance));
return instance;
}