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

View file

@ -20,7 +20,7 @@ protected:
public:
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 blocksLight();
virtual bool isCubeShaped();
@ -56,4 +56,4 @@ protected:
public:
virtual void registerIcons(IconRegister* iconRegister);
};
};

View file

@ -3,6 +3,7 @@
#include "../Headers/net.minecraft.world.level.h"
#include "../Headers/net.minecraft.world.h"
#include "BaseRailTile.h"
#include <optional>
BaseRailTile::Rail::Rail(Level* level, int x, int y, int z) {
this->level = level;
@ -311,7 +312,7 @@ BaseRailTile::BaseRailTile(int id, bool 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; }
@ -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 - 1, z, id);
}
}
}

View file

@ -70,7 +70,7 @@ public:
using Tile::getResourceCount;
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 isSolidRender(bool isServerLevel = false);
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.h"
#include "ButtonTile.h"
#include <optional>
#include "../Util/SoundTypes.h"
ButtonTile::ButtonTile(int id, bool sensitive)
@ -20,7 +21,7 @@ Icon* ButtonTile::getTexture(int face, int data) {
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; }

View file

@ -17,7 +17,7 @@ protected:
public:
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 bool blocksLight();
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
// it's actually going to do seomthing
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;
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) {

View file

@ -20,7 +20,7 @@ protected:
public:
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 Icon* getTexture(int face, int data);
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
// it's actually going to do seomthing
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);
}
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);
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 - 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) {

View file

@ -24,7 +24,7 @@ protected:
std::shared_ptr<TileEntity> forceEntity = std::shared_ptr<
TileEntity>()); // 4J added forceData, forceEntity param
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 Icon* getTexture(int face, int data);
//@Override
@ -49,4 +49,4 @@ public:
virtual int getResourceCount(Random* random);
virtual int getResource(int data, Random* random, int playerBonusLevel);
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.h"
#include "CocoaTile.h"
#include "Util/AABB.h"
const std::wstring CocoaTile::TEXTURE_AGES[] = {L"cocoa_0", L"cocoa_1",
L"cocoa_2"};
@ -56,7 +57,7 @@ bool CocoaTile::isCubeShaped() { 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);
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++) {
icons[i] = iconRegister->registerIcon(TEXTURE_AGES[i]);
}
}
}

View file

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

View file

@ -91,10 +91,9 @@ AABB* DoorTile::getTileAABB(Level* level, int x, int y, int z) {
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);
AABB* retval = Tile::getAABB(level, x, y, z);
return retval;
return Tile::getAABB(level, x, y, z);
}
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 int getRenderShape();
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(
LevelSource* level, int x, int y, int z, int forceData = -1,
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
void FarmTile::updateDefaultShape() { setShape(0, 0, 0, 1, 15 / 16.0f, 1); }
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);
std::optional<AABB> FarmTile::getAABB(Level* level, int x, int y, int z) {
return AABB(x + 0, y + 0, z + 0, x + 1, y + 1, z + 1);
}
bool FarmTile::isSolidRender(bool isServerLevel) { return false; }

View file

@ -18,7 +18,7 @@ protected:
public:
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 isCubeShaped();
virtual Icon* getTexture(int face, int data);

View file

@ -4,6 +4,7 @@
#include "../Headers/net.minecraft.world.level.h"
#include "../Headers/net.minecraft.h"
#include "../Level/Events/LevelEvent.h"
#include "Util/Direction.h"
FenceGateTile::FenceGateTile(int id)
: 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);
}
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);
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) {
return AABB::newTemp(x, y, z + 6.0f / 16.0f, x + 1, y + 1.5f,
z + 10.0f / 16.0f);
switch (data) {
case Direction::NORTH:
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

View file

@ -9,7 +9,7 @@ public:
FenceGateTile(int id);
Icon* getTexture(int face, int data);
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(
LevelSource* level, int x, int y, int z, int forceData = -1,
std::shared_ptr<TileEntity> forceEntity = std::shared_ptr<

View file

@ -7,6 +7,7 @@
#include "../Util/SoundTypes.h"
#include "../../Minecraft.Client/MinecraftServer.h"
#include "../../Minecraft.Client/Network/PlayerList.h"
#include "Util/AABB.h"
// AP - added for Vita to set Alpha Cut out
#include "../IO/Streams/IntBuffer.h"
@ -57,7 +58,7 @@ void FireTile::setFlammable(int id, int flame, int 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; }

View file

@ -39,7 +39,7 @@ private:
void setFlammable(int id, int flame, int burn);
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 isSolidRender(bool isServerLevel = false);
virtual bool isCubeShaped();
@ -69,4 +69,4 @@ public:
void registerIcons(IconRegister* iconRegister);
Icon* getTextureLayer(int layer);
Icon* getTexture(int face, int data);
};
};

View file

@ -1,11 +1,12 @@
#include "../Platform/stdafx.h"
#include "../Headers/net.minecraft.world.level.h"
#include "LadderTile.h"
#include "Util/AABB.h"
LadderTile::LadderTile(int id)
: 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);
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);
}
int LadderTile::getResourceCount(Random* random) { return 1; }
int LadderTile::getResourceCount(Random* random) { return 1; }

