mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-07 16:07:12 +00:00
refactor: make Tile::getTileAABB return AABB
This commit is contained in:
parent
7158fd398f
commit
ddfe9b3d48
|
|
@ -2482,7 +2482,7 @@ void LevelRenderer::renderHitOutline(std::shared_ptr<Player> player,
|
|||
|
||||
AABB bb = Tile::tiles[tileId]
|
||||
->getTileAABB(level[iPad], h->x, h->y, h->z)
|
||||
->grow(ss, ss, ss)
|
||||
.grow(ss, ss, ss)
|
||||
.move(-xo, -yo, -zo);
|
||||
|
||||
render(&bb);
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ std::optional<AABB> CactusTile::getAABB(Level* level, int x, int y, int z) {
|
|||
return AABB{x + r, static_cast<double>(y), z + r, x + 1 - r, y + 1 - r, z + 1 - r};
|
||||
}
|
||||
|
||||
AABB* CactusTile::getTileAABB(Level* level, int x, int y, int z) {
|
||||
AABB CactusTile::getTileAABB(Level* level, int x, int y, int z) {
|
||||
float r = 1 / 16.0f;
|
||||
return AABB::newTemp(x + r, y, z + r, x + 1 - r, y + 1, z + 1 - r);
|
||||
return AABB(x + r, y, z + r, x + 1 - r, y + 1, z + 1 - r);
|
||||
}
|
||||
|
||||
Icon* CactusTile::getTexture(int face, int data) {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ protected:
|
|||
public:
|
||||
virtual void tick(Level* level, int x, int y, int z, Random* random);
|
||||
virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
|
||||
virtual AABB* getTileAABB(Level* level, int x, int y, int z);
|
||||
virtual AABB getTileAABB(Level* level, int x, int y, int z);
|
||||
virtual Icon* getTexture(int face, int data);
|
||||
virtual bool isCubeShaped();
|
||||
virtual bool isSolidRender(bool isServerLevel = false);
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ std::optional<AABB> CakeTile::getAABB(Level* level, int x, int y, int z) {
|
|||
return AABB{x + r2, static_cast<double>(y), z + r, x + 1 - r, y + h - r, z + 1 - r};
|
||||
}
|
||||
|
||||
AABB* CakeTile::getTileAABB(Level* level, int x, int y, int z) {
|
||||
AABB CakeTile::getTileAABB(Level* level, int x, int y, int z) {
|
||||
int d = level->getData(x, y, z);
|
||||
float r = 1 / 16.0f;
|
||||
float r2 = (1 + d * 2) / 16.0f;
|
||||
float h = 8 / 16.0f;
|
||||
return AABB::newTemp(x + r2, y, z + r, x + 1 - r, y + h, z + 1 - r);
|
||||
return AABB(x + r2, y, z + r, x + 1 - r, y + h, z + 1 - r);
|
||||
}
|
||||
|
||||
Icon* CakeTile::getTexture(int face, int data) {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ protected:
|
|||
TileEntity>()); // 4J added forceData, forceEntity param
|
||||
virtual void updateDefaultShape();
|
||||
virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
|
||||
virtual AABB* getTileAABB(Level* level, int x, int y, int z);
|
||||
virtual AABB getTileAABB(Level* level, int x, int y, int z);
|
||||
virtual Icon* getTexture(int face, int data);
|
||||
//@Override
|
||||
void registerIcons(IconRegister* iconRegister);
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ std::optional<AABB> CocoaTile::getAABB(Level* level, int x, int y, int z) {
|
|||
return DirectionalTile::getAABB(level, x, y, z);
|
||||
}
|
||||
|
||||
AABB* CocoaTile::getTileAABB(Level* level, int x, int y, int z) {
|
||||
AABB CocoaTile::getTileAABB(Level* level, int x, int y, int z) {
|
||||
updateShape(level, x, y, z);
|
||||
return DirectionalTile::getTileAABB(level, x, y, z);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public:
|
|||
virtual bool isCubeShaped();
|
||||
virtual bool isSolidRender(bool isServerLevel = false);
|
||||
virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
|
||||
virtual AABB* getTileAABB(Level* level, int x, int y, int z);
|
||||
virtual AABB getTileAABB(Level* level, int x, int y, int z);
|
||||
virtual void updateShape(LevelSource* level, int x, int y, int z,
|
||||
int forceData = -1,
|
||||
std::shared_ptr<TileEntity> forceEntity =
|
||||
|
|
|
|||
|
|
@ -85,10 +85,9 @@ bool DoorTile::isCubeShaped() { return false; }
|
|||
|
||||
int DoorTile::getRenderShape() { return Tile::SHAPE_DOOR; }
|
||||
|
||||
AABB* DoorTile::getTileAABB(Level* level, int x, int y, int z) {
|
||||
AABB DoorTile::getTileAABB(Level* level, int x, int y, int z) {
|
||||
updateShape(level, x, y, z);
|
||||
AABB* retval = Tile::getTileAABB(level, x, y, z);
|
||||
return retval;
|
||||
return Tile::getTileAABB(level, x, y, z);
|
||||
}
|
||||
|
||||
std::optional<AABB> DoorTile::getAABB(Level* level, int x, int y, int z) {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public:
|
|||
virtual bool isSolidRender(bool isServerLevel = false);
|
||||
virtual bool isCubeShaped();
|
||||
virtual int getRenderShape();
|
||||
virtual AABB* getTileAABB(Level* level, int x, int y, int z);
|
||||
virtual AABB getTileAABB(Level* level, int x, int y, int z);
|
||||
virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
|
||||
virtual void updateShape(
|
||||
LevelSource* level, int x, int y, int z, int forceData = -1,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ std::optional<AABB> LadderTile::getAABB(Level* level, int x, int y, int z) {
|
|||
return Tile::getAABB(level, x, y, z);
|
||||
}
|
||||
|
||||
AABB* LadderTile::getTileAABB(Level* level, int x, int y, int z) {
|
||||
AABB LadderTile::getTileAABB(Level* level, int x, int y, int z) {
|
||||
updateShape(level, x, y, z);
|
||||
return Tile::getTileAABB(level, x, y, z);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ protected:
|
|||
|
||||
public:
|
||||
virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
|
||||
virtual AABB* getTileAABB(Level* level, int x, int y, int z);
|
||||
virtual AABB getTileAABB(Level* level, int x, int y, int z);
|
||||
virtual void updateShape(
|
||||
LevelSource* level, int x, int y, int z, int forceData = -1,
|
||||
std::shared_ptr<TileEntity> forceEntity = std::shared_ptr<
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ void SignTile::updateDefaultShape() {
|
|||
|
||||
std::optional<AABB> SignTile::getAABB(Level* level, int x, int y, int z) { return std::nullopt; }
|
||||
|
||||
AABB* SignTile::getTileAABB(Level* level, int x, int y, int z) {
|
||||
AABB SignTile::getTileAABB(Level* level, int x, int y, int z) {
|
||||
updateShape(level, x, y, z);
|
||||
return BaseEntityTile::getTileAABB(level, x, y, z);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public:
|
|||
Icon* getTexture(int face, int data);
|
||||
virtual void updateDefaultShape();
|
||||
std::optional<AABB> getAABB(Level* level, int x, int y, int z);
|
||||
AABB* getTileAABB(Level* level, int x, int y, int z);
|
||||
AABB getTileAABB(Level* level, int x, int y, int z);
|
||||
void updateShape(LevelSource* level, int x, int y, int z,
|
||||
int forceData = -1,
|
||||
std::shared_ptr<TileEntity> forceEntity =
|
||||
|
|
|
|||
|
|
@ -326,7 +326,7 @@ Icon* StairTile::getTexture(int face, int data) {
|
|||
|
||||
int StairTile::getTickDelay(Level* level) { return base->getTickDelay(level); }
|
||||
|
||||
AABB* StairTile::getTileAABB(Level* level, int x, int y, int z) {
|
||||
AABB StairTile::getTileAABB(Level* level, int x, int y, int z) {
|
||||
return base->getTileAABB(level, x, y, z);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public:
|
|||
virtual int getRenderLayer();
|
||||
virtual Icon* getTexture(int face, int data);
|
||||
virtual int getTickDelay(Level* level);
|
||||
virtual AABB* getTileAABB(Level* level, int x, int y, int z);
|
||||
virtual AABB getTileAABB(Level* level, int x, int y, int z);
|
||||
virtual void handleEntityInside(Level* level, int x, int y, int z,
|
||||
std::shared_ptr<Entity> e, Vec3* current);
|
||||
virtual bool mayPick();
|
||||
|
|
|
|||
|
|
@ -2005,11 +2005,11 @@ Icon* Tile::getTexture(int face, int data) { return icon; }
|
|||
|
||||
Icon* Tile::getTexture(int face) { return getTexture(face, 0); }
|
||||
|
||||
AABB* Tile::getTileAABB(Level* level, int x, int y, int z) {
|
||||
AABB Tile::getTileAABB(Level* level, int x, int y, int z) {
|
||||
ThreadStorage* tls = m_tlsShape;
|
||||
// 4J Stu - Added this so that the TLS shape is correct for this tile
|
||||
if (tls->tileId != this->id) updateDefaultShape();
|
||||
return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1,
|
||||
return AABB(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1,
|
||||
y + tls->yy1, z + tls->zz1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -631,7 +631,7 @@ public:
|
|||
virtual Icon* getTexture(LevelSource* level, int x, int y, int z, int face);
|
||||
virtual Icon* getTexture(int face, int data);
|
||||
virtual Icon* getTexture(int face);
|
||||
virtual AABB* getTileAABB(Level* level, int x, int y, int z);
|
||||
virtual AABB getTileAABB(Level* level, int x, int y, int z);
|
||||
virtual void addAABBs(Level* level, int x, int y, int z, AABB* box,
|
||||
AABBList* boxes, std::shared_ptr<Entity> source);
|
||||
virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ TorchTile::TorchTile(int id) : Tile(id, Material::decoration, false) {
|
|||
|
||||
std::optional<AABB> TorchTile::getAABB(Level* level, int x, int y, int z) { return std::nullopt; }
|
||||
|
||||
AABB* TorchTile::getTileAABB(Level* level, int x, int y, int z) {
|
||||
AABB TorchTile::getTileAABB(Level* level, int x, int y, int z) {
|
||||
updateShape(level, x, y, z);
|
||||
return Tile::getTileAABB(level, x, y, z);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ protected:
|
|||
|
||||
public:
|
||||
virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
|
||||
virtual AABB* getTileAABB(Level* level, int x, int y, int z);
|
||||
virtual AABB getTileAABB(Level* level, int x, int y, int z);
|
||||
virtual void updateShape(
|
||||
LevelSource* level, int x, int y, int z, int forceData = -1,
|
||||
std::shared_ptr<TileEntity> forceEntity = std::shared_ptr<
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ bool TrapDoorTile::isPathfindable(LevelSource* level, int x, int y, int z) {
|
|||
|
||||
int TrapDoorTile::getRenderShape() { return Tile::SHAPE_BLOCK; }
|
||||
|
||||
AABB* TrapDoorTile::getTileAABB(Level* level, int x, int y, int z) {
|
||||
AABB TrapDoorTile::getTileAABB(Level* level, int x, int y, int z) {
|
||||
updateShape(level, x, y, z);
|
||||
return Tile::getTileAABB(level, x, y, z);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public:
|
|||
int getRenderShape();
|
||||
|
||||
public:
|
||||
AABB* getTileAABB(Level* level, int x, int y, int z);
|
||||
AABB getTileAABB(Level* level, int x, int y, int z);
|
||||
|
||||
public:
|
||||
std::optional<AABB> getAABB(Level* level, int x, int y, int z);
|
||||
|
|
|
|||
Loading…
Reference in a new issue