mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-06-13 04:02:36 +00:00
chore: format Minecraft.World
This commit is contained in:
@@ -11,179 +11,148 @@ const float WallTile::WALL_HEIGHT = 13.0f / 16.0f;
|
||||
const float WallTile::POST_WIDTH = 4.0f / 16.0f;
|
||||
const float WallTile::POST_HEIGHT = 16.0f / 16.0f;
|
||||
|
||||
const unsigned int WallTile::COBBLE_NAMES[2] = { IDS_TILE_COBBLESTONE_WALL,
|
||||
IDS_TILE_COBBLESTONE_WALL_MOSSY,
|
||||
const unsigned int WallTile::COBBLE_NAMES[2] = {
|
||||
IDS_TILE_COBBLESTONE_WALL,
|
||||
IDS_TILE_COBBLESTONE_WALL_MOSSY,
|
||||
};
|
||||
|
||||
WallTile::WallTile(int id, Tile *baseTile) : Tile(id, baseTile->material, false)
|
||||
{
|
||||
setDestroyTime(baseTile->destroySpeed);
|
||||
setExplodeable(baseTile->explosionResistance / 3);
|
||||
setSoundType(baseTile->soundType);
|
||||
WallTile::WallTile(int id, Tile* baseTile)
|
||||
: Tile(id, baseTile->material, false) {
|
||||
setDestroyTime(baseTile->destroySpeed);
|
||||
setExplodeable(baseTile->explosionResistance / 3);
|
||||
setSoundType(baseTile->soundType);
|
||||
}
|
||||
|
||||
Icon *WallTile::getTexture(int face, int data)
|
||||
{
|
||||
if (data == TYPE_MOSSY)
|
||||
{
|
||||
return Tile::mossStone->getTexture(face);
|
||||
}
|
||||
return Tile::stoneBrick->getTexture(face);
|
||||
Icon* WallTile::getTexture(int face, int data) {
|
||||
if (data == TYPE_MOSSY) {
|
||||
return Tile::mossStone->getTexture(face);
|
||||
}
|
||||
return Tile::stoneBrick->getTexture(face);
|
||||
}
|
||||
|
||||
int WallTile::getRenderShape()
|
||||
{
|
||||
return SHAPE_WALL;
|
||||
int WallTile::getRenderShape() { return SHAPE_WALL; }
|
||||
|
||||
bool WallTile::isCubeShaped() { return false; }
|
||||
|
||||
bool WallTile::isPathfindable(LevelSource* level, int x, int y, int z) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WallTile::isCubeShaped()
|
||||
{
|
||||
return false;
|
||||
bool WallTile::isSolidRender(bool isServerLevel) { return false; }
|
||||
|
||||
void WallTile::updateShape(LevelSource* level, int x, int y, int z,
|
||||
int forceData,
|
||||
std::shared_ptr<TileEntity> forceEntity) {
|
||||
bool n = connectsTo(level, x, y, z - 1);
|
||||
bool s = connectsTo(level, x, y, z + 1);
|
||||
bool w = connectsTo(level, x - 1, y, z);
|
||||
bool e = connectsTo(level, x + 1, y, z);
|
||||
|
||||
float west = .5f - POST_WIDTH;
|
||||
float east = .5f + POST_WIDTH;
|
||||
float north = .5f - POST_WIDTH;
|
||||
float south = .5f + POST_WIDTH;
|
||||
float up = POST_HEIGHT;
|
||||
|
||||
if (n) {
|
||||
north = 0;
|
||||
}
|
||||
if (s) {
|
||||
south = 1;
|
||||
}
|
||||
if (w) {
|
||||
west = 0;
|
||||
}
|
||||
if (e) {
|
||||
east = 1;
|
||||
}
|
||||
|
||||
if (n && s && !w && !e) {
|
||||
up = WALL_HEIGHT;
|
||||
west = .5f - WALL_WIDTH;
|
||||
east = .5f + WALL_WIDTH;
|
||||
} else if (!n && !s && w && e) {
|
||||
up = WALL_HEIGHT;
|
||||
north = .5f - WALL_WIDTH;
|
||||
south = .5f + WALL_WIDTH;
|
||||
}
|
||||
|
||||
setShape(west, 0, north, east, up, south);
|
||||
}
|
||||
|
||||
bool WallTile::isPathfindable(LevelSource *level, int x, int y, int z)
|
||||
{
|
||||
return false;
|
||||
AABB* WallTile::getAABB(Level* level, int x, int y, int z) {
|
||||
// 4J-JEV: Changed to avoid race conditions associated with calling update
|
||||
// shape.
|
||||
|
||||
bool n = connectsTo(level, x, y, z - 1);
|
||||
bool s = connectsTo(level, x, y, z + 1);
|
||||
bool w = connectsTo(level, x - 1, y, z);
|
||||
bool e = connectsTo(level, x + 1, y, z);
|
||||
|
||||
float west = .5f - POST_WIDTH;
|
||||
float east = .5f + POST_WIDTH;
|
||||
float north = .5f - POST_WIDTH;
|
||||
float south = .5f + POST_WIDTH;
|
||||
float up = POST_HEIGHT;
|
||||
|
||||
if (n) {
|
||||
north = 0;
|
||||
}
|
||||
if (s) {
|
||||
south = 1;
|
||||
}
|
||||
if (w) {
|
||||
west = 0;
|
||||
}
|
||||
if (e) {
|
||||
east = 1;
|
||||
}
|
||||
|
||||
/* 4J-JEV:
|
||||
Stopping the width changing here, it's causing cows/mobs/passers-by
|
||||
to 'jump' up when they are pressed against the wall and then the wall
|
||||
section is upgraded to a wall post expanding the bounding box. It's only
|
||||
a 1/16 of a block difference, it shouldn't matter if we leave it a little
|
||||
larger.
|
||||
*/
|
||||
if (n && s && !w && !e) {
|
||||
up = WALL_HEIGHT;
|
||||
// west = .5f - WALL_WIDTH;
|
||||
// east = .5f + WALL_WIDTH;
|
||||
} else if (!n && !s && w && e) {
|
||||
up = WALL_HEIGHT;
|
||||
// north = .5f - WALL_WIDTH;
|
||||
// south = .5f + WALL_WIDTH;
|
||||
}
|
||||
|
||||
return AABB::newTemp(x + west, y, z + north, x + east, y + 1.5f, z + south);
|
||||
}
|
||||
|
||||
bool WallTile::isSolidRender(bool isServerLevel)
|
||||
{
|
||||
return false;
|
||||
bool WallTile::connectsTo(LevelSource* level, int x, int y, int z) {
|
||||
int tile = level->getTile(x, y, z);
|
||||
if (tile == id || tile == Tile::fenceGate_Id) {
|
||||
return true;
|
||||
}
|
||||
Tile* tileInstance = Tile::tiles[tile];
|
||||
if (tileInstance != NULL) {
|
||||
if (tileInstance->material->isSolidBlocking() &&
|
||||
tileInstance->isCubeShaped()) {
|
||||
return tileInstance->material != Material::vegetable;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void WallTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, std::shared_ptr<TileEntity> forceEntity)
|
||||
{
|
||||
bool n = connectsTo(level, x, y, z - 1);
|
||||
bool s = connectsTo(level, x, y, z + 1);
|
||||
bool w = connectsTo(level, x - 1, y, z);
|
||||
bool e = connectsTo(level, x + 1, y, z);
|
||||
int WallTile::getSpawnResourcesAuxValue(int data) { return data; }
|
||||
|
||||
float west = .5f - POST_WIDTH;
|
||||
float east = .5f + POST_WIDTH;
|
||||
float north = .5f - POST_WIDTH;
|
||||
float south = .5f + POST_WIDTH;
|
||||
float up = POST_HEIGHT;
|
||||
|
||||
if (n)
|
||||
{
|
||||
north = 0;
|
||||
}
|
||||
if (s)
|
||||
{
|
||||
south = 1;
|
||||
}
|
||||
if (w)
|
||||
{
|
||||
west = 0;
|
||||
}
|
||||
if (e)
|
||||
{
|
||||
east = 1;
|
||||
}
|
||||
|
||||
if (n && s && !w && !e)
|
||||
{
|
||||
up = WALL_HEIGHT;
|
||||
west = .5f - WALL_WIDTH;
|
||||
east = .5f + WALL_WIDTH;
|
||||
}
|
||||
else if (!n && !s && w && e)
|
||||
{
|
||||
up = WALL_HEIGHT;
|
||||
north = .5f - WALL_WIDTH;
|
||||
south = .5f + WALL_WIDTH;
|
||||
}
|
||||
|
||||
setShape(west, 0, north, east, up, south);
|
||||
bool WallTile::shouldRenderFace(LevelSource* level, int x, int y, int z,
|
||||
int face) {
|
||||
if (face == Facing::DOWN) {
|
||||
return Tile::shouldRenderFace(level, x, y, z, face);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
AABB *WallTile::getAABB(Level *level, int x, int y, int z)
|
||||
{
|
||||
// 4J-JEV: Changed to avoid race conditions associated with calling update shape.
|
||||
|
||||
bool n = connectsTo(level, x, y, z - 1);
|
||||
bool s = connectsTo(level, x, y, z + 1);
|
||||
bool w = connectsTo(level, x - 1, y, z);
|
||||
bool e = connectsTo(level, x + 1, y, z);
|
||||
|
||||
float west = .5f - POST_WIDTH;
|
||||
float east = .5f + POST_WIDTH;
|
||||
float north = .5f - POST_WIDTH;
|
||||
float south = .5f + POST_WIDTH;
|
||||
float up = POST_HEIGHT;
|
||||
|
||||
if (n)
|
||||
{
|
||||
north = 0;
|
||||
}
|
||||
if (s)
|
||||
{
|
||||
south = 1;
|
||||
}
|
||||
if (w)
|
||||
{
|
||||
west = 0;
|
||||
}
|
||||
if (e)
|
||||
{
|
||||
east = 1;
|
||||
}
|
||||
|
||||
/* 4J-JEV:
|
||||
Stopping the width changing here, it's causing cows/mobs/passers-by to 'jump' up when they are pressed against the
|
||||
wall and then the wall section is upgraded to a wall post expanding the bounding box.
|
||||
It's only a 1/16 of a block difference, it shouldn't matter if we leave it a little larger.
|
||||
*/
|
||||
if (n && s && !w && !e)
|
||||
{
|
||||
up = WALL_HEIGHT;
|
||||
//west = .5f - WALL_WIDTH;
|
||||
//east = .5f + WALL_WIDTH;
|
||||
}
|
||||
else if (!n && !s && w && e)
|
||||
{
|
||||
up = WALL_HEIGHT;
|
||||
//north = .5f - WALL_WIDTH;
|
||||
//south = .5f + WALL_WIDTH;
|
||||
}
|
||||
|
||||
return AABB::newTemp(x+west, y, z+north, x+east, y+1.5f, z+south);
|
||||
}
|
||||
|
||||
|
||||
bool WallTile::connectsTo(LevelSource *level, int x, int y, int z)
|
||||
{
|
||||
int tile = level->getTile(x, y, z);
|
||||
if (tile == id || tile == Tile::fenceGate_Id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
Tile *tileInstance = Tile::tiles[tile];
|
||||
if (tileInstance != NULL)
|
||||
{
|
||||
if (tileInstance->material->isSolidBlocking() && tileInstance->isCubeShaped())
|
||||
{
|
||||
return tileInstance->material != Material::vegetable;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int WallTile::getSpawnResourcesAuxValue(int data)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
bool WallTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face)
|
||||
{
|
||||
if (face == Facing::DOWN)
|
||||
{
|
||||
return Tile::shouldRenderFace(level, x, y, z, face);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void WallTile::registerIcons(IconRegister *iconRegister)
|
||||
{
|
||||
// None
|
||||
void WallTile::registerIcons(IconRegister* iconRegister) {
|
||||
// None
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user