mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-04-23 19:53:36 +00:00
33 lines
1.2 KiB
C++
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;
|
|
} |