mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-05-28 17:55:54 +00:00
chore: format Minecraft.World
This commit is contained in:
@@ -6,64 +6,51 @@
|
||||
#include "../Util/Facing.h"
|
||||
#include "../Util/AABB.h"
|
||||
|
||||
PistonMovingPiece::PistonMovingPiece(int id) : EntityTile(id, Material::piston, false )
|
||||
{
|
||||
setDestroyTime(INDESTRUCTIBLE_DESTROY_TIME);
|
||||
PistonMovingPiece::PistonMovingPiece(int id)
|
||||
: EntityTile(id, Material::piston, false) {
|
||||
setDestroyTime(INDESTRUCTIBLE_DESTROY_TIME);
|
||||
}
|
||||
|
||||
std::shared_ptr<TileEntity> PistonMovingPiece::newTileEntity(Level *level)
|
||||
{
|
||||
return nullptr;
|
||||
std::shared_ptr<TileEntity> PistonMovingPiece::newTileEntity(Level* level) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void PistonMovingPiece::onPlace(Level *level, int x, int y, int z)
|
||||
{
|
||||
}
|
||||
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)
|
||||
{
|
||||
void PistonMovingPiece::onRemove(Level* level, int x, int y, int z, int id,
|
||||
int data) {
|
||||
std::shared_ptr<TileEntity> tileEntity = level->getTileEntity(x, y, z);
|
||||
if (tileEntity != NULL && std::dynamic_pointer_cast<PistonPieceEntity>(tileEntity) != NULL)
|
||||
{
|
||||
if (tileEntity != NULL &&
|
||||
std::dynamic_pointer_cast<PistonPieceEntity>(tileEntity) != NULL) {
|
||||
std::dynamic_pointer_cast<PistonPieceEntity>(tileEntity)->finalTick();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
EntityTile::onRemove(level, x, y, z, id, data);
|
||||
}
|
||||
}
|
||||
|
||||
bool PistonMovingPiece::mayPlace(Level *level, int x, int y, int z)
|
||||
{
|
||||
return false;
|
||||
bool PistonMovingPiece::mayPlace(Level* level, int x, int y, int z) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PistonMovingPiece::mayPlace(Level *level, int x, int y, int z, int face)
|
||||
{
|
||||
return false;
|
||||
bool PistonMovingPiece::mayPlace(Level* level, int x, int y, int z, int face) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int PistonMovingPiece::getRenderShape()
|
||||
{
|
||||
return SHAPE_INVISIBLE;
|
||||
}
|
||||
int PistonMovingPiece::getRenderShape() { return SHAPE_INVISIBLE; }
|
||||
|
||||
bool PistonMovingPiece::isSolidRender(bool isServerLevel)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool PistonMovingPiece::isSolidRender(bool isServerLevel) { return false; }
|
||||
|
||||
bool PistonMovingPiece::isCubeShaped()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool PistonMovingPiece::isCubeShaped() { return false; }
|
||||
|
||||
bool PistonMovingPiece::use(Level *level, int x, int y, int z, std::shared_ptr<Player> player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly/*=false*/) // 4J added soundOnly param
|
||||
bool PistonMovingPiece::use(
|
||||
Level* level, int x, int y, int z, std::shared_ptr<Player> player,
|
||||
int clickedFace, float clickX, float clickY, float clickZ,
|
||||
bool soundOnly /*=false*/) // 4J added soundOnly param
|
||||
{
|
||||
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 (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) {
|
||||
// this block is no longer valid
|
||||
level->setTile(x, y, z, 0);
|
||||
return true;
|
||||
@@ -71,73 +58,72 @@ bool PistonMovingPiece::use(Level *level, int x, int y, int z, std::shared_ptr<P
|
||||
return false;
|
||||
}
|
||||
|
||||
int PistonMovingPiece::getResource(int data, Random *random, int playerBonusLevel)
|
||||
{
|
||||
return 0;
|
||||
int PistonMovingPiece::getResource(int data, Random* random,
|
||||
int playerBonusLevel) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PistonMovingPiece::spawnResources(Level *level, int x, int y, int z, int data, float odds, int playerBonus)
|
||||
{
|
||||
void PistonMovingPiece::spawnResources(Level* level, int x, int y, int z,
|
||||
int data, float odds, int playerBonus) {
|
||||
if (level->isClientSide) return;
|
||||
|
||||
std::shared_ptr<PistonPieceEntity> entity = getEntity(level, x, y, z);
|
||||
if (entity == NULL)
|
||||
{
|
||||
if (entity == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
Tile::tiles[entity->getId()]->spawnResources(level, x, y, z, entity->getData(), 0);
|
||||
Tile::tiles[entity->getId()]->spawnResources(level, x, y, z,
|
||||
entity->getData(), 0);
|
||||
}
|
||||
|
||||
void PistonMovingPiece::neighborChanged(Level *level, int x, int y, int z, int type)
|
||||
{
|
||||
if (!level->isClientSide && level->getTileEntity(x, y, z) == NULL)
|
||||
{
|
||||
void PistonMovingPiece::neighborChanged(Level* level, int x, int y, int z,
|
||||
int type) {
|
||||
if (!level->isClientSide && level->getTileEntity(x, y, z) == NULL) {
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<TileEntity> PistonMovingPiece::newMovingPieceEntity(int block, int data, int facing, bool extending, bool isSourcePiston)
|
||||
{
|
||||
return std::shared_ptr<TileEntity>(new PistonPieceEntity(block, data, facing, extending, isSourcePiston));
|
||||
std::shared_ptr<TileEntity> PistonMovingPiece::newMovingPieceEntity(
|
||||
int block, int data, int facing, bool extending, bool isSourcePiston) {
|
||||
return std::shared_ptr<TileEntity>(
|
||||
new PistonPieceEntity(block, data, facing, extending, isSourcePiston));
|
||||
}
|
||||
|
||||
AABB *PistonMovingPiece::getAABB(Level *level, int x, int y, int z)
|
||||
{
|
||||
AABB* PistonMovingPiece::getAABB(Level* level, int x, int y, int z) {
|
||||
std::shared_ptr<PistonPieceEntity> entity = getEntity(level, x, y, z);
|
||||
if (entity == NULL)
|
||||
{
|
||||
if (entity == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// move the aabb depending on the animation
|
||||
float progress = entity->getProgress(0);
|
||||
if (entity->isExtending())
|
||||
{
|
||||
if (entity->isExtending()) {
|
||||
progress = 1.0f - progress;
|
||||
}
|
||||
return getAABB(level, x, y, z, entity->getId(), progress, entity->getFacing());
|
||||
return getAABB(level, x, y, z, entity->getId(), progress,
|
||||
entity->getFacing());
|
||||
}
|
||||
|
||||
void PistonMovingPiece::updateShape(LevelSource *level, int x, int y, int z, int forceData, std::shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param
|
||||
void PistonMovingPiece::updateShape(
|
||||
LevelSource* level, int x, int y, int z, int forceData,
|
||||
std::shared_ptr<TileEntity>
|
||||
forceEntity) // 4J added forceData, forceEntity param
|
||||
{
|
||||
std::shared_ptr<PistonPieceEntity> entity = std::dynamic_pointer_cast<PistonPieceEntity>(forceEntity);
|
||||
if( entity == NULL ) entity = getEntity(level, x, y, z);
|
||||
if (entity != NULL)
|
||||
{
|
||||
Tile *tile = Tile::tiles[entity->getId()];
|
||||
if (tile == NULL || tile == this)
|
||||
{
|
||||
std::shared_ptr<PistonPieceEntity> entity =
|
||||
std::dynamic_pointer_cast<PistonPieceEntity>(forceEntity);
|
||||
if (entity == NULL) entity = getEntity(level, x, y, z);
|
||||
if (entity != NULL) {
|
||||
Tile* tile = Tile::tiles[entity->getId()];
|
||||
if (tile == NULL || tile == this) {
|
||||
return;
|
||||
}
|
||||
tile->updateShape(level, x, y, z);
|
||||
|
||||
float progress = entity->getProgress(0);
|
||||
if (entity->isExtending())
|
||||
{
|
||||
if (entity->isExtending()) {
|
||||
progress = 1.0f - progress;
|
||||
}
|
||||
int facing = entity->getFacing();
|
||||
ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape);
|
||||
ThreadStorage* tls = (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;
|
||||
@@ -147,65 +133,52 @@ void PistonMovingPiece::updateShape(LevelSource *level, int x, int y, int z, int
|
||||
}
|
||||
}
|
||||
|
||||
AABB *PistonMovingPiece::getAABB(Level *level, int x, int y, int z, int tile, float progress, int facing)
|
||||
{
|
||||
if (tile == 0 || tile == id)
|
||||
{
|
||||
return NULL;
|
||||
AABB* PistonMovingPiece::getAABB(Level* level, int x, int y, int z, int tile,
|
||||
float progress, int facing) {
|
||||
if (tile == 0 || tile == id) {
|
||||
return NULL;
|
||||
}
|
||||
AABB *aabb = Tile::tiles[tile]->getAABB(level, x, y, z);
|
||||
AABB* aabb = Tile::tiles[tile]->getAABB(level, x, y, z);
|
||||
|
||||
if (aabb == NULL)
|
||||
{
|
||||
if (aabb == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// move the aabb depending on the animation
|
||||
if (Facing::STEP_X[facing] < 0)
|
||||
{
|
||||
aabb->x0 -= Facing::STEP_X[facing] * progress;
|
||||
}
|
||||
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;
|
||||
}
|
||||
if (Facing::STEP_X[facing] < 0) {
|
||||
aabb->x0 -= Facing::STEP_X[facing] * progress;
|
||||
} 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;
|
||||
}
|
||||
|
||||
std::shared_ptr<PistonPieceEntity> PistonMovingPiece::getEntity(LevelSource *level, int x, int y, int z)
|
||||
{
|
||||
std::shared_ptr<PistonPieceEntity> PistonMovingPiece::getEntity(
|
||||
LevelSource* level, int x, int y, int z) {
|
||||
std::shared_ptr<TileEntity> tileEntity = level->getTileEntity(x, y, z);
|
||||
if (tileEntity != NULL && std::dynamic_pointer_cast<PistonPieceEntity>(tileEntity) != NULL)
|
||||
{
|
||||
return std::dynamic_pointer_cast<PistonPieceEntity>(tileEntity);
|
||||
if (tileEntity != NULL &&
|
||||
std::dynamic_pointer_cast<PistonPieceEntity>(tileEntity) != NULL) {
|
||||
return std::dynamic_pointer_cast<PistonPieceEntity>(tileEntity);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void PistonMovingPiece::registerIcons(IconRegister *iconRegister)
|
||||
{
|
||||
// don't register null, register piston top instead (to get proper
|
||||
// particle effect)
|
||||
icon = iconRegister->registerIcon(L"piston_top");
|
||||
void PistonMovingPiece::registerIcons(IconRegister* iconRegister) {
|
||||
// don't register null, register piston top instead (to get proper
|
||||
// particle effect)
|
||||
icon = iconRegister->registerIcon(L"piston_top");
|
||||
}
|
||||
|
||||
int PistonMovingPiece::cloneTileId(Level *level, int x, int y, int z)
|
||||
{
|
||||
return 0;
|
||||
int PistonMovingPiece::cloneTileId(Level* level, int x, int y, int z) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user