refactor: make Tile::getAABB return optional<AABB>

This commit is contained in:
orng 2026-03-28 00:11:19 -05:00
parent 78b5255224
commit 7158fd398f
71 changed files with 205 additions and 139 deletions

View file

@ -6,6 +6,8 @@
#include "../Headers/net.minecraft.h" #include "../Headers/net.minecraft.h"
#include "../Headers/net.minecraft.world.h" #include "../Headers/net.minecraft.world.h"
#include "BasePressurePlateTile.h" #include "BasePressurePlateTile.h"
#include <optional>
#include "Util/AABB.h"
BasePressurePlateTile::BasePressurePlateTile(int id, const std::wstring& tex, BasePressurePlateTile::BasePressurePlateTile(int id, const std::wstring& tex,
Material* material) Material* material)
@ -38,8 +40,8 @@ int BasePressurePlateTile::getTickDelay(Level* level) {
return SharedConstants::TICKS_PER_SECOND; return SharedConstants::TICKS_PER_SECOND;
} }
AABB* BasePressurePlateTile::getAABB(Level* level, int x, int y, int z) { std::optional<AABB> BasePressurePlateTile::getAABB(Level* level, int x, int y, int z) {
return NULL; return std::nullopt;
} }
bool BasePressurePlateTile::isSolidRender(bool isServerLevel) { return false; } bool BasePressurePlateTile::isSolidRender(bool isServerLevel) { return false; }

View file

@ -20,7 +20,7 @@ protected:
public: public:
virtual int getTickDelay(Level* level); virtual int getTickDelay(Level* level);
virtual AABB* getAABB(Level* level, int x, int y, int z); virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
virtual bool isSolidRender(bool isServerLevel = false); virtual bool isSolidRender(bool isServerLevel = false);
virtual bool blocksLight(); virtual bool blocksLight();
virtual bool isCubeShaped(); virtual bool isCubeShaped();
@ -56,4 +56,4 @@ protected:
public: public:
virtual void registerIcons(IconRegister* iconRegister); virtual void registerIcons(IconRegister* iconRegister);
}; };

View file

@ -3,6 +3,7 @@
#include "../Headers/net.minecraft.world.level.h" #include "../Headers/net.minecraft.world.level.h"
#include "../Headers/net.minecraft.world.h" #include "../Headers/net.minecraft.world.h"
#include "BaseRailTile.h" #include "BaseRailTile.h"
#include <optional>
BaseRailTile::Rail::Rail(Level* level, int x, int y, int z) { BaseRailTile::Rail::Rail(Level* level, int x, int y, int z) {
this->level = level; this->level = level;
@ -311,7 +312,7 @@ BaseRailTile::BaseRailTile(int id, bool usesDataBit)
bool BaseRailTile::isUsesDataBit() { return usesDataBit; } bool BaseRailTile::isUsesDataBit() { return usesDataBit; }
AABB* BaseRailTile::getAABB(Level* level, int x, int y, int z) { return NULL; } std::optional<AABB> BaseRailTile::getAABB(Level* level, int x, int y, int z) { return std::nullopt; }
bool BaseRailTile::blocksLight() { return false; } bool BaseRailTile::blocksLight() { return false; }
@ -415,4 +416,4 @@ void BaseRailTile::onRemove(Level* level, int x, int y, int z, int id,
level->updateNeighborsAt(x, y, z, id); level->updateNeighborsAt(x, y, z, id);
level->updateNeighborsAt(x, y - 1, z, id); level->updateNeighborsAt(x, y - 1, z, id);
} }
} }

View file

@ -70,7 +70,7 @@ public:
using Tile::getResourceCount; using Tile::getResourceCount;
bool isUsesDataBit(); bool isUsesDataBit();
virtual AABB* getAABB(Level* level, int x, int y, int z); virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
virtual bool blocksLight(); virtual bool blocksLight();
virtual bool isSolidRender(bool isServerLevel = false); virtual bool isSolidRender(bool isServerLevel = false);
virtual HitResult* clip(Level* level, int xt, int yt, int zt, Vec3* a, virtual HitResult* clip(Level* level, int xt, int yt, int zt, Vec3* a,

View file

@ -5,6 +5,7 @@
#include "../Headers/net.minecraft.world.phys.h" #include "../Headers/net.minecraft.world.phys.h"
#include "../Headers/net.minecraft.h" #include "../Headers/net.minecraft.h"
#include "ButtonTile.h" #include "ButtonTile.h"
#include <optional>
#include "../Util/SoundTypes.h" #include "../Util/SoundTypes.h"
ButtonTile::ButtonTile(int id, bool sensitive) ButtonTile::ButtonTile(int id, bool sensitive)
@ -20,7 +21,7 @@ Icon* ButtonTile::getTexture(int face, int data) {
return Tile::stone->getTexture(Facing::UP); return Tile::stone->getTexture(Facing::UP);
} }
AABB* ButtonTile::getAABB(Level* level, int x, int y, int z) { return NULL; } std::optional<AABB> ButtonTile::getAABB(Level* level, int x, int y, int z) { return std::nullopt; }
int ButtonTile::getTickDelay(Level* level) { return sensitive ? 30 : 20; } int ButtonTile::getTickDelay(Level* level) { return sensitive ? 30 : 20; }

View file

@ -17,7 +17,7 @@ protected:
public: public:
Icon* getTexture(int face, int data); Icon* getTexture(int face, int data);
virtual AABB* getAABB(Level* level, int x, int y, int z); virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
virtual int getTickDelay(Level* level); virtual int getTickDelay(Level* level);
virtual bool blocksLight(); virtual bool blocksLight();
virtual bool isSolidRender(bool isServerLevel = false); virtual bool isSolidRender(bool isServerLevel = false);
@ -74,4 +74,4 @@ public:
// 4J Added so we can check before we try to add a tile to the tick list if // 4J Added so we can check before we try to add a tile to the tick list if
// it's actually going to do seomthing // it's actually going to do seomthing
virtual bool shouldTileTick(Level* level, int x, int y, int z); virtual bool shouldTileTick(Level* level, int x, int y, int z);
}; };

View file

@ -33,9 +33,9 @@ void CactusTile::tick(Level* level, int x, int y, int z, Random* random) {
} }
} }
AABB* CactusTile::getAABB(Level* level, int x, int y, int z) { std::optional<AABB> CactusTile::getAABB(Level* level, int x, int y, int z) {
float r = 1 / 16.0f; float r = 1 / 16.0f;
return AABB::newTemp(x + r, y, z + r, x + 1 - r, y + 1 - r, z + 1 - r); 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) {

View file

@ -20,7 +20,7 @@ protected:
public: public:
virtual void tick(Level* level, int x, int y, int z, Random* random); virtual void tick(Level* level, int x, int y, int z, Random* random);
virtual AABB* getAABB(Level* level, int x, int y, int z); 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 Icon* getTexture(int face, int data);
virtual bool isCubeShaped(); virtual bool isCubeShaped();
@ -37,4 +37,4 @@ public:
// 4J Added so we can check before we try to add a tile to the tick list if // 4J Added so we can check before we try to add a tile to the tick list if
// it's actually going to do seomthing // it's actually going to do seomthing
virtual bool shouldTileTick(Level* level, int x, int y, int z); virtual bool shouldTileTick(Level* level, int x, int y, int z);
}; };

View file

@ -34,12 +34,12 @@ void CakeTile::updateDefaultShape() {
this->setShape(r, 0, r, 1 - r, h, 1 - r); this->setShape(r, 0, r, 1 - r, h, 1 - r);
} }
AABB* CakeTile::getAABB(Level* level, int x, int y, int z) { std::optional<AABB> CakeTile::getAABB(Level* level, int x, int y, int z) {
int d = level->getData(x, y, z); int d = level->getData(x, y, z);
float r = 1 / 16.0f; float r = 1 / 16.0f;
float r2 = (1 + d * 2) / 16.0f; float r2 = (1 + d * 2) / 16.0f;
float h = 8 / 16.0f; float h = 8 / 16.0f;
return AABB::newTemp(x + r2, y, z + r, x + 1 - r, y + h - r, z + 1 - r); 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) {

View file

@ -24,7 +24,7 @@ protected:
std::shared_ptr<TileEntity> forceEntity = std::shared_ptr< std::shared_ptr<TileEntity> forceEntity = std::shared_ptr<
TileEntity>()); // 4J added forceData, forceEntity param TileEntity>()); // 4J added forceData, forceEntity param
virtual void updateDefaultShape(); virtual void updateDefaultShape();
virtual AABB* getAABB(Level* level, int x, int y, int z); 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 Icon* getTexture(int face, int data);
//@Override //@Override
@ -49,4 +49,4 @@ public:
virtual int getResourceCount(Random* random); virtual int getResourceCount(Random* random);
virtual int getResource(int data, Random* random, int playerBonusLevel); virtual int getResource(int data, Random* random, int playerBonusLevel);
int cloneTileId(Level* level, int x, int y, int z); int cloneTileId(Level* level, int x, int y, int z);
}; };

View file

