4jcraft/Minecraft.World/Items/EnderPearlItem.cpp
2026-03-21 16:39:12 -05:00

33 lines
1.2 KiB
C++

#include "../Platform/stdafx.h"
#include "../Headers/net.minecraft.world.level.h"
#include "../Headers/net.minecraft.world.entity.player.h"
#include "../Headers/net.minecraft.world.entity.projectile.h"
#include "EnderPearlItem.h"
#include "../Util/SoundTypes.h"
EnderpearlItem::EnderpearlItem(int id) : Item(id) { maxStackSize = 16; }
bool EnderpearlItem::TestUse(std::shared_ptr<ItemInstance> itemInstance,
Level* level, std::shared_ptr<Player> player) {
return true;
}
std::shared_ptr<ItemInstance> EnderpearlItem::use(
std::shared_ptr<ItemInstance> instance, Level* level,
std::shared_ptr<Player> player) {
// 4J-PB - Not sure why this was disabled for creative mode, so commenting
// out
// if (player->abilities.instabuild) return instance;
if (player->riding != NULL) return instance;
if (!player->abilities.instabuild) {
instance->count--;
}
level->playEntitySound(player, eSoundType_RANDOM_BOW, 0.5f,
0.4f / (random->nextFloat() * 0.4f + 0.8f));
if (!level->isClientSide) {
level->addEntity(std::shared_ptr<ThrownEnderpearl>(
new ThrownEnderpearl(level, player)));
}
return instance;
}