aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/PistonMovingPiece.cpp
diff options
context:
space:
mode:
authorModMaker101 <119018978+ModMaker101@users.noreply.github.com>2026-03-08 19:08:36 -0400
committerGitHub <noreply@github.com>2026-03-08 18:08:36 -0500
commit28614b922fb77149a54da1a87bebfbc98736f296 (patch)
tree7f828ba86a4ee18d0a80d29de64f6199a5412512 /Minecraft.World/PistonMovingPiece.cpp
parent88798b501d0cf6287b6f87acb2592676e3cec58d (diff)
Modernize project codebase (#906)
* Fixed boats falling and a TP glitch #266 * Replaced every C-style cast with C++ ones * Replaced every C-style cast with C++ ones * Fixed boats falling and a TP glitch #266 * Updated NULL to nullptr and fixing some type issues * Modernized and fixed a few bugs - Replaced most instances of `NULL` with `nullptr`. - Replaced most `shared_ptr(new ...)` with `make_shared`. - Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances. * Fixing more conflicts * Replace int loops with size_t and start work on overrides * Add safety checks and fix a issue with vector going OOR
Diffstat (limited to 'Minecraft.World/PistonMovingPiece.cpp')
-rw-r--r--Minecraft.World/PistonMovingPiece.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/Minecraft.World/PistonMovingPiece.cpp b/Minecraft.World/PistonMovingPiece.cpp
index 5fa9a475..5ae01007 100644
--- a/Minecraft.World/PistonMovingPiece.cpp
+++ b/Minecraft.World/PistonMovingPiece.cpp
@@ -23,7 +23,7 @@ void PistonMovingPiece::onPlace(Level *level, int x, int y, int z)
void PistonMovingPiece::onRemove(Level *level, int x, int y, int z, int id, int data)
{
shared_ptr<TileEntity> tileEntity = level->getTileEntity(x, y, z);
- if (tileEntity != NULL && dynamic_pointer_cast<PistonPieceEntity>(tileEntity) != NULL)
+ if (tileEntity != nullptr && dynamic_pointer_cast<PistonPieceEntity>(tileEntity) != nullptr)
{
dynamic_pointer_cast<PistonPieceEntity>(tileEntity)->finalTick();
}
@@ -62,7 +62,7 @@ bool PistonMovingPiece::use(Level *level, int x, int y, int z, shared_ptr<Player
{
if( soundOnly) return false;
// this is a special case in order to help removing invisible, unbreakable, blocks in the world
- if (!level->isClientSide && level->getTileEntity(x, y, z) == NULL)
+ if (!level->isClientSide && level->getTileEntity(x, y, z) == nullptr)
{
// this block is no longer valid
level->removeTile(x, y, z);
@@ -81,7 +81,7 @@ void PistonMovingPiece::spawnResources(Level *level, int x, int y, int z, int da
if (level->isClientSide) return;
shared_ptr<PistonPieceEntity> entity = getEntity(level, x, y, z);
- if (entity == NULL)
+ if (entity == nullptr)
{
return;
}
@@ -93,21 +93,21 @@ void PistonMovingPiece::neighborChanged(Level *level, int x, int y, int z, int t
{
if (!level->isClientSide)
{
- level->getTileEntity(x, y, z) == NULL;
+ level->getTileEntity(x, y, z) == nullptr;
}
}
shared_ptr<TileEntity> PistonMovingPiece::newMovingPieceEntity(int block, int data, int facing, bool extending, bool isSourcePiston)
{
- return shared_ptr<TileEntity>(new PistonPieceEntity(block, data, facing, extending, isSourcePiston));
+ return std::make_shared<PistonPieceEntity>(block, data, facing, extending, isSourcePiston);
}
AABB *PistonMovingPiece::getAABB(Level *level, int x, int y, int z)
{
shared_ptr<PistonPieceEntity> entity = getEntity(level, x, y, z);
- if (entity == NULL)
+ if (entity == nullptr)
{
- return NULL;
+ return nullptr;
}
// move the aabb depending on the animation
@@ -122,11 +122,11 @@ AABB *PistonMovingPiece::getAABB(Level *level, int x, int y, int z)
void PistonMovingPiece::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param
{
shared_ptr<PistonPieceEntity> entity = dynamic_pointer_cast<PistonPieceEntity>(forceEntity);
- if( entity == NULL ) entity = getEntity(level, x, y, z);
- if (entity != NULL)
+ if( entity == nullptr ) entity = getEntity(level, x, y, z);
+ if (entity != nullptr)
{
Tile *tile = Tile::tiles[entity->getId()];
- if (tile == NULL || tile == this)
+ if (tile == nullptr || tile == this)
{
return;
}
@@ -138,7 +138,7 @@ void PistonMovingPiece::updateShape(LevelSource *level, int x, int y, int z, int
progress = 1.0f - progress;
}
int facing = entity->getFacing();
- ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
+ ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(Tile::tlsIdxShape));
tls->xx0 = tile->getShapeX0() - Facing::STEP_X[facing] * progress;
tls->yy0 = tile->getShapeY0() - Facing::STEP_Y[facing] * progress;
tls->zz0 = tile->getShapeZ0() - Facing::STEP_Z[facing] * progress;
@@ -152,13 +152,13 @@ AABB *PistonMovingPiece::getAABB(Level *level, int x, int y, int z, int tile, fl
{
if (tile == 0 || tile == id)
{
- return NULL;
+ return nullptr;
}
AABB *aabb = Tile::tiles[tile]->getAABB(level, x, y, z);
- if (aabb == NULL)
+ if (aabb == nullptr)
{
- return NULL;
+ return nullptr;
}
// move the aabb depending on the animation
@@ -192,7 +192,7 @@ AABB *PistonMovingPiece::getAABB(Level *level, int x, int y, int z, int tile, fl
shared_ptr<PistonPieceEntity> PistonMovingPiece::getEntity(LevelSource *level, int x, int y, int z)
{
shared_ptr<TileEntity> tileEntity = level->getTileEntity(x, y, z);
- if (tileEntity != NULL && dynamic_pointer_cast<PistonPieceEntity>(tileEntity) != NULL)
+ if (tileEntity != nullptr && dynamic_pointer_cast<PistonPieceEntity>(tileEntity) != nullptr)
{
return dynamic_pointer_cast<PistonPieceEntity>(tileEntity);
}