@ -5,6 +5,7 @@
#include "../Headers/net.minecraft.world.h" #include "../Headers/net.minecraft.world.h"
#include "../Headers/net.minecraft.h" #include "../Headers/net.minecraft.h"
#include "CocoaTile.h" #include "CocoaTile.h"
#include "Util/AABB.h"
const std::wstring CocoaTile::TEXTURE_AGES[] = {L"cocoa_0", L"cocoa_1", const std::wstring CocoaTile::TEXTURE_AGES[] = {L"cocoa_0", L"cocoa_1",
L"cocoa_2"}; L"cocoa_2"};
@ -56,7 +57,7 @@ bool CocoaTile::isCubeShaped() { return false; }
bool CocoaTile::isSolidRender(bool isServerLevel) { return false; } bool CocoaTile::isSolidRender(bool isServerLevel) { return false; }
AABB* CocoaTile::getAABB(Level* level, int x, int y, int z) { std::optional<AABB> CocoaTile::getAABB(Level* level, int x, int y, int z) {
updateShape(level, x, y, z); updateShape(level, x, y, z);
return DirectionalTile::getAABB(level, x, y, z); return DirectionalTile::getAABB(level, x, y, z);
} }
@ -157,4 +158,4 @@ void CocoaTile::registerIcons(IconRegister* iconRegister) {
for (int i = 0; i < COCOA_TEXTURES_LENGTH; i++) { for (int i = 0; i < COCOA_TEXTURES_LENGTH; i++) {
icons[i] = iconRegister->registerIcon(TEXTURE_AGES[i]); icons[i] = iconRegister->registerIcon(TEXTURE_AGES[i]);
} }
} }

View file

@ -22,7 +22,7 @@ public:
virtual int getRenderShape(); virtual int getRenderShape();
virtual bool isCubeShaped(); virtual bool isCubeShaped();
virtual bool isSolidRender(bool isServerLevel = false); virtual bool isSolidRender(bool isServerLevel = false);
virtual AABB* getAABB(Level* level, int x, int y, int z); 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, virtual void updateShape(LevelSource* level, int x, int y, int z,
int forceData = -1, int forceData = -1,

View file

@ -91,10 +91,9 @@ AABB* DoorTile::getTileAABB(Level* level, int x, int y, int z) {
return retval; return retval;
} }
AABB* DoorTile::getAABB(Level* level, int x, int y, int z) { std::optional<AABB> DoorTile::getAABB(Level* level, int x, int y, int z) {
updateShape(level, x, y, z); updateShape(level, x, y, z);
AABB* retval = Tile::getAABB(level, x, y, z); return Tile::getAABB(level, x, y, z);
return retval;
} }
void DoorTile::updateShape( void DoorTile::updateShape(
@ -307,4 +306,4 @@ void DoorTile::playerWillDestroy(Level* level, int x, int y, int z, int data,
} }
} }
} }
} }

View file

@ -41,7 +41,7 @@ public:
virtual bool isCubeShaped(); virtual bool isCubeShaped();
virtual int getRenderShape(); 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 AABB* getAABB(Level* level, int x, int y, int z); virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
virtual void updateShape( virtual void updateShape(
LevelSource* level, int x, int y, int z, int forceData = -1, LevelSource* level, int x, int y, int z, int forceData = -1,
std::shared_ptr<TileEntity> forceEntity = std::shared_ptr< std::shared_ptr<TileEntity> forceEntity = std::shared_ptr<

View file

@ -17,8 +17,8 @@ FarmTile::FarmTile(int id) : Tile(id, Material::dirt, false) {
// 4J Added override // 4J Added override
void FarmTile::updateDefaultShape() { setShape(0, 0, 0, 1, 15 / 16.0f, 1); } void FarmTile::updateDefaultShape() { setShape(0, 0, 0, 1, 15 / 16.0f, 1); }
AABB* FarmTile::getAABB(Level* level, int x, int y, int z) { std::optional<AABB> FarmTile::getAABB(Level* level, int x, int y, int z) {
return AABB::newTemp(x + 0, y + 0, z + 0, x + 1, y + 1, z + 1); return AABB(x + 0, y + 0, z + 0, x + 1, y + 1, z + 1);
} }
bool FarmTile::isSolidRender(bool isServerLevel) { return false; } bool FarmTile::isSolidRender(bool isServerLevel) { return false; }

View file

@ -18,7 +18,7 @@ protected:
public: public:
virtual void updateDefaultShape(); // 4J Added override virtual void updateDefaultShape(); // 4J Added override
virtual AABB* getAABB(Level* level, int x, int y, int z); virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
virtual bool isSolidRender(bool isServerLevel = false); virtual bool isSolidRender(bool isServerLevel = false);
virtual bool isCubeShaped(); virtual bool isCubeShaped();
virtual Icon* getTexture(int face, int data); virtual Icon* getTexture(int face, int data);

View file

@ -4,6 +4,7 @@
#include "../Headers/net.minecraft.world.level.h" #include "../Headers/net.minecraft.world.level.h"
#include "../Headers/net.minecraft.h" #include "../Headers/net.minecraft.h"
#include "../Level/Events/LevelEvent.h" #include "../Level/Events/LevelEvent.h"
#include "Util/Direction.h"
FenceGateTile::FenceGateTile(int id) FenceGateTile::FenceGateTile(int id)
: DirectionalTile(id, Material::wood, false) {} : DirectionalTile(id, Material::wood, false) {}
@ -17,19 +18,29 @@ bool FenceGateTile::mayPlace(Level* level, int x, int y, int z) {
return Tile::mayPlace(level, x, y, z); return Tile::mayPlace(level, x, y, z);
} }
AABB* FenceGateTile::getAABB(Level* level, int x, int y, int z) { std::optional<AABB> FenceGateTile::getAABB(Level* level, int x, int y, int z) {
int data = level->getData(x, y, z); int data = level->getData(x, y, z);
if (isOpen(data)) { if (isOpen(data)) {
return NULL; return std::nullopt;
} }
// 4J Brought forward change from 1.2.3 to fix hit box rotation
if (data == Direction::NORTH || data == Direction::SOUTH) { switch (data) {
return AABB::newTemp(x, y, z + 6.0f / 16.0f, x + 1, y + 1.5f, case Direction::NORTH:
z + 10.0f / 16.0f); case Direction::SOUTH:
return AABB{static_cast<double>(x),
static_cast<double>(y),
z + 6.0 / 16.0,
x + 1.0,
y + 1.5,
z + 10.0 / 16.0};
default:
return AABB{x + 6.0 / 16.0,
static_cast<double>(y),
static_cast<double>(z),
x + 10.0 / 16.0,
y + 1.5,
z + 1.0};
} }
return AABB::newTemp(x + 6.0f / 16.0f, y, z, x + 10.0f / 16.0f, y + 1.5f,
z + 1);
// return AABB::newTemp(x, y, z, x + 1, y + 1.5f, z + 1);
} }
// 4J - Brought forward from 1.2.3 to fix hit box rotation // 4J - Brought forward from 1.2.3 to fix hit box rotation

View file

@ -9,7 +9,7 @@ public:
FenceGateTile(int id); FenceGateTile(int id);
Icon* getTexture(int face, int data); Icon* getTexture(int face, int data);
virtual bool mayPlace(Level* level, int x, int y, int z); virtual bool mayPlace(Level* level, int x, int y, int z);
virtual AABB* getAABB(Level* level, int x, int y, int z); virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
virtual void updateShape( virtual void updateShape(
LevelSource* level, int x, int y, int z, int forceData = -1, LevelSource* level, int x, int y, int z, int forceData = -1,
std::shared_ptr<TileEntity> forceEntity = std::shared_ptr< std::shared_ptr<TileEntity> forceEntity = std::shared_ptr<

View file

@ -7,6 +7,7 @@
#include "../Util/SoundTypes.h" #include "../Util/SoundTypes.h"
#include "../../Minecraft.Client/MinecraftServer.h" #include "../../Minecraft.Client/MinecraftServer.h"
#include "../../Minecraft.Client/Network/PlayerList.h" #include "../../Minecraft.Client/Network/PlayerList.h"
#include "Util/AABB.h"
// AP - added for Vita to set Alpha Cut out // AP - added for Vita to set Alpha Cut out
#include "../IO/Streams/IntBuffer.h" #include "../IO/Streams/IntBuffer.h"
@ -57,7 +58,7 @@ void FireTile::setFlammable(int id, int flame, int burn) {
burnOdds[id] = burn; burnOdds[id] = burn;
} }
AABB* FireTile::getAABB(Level* level, int x, int y, int z) { return NULL; } std::optional<AABB> FireTile::getAABB(Level* level, int x, int y, int z) { return std::nullopt; }
bool FireTile::blocksLight() { return false; } bool FireTile::blocksLight() { return false; }

View file

@ -39,7 +39,7 @@ private:
void setFlammable(int id, int flame, int burn); void setFlammable(int id, int flame, int burn);
public: public:
virtual AABB* getAABB(Level* level, int x, int y, int z); virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
virtual bool blocksLight(); virtual bool blocksLight();
virtual bool isSolidRender(bool isServerLevel = false); virtual bool isSolidRender(bool isServerLevel = false);
virtual bool isCubeShaped(); virtual bool isCubeShaped();
@ -69,4 +69,4 @@ public:
void registerIcons(IconRegister* iconRegister); void registerIcons(IconRegister* iconRegister);
Icon* getTextureLayer(int layer); Icon* getTextureLayer(int layer);
Icon* getTexture(int face, int data); Icon* getTexture(int face, int data);
}; };

View file

@ -1,11 +1,12 @@
#include "../Platform/stdafx.h" #include "../Platform/stdafx.h"
#include "../Headers/net.minecraft.world.level.h" #include "../Headers/net.minecraft.world.level.h"
#include "LadderTile.h" #include "LadderTile.h"
#include "Util/AABB.h"
LadderTile::LadderTile(int id) LadderTile::LadderTile(int id)
: Tile(id, Material::decoration, false) {} : Tile(id, Material::decoration, false) {}
AABB* LadderTile::getAABB(Level* level, int x, int y, int z) { std::optional<AABB> LadderTile::getAABB(Level* level, int x, int y, int z) {
updateShape(level, x, y, z); updateShape(level, x, y, z);
return Tile::getAABB(level, x, y, z); return Tile::getAABB(level, x, y, z);
} }
@ -87,4 +88,4 @@ void LadderTile::neighborChanged(Level* level, int x, int y, int z, int type) {
Tile::neighborChanged(level, x, y, z, type); Tile::neighborChanged(level, x, y, z, type);
} }
int LadderTile::getResourceCount(Random* random) { return 1; } int LadderTile::getResourceCount(Random* random) { return 1; }