View file

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

View file

@ -3,11 +3,12 @@
#include "../Headers/net.minecraft.world.level.redstone.h"
#include "../Headers/net.minecraft.h"
#include "LeverTile.h"
#include "Util/AABB.h"
LeverTile::LeverTile(int id)
: 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; }

View file

@ -8,7 +8,7 @@ protected:
LeverTile(int id);
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 isSolidRender(bool isServerLevel = false);
virtual bool isCubeShaped();

View file

@ -5,9 +5,11 @@
#include "../Headers/net.minecraft.world.level.biome.h"
#include "../Headers/net.minecraft.world.h"
#include "LiquidTile.h"
#include <cstddef>
#include "../Util/Facing.h"
#include "../Util/SoundTypes.h"
#include "Blocks/Material.h"
#include "Util/AABB.h"
const std::wstring LiquidTile::TEXTURE_LAVA_STILL = L"lava";
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);
}
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; }

View file

@ -1,4 +1,5 @@
#pragma once
#include <optional>
#include "Tile.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 shouldRenderFace(LevelSource* level, int x, int y, int z,
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 getResource(int data, Random* random, int playerBonusLevel);
virtual int getResourceCount(Random* random);

View file

@ -1,5 +1,6 @@
#include "../Platform/stdafx.h"
#include <cstdint>
#include <optional>
#include "PistonBaseTile.h"
#include "PistonMovingTileEntity.h"
#include "TileEntities/PistonPieceTileEntity.h"
@ -12,6 +13,8 @@
#include "../Level/LevelChunk.h"
#include "../Level/Dimensions/Dimension.h"
#include "Util/AABB.h"
const std::wstring PistonBaseTile::EDGE_TEX = L"piston_side";
const std::wstring PistonBaseTile::PLATFORM_TEX = L"piston_top";
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);
}
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);
return Tile::getAABB(level, x, y, z);
}

View file

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

View file

@ -1,5 +1,6 @@
#include "../Platform/stdafx.h"
#include "PistonMovingTileEntity.h"
#include <optional>
#include "TileEntities/PistonPieceTileEntity.h"
#include "../Headers/net.minecraft.world.level.h"
#include "../Headers/net.minecraft.world.h"
@ -91,10 +92,11 @@ std::shared_ptr<TileEntity> PistonMovingPiece::newMovingPieceEntity(
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);
if (entity == NULL) {
return NULL;
return std::nullopt;
}
// 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,
float progress, int facing) {
std::optional<AABB> PistonMovingPiece::getAABB(Level* level, int x, int y,
int z, int tile, float progress,
int facing) {
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) {
return NULL;
if (!aabb.has_value()) {
return std::nullopt;
}
// 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 {
aabb->x1 -= Facing::STEP_X[facing] * progress;
}
if (Facing::STEP_Y[facing] < 0) {
aabb->y0 -= Facing::STEP_Y[facing] * progress;
} else {
aabb->y1 -= Facing::STEP_Y[facing] * progress;
}
if (Facing::STEP_Z[facing] < 0) {
aabb->z0 -= Facing::STEP_Z[facing] * progress;
} else {
aabb->z1 -= Facing::STEP_Z[facing] * progress;
}
return aabb;
}

View file

@ -28,13 +28,13 @@ public:
virtual void neighborChanged(Level* level, int x, int y, int z, int type);
static std::shared_ptr<TileEntity> newMovingPieceEntity(
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(
LevelSource* level, int x, int y, int z, int forceData = -1,
std::shared_ptr<TileEntity> forceEntity = std::shared_ptr<
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);
private:
@ -44,4 +44,4 @@ private:
public:
virtual int cloneTileId(Level* level, int x, int y, int z);
void registerIcons(IconRegister* iconRegister);
};
};

