mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-09-27 20:00:46 +00:00
chore: format Minecraft.World
This commit is contained in:
@@ -7,119 +7,118 @@
|
||||
#include "../../Headers/net.minecraft.world.h"
|
||||
#include "SkullItem.h"
|
||||
|
||||
const unsigned int SkullItem::NAMES[SKULL_COUNT] = {IDS_ITEM_SKULL_SKELETON, IDS_ITEM_SKULL_WITHER, IDS_ITEM_SKULL_ZOMBIE, IDS_ITEM_SKULL_CHARACTER, IDS_ITEM_SKULL_CREEPER};
|
||||
const unsigned int SkullItem::NAMES[SKULL_COUNT] = {
|
||||
IDS_ITEM_SKULL_SKELETON, IDS_ITEM_SKULL_WITHER, IDS_ITEM_SKULL_ZOMBIE,
|
||||
IDS_ITEM_SKULL_CHARACTER, IDS_ITEM_SKULL_CREEPER};
|
||||
|
||||
std::wstring SkullItem::ICON_NAMES[SKULL_COUNT] = {L"skull_skeleton", L"skull_wither", L"skull_zombie", L"skull_char", L"skull_creeper"};
|
||||
std::wstring SkullItem::ICON_NAMES[SKULL_COUNT] = {
|
||||
L"skull_skeleton", L"skull_wither", L"skull_zombie", L"skull_char",
|
||||
L"skull_creeper"};
|
||||
|
||||
SkullItem::SkullItem(int id) : Item(id)
|
||||
{
|
||||
//setItemCategory(CreativeModeTab.TAB_DECORATIONS);
|
||||
setMaxDamage(0);
|
||||
setStackedByData(true);
|
||||
SkullItem::SkullItem(int id) : Item(id) {
|
||||
// setItemCategory(CreativeModeTab.TAB_DECORATIONS);
|
||||
setMaxDamage(0);
|
||||
setStackedByData(true);
|
||||
}
|
||||
|
||||
bool SkullItem::useOn(std::shared_ptr<ItemInstance> instance, std::shared_ptr<Player> player, Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly) //float clickX, float clickY, float clickZ)
|
||||
bool SkullItem::useOn(
|
||||
std::shared_ptr<ItemInstance> instance, std::shared_ptr<Player> player,
|
||||
Level* level, int x, int y, int z, int face, float clickX, float clickY,
|
||||
float clickZ,
|
||||
bool bTestUseOnOnly) // float clickX, float clickY, float clickZ)
|
||||
{
|
||||
if (face == 0) return false;
|
||||
if (!level->getMaterial(x, y, z)->isSolid()) return false;
|
||||
if (face == 0) return false;
|
||||
if (!level->getMaterial(x, y, z)->isSolid()) return false;
|
||||
|
||||
if (face == 1) y++;
|
||||
if (face == 1) y++;
|
||||
|
||||
if (face == 2) z--;
|
||||
if (face == 3) z++;
|
||||
if (face == 4) x--;
|
||||
if (face == 5) x++;
|
||||
if (face == 2) z--;
|
||||
if (face == 3) z++;
|
||||
if (face == 4) x--;
|
||||
if (face == 5) x++;
|
||||
|
||||
//if (!player->mayUseItemAt(x, y, z, face, instance)) return false;
|
||||
if (!player->mayBuild(x, y, z)) return false;
|
||||
// if (!player->mayUseItemAt(x, y, z, face, instance)) return false;
|
||||
if (!player->mayBuild(x, y, z)) return false;
|
||||
|
||||
if (!Tile::skull->mayPlace(level, x, y, z)) return false;
|
||||
if (!Tile::skull->mayPlace(level, x, y, z)) return false;
|
||||
|
||||
if(!bTestUseOnOnly)
|
||||
{
|
||||
level->setTileAndData(x, y, z, Tile::skull_Id, face) ;//, Tile.UPDATE_CLIENTS);
|
||||
if (!bTestUseOnOnly) {
|
||||
level->setTileAndData(x, y, z, Tile::skull_Id,
|
||||
face); //, Tile.UPDATE_CLIENTS);
|
||||
|
||||
int rot = 0;
|
||||
if (face == Facing::UP)
|
||||
{
|
||||
rot = Mth::floor(((player->yRot) * 16) / 360 + 0.5) & 15;
|
||||
}
|
||||
int rot = 0;
|
||||
if (face == Facing::UP) {
|
||||
rot = Mth::floor(((player->yRot) * 16) / 360 + 0.5) & 15;
|
||||
}
|
||||
|
||||
std::shared_ptr<TileEntity> skullTE = level->getTileEntity(x, y, z);
|
||||
std::shared_ptr<SkullTileEntity> skull = std::dynamic_pointer_cast<SkullTileEntity>(skullTE);
|
||||
std::shared_ptr<TileEntity> skullTE = level->getTileEntity(x, y, z);
|
||||
std::shared_ptr<SkullTileEntity> skull =
|
||||
std::dynamic_pointer_cast<SkullTileEntity>(skullTE);
|
||||
|
||||
if (skull != NULL)
|
||||
{
|
||||
std::wstring extra = L"";
|
||||
if (instance->hasTag() && instance->getTag()->contains(L"SkullOwner"))
|
||||
{
|
||||
extra = instance->getTag()->getString(L"SkullOwner");
|
||||
}
|
||||
skull->setSkullType(instance->getAuxValue(), extra);
|
||||
skull->setRotation(rot);
|
||||
((SkullTile *) Tile::skull)->checkMobSpawn(level, x, y, z, skull);
|
||||
}
|
||||
if (skull != NULL) {
|
||||
std::wstring extra = L"";
|
||||
if (instance->hasTag() &&
|
||||
instance->getTag()->contains(L"SkullOwner")) {
|
||||
extra = instance->getTag()->getString(L"SkullOwner");
|
||||
}
|
||||
skull->setSkullType(instance->getAuxValue(), extra);
|
||||
skull->setRotation(rot);
|
||||
((SkullTile*)Tile::skull)->checkMobSpawn(level, x, y, z, skull);
|
||||
}
|
||||
|
||||
instance->count--;
|
||||
}
|
||||
return true;
|
||||
instance->count--;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SkullItem::mayPlace(Level *level, int x, int y, int z, int face, std::shared_ptr<Player> player, std::shared_ptr<ItemInstance> item)
|
||||
{
|
||||
int currentTile = level->getTile(x, y, z);
|
||||
if (currentTile == Tile::topSnow_Id)
|
||||
{
|
||||
face = Facing::UP;
|
||||
}
|
||||
else if (currentTile != Tile::vine_Id && currentTile != Tile::tallgrass_Id && currentTile != Tile::deadBush_Id)
|
||||
{
|
||||
if (face == 0) y--;
|
||||
if (face == 1) y++;
|
||||
if (face == 2) z--;
|
||||
if (face == 3) z++;
|
||||
if (face == 4) x--;
|
||||
if (face == 5) x++;
|
||||
}
|
||||
bool SkullItem::mayPlace(Level* level, int x, int y, int z, int face,
|
||||
std::shared_ptr<Player> player,
|
||||
std::shared_ptr<ItemInstance> item) {
|
||||
int currentTile = level->getTile(x, y, z);
|
||||
if (currentTile == Tile::topSnow_Id) {
|
||||
face = Facing::UP;
|
||||
} else if (currentTile != Tile::vine_Id &&
|
||||
currentTile != Tile::tallgrass_Id &&
|
||||
currentTile != Tile::deadBush_Id) {
|
||||
if (face == 0) y--;
|
||||
if (face == 1) y++;
|
||||
if (face == 2) z--;
|
||||
if (face == 3) z++;
|
||||
if (face == 4) x--;
|
||||
if (face == 5) x++;
|
||||
}
|
||||
|
||||
return level->mayPlace(Tile::skull_Id, x, y, z, false, face, nullptr) ;//, item);
|
||||
return level->mayPlace(Tile::skull_Id, x, y, z, false, face,
|
||||
nullptr); //, item);
|
||||
}
|
||||
|
||||
Icon *SkullItem::getIcon(int itemAuxValue)
|
||||
{
|
||||
if (itemAuxValue < 0 || itemAuxValue >= SKULL_COUNT)
|
||||
{
|
||||
itemAuxValue = 0;
|
||||
}
|
||||
return icons[itemAuxValue];
|
||||
Icon* SkullItem::getIcon(int itemAuxValue) {
|
||||
if (itemAuxValue < 0 || itemAuxValue >= SKULL_COUNT) {
|
||||
itemAuxValue = 0;
|
||||
}
|
||||
return icons[itemAuxValue];
|
||||
}
|
||||
|
||||
int SkullItem::getLevelDataForAuxValue(int auxValue)
|
||||
{
|
||||
return auxValue;
|
||||
int SkullItem::getLevelDataForAuxValue(int auxValue) { return auxValue; }
|
||||
|
||||
unsigned int SkullItem::getDescriptionId(int iData) {
|
||||
if (iData < 0 || iData >= SKULL_COUNT) {
|
||||
iData = 0;
|
||||
}
|
||||
return NAMES[iData];
|
||||
}
|
||||
|
||||
unsigned int SkullItem::getDescriptionId(int iData)
|
||||
{
|
||||
if (iData < 0 || iData >= SKULL_COUNT)
|
||||
{
|
||||
iData = 0;
|
||||
}
|
||||
return NAMES[iData];
|
||||
unsigned int SkullItem::getDescriptionId(
|
||||
std::shared_ptr<ItemInstance> instance) {
|
||||
int auxValue = instance->getAuxValue();
|
||||
if (auxValue < 0 || auxValue >= SKULL_COUNT) {
|
||||
auxValue = 0;
|
||||
}
|
||||
return NAMES[auxValue];
|
||||
}
|
||||
|
||||
unsigned int SkullItem::getDescriptionId(std::shared_ptr<ItemInstance> instance)
|
||||
{
|
||||
int auxValue = instance->getAuxValue();
|
||||
if (auxValue < 0 || auxValue >= SKULL_COUNT)
|
||||
{
|
||||
auxValue = 0;
|
||||
}
|
||||
return NAMES[auxValue];
|
||||
}
|
||||
|
||||
std::wstring SkullItem::getHoverName(std::shared_ptr<ItemInstance> itemInstance)
|
||||
{
|
||||
std::wstring SkullItem::getHoverName(
|
||||
std::shared_ptr<ItemInstance> itemInstance) {
|
||||
#if 0
|
||||
if (itemInstance->getAuxValue() == SkullTileEntity::TYPE_CHAR && itemInstance->hasTag() && itemInstance->getTag()->contains(L"SkullOwner"))
|
||||
{
|
||||
@@ -127,15 +126,13 @@ std::wstring SkullItem::getHoverName(std::shared_ptr<ItemInstance> itemInstance)
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
return Item::getHoverName(itemInstance);
|
||||
}
|
||||
{
|
||||
return Item::getHoverName(itemInstance);
|
||||
}
|
||||
}
|
||||
|
||||
void SkullItem::registerIcons(IconRegister *iconRegister)
|
||||
{
|
||||
for (int i = 0; i < SKULL_COUNT; i++)
|
||||
{
|
||||
icons[i] = iconRegister->registerIcon(ICON_NAMES[i]);
|
||||
}
|
||||
void SkullItem::registerIcons(IconRegister* iconRegister) {
|
||||
for (int i = 0; i < SKULL_COUNT; i++) {
|
||||
icons[i] = iconRegister->registerIcon(ICON_NAMES[i]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user