View file

@ -11,7 +11,7 @@ protected:
LadderTile(int id); LadderTile(int id);
public: public:
virtual AABB* getAABB(Level* level, int x, int y, int z); 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( virtual void updateShape(
LevelSource* level, int x, int y, int z, int forceData = -1, LevelSource* level, int x, int y, int z, int forceData = -1,
@ -29,4 +29,4 @@ public:
float clickZ, int itemValue); float clickZ, int itemValue);
virtual void neighborChanged(Level* level, int x, int y, int z, int type); virtual void neighborChanged(Level* level, int x, int y, int z, int type);
virtual int getResourceCount(Random* random); virtual int getResourceCount(Random* random);
}; };

View file

@ -3,11 +3,12 @@
#include "../Headers/net.minecraft.world.level.redstone.h" #include "../Headers/net.minecraft.world.level.redstone.h"
#include "../Headers/net.minecraft.h" #include "../Headers/net.minecraft.h"
#include "LeverTile.h" #include "LeverTile.h"
#include "Util/AABB.h"
LeverTile::LeverTile(int id) LeverTile::LeverTile(int id)
: Tile(id, Material::decoration, false) {} : Tile(id, Material::decoration, false) {}
AABB* LeverTile::getAABB(Level* level, int x, int y, int z) { return NULL; } std::optional<AABB> LeverTile::getAABB(Level* level, int x, int y, int z) { return std::nullopt; }
bool LeverTile::blocksLight() { return false; } bool LeverTile::blocksLight() { return false; }

View file

@ -8,7 +8,7 @@ protected:
LeverTile(int id); LeverTile(int id);
public: public:
virtual AABB* getAABB(Level* level, int x, int y, int z); virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
virtual bool blocksLight(); virtual bool blocksLight();
virtual bool isSolidRender(bool isServerLevel = false); virtual bool isSolidRender(bool isServerLevel = false);
virtual bool isCubeShaped(); virtual bool isCubeShaped();

View file

@ -5,9 +5,11 @@
#include "../Headers/net.minecraft.world.level.biome.h" #include "../Headers/net.minecraft.world.level.biome.h"
#include "../Headers/net.minecraft.world.h" #include "../Headers/net.minecraft.world.h"
#include "LiquidTile.h" #include "LiquidTile.h"
#include <cstddef>
#include "../Util/Facing.h" #include "../Util/Facing.h"
#include "../Util/SoundTypes.h" #include "../Util/SoundTypes.h"
#include "Blocks/Material.h" #include "Blocks/Material.h"
#include "Util/AABB.h"
const std::wstring LiquidTile::TEXTURE_LAVA_STILL = L"lava"; const std::wstring LiquidTile::TEXTURE_LAVA_STILL = L"lava";
const std::wstring LiquidTile::TEXTURE_WATER_STILL = L"water"; const std::wstring LiquidTile::TEXTURE_WATER_STILL = L"water";
@ -107,7 +109,9 @@ bool LiquidTile::shouldRenderFace(LevelSource* level, int x, int y, int z,
return Tile::shouldRenderFace(level, x, y, z, face); return Tile::shouldRenderFace(level, x, y, z, face);
} }
AABB* LiquidTile::getAABB(Level* level, int x, int y, int z) { return NULL; } std::optional<AABB> LiquidTile::getAABB(Level* level, int x, int y, int z) {
return std::nullopt;
}
int LiquidTile::getRenderShape() { return Tile::SHAPE_WATER; } int LiquidTile::getRenderShape() { return Tile::SHAPE_WATER; }

View file

@ -1,4 +1,5 @@
#pragma once #pragma once
#include <optional>
#include "Tile.h" #include "Tile.h"
#include "../Util/Definitions.h" #include "../Util/Definitions.h"
@ -40,7 +41,7 @@ public:
virtual bool isSolidFace(LevelSource* level, int x, int y, int z, int face); virtual bool isSolidFace(LevelSource* level, int x, int y, int z, int face);
virtual bool shouldRenderFace(LevelSource* level, int x, int y, int z, virtual bool shouldRenderFace(LevelSource* level, int x, int y, int z,
int face); int face);
virtual AABB* getAABB(Level* level, int x, int y, int z); virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
virtual int getRenderShape(); virtual int getRenderShape();
virtual int getResource(int data, Random* random, int playerBonusLevel); virtual int getResource(int data, Random* random, int playerBonusLevel);
virtual int getResourceCount(Random* random); virtual int getResourceCount(Random* random);

View file

@ -1,5 +1,6 @@
#include "../Platform/stdafx.h" #include "../Platform/stdafx.h"
#include <cstdint> #include <cstdint>
#include <optional>
#include "PistonBaseTile.h" #include "PistonBaseTile.h"
#include "PistonMovingTileEntity.h" #include "PistonMovingTileEntity.h"
#include "TileEntities/PistonPieceTileEntity.h" #include "TileEntities/PistonPieceTileEntity.h"
@ -12,6 +13,8 @@
#include "../Level/LevelChunk.h" #include "../Level/LevelChunk.h"
#include "../Level/Dimensions/Dimension.h" #include "../Level/Dimensions/Dimension.h"
#include "Util/AABB.h"
const std::wstring PistonBaseTile::EDGE_TEX = L"piston_side"; const std::wstring PistonBaseTile::EDGE_TEX = L"piston_side";
const std::wstring PistonBaseTile::PLATFORM_TEX = L"piston_top"; const std::wstring PistonBaseTile::PLATFORM_TEX = L"piston_top";
const std::wstring PistonBaseTile::PLATFORM_STICKY_TEX = L"piston_top_sticky"; const std::wstring PistonBaseTile::PLATFORM_STICKY_TEX = L"piston_top_sticky";
@ -398,7 +401,7 @@ void PistonBaseTile::addAABBs(Level* level, int x, int y, int z, AABB* box,
Tile::addAABBs(level, x, y, z, box, boxes, source); Tile::addAABBs(level, x, y, z, box, boxes, source);
} }
AABB* PistonBaseTile::getAABB(Level* level, int x, int y, int z) { std::optional<AABB> PistonBaseTile::getAABB(Level* level, int x, int y, int z) {
updateShape(level, x, y, z); updateShape(level, x, y, z);
return Tile::getAABB(level, x, y, z); return Tile::getAABB(level, x, y, z);
} }

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "Tile.h" #include "Tile.h"
#include <cstdint> #include <cstdint>
#include <optional>
class PistonBaseTile : public Tile { class PistonBaseTile : public Tile {
public: public:
@ -68,7 +69,7 @@ public:
virtual void updateDefaultShape(); virtual void updateDefaultShape();
virtual void addAABBs(Level* level, int x, int y, int z, AABB* box, virtual void addAABBs(Level* level, int x, int y, int z, AABB* box,
AABBList* boxes, std::shared_ptr<Entity> source); AABBList* boxes, std::shared_ptr<Entity> source);
virtual AABB* getAABB(Level* level, int x, int y, int z); virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
virtual bool isCubeShaped(); virtual bool isCubeShaped();
static int getFacing(int data); static int getFacing(int data);
@ -84,4 +85,4 @@ private:
int z); // 4J added int z); // 4J added
bool createPush(Level* level, int sx, int sy, int sz, int facing); bool createPush(Level* level, int sx, int sy, int sz, int facing);
}; };

View file