View file

@ -2,6 +2,7 @@
#include "../Headers/net.minecraft.world.level.h"
#include "GrassTile.h"
#include "PlantTile.h"
#include "Util/AABB.h"
void Bush::_init() {
setTicking(true);
@ -52,7 +53,7 @@ bool Bush::canSurvive(Level* level, int x, int y, int 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; }

View file

@ -32,7 +32,7 @@ protected:
public:
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 isSolidRender(bool isServerLevel = false);

View file

@ -4,6 +4,9 @@
#include "../Headers/net.minecraft.world.level.dimension.h"
#include "../Headers/net.minecraft.world.item.h"
#include "PortalTile.h"
#include <optional>
#include "Util/AABB.h"
#include "FireTile.h"
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(
LevelSource* level, int x, int y, int z, int forceData,

View file

@ -1,4 +1,5 @@
#pragma once
#include <optional>
#include "HalfTransparentTile.h"
#include "../Util/Definitions.h"
@ -8,7 +9,7 @@ class PortalTile : public HalfTransparentTile {
public:
PortalTile(int id);
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(
LevelSource* level, int x, int y, int z, int forceData = -1,
std::shared_ptr<TileEntity> forceEntity = std::shared_ptr<

View file

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

View file

@ -1,4 +1,5 @@
#pragma once
#include <optional>
#include "Tile.h"
#include "../Util/Definitions.h"
@ -26,7 +27,7 @@ private:
public:
RedStoneDustTile(int id);
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 isCubeShaped();
virtual int getRenderShape();

View file

@ -5,6 +5,7 @@
#include "../Headers/net.minecraft.world.level.material.h"
#include "../Headers/net.minecraft.world.phys.h"
#include "ReedTile.h"
#include <optional>
ReedTile::ReedTile(int id) : Tile(id, Material::plant, false) {
this->updateDefaultShape();
@ -64,7 +65,7 @@ bool ReedTile::canSurvive(Level* level, int x, int y, int 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) {
return Item::reeds->id;

View file

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

View file

@ -4,6 +4,9 @@
#include "Material.h"
#include "TileEntities/SignTileEntity.h"
#include "SignTile.h"
#include "Util/AABB.h"
#include <optional>
SignTile::SignTile(int id, eINSTANCEOF clas, bool onGround)
: 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);
}
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) {
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) {
// None
}
}

View file

@ -1,5 +1,6 @@
#pragma once
#include <optional>
#include "BaseEntityTile.h"
#include "TileEntities/TileEntity.h"
@ -19,7 +20,7 @@ protected:
public:
Icon* getTexture(int face, int data);
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);
void updateShape(LevelSource* level, int x, int y, int z,
int forceData = -1,
@ -39,4 +40,4 @@ public:
void neighborChanged(Level* level, int x, int y, int z, int type);
int cloneTileId(Level* level, int x, int y, int z);
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);
return BaseEntityTile::getAABB(level, x, y, z);
}
@ -316,4 +316,4 @@ Icon* SkullTile::getTexture(int face, int data) {
std::wstring SkullTile::getTileItemIconName() {
return getIconName() + L"_" + SkullItem::ICON_NAMES[0];
}
}

View file

@ -26,7 +26,7 @@ public:
int forceData = -1,
std::shared_ptr<TileEntity> forceEntity =
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,
std::shared_ptr<LivingEntity> by);
std::shared_ptr<TileEntity> newTileEntity(Level* level);

View file

@ -5,9 +5,9 @@
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;
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,

View file

@ -5,7 +5,7 @@
class SoulSandTile : public Tile {
public:
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,
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,
AABBList* boxes, std::shared_ptr<Entity> source) {
AABB* aabb = getAABB(level, x, y, z);
if (aabb != NULL && box->intersects(*aabb)) boxes->push_back(*aabb);
auto aabb = getAABB(level, x, y, z);
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;
// 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,
y + tls->yy1, z + tls->zz1);
return AABB{x + tls->xx0, y + tls->yy0, z + tls->zz0,
x + tls->xx1, y + tls->yy1, z + tls->zz1};
}
bool Tile::isSolidRender(bool isServerLevel) { return true; }

