mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-06-02 20:04:47 +00:00
chore: format Minecraft.World
This commit is contained in:
@@ -7,111 +7,89 @@
|
||||
#include "../Headers/net.minecraft.h"
|
||||
#include "AnvilTile.h"
|
||||
|
||||
const unsigned int AnvilTile::ANVIL_NAMES[ANVIL_NAMES_LENGTH] = { IDS_TILE_ANVIL_INTACT,
|
||||
IDS_TILE_ANVIL_SLIGHTLYDAMAGED,
|
||||
IDS_TILE_ANVIL_VERYDAMAGED,
|
||||
};
|
||||
|
||||
|
||||
std::wstring AnvilTile::TEXTURE_DAMAGE_NAMES[ANVIL_NAMES_LENGTH] = {
|
||||
L"anvil_top", L"anvil_top_damaged_1", L"anvil_top_damaged_2"
|
||||
const unsigned int AnvilTile::ANVIL_NAMES[ANVIL_NAMES_LENGTH] = {
|
||||
IDS_TILE_ANVIL_INTACT,
|
||||
IDS_TILE_ANVIL_SLIGHTLYDAMAGED,
|
||||
IDS_TILE_ANVIL_VERYDAMAGED,
|
||||
};
|
||||
|
||||
AnvilTile::AnvilTile(int id) : HeavyTile(id, Material::heavyMetal, false)
|
||||
{
|
||||
part = PART_BASE;
|
||||
setLightBlock(0);
|
||||
icons = NULL;
|
||||
std::wstring AnvilTile::TEXTURE_DAMAGE_NAMES[ANVIL_NAMES_LENGTH] = {
|
||||
L"anvil_top", L"anvil_top_damaged_1", L"anvil_top_damaged_2"};
|
||||
|
||||
AnvilTile::AnvilTile(int id) : HeavyTile(id, Material::heavyMetal, false) {
|
||||
part = PART_BASE;
|
||||
setLightBlock(0);
|
||||
icons = NULL;
|
||||
}
|
||||
|
||||
bool AnvilTile::isCubeShaped()
|
||||
{
|
||||
return false;
|
||||
bool AnvilTile::isCubeShaped() { return false; }
|
||||
|
||||
bool AnvilTile::isSolidRender(bool isServerLevel) { return false; }
|
||||
|
||||
Icon* AnvilTile::getTexture(int face, int data) {
|
||||
if (part == PART_TOP && face == Facing::UP) {
|
||||
int damage = (data >> 2) % ANVIL_NAMES_LENGTH;
|
||||
return icons[damage];
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
bool AnvilTile::isSolidRender(bool isServerLevel)
|
||||
{
|
||||
return false;
|
||||
void AnvilTile::registerIcons(IconRegister* iconRegister) {
|
||||
icon = iconRegister->registerIcon(L"anvil_base");
|
||||
icons = new Icon*[ANVIL_NAMES_LENGTH];
|
||||
|
||||
for (int i = 0; i < ANVIL_NAMES_LENGTH; i++) {
|
||||
icons[i] = iconRegister->registerIcon(TEXTURE_DAMAGE_NAMES[i]);
|
||||
}
|
||||
}
|
||||
|
||||
Icon *AnvilTile::getTexture(int face, int data)
|
||||
{
|
||||
if (part == PART_TOP && face == Facing::UP)
|
||||
{
|
||||
int damage = (data >> 2) % ANVIL_NAMES_LENGTH;
|
||||
return icons[damage];
|
||||
}
|
||||
return icon;
|
||||
void AnvilTile::setPlacedBy(Level* level, int x, int y, int z,
|
||||
std::shared_ptr<Mob> by) {
|
||||
int dir = (Mth::floor(by->yRot * 4 / (360) + 0.5)) & 3;
|
||||
int dmg = level->getData(x, y, z) >> 2;
|
||||
|
||||
dir = ++dir % 4;
|
||||
if (dir == 0) level->setData(x, y, z, Direction::NORTH | (dmg << 2));
|
||||
if (dir == 1) level->setData(x, y, z, Direction::EAST | (dmg << 2));
|
||||
if (dir == 2) level->setData(x, y, z, Direction::SOUTH | (dmg << 2));
|
||||
if (dir == 3) level->setData(x, y, z, Direction::WEST | (dmg << 2));
|
||||
}
|
||||
|
||||
void AnvilTile::registerIcons(IconRegister *iconRegister)
|
||||
{
|
||||
icon = iconRegister->registerIcon(L"anvil_base");
|
||||
icons = new Icon*[ANVIL_NAMES_LENGTH];
|
||||
|
||||
for (int i = 0; i < ANVIL_NAMES_LENGTH; i++)
|
||||
{
|
||||
icons[i] = iconRegister->registerIcon(TEXTURE_DAMAGE_NAMES[i]);
|
||||
}
|
||||
bool AnvilTile::use(Level* level, int x, int y, int z,
|
||||
std::shared_ptr<Player> player, int clickedFace,
|
||||
float clickX, float clickY, float clickZ, bool soundOnly) {
|
||||
if (level->isClientSide) {
|
||||
return true;
|
||||
}
|
||||
player->startRepairing(x, y, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
void AnvilTile::setPlacedBy(Level *level, int x, int y, int z, std::shared_ptr<Mob> by)
|
||||
{
|
||||
int dir = (Mth::floor(by->yRot * 4 / (360) + 0.5)) & 3;
|
||||
int dmg = level->getData(x, y, z) >> 2;
|
||||
int AnvilTile::getRenderShape() { return SHAPE_ANVIL; }
|
||||
|
||||
dir = ++dir % 4;
|
||||
if (dir == 0) level->setData(x, y, z, Direction::NORTH | (dmg << 2));
|
||||
if (dir == 1) level->setData(x, y, z, Direction::EAST | (dmg << 2));
|
||||
if (dir == 2) level->setData(x, y, z, Direction::SOUTH | (dmg << 2));
|
||||
if (dir == 3) level->setData(x, y, z, Direction::WEST | (dmg << 2));
|
||||
int AnvilTile::getSpawnResourcesAuxValue(int data) { return data >> 2; }
|
||||
|
||||
void AnvilTile::updateShape(LevelSource* level, int x, int y, int z,
|
||||
int forceData,
|
||||
std::shared_ptr<TileEntity> forceEntity) {
|
||||
int dir = level->getData(x, y, z) & 3;
|
||||
|
||||
if (dir == Direction::EAST || dir == Direction::WEST) {
|
||||
setShape(0, 0, 2 / 16.0f, 1, 1, 1 - 2 / 16.0f);
|
||||
} else {
|
||||
setShape(2 / 16.0f, 0, 0, 1 - 2 / 16.0f, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
bool AnvilTile::use(Level *level, int x, int y, int z, std::shared_ptr<Player> player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly)
|
||||
{
|
||||
if (level->isClientSide)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
player->startRepairing(x, y, z);
|
||||
return true;
|
||||
void AnvilTile::falling(std::shared_ptr<FallingTile> entity) {
|
||||
entity->setHurtsEntities(true);
|
||||
}
|
||||
|
||||
int AnvilTile::getRenderShape()
|
||||
{
|
||||
return SHAPE_ANVIL;
|
||||
void AnvilTile::onLand(Level* level, int xt, int yt, int zt, int data) {
|
||||
level->levelEvent(LevelEvent::SOUND_ANVIL_LAND, xt, yt, zt, 0);
|
||||
}
|
||||
|
||||
int AnvilTile::getSpawnResourcesAuxValue(int data)
|
||||
{
|
||||
return data >> 2;
|
||||
}
|
||||
|
||||
void AnvilTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, std::shared_ptr<TileEntity> forceEntity)
|
||||
{
|
||||
int dir = level->getData(x, y, z) & 3;
|
||||
|
||||
if (dir == Direction::EAST || dir == Direction::WEST)
|
||||
{
|
||||
setShape(0, 0, 2 / 16.0f, 1, 1, 1 - 2 / 16.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
setShape(2 / 16.0f, 0, 0, 1 - 2 / 16.0f, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void AnvilTile::falling(std::shared_ptr<FallingTile> entity)
|
||||
{
|
||||
entity->setHurtsEntities(true);
|
||||
}
|
||||
|
||||
void AnvilTile::onLand(Level *level, int xt, int yt, int zt, int data)
|
||||
{
|
||||
level->levelEvent(LevelEvent::SOUND_ANVIL_LAND, xt, yt, zt, 0);
|
||||
}
|
||||
|
||||
bool AnvilTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face)
|
||||
{
|
||||
return true;
|
||||
bool AnvilTile::shouldRenderFace(LevelSource* level, int x, int y, int z,
|
||||
int face) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user