@ -1,5 +1,6 @@
#include "../Platform/stdafx.h" #include "../Platform/stdafx.h"
#include "PistonMovingTileEntity.h" #include "PistonMovingTileEntity.h"
#include <optional>
#include "TileEntities/PistonPieceTileEntity.h" #include "TileEntities/PistonPieceTileEntity.h"
#include "../Headers/net.minecraft.world.level.h" #include "../Headers/net.minecraft.world.level.h"
#include "../Headers/net.minecraft.world.h" #include "../Headers/net.minecraft.world.h"
@ -91,10 +92,11 @@ std::shared_ptr<TileEntity> PistonMovingPiece::newMovingPieceEntity(
new PistonPieceEntity(block, data, facing, extending, isSourcePiston)); new PistonPieceEntity(block, data, facing, extending, isSourcePiston));
} }
AABB* PistonMovingPiece::getAABB(Level* level, int x, int y, int z) { std::optional<AABB> PistonMovingPiece::getAABB(Level* level, int x, int y,
int z) {
std::shared_ptr<PistonPieceEntity> entity = getEntity(level, x, y, z); std::shared_ptr<PistonPieceEntity> entity = getEntity(level, x, y, z);
if (entity == NULL) { if (entity == NULL) {
return NULL; return std::nullopt;
} }
// move the aabb depending on the animation // move the aabb depending on the animation
@ -136,15 +138,16 @@ void PistonMovingPiece::updateShape(
} }
} }
AABB* PistonMovingPiece::getAABB(Level* level, int x, int y, int z, int tile, std::optional<AABB> PistonMovingPiece::getAABB(Level* level, int x, int y,
float progress, int facing) { int z, int tile, float progress,
int facing) {
if (tile == 0 || tile == id) { if (tile == 0 || tile == id) {
return NULL; return std::nullopt;
} }
AABB* aabb = Tile::tiles[tile]->getAABB(level, x, y, z); auto aabb = Tile::tiles[tile]->getAABB(level, x, y, z);
if (aabb == NULL) { if (!aabb.has_value()) {
return NULL; return std::nullopt;
} }
// move the aabb depending on the animation // move the aabb depending on the animation
@ -153,16 +156,19 @@ AABB* PistonMovingPiece::getAABB(Level* level, int x, int y, int z, int tile,
} else { } else {
aabb->x1 -= Facing::STEP_X[facing] * progress; aabb->x1 -= Facing::STEP_X[facing] * progress;
} }
if (Facing::STEP_Y[facing] < 0) { if (Facing::STEP_Y[facing] < 0) {
aabb->y0 -= Facing::STEP_Y[facing] * progress; aabb->y0 -= Facing::STEP_Y[facing] * progress;
} else { } else {
aabb->y1 -= Facing::STEP_Y[facing] * progress; aabb->y1 -= Facing::STEP_Y[facing] * progress;
} }
if (Facing::STEP_Z[facing] < 0) { if (Facing::STEP_Z[facing] < 0) {
aabb->z0 -= Facing::STEP_Z[facing] * progress; aabb->z0 -= Facing::STEP_Z[facing] * progress;
} else { } else {
aabb->z1 -= Facing::STEP_Z[facing] * progress; aabb->z1 -= Facing::STEP_Z[facing] * progress;
} }
return aabb; return aabb;
} }

View file

@ -28,13 +28,13 @@ public:
virtual void neighborChanged(Level* level, int x, int y, int z, int type); virtual void neighborChanged(Level* level, int x, int y, int z, int type);
static std::shared_ptr<TileEntity> newMovingPieceEntity( static std::shared_ptr<TileEntity> newMovingPieceEntity(
int block, int data, int facing, bool extending, bool isSourcePiston); int block, int data, int facing, bool extending, bool isSourcePiston);
virtual AABB* getAABB(Level* level, int x, int y, int z); virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
virtual void updateShape( virtual void updateShape(
LevelSource* level, int x, int y, int z, int forceData = -1, LevelSource* level, int x, int y, int z, int forceData = -1,
std::shared_ptr<TileEntity> forceEntity = std::shared_ptr< std::shared_ptr<TileEntity> forceEntity = std::shared_ptr<
TileEntity>()); // 4J added forceData, forceEntity param TileEntity>()); // 4J added forceData, forceEntity param
AABB* getAABB(Level* level, int x, int y, int z, int tile, float progress, std::optional<AABB> getAABB(Level* level, int x, int y, int z, int tile, float progress,
int facing); int facing);
private: private:
@ -44,4 +44,4 @@ private:
public: public:
virtual int cloneTileId(Level* level, int x, int y, int z); virtual int cloneTileId(Level* level, int x, int y, int z);
void registerIcons(IconRegister* iconRegister); void registerIcons(IconRegister* iconRegister);
}; };

View file