View file

@ -4,6 +4,7 @@
#include "../Util/Definitions.h"
#include "../Util/SoundTypes.h"
#include <cstdint>
#include <optional>
class GrassTile;
class LeafTile;
@ -633,7 +634,7 @@ public:
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 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); // 4J - Added isServerLevel param
virtual bool mayPick(int data, bool liquid);

View file

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

View file

@ -16,7 +16,7 @@ protected:
public:
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:
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.tile.h"
#include "TorchTile.h"
#include <optional>
#include "Util/AABB.h"
TorchTile::TorchTile(int id) : Tile(id, Material::decoration, false) {
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) {
updateShape(level, x, y, z);

View file

@ -12,7 +12,7 @@ protected:
TorchTile(int id);
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 void updateShape(
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.h"
#include "TrapDoorTile.h"
#include "Util/AABB.h"
TrapDoorTile::TrapDoorTile(int id, Material* material)
: 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);
}
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);
return Tile::getAABB(level, x, y, z);
}
@ -175,4 +176,4 @@ bool TrapDoorTile::attachesTo(int id) {
tile == Tile::glowstone ||
(dynamic_cast<HalfSlabTile*>(tile) != NULL) ||
(dynamic_cast<StairTile*>(tile) != NULL);
}
}

View file

@ -40,7 +40,7 @@ public:
AABB* getTileAABB(Level* level, int x, int y, int z);
public:
AABB* getAABB(Level* level, int x, int y, int z);
std::optional<AABB> getAABB(Level* level, int x, int y, int z);
public:
void updateShape(LevelSource* level, int x, int y, int z,
@ -91,4 +91,4 @@ public:
private:
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.redstone.h"
#include "TripWireSourceTile.h"
#include "optional"
#include "Util/AABB.h"
TripWireSourceTile::TripWireSourceTile(int id)
: Tile(id, Material::decoration, false) {
this->setTicking(true);
}
AABB* TripWireSourceTile::getAABB(Level* level, int x, int y, int z) {
return NULL;
std::optional<AABB> TripWireSourceTile::getAABB(Level* level, int x, int y, int z) {
return std::nullopt;
}
bool TripWireSourceTile::blocksLight() { return false; }

View file

@ -14,7 +14,7 @@ public:
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 isSolidRender(bool isServerLevel = false);
bool isCubeShaped();

View file

@ -4,6 +4,7 @@
#include "../Headers/net.minecraft.world.level.tile.h"
#include "../Headers/net.minecraft.world.phys.h"
#include "TripWireTile.h"
#include <optional>
TripWireTile::TripWireTile(int id) : Tile(id, Material::decoration, false) {
setShape(0, 0, 0, 1, 2.5f / 16.0f, 1);
@ -16,7 +17,7 @@ int TripWireTile::getTickDelay(Level* level) {
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; }

View file

@ -14,7 +14,7 @@ public:
TripWireTile(int id);
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 isSolidRender(bool isServerLevel = false);
bool isCubeShaped();

View file

@ -7,6 +7,7 @@
#include "../Headers/net.minecraft.world.item.h"
#include "../Headers/net.minecraft.stats.h"
#include "../Headers/net.minecraft.world.level.biome.h"
#include "Util/AABB.h"
VineTile::VineTile(int id)
: Tile(id, Material::replaceable_plant, false) {
@ -85,7 +86,7 @@ void VineTile::updateShape(
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) {
switch (face) {

View file

@ -21,7 +21,7 @@ public:
LevelSource* level, int x, int y, int z, int forceData = -1,
std::shared_ptr<TileEntity> forceEntity = std::shared_ptr<
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);
private:
@ -43,4 +43,4 @@ public:
virtual int getResourceCount(Random* random);
virtual void playerDestroy(Level* level, std::shared_ptr<Player> player,
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);
}
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
// shape.
@ -125,7 +125,7 @@ AABB* WallTile::getAABB(Level* level, int x, int y, int z) {
// 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) {

View file

@ -25,9 +25,9 @@ public:
int forceData = -1,
std::shared_ptr<TileEntity> forceEntity =
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);
int getSpawnResourcesAuxValue(int data);
bool shouldRenderFace(LevelSource* level, int x, int y, int z, int face);
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;
// 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);
}

View file

@ -12,7 +12,7 @@ public:
virtual int getRenderShape();
virtual void addAABBs(Level* level, int x, int y, int z, AABB* box,
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(int auxData);
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.item.h"
#include "WebTile.h"
#include "Util/AABB.h"
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; }
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; }
@ -25,4 +26,4 @@ int WebTile::getResource(int data, Random* random, int playerBonusLevel) {
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);
public:
AABB* getAABB(Level* level, int x, int y, int z);
std::optional<AABB> getAABB(Level* level, int x, int y, int z);
public:
int getRenderShape();
@ -25,4 +25,4 @@ public:
protected:
bool isSilkTouchable();
};
};

