b3feddfef3
* try to resolve merge conflict * feat: TU19 (Dec 2014) Features & Content (#32) * December 2014 files * Working release build * Fix compilation issues * Add sound to Windows64Media * Add DLC content and force Tutorial DLC * Revert "Add DLC content and force Tutorial DLC" This reverts commit 97a43994725008e35fceb984d5549df9c8cea470. * Disable broken light packing * Disable breakpoint during DLC texture map load Allows DLC loading but the DLC textures are still broken * Fix post build not working * ... * fix vs2022 build * fix cmake build --------- Co-authored-by: Loki <lokirautio@gmail.com>
99 lines
2.0 KiB
C++
99 lines
2.0 KiB
C++
#include "stdafx.h"
|
|
#include "net.minecraft.world.phys.h"
|
|
#include "net.minecraft.world.entity.player.h"
|
|
#include "net.minecraft.world.level.h"
|
|
#include "net.minecraft.world.level.material.h"
|
|
#include "net.minecraft.world.item.h"
|
|
#include "BottleItem.h"
|
|
|
|
BottleItem::BottleItem(int id) : Item(id)
|
|
{
|
|
}
|
|
|
|
Icon *BottleItem::getIcon(int auxValue)
|
|
{
|
|
return Item::potion->getIcon(0);
|
|
}
|
|
|
|
shared_ptr<ItemInstance> BottleItem::use(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player)
|
|
{
|
|
HitResult *hr = getPlayerPOVHitResult(level, player, true);
|
|
if (hr == NULL) return itemInstance;
|
|
|
|
if (hr->type == HitResult::TILE)
|
|
{
|
|
int xt = hr->x;
|
|
int yt = hr->y;
|
|
int zt = hr->z;
|
|
delete hr;
|
|
|
|
if (!level->mayInteract(player, xt, yt, zt, 0))
|
|
{
|
|
return itemInstance;
|
|
}
|
|
if (!player->mayUseItemAt(xt, yt, zt, hr->f, itemInstance))
|
|
{
|
|
return itemInstance;
|
|
}
|
|
if (level->getMaterial(xt, yt, zt) == Material::water)
|
|
{
|
|
itemInstance->count--;
|
|
if (itemInstance->count <= 0)
|
|
{
|
|
return shared_ptr<ItemInstance>( new ItemInstance( (Item *)Item::potion) );
|
|
}
|
|
else
|
|
{
|
|
if (!player->inventory->add(shared_ptr<ItemInstance>( new ItemInstance( (Item *)Item::potion) )))
|
|
{
|
|
player->drop( shared_ptr<ItemInstance>( new ItemInstance(Item::potion_Id, 1, 0) ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
delete hr;
|
|
}
|
|
|
|
return itemInstance;
|
|
}
|
|
|
|
// 4J-PB - added to allow tooltips
|
|
bool BottleItem::TestUse(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player)
|
|
{
|
|
HitResult *hr = getPlayerPOVHitResult(level, player, true);
|
|
if (hr == NULL) return false;
|
|
|
|
if (hr->type == HitResult::TILE)
|
|
{
|
|
int xt = hr->x;
|
|
int yt = hr->y;
|
|
int zt = hr->z;
|
|
delete hr;
|
|
|
|
if (!level->mayInteract(player, xt, yt, zt, 0))
|
|
{
|
|
return false;
|
|
}
|
|
if (!player->mayUseItemAt(xt, yt, zt, hr->f, itemInstance))
|
|
{
|
|
return false;
|
|
}
|
|
if (level->getMaterial(xt, yt, zt) == Material::water)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
delete hr;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
void BottleItem::registerIcons(IconRegister *iconRegister)
|
|
{
|
|
// We reuse another texture.
|
|
} |