@ -2,6 +2,7 @@
#include "../Headers/net.minecraft.world.level.h" #include "../Headers/net.minecraft.world.level.h"
#include "GrassTile.h" #include "GrassTile.h"
#include "PlantTile.h" #include "PlantTile.h"
#include "Util/AABB.h"
void Bush::_init() { void Bush::_init() {
setTicking(true); setTicking(true);
@ -52,7 +53,7 @@ bool Bush::canSurvive(Level* level, int x, int y, int z) {
mayPlaceOn(level->getTile(x, y - 1, z)); mayPlaceOn(level->getTile(x, y - 1, z));
} }
AABB* Bush::getAABB(Level* level, int x, int y, int z) { return NULL; } std::optional<AABB> Bush::getAABB(Level* level, int x, int y, int z) { return std::nullopt; }
bool Bush::blocksLight() { return false; } bool Bush::blocksLight() { return false; }

View file

@ -32,7 +32,7 @@ protected:
public: public:
virtual bool canSurvive(Level* level, int x, int y, int z); virtual bool canSurvive(Level* level, int x, int y, int z);
virtual AABB* getAABB(Level* level, int x, int y, int z); virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
virtual bool blocksLight(); virtual bool blocksLight();
virtual bool isSolidRender(bool isServerLevel = false); virtual bool isSolidRender(bool isServerLevel = false);

View file

@ -4,6 +4,9 @@
#include "../Headers/net.minecraft.world.level.dimension.h" #include "../Headers/net.minecraft.world.level.dimension.h"
#include "../Headers/net.minecraft.world.item.h" #include "../Headers/net.minecraft.world.item.h"
#include "PortalTile.h" #include "PortalTile.h"
#include <optional>
#include "Util/AABB.h"
#include "FireTile.h" #include "FireTile.h"
PortalTile::PortalTile(int id) PortalTile::PortalTile(int id)
@ -34,7 +37,7 @@ void PortalTile::tick(Level* level, int x, int y, int z, Random* random) {
} }
} }
AABB* PortalTile::getAABB(Level* level, int x, int y, int z) { return NULL; } std::optional<AABB> PortalTile::getAABB(Level* level, int x, int y, int z) { return std::nullopt; }
void PortalTile::updateShape( void PortalTile::updateShape(
LevelSource* level, int x, int y, int z, int forceData, LevelSource* level, int x, int y, int z, int forceData,

View file

@ -1,4 +1,5 @@
#pragma once #pragma once
#include <optional>
#include "HalfTransparentTile.h" #include "HalfTransparentTile.h"
#include "../Util/Definitions.h" #include "../Util/Definitions.h"
@ -8,7 +9,7 @@ class PortalTile : public HalfTransparentTile {
public: public:
PortalTile(int id); PortalTile(int id);
virtual void tick(Level* level, int x, int y, int z, Random* random); virtual void tick(Level* level, int x, int y, int z, Random* random);
virtual AABB* getAABB(Level* level, int x, int y, int z); virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
virtual void updateShape( virtual void updateShape(
LevelSource* level, int x, int y, int z, int forceData = -1, LevelSource* level, int x, int y, int z, int forceData = -1,
std::shared_ptr<TileEntity> forceEntity = std::shared_ptr< std::shared_ptr<TileEntity> forceEntity = std::shared_ptr<

View file

@ -1,6 +1,8 @@
#include "../Platform/stdafx.h" #include "../Platform/stdafx.h"
#include "../../Minecraft.Client/Minecraft.h" #include "../../Minecraft.Client/Minecraft.h"
#include "RedStoneDustTile.h" #include "RedStoneDustTile.h"
#include <cstddef>
#include <optional>
#include "../Headers/net.minecraft.world.item.h" #include "../Headers/net.minecraft.world.item.h"
#include "../Headers/net.minecraft.world.level.h" #include "../Headers/net.minecraft.world.level.h"
#include "../Headers/net.minecraft.world.level.redstone.h" #include "../Headers/net.minecraft.world.level.redstone.h"
@ -9,6 +11,7 @@
#include "../Headers/net.minecraft.h" #include "../Headers/net.minecraft.h"
#include "../Util/Direction.h" #include "../Util/Direction.h"
#include "DiodeTile.h" #include "DiodeTile.h"
#include "Util/AABB.h"
// AP - added for Vita to set Alpha Cut out // AP - added for Vita to set Alpha Cut out
#include "../IO/Streams/IntBuffer.h" #include "../IO/Streams/IntBuffer.h"
@ -36,8 +39,9 @@ void RedStoneDustTile::updateDefaultShape() {
setShape(0, 0, 0, 1, 1 / 16.0f, 1); setShape(0, 0, 0, 1, 1 / 16.0f, 1);
} }
AABB* RedStoneDustTile::getAABB(Level* level, int x, int y, int z) { std::optional<AABB> RedStoneDustTile::getAABB(Level* level, int x, int y,
return NULL; int z) {
return std::nullopt;
} }
bool RedStoneDustTile::isSolidRender(bool isServerLevel) { return false; } bool RedStoneDustTile::isSolidRender(bool isServerLevel) { return false; }

View file

@ -1,4 +1,5 @@
#pragma once #pragma once
#include <optional>
#include "Tile.h" #include "Tile.h"
#include "../Util/Definitions.h" #include "../Util/Definitions.h"
@ -26,7 +27,7 @@ private:
public: public:
RedStoneDustTile(int id); RedStoneDustTile(int id);
virtual void updateDefaultShape(); // 4J Added override virtual void updateDefaultShape(); // 4J Added override
virtual AABB* getAABB(Level* level, int x, int y, int z); virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
virtual bool isSolidRender(bool isServerLevel = false); virtual bool isSolidRender(bool isServerLevel = false);
virtual bool isCubeShaped(); virtual bool isCubeShaped();
virtual int getRenderShape(); virtual int getRenderShape();

View file

@ -5,6 +5,7 @@
#include "../Headers/net.minecraft.world.level.material.h" #include "../Headers/net.minecraft.world.level.material.h"
#include "../Headers/net.minecraft.world.phys.h" #include "../Headers/net.minecraft.world.phys.h"
#include "ReedTile.h" #include "ReedTile.h"
#include <optional>
ReedTile::ReedTile(int id) : Tile(id, Material::plant, false) { ReedTile::ReedTile(int id) : Tile(id, Material::plant, false) {
this->updateDefaultShape(); this->updateDefaultShape();
@ -64,7 +65,7 @@ bool ReedTile::canSurvive(Level* level, int x, int y, int z) {
return mayPlace(level, x, y, z); return mayPlace(level, x, y, z);
} }
AABB* ReedTile::getAABB(Level* level, int x, int y, int z) { return NULL; } std::optional<AABB> ReedTile::getAABB(Level* level, int x, int y, int z) { return std::nullopt; }
int ReedTile::getResource(int data, Random* random, int playerBonusLevel) { int ReedTile::getResource(int data, Random* random, int playerBonusLevel) {
return Item::reeds->id; return Item::reeds->id;

View file

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <optional>
#include "Tile.h" #include "Tile.h"
#include "../Util/Definitions.h" #include "../Util/Definitions.h"
@ -28,7 +29,7 @@ public:
bool canSurvive(Level* level, int x, int y, int z); bool canSurvive(Level* level, int x, int y, int z);
public: public:
AABB* getAABB(Level* level, int x, int y, int z); std::optional<AABB> getAABB(Level* level, int x, int y, int z);
public: public:
int getResource(int data, Random* random, int playerBonusLevel); int getResource(int data, Random* random, int playerBonusLevel);

View file

@ -4,6 +4,9 @@
#include "Material.h" #include "Material.h"
#include "TileEntities/SignTileEntity.h" #include "TileEntities/SignTileEntity.h"
#include "SignTile.h" #include "SignTile.h"
#include "Util/AABB.h"
#include <optional>
SignTile::SignTile(int id, eINSTANCEOF clas, bool onGround) SignTile::SignTile(int id, eINSTANCEOF clas, bool onGround)
: BaseEntityTile(id, Material::wood, false) { : BaseEntityTile(id, Material::wood, false) {
@ -22,7 +25,7 @@ void SignTile::updateDefaultShape() {
this->setShape(0.5f - r, 0, 0.5f - r, 0.5f + r, h, 0.5f + r); this->setShape(0.5f - r, 0, 0.5f - r, 0.5f + r, h, 0.5f + r);
} }
AABB* SignTile::getAABB(Level* level, int x, int y, int z) { return NULL; } 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); updateShape(level, x, y, z);
@ -109,4 +112,4 @@ int SignTile::cloneTileId(Level* level, int x, int y, int z) {
void SignTile::registerIcons(IconRegister* iconRegister) { void SignTile::registerIcons(IconRegister* iconRegister) {
// None // None
} }

View file

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <optional>
#include "BaseEntityTile.h" #include "BaseEntityTile.h"
#include "TileEntities/TileEntity.h" #include "TileEntities/TileEntity.h"
@ -19,7 +20,7 @@ protected:
public: public:
Icon* getTexture(int face, int data); Icon* getTexture(int face, int data);
virtual void updateDefaultShape(); virtual void updateDefaultShape();
AABB* getAABB(Level* level, int x, int y, int z); 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, void updateShape(LevelSource* level, int x, int y, int z,
int forceData = -1, int forceData = -1,
@ -39,4 +40,4 @@ public:
void neighborChanged(Level* level, int x, int y, int z, int type); void neighborChanged(Level* level, int x, int y, int z, int type);
int cloneTileId(Level* level, int x, int y, int z); int cloneTileId(Level* level, int x, int y, int z);
void registerIcons(IconRegister* iconRegister); void registerIcons(IconRegister* iconRegister);
}; };

View file

@ -49,7 +49,7 @@ void SkullTile::updateShape(LevelSource* level, int x, int y, int z,
} }
} }
AABB* SkullTile::getAABB(Level* level, int x, int y, int z) { std::optional<AABB> SkullTile::getAABB(Level* level, int x, int y, int z) {
updateShape(level, x, y, z); updateShape(level, x, y, z);
return BaseEntityTile::getAABB(level, x, y, z); return BaseEntityTile::getAABB(level, x, y, z);
} }
@ -316,4 +316,4 @@ Icon* SkullTile::getTexture(int face, int data) {
std::wstring SkullTile::getTileItemIconName() { std::wstring SkullTile::getTileItemIconName() {
return getIconName() + L"_" + SkullItem::ICON_NAMES[0]; return getIconName() + L"_" + SkullItem::ICON_NAMES[0];
} }

View file

@ -26,7 +26,7 @@ public:
int forceData = -1, int forceData = -1,
std::shared_ptr<TileEntity> forceEntity = std::shared_ptr<TileEntity> forceEntity =
std::shared_ptr<TileEntity>()); std::shared_ptr<TileEntity>());
AABB* getAABB(Level* level, int x, int y, int z); std::optional<AABB> getAABB(Level* level, int x, int y, int z);
void setPlacedBy(Level* level, int x, int y, int z, void setPlacedBy(Level* level, int x, int y, int z,
std::shared_ptr<LivingEntity> by); std::shared_ptr<LivingEntity> by);
std::shared_ptr<TileEntity> newTileEntity(Level* level); std::shared_ptr<TileEntity> newTileEntity(Level* level);

View file

@ -5,9 +5,9 @@
SoulSandTile::SoulSandTile(int id) : Tile(id, Material::sand) {} SoulSandTile::SoulSandTile(int id) : Tile(id, Material::sand) {}
AABB* SoulSandTile::getAABB(Level* level, int x, int y, int z) { std::optional<AABB> SoulSandTile::getAABB(Level* level, int x, int y, int z) {
float r = 2 / 16.0f; float r = 2 / 16.0f;
return AABB::newTemp(x, y, z, x + 1, y + 1 - r, z + 1); return AABB(x, y, z, x + 1, y + 1 - r, z + 1);
} }
void SoulSandTile::entityInside(Level* level, int x, int y, int z, void SoulSandTile::entityInside(Level* level, int x, int y, int z,

View file

@ -5,7 +5,7 @@
class SoulSandTile : public Tile { class SoulSandTile : public Tile {
public: public:
SoulSandTile(int id); SoulSandTile(int id);
virtual AABB* getAABB(Level* level, int x, int y, int z); virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
virtual void entityInside(Level* level, int x, int y, int z, virtual void entityInside(Level* level, int x, int y, int z,
std::shared_ptr<Entity> entity); std::shared_ptr<Entity> entity);
}; };

View file

@ -2015,16 +2015,16 @@ AABB* Tile::getTileAABB(Level* level, int x, int y, int z) {
void Tile::addAABBs(Level* level, int x, int y, int z, AABB* box, void Tile::addAABBs(Level* level, int x, int y, int z, AABB* box,
AABBList* boxes, std::shared_ptr<Entity> source) { AABBList* boxes, std::shared_ptr<Entity> source) {
AABB* aabb = getAABB(level, x, y, z); auto aabb = getAABB(level, x, y, z);
if (aabb != NULL && box->intersects(*aabb)) boxes->push_back(*aabb); if (aabb.has_value() && box->intersects(*aabb)) boxes->push_back(*aabb);
} }
AABB* Tile::getAABB(Level* level, int x, int y, int z) { std::optional<AABB> Tile::getAABB(Level* level, int x, int y, int z) {
ThreadStorage* tls = m_tlsShape; ThreadStorage* tls = m_tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if (tls->tileId != this->id) updateDefaultShape(); 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,
y + tls->yy1, z + tls->zz1); x + tls->xx1, y + tls->yy1, z + tls->zz1};
} }
bool Tile::isSolidRender(bool isServerLevel) { return true; } bool Tile::isSolidRender(bool isServerLevel) { return true; }

View file

@ -4,6 +4,7 @@
#include "../Util/Definitions.h" #include "../Util/Definitions.h"
#include "../Util/SoundTypes.h" #include "../Util/SoundTypes.h"
#include <cstdint> #include <cstdint>
#include <optional>
class GrassTile; class GrassTile;
class LeafTile; class LeafTile;
@ -633,7 +634,7 @@ public:
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, virtual void addAABBs(Level* level, int x, int y, int z, AABB* box,
AABBList* boxes, std::shared_ptr<Entity> source); AABBList* boxes, std::shared_ptr<Entity> source);
virtual AABB* getAABB(Level* level, int x, int y, int z); virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
virtual bool isSolidRender( virtual bool isSolidRender(
bool isServerLevel = false); // 4J - Added isServerLevel param bool isServerLevel = false); // 4J - Added isServerLevel param
virtual bool mayPick(int data, bool liquid); virtual bool mayPick(int data, bool liquid);

View file

@ -5,6 +5,7 @@
#include "../../Headers/net.minecraft.world.level.h" #include "../../Headers/net.minecraft.world.level.h"
#include "../../Util/Facing.h" #include "../../Util/Facing.h"
#include "../Tile.h" #include "../Tile.h"
#include "../../Util/AABB.h"
PistonPieceEntity::PistonPieceEntity() { PistonPieceEntity::PistonPieceEntity() {
// for the tile entity loader // for the tile entity loader
@ -81,11 +82,11 @@ void PistonPieceEntity::moveCollidedEntities(float progress, float amount) {
progress = progress - 1.0f; progress = progress - 1.0f;
} }
AABB* aabb = auto aabb =
Tile::pistonMovingPiece->getAABB(level, x, y, z, id, progress, facing); Tile::pistonMovingPiece->getAABB(level, x, y, z, id, progress, facing);
if (aabb != NULL) { if (aabb.has_value()) {
std::vector<std::shared_ptr<Entity> >* entities = std::vector<std::shared_ptr<Entity> >* entities =
level->getEntities(nullptr, aabb); level->getEntities(nullptr, &*aabb);
if (!entities->empty()) { if (!entities->empty()) {
std::vector<std::shared_ptr<Entity> > collisionHolder; std::vector<std::shared_ptr<Entity> > collisionHolder;
for (AUTO_VAR(it, entities->begin()); it != entities->end(); it++) { for (AUTO_VAR(it, entities->begin()); it != entities->end(); it++) {

View file

@ -21,11 +21,11 @@ void TopSnowTile::registerIcons(IconRegister* iconRegister) {
icon = iconRegister->registerIcon(L"snow"); icon = iconRegister->registerIcon(L"snow");
} }
AABB* TopSnowTile::getAABB(Level* level, int x, int y, int z) { std::optional<AABB> TopSnowTile::getAABB(Level* level, int x, int y, int z) {
int height = level->getData(x, y, z) & HEIGHT_MASK; int height = level->getData(x, y, z) & HEIGHT_MASK;
float offset = 2.0f / SharedConstants::WORLD_RESOLUTION; float offset = 2.0f / SharedConstants::WORLD_RESOLUTION;
ThreadStorage* tls = m_tlsShape; ThreadStorage* tls = m_tlsShape;
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 + (height * offset), z + tls->zz1); y + (height * offset), z + tls->zz1);
} }

View file

@ -16,7 +16,7 @@ protected:
public: public:
void registerIcons(IconRegister* iconRegister); void registerIcons(IconRegister* iconRegister);
AABB* getAABB(Level* level, int x, int y, int z); std::optional<AABB> getAABB(Level* level, int x, int y, int z);
public: public:
static float getHeight(Level* level, int x, int y, int z); static float getHeight(Level* level, int x, int y, int z);

View file

@ -3,12 +3,14 @@
#include "../Headers/net.minecraft.world.level.h" #include "../Headers/net.minecraft.world.level.h"
#include "../Headers/net.minecraft.world.level.tile.h" #include "../Headers/net.minecraft.world.level.tile.h"
#include "TorchTile.h" #include "TorchTile.h"
#include <optional>
#include "Util/AABB.h"
TorchTile::TorchTile(int id) : Tile(id, Material::decoration, false) { TorchTile::TorchTile(int id) : Tile(id, Material::decoration, false) {
this->setTicking(true); this->setTicking(true);
} }
AABB* TorchTile::getAABB(Level* level, int x, int y, int z) { return NULL; } 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); updateShape(level, x, y, z);

View file

@ -12,7 +12,7 @@ protected:
TorchTile(int id); TorchTile(int id);
public: public:
virtual AABB* getAABB(Level* level, int x, int y, int z); 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( virtual void updateShape(
LevelSource* level, int x, int y, int z, int forceData = -1, LevelSource* level, int x, int y, int z, int forceData = -1,

View file

@ -4,6 +4,7 @@
#include "../Headers/net.minecraft.world.level.tile.h" #include "../Headers/net.minecraft.world.level.tile.h"
#include "../Headers/net.minecraft.h" #include "../Headers/net.minecraft.h"
#include "TrapDoorTile.h" #include "TrapDoorTile.h"
#include "Util/AABB.h"
TrapDoorTile::TrapDoorTile(int id, Material* material) TrapDoorTile::TrapDoorTile(int id, Material* material)
: Tile(id, material, false) { : Tile(id, material, false) {
@ -29,7 +30,7 @@ AABB* TrapDoorTile::getTileAABB(Level* level, int x, int y, int z) {
return Tile::getTileAABB(level, x, y, z); return Tile::getTileAABB(level, x, y, z);
} }
AABB* TrapDoorTile::getAABB(Level* level, int x, int y, int z) { std::optional<AABB> TrapDoorTile::getAABB(Level* level, int x, int y, int z) {
updateShape(level, x, y, z); updateShape(level, x, y, z);
return Tile::getAABB(level, x, y, z); return Tile::getAABB(level, x, y, z);
} }
@ -175,4 +176,4 @@ bool TrapDoorTile::attachesTo(int id) {
tile == Tile::glowstone || tile == Tile::glowstone ||
(dynamic_cast<HalfSlabTile*>(tile) != NULL) || (dynamic_cast<HalfSlabTile*>(tile) != NULL) ||
(dynamic_cast<StairTile*>(tile) != NULL); (dynamic_cast<StairTile*>(tile) != NULL);
} }

View file

@ -40,7 +40,7 @@ public:
AABB* getTileAABB(Level* level, int x, int y, int z); AABB* getTileAABB(Level* level, int x, int y, int z);
public: public:
AABB* getAABB(Level* level, int x, int y, int z); std::optional<AABB> getAABB(Level* level, int x, int y, int z);
public: public:
void updateShape(LevelSource* level, int x, int y, int z, void updateShape(LevelSource* level, int x, int y, int z,
@ -91,4 +91,4 @@ public:
private: private:
static bool attachesTo(int id); static bool attachesTo(int id);
}; };

View file

@ -4,14 +4,16 @@
#include "../Headers/net.minecraft.world.level.tile.h" #include "../Headers/net.minecraft.world.level.tile.h"
#include "../Headers/net.minecraft.world.level.redstone.h" #include "../Headers/net.minecraft.world.level.redstone.h"
#include "TripWireSourceTile.h" #include "TripWireSourceTile.h"
#include "optional"
#include "Util/AABB.h"
TripWireSourceTile::TripWireSourceTile(int id) TripWireSourceTile::TripWireSourceTile(int id)
: Tile(id, Material::decoration, false) { : Tile(id, Material::decoration, false) {
this->setTicking(true); this->setTicking(true);
} }
AABB* TripWireSourceTile::getAABB(Level* level, int x, int y, int z) { std::optional<AABB> TripWireSourceTile::getAABB(Level* level, int x, int y, int z) {
return NULL; return std::nullopt;
} }
bool TripWireSourceTile::blocksLight() { return false; } bool TripWireSourceTile::blocksLight() { return false; }

View file

@ -14,7 +14,7 @@ public:
TripWireSourceTile(int id); TripWireSourceTile(int id);
AABB* getAABB(Level* level, int x, int y, int z); std::optional<AABB> getAABB(Level* level, int x, int y, int z);
bool blocksLight(); bool blocksLight();
bool isSolidRender(bool isServerLevel = false); bool isSolidRender(bool isServerLevel = false);
bool isCubeShaped(); bool isCubeShaped();

View file

@ -4,6 +4,7 @@
#include "../Headers/net.minecraft.world.level.tile.h" #include "../Headers/net.minecraft.world.level.tile.h"
#include "../Headers/net.minecraft.world.phys.h" #include "../Headers/net.minecraft.world.phys.h"
#include "TripWireTile.h" #include "TripWireTile.h"
#include <optional>
TripWireTile::TripWireTile(int id) : Tile(id, Material::decoration, false) { TripWireTile::TripWireTile(int id) : Tile(id, Material::decoration, false) {
setShape(0, 0, 0, 1, 2.5f / 16.0f, 1); setShape(0, 0, 0, 1, 2.5f / 16.0f, 1);
@ -16,7 +17,7 @@ int TripWireTile::getTickDelay(Level* level) {
return 20; // 10; return 20; // 10;
} }
AABB* TripWireTile::getAABB(Level* level, int x, int y, int z) { return NULL; } std::optional<AABB> TripWireTile::getAABB(Level* level, int x, int y, int z) { return std::nullopt; }
bool TripWireTile::blocksLight() { return false; } bool TripWireTile::blocksLight() { return false; }

View file

@ -14,7 +14,7 @@ public:
TripWireTile(int id); TripWireTile(int id);
int getTickDelay(Level* level); int getTickDelay(Level* level);
AABB* getAABB(Level* level, int x, int y, int z); std::optional<AABB> getAABB(Level* level, int x, int y, int z);
bool blocksLight(); bool blocksLight();
bool isSolidRender(bool isServerLevel = false); bool isSolidRender(bool isServerLevel = false);
bool isCubeShaped(); bool isCubeShaped();

View file

@ -7,6 +7,7 @@
#include "../Headers/net.minecraft.world.item.h" #include "../Headers/net.minecraft.world.item.h"
#include "../Headers/net.minecraft.stats.h" #include "../Headers/net.minecraft.stats.h"
#include "../Headers/net.minecraft.world.level.biome.h" #include "../Headers/net.minecraft.world.level.biome.h"
#include "Util/AABB.h"
VineTile::VineTile(int id) VineTile::VineTile(int id)
: Tile(id, Material::replaceable_plant, false) { : Tile(id, Material::replaceable_plant, false) {
@ -85,7 +86,7 @@ void VineTile::updateShape(
setShape(minX, minY, minZ, maxX, maxY, maxZ); setShape(minX, minY, minZ, maxX, maxY, maxZ);
} }
AABB* VineTile::getAABB(Level* level, int x, int y, int z) { return NULL; } std::optional<AABB> VineTile::getAABB(Level* level, int x, int y, int z) { return std::nullopt; }
bool VineTile::mayPlace(Level* level, int x, int y, int z, int face) { bool VineTile::mayPlace(Level* level, int x, int y, int z, int face) {
switch (face) { switch (face) {

View file

@ -21,7 +21,7 @@ public:
LevelSource* level, int x, int y, int z, int forceData = -1, LevelSource* level, int x, int y, int z, int forceData = -1,
std::shared_ptr<TileEntity> forceEntity = std::shared_ptr< std::shared_ptr<TileEntity> forceEntity = std::shared_ptr<
TileEntity>()); // 4J added forceData, forceEntity param TileEntity>()); // 4J added forceData, forceEntity param
virtual AABB* getAABB(Level* level, int x, int y, int z); virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
virtual bool mayPlace(Level* level, int x, int y, int z, int face); virtual bool mayPlace(Level* level, int x, int y, int z, int face);
private: private:
@ -43,4 +43,4 @@ public:
virtual int getResourceCount(Random* random); virtual int getResourceCount(Random* random);
virtual void playerDestroy(Level* level, std::shared_ptr<Player> player, virtual void playerDestroy(Level* level, std::shared_ptr<Player> player,
int x, int y, int z, int data); int x, int y, int z, int data);
}; };

View file

@ -80,7 +80,7 @@ void WallTile::updateShape(LevelSource* level, int x, int y, int z,
setShape(west, 0, north, east, up, south); setShape(west, 0, north, east, up, south);
} }
AABB* WallTile::getAABB(Level* level, int x, int y, int z) { std::optional<AABB> WallTile::getAABB(Level* level, int x, int y, int z) {
// 4J-JEV: Changed to avoid race conditions associated with calling update // 4J-JEV: Changed to avoid race conditions associated with calling update
// shape. // shape.
@ -125,7 +125,7 @@ AABB* WallTile::getAABB(Level* level, int x, int y, int z) {
// south = .5f + WALL_WIDTH; // south = .5f + WALL_WIDTH;
} }
return AABB::newTemp(x + west, y, z + north, x + east, y + 1.5f, z + south); return AABB(x + west, y, z + north, x + east, y + 1.5f, z + south);
} }
bool WallTile::connectsTo(LevelSource* level, int x, int y, int z) { bool WallTile::connectsTo(LevelSource* level, int x, int y, int z) {

View file

@ -25,9 +25,9 @@ public:
int forceData = -1, int forceData = -1,
std::shared_ptr<TileEntity> forceEntity = std::shared_ptr<TileEntity> forceEntity =
std::shared_ptr<TileEntity>()); std::shared_ptr<TileEntity>());
AABB* getAABB(Level* level, int x, int y, int z); std::optional<AABB> getAABB(Level* level, int x, int y, int z);
bool connectsTo(LevelSource* level, int x, int y, int z); bool connectsTo(LevelSource* level, int x, int y, int z);
int getSpawnResourcesAuxValue(int data); int getSpawnResourcesAuxValue(int data);
bool shouldRenderFace(LevelSource* level, int x, int y, int z, int face); bool shouldRenderFace(LevelSource* level, int x, int y, int z, int face);
void registerIcons(IconRegister* iconRegister); void registerIcons(IconRegister* iconRegister);
}; };

View file

@ -23,11 +23,11 @@ void WaterlilyTile::addAABBs(Level* level, int x, int y, int z, AABB* box,
} }
} }
AABB* WaterlilyTile::getAABB(Level* level, int x, int y, int z) { std::optional<AABB> WaterlilyTile::getAABB(Level* level, int x, int y, int z) {
ThreadStorage* tls = m_tlsShape; ThreadStorage* tls = m_tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if (tls->tileId != this->id) updateDefaultShape(); 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); y + tls->yy1, z + tls->zz1);
} }

View file

@ -12,7 +12,7 @@ public:
virtual int getRenderShape(); virtual int getRenderShape();
virtual void addAABBs(Level* level, int x, int y, int z, AABB* box, virtual void addAABBs(Level* level, int x, int y, int z, AABB* box,
AABBList* boxes, std::shared_ptr<Entity> source); AABBList* boxes, std::shared_ptr<Entity> source);
virtual AABB* getAABB(Level* level, int x, int y, int z); virtual std::optional<AABB> getAABB(Level* level, int x, int y, int z);
virtual int getColor() const; virtual int getColor() const;
virtual int getColor(int auxData); virtual int getColor(int auxData);
virtual int getColor(LevelSource* level, int x, int y, int z); virtual int getColor(LevelSource* level, int x, int y, int z);

View file

@ -2,6 +2,7 @@
#include "../Headers/net.minecraft.world.entity.h" #include "../Headers/net.minecraft.world.entity.h"
#include "../Headers/net.minecraft.world.item.h" #include "../Headers/net.minecraft.world.item.h"
#include "WebTile.h" #include "WebTile.h"
#include "Util/AABB.h"
WebTile::WebTile(int id) : Tile(id, Material::web) {} WebTile::WebTile(int id) : Tile(id, Material::web) {}
@ -12,7 +13,7 @@ void WebTile::entityInside(Level* level, int x, int y, int z,
bool WebTile::isSolidRender(bool isServerLevel) { return false; } bool WebTile::isSolidRender(bool isServerLevel) { return false; }
AABB* WebTile::getAABB(Level* level, int x, int y, int z) { return NULL; } std::optional<AABB> WebTile::getAABB(Level* level, int x, int y, int z) { return std::nullopt; }
int WebTile::getRenderShape() { return Tile::SHAPE_CROSS_TEXTURE; } int WebTile::getRenderShape() { return Tile::SHAPE_CROSS_TEXTURE; }
@ -25,4 +26,4 @@ int WebTile::getResource(int data, Random* random, int playerBonusLevel) {
return Item::string->id; return Item::string->id;
} }
bool WebTile::isSilkTouchable() { return true; } bool WebTile::isSilkTouchable() { return true; }

View file

@ -14,7 +14,7 @@ public:
bool isSolidRender(bool isServerLevel = false); bool isSolidRender(bool isServerLevel = false);
public: public:
AABB* getAABB(Level* level, int x, int y, int z); std::optional<AABB> getAABB(Level* level, int x, int y, int z);
public: public:
int getRenderShape(); int getRenderShape();
@ -25,4 +25,4 @@ public:
protected: protected:
bool isSilkTouchable(); bool isSilkTouchable();
}; };

View file

@ -15,13 +15,13 @@ Icon* WoolCarpetTile::getTexture(int face, int data) {
return Tile::wool->getTexture(face, data); return Tile::wool->getTexture(face, data);
} }
AABB* WoolCarpetTile::getAABB(Level* level, int x, int y, int z) { std::optional<AABB> WoolCarpetTile::getAABB(Level* level, int x, int y, int z) {
int height = 0; int height = 0;
float offset = 1.0f / SharedConstants::WORLD_RESOLUTION; float offset = 1.0f / SharedConstants::WORLD_RESOLUTION;
ThreadStorage* tls = m_tlsShape; ThreadStorage* tls = m_tlsShape;
// 4J Stu - Added this so that the TLS shape is correct for this tile // 4J Stu - Added this so that the TLS shape is correct for this tile
if (tls->tileId != this->id) updateDefaultShape(); 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 + (height * offset), z + tls->zz1); y + (height * offset), z + tls->zz1);
} }