View file

@ -15,13 +15,13 @@ Icon* WoolCarpetTile::getTexture(int face, int 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;
float offset = 1.0f / SharedConstants::WORLD_RESOLUTION;
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 + (height * offset), z + tls->zz1);
}

View file

@ -1,5 +1,6 @@
#pragma once
#include <optional>
#include "Tile.h"
class WoolCarpetTile : public Tile {
@ -10,7 +11,7 @@ protected:
public:
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 isSolidRender(bool isServerLevel = false);
bool isCubeShaped();
@ -37,4 +38,4 @@ public:
static int getTileDataForItemAuxValue(int auxValue);
static int getItemAuxValueForTileData(int data);
void registerIcons(IconRegister* iconRegister);
};
};

View file

@ -183,9 +183,9 @@ void Arrow::tick() {
int t = level->getTile(xTile, yTile, zTile);
if (t > 0) {
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};
if (aabb != NULL && aabb->contains(pos)) {
if (aabb.has_value() && aabb->contains(pos)) {
inGround = true;
}
}

View file

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

View file

@ -6,6 +6,7 @@
#include "../../Headers/net.minecraft.world.level.tile.h"
#include "../../Headers/net.minecraft.h"
#include "StoneSlabTileItem.h"
#include "../../Util/AABB.h"
StoneSlabTileItem::StoneSlabTileItem(int id, HalfSlabTile* halfTile,
HalfSlabTile* fullTile, bool full)
@ -55,7 +56,8 @@ bool StoneSlabTileItem::useOn(std::shared_ptr<ItemInstance> instance,
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,
Tile::UPDATE_ALL)) {
level->playSound(x + 0.5f, y + 0.5f, z + 0.5f,
@ -127,7 +129,8 @@ bool StoneSlabTileItem::tryConvertTargetTile(
if (bTestUseOnOnly) {
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,
Tile::UPDATE_ALL)) {
level->playSound(x + 0.5f, y + 0.5f, z + 0.5f,
@ -140,4 +143,4 @@ bool StoneSlabTileItem::tryConvertTargetTile(
}
return false;
}
}

View file

@ -41,6 +41,7 @@
#include <cmath>
#include <cstdint>
#include <limits>
#include <optional>
// 4J : WESTY : Added for time played stats.
#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);
Tile* tile = Tile::tiles[t];
if (solidOnly && tile != NULL &&
tile->getAABB(this, xTile0, yTile0, zTile0) == NULL) {
!tile->getAABB(this, xTile0, yTile0, zTile0).has_value()) {
// No collision
} 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);
Tile* tile = Tile::tiles[t];
if (solidOnly && tile != NULL &&
tile->getAABB(this, xTile0, yTile0, zTile0) == NULL) {
!tile->getAABB(this, xTile0, yTile0, zTile0).has_value()) {
// No collision
} 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) {
return false;
}
AABB* aabb = Tile::tiles[tile]->getAABB(this, x, y, z);
return aabb != NULL && aabb->getSize() >= 1;
auto aabb = Tile::tiles[tile]->getAABB(this, x, y, z);
return aabb.has_value() && aabb->getSize() >= 1;
}
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];
AABB* aabb = tile->getAABB(this, x, y, z);
if (ignoreEntities) aabb = NULL;
if (aabb != NULL && !isUnobstructed(aabb, ignoreEntity)) return false;
auto aabb = tile->getAABB(this, x, y, z);
if (ignoreEntities) aabb = std::nullopt;
if (aabb.has_value() && !isUnobstructed(&*aabb, ignoreEntity)) return false;
if (targetTile != NULL &&
(targetTile == Tile::water || targetTile == Tile::calmWater ||
targetTile == Tile::lava || targetTile == Tile::calmLava ||