View file

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <optional>
#include "Tile.h" #include "Tile.h"
class WoolCarpetTile : public Tile { class WoolCarpetTile : public Tile {
@ -10,7 +11,7 @@ protected:
public: public:
Icon* getTexture(int face, int data); Icon* getTexture(int face, int data);
AABB* getAABB(Level* level, int x, int y, int z); std::optional<AABB> getAABB(Level* level, int x, int y, int z);
bool blocksLight(); bool blocksLight();
bool isSolidRender(bool isServerLevel = false); bool isSolidRender(bool isServerLevel = false);
bool isCubeShaped(); bool isCubeShaped();
@ -37,4 +38,4 @@ public:
static int getTileDataForItemAuxValue(int auxValue); static int getTileDataForItemAuxValue(int auxValue);
static int getItemAuxValueForTileData(int data); static int getItemAuxValueForTileData(int data);
void registerIcons(IconRegister* iconRegister); void registerIcons(IconRegister* iconRegister);
}; };

View file

@ -183,9 +183,9 @@ void Arrow::tick() {
int t = level->getTile(xTile, yTile, zTile); int t = level->getTile(xTile, yTile, zTile);
if (t > 0) { if (t > 0) {
Tile::tiles[t]->updateShape(level, xTile, yTile, zTile); Tile::tiles[t]->updateShape(level, xTile, yTile, zTile);
AABB* aabb = Tile::tiles[t]->getAABB(level, xTile, yTile, zTile); auto aabb = Tile::tiles[t]->getAABB(level, xTile, yTile, zTile);
Vec3 pos{x, y, z}; Vec3 pos{x, y, z};
if (aabb != NULL && aabb->contains(pos)) { if (aabb.has_value() && aabb->contains(pos)) {
inGround = true; inGround = true;
} }
} }

View file

@ -3,6 +3,7 @@
#include "../Headers/net.minecraft.world.level.tile.h" #include "../Headers/net.minecraft.world.level.tile.h"
#include "../Headers/net.minecraft.world.level.h" #include "../Headers/net.minecraft.world.level.h"
#include "SnowItem.h" #include "SnowItem.h"
#include "Util/AABB.h"
SnowItem::SnowItem(int id, Tile* parentTile) SnowItem::SnowItem(int id, Tile* parentTile)
: AuxDataTileItem(id, parentTile) {} : AuxDataTileItem(id, parentTile) {}
@ -22,8 +23,9 @@ bool SnowItem::useOn(std::shared_ptr<ItemInstance> instance,
int currentData = level->getData(x, y, z); int currentData = level->getData(x, y, z);
int currentHeight = currentData & TopSnowTile::HEIGHT_MASK; int currentHeight = currentData & TopSnowTile::HEIGHT_MASK;
auto snow_bb = snowTile->getAABB(level, x, y, z);
if (currentHeight <= TopSnowTile::MAX_HEIGHT && if (currentHeight <= TopSnowTile::MAX_HEIGHT &&
level->isUnobstructed(snowTile->getAABB(level, x, y, z))) { level->isUnobstructed(snow_bb.has_value() ? &*snow_bb : nullptr)) {
if (!bTestUseOnOnly) { if (!bTestUseOnOnly) {
// Increase snow tile height // Increase snow tile height
if (level->setData( if (level->setData(
@ -46,4 +48,4 @@ bool SnowItem::useOn(std::shared_ptr<ItemInstance> instance,
return AuxDataTileItem::useOn(instance, player, level, x, y, z, face, return AuxDataTileItem::useOn(instance, player, level, x, y, z, face,
clickX, clickY, clickZ, bTestUseOnOnly); clickX, clickY, clickZ, bTestUseOnOnly);
} }

View file

@ -6,6 +6,7 @@
#include "../../Headers/net.minecraft.world.level.tile.h" #include "../../Headers/net.minecraft.world.level.tile.h"
#include "../../Headers/net.minecraft.h" #include "../../Headers/net.minecraft.h"
#include "StoneSlabTileItem.h" #include "StoneSlabTileItem.h"
#include "../../Util/AABB.h"
StoneSlabTileItem::StoneSlabTileItem(int id, HalfSlabTile* halfTile, StoneSlabTileItem::StoneSlabTileItem(int id, HalfSlabTile* halfTile,
HalfSlabTile* fullTile, bool full) HalfSlabTile* fullTile, bool full)
@ -55,7 +56,8 @@ bool StoneSlabTileItem::useOn(std::shared_ptr<ItemInstance> instance,
return true; return true;
} }
if (level->isUnobstructed(fullTile->getAABB(level, x, y, z)) && auto tile_bb = fullTile->getAABB(level, x, y, z);
if (level->isUnobstructed(tile_bb.has_value() ? &*tile_bb : nullptr) &&
level->setTileAndData(x, y, z, fullTile->id, slabType, level->setTileAndData(x, y, z, fullTile->id, slabType,
Tile::UPDATE_ALL)) { Tile::UPDATE_ALL)) {
level->playSound(x + 0.5f, y + 0.5f, z + 0.5f, level->playSound(x + 0.5f, y + 0.5f, z + 0.5f,
@ -127,7 +129,8 @@ bool StoneSlabTileItem::tryConvertTargetTile(
if (bTestUseOnOnly) { if (bTestUseOnOnly) {
return true; return true;
} }
if (level->isUnobstructed(fullTile->getAABB(level, x, y, z)) && auto tile_bb = fullTile->getAABB(level, x, y, z);
if (level->isUnobstructed(tile_bb.has_value() ? &*tile_bb : nullptr) &&
level->setTileAndData(x, y, z, fullTile->id, slabType, level->setTileAndData(x, y, z, fullTile->id, slabType,
Tile::UPDATE_ALL)) { Tile::UPDATE_ALL)) {
level->playSound(x + 0.5f, y + 0.5f, z + 0.5f, level->playSound(x + 0.5f, y + 0.5f, z + 0.5f,
@ -140,4 +143,4 @@ bool StoneSlabTileItem::tryConvertTargetTile(
} }
return false; return false;
} }

View file

@ -41,6 +41,7 @@
#include <cmath> #include <cmath>
#include <cstdint> #include <cstdint>
#include <limits> #include <limits>
#include <optional>
// 4J : WESTY : Added for time played stats. // 4J : WESTY : Added for time played stats.
#include "../Headers/net.minecraft.stats.h" #include "../Headers/net.minecraft.stats.h"
@ -1391,7 +1392,7 @@ HitResult* Level::clip(Vec3* a, Vec3* b, bool liquid, bool solidOnly) {
int data = getData(xTile0, yTile0, zTile0); int data = getData(xTile0, yTile0, zTile0);
Tile* tile = Tile::tiles[t]; Tile* tile = Tile::tiles[t];
if (solidOnly && tile != NULL && if (solidOnly && tile != NULL &&
tile->getAABB(this, xTile0, yTile0, zTile0) == NULL) { !tile->getAABB(this, xTile0, yTile0, zTile0).has_value()) {
// No collision // No collision
} else if (t > 0 && tile->mayPick(data, liquid)) { } else if (t > 0 && tile->mayPick(data, liquid)) {
@ -1499,7 +1500,7 @@ HitResult* Level::clip(Vec3* a, Vec3* b, bool liquid, bool solidOnly) {
int data = getData(xTile0, yTile0, zTile0); int data = getData(xTile0, yTile0, zTile0);
Tile* tile = Tile::tiles[t]; Tile* tile = Tile::tiles[t];
if (solidOnly && tile != NULL && if (solidOnly && tile != NULL &&
tile->getAABB(this, xTile0, yTile0, zTile0) == NULL) { !tile->getAABB(this, xTile0, yTile0, zTile0).has_value()) {
// No collision // No collision
} else if (t > 0 && tile->mayPick(data, liquid)) { } else if (t > 0 && tile->mayPick(data, liquid)) {
@ -2796,8 +2797,8 @@ bool Level::isFullAABBTile(int x, int y, int z) {
if (tile == 0 || Tile::tiles[tile] == NULL) { if (tile == 0 || Tile::tiles[tile] == NULL) {
return false; return false;
} }
AABB* aabb = Tile::tiles[tile]->getAABB(this, x, y, z); auto aabb = Tile::tiles[tile]->getAABB(this, x, y, z);
return aabb != NULL && aabb->getSize() >= 1; return aabb.has_value() && aabb->getSize() >= 1;
} }
bool Level::isTopSolidBlocking(int x, int y, int z) { bool Level::isTopSolidBlocking(int x, int y, int z) {
@ -3664,9 +3665,9 @@ bool Level::mayPlace(int tileId, int x, int y, int z, bool ignoreEntities,
Tile* tile = Tile::tiles[tileId]; Tile* tile = Tile::tiles[tileId];
AABB* aabb = tile->getAABB(this, x, y, z); auto aabb = tile->getAABB(this, x, y, z);
if (ignoreEntities) aabb = NULL; if (ignoreEntities) aabb = std::nullopt;
if (aabb != NULL && !isUnobstructed(aabb, ignoreEntity)) return false; if (aabb.has_value() && !isUnobstructed(&*aabb, ignoreEntity)) return false;
if (targetTile != NULL && if (targetTile != NULL &&
(targetTile == Tile::water || targetTile == Tile::calmWater || (targetTile == Tile::water || targetTile == Tile::calmWater ||
targetTile == Tile::lava || targetTile == Tile::calmLava || targetTile == Tile::lava || targetTile == Tile::calmLava ||