mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-06-10 01:13:26 +00:00
chore: format Minecraft.World
This commit is contained in:
@@ -6,173 +6,160 @@
|
||||
#include "PortalTile.h"
|
||||
#include "FireTile.h"
|
||||
|
||||
PortalTile::PortalTile(int id) : HalfTransparentTile(id, L"portal", Material::portal, false)
|
||||
{
|
||||
setTicking(true);
|
||||
PortalTile::PortalTile(int id)
|
||||
: HalfTransparentTile(id, L"portal", Material::portal, false) {
|
||||
setTicking(true);
|
||||
}
|
||||
|
||||
void PortalTile::tick(Level *level, int x, int y, int z, Random *random)
|
||||
{
|
||||
HalfTransparentTile::tick(level, x, y, z, random);
|
||||
void PortalTile::tick(Level* level, int x, int y, int z, Random* random) {
|
||||
HalfTransparentTile::tick(level, x, y, z, random);
|
||||
|
||||
if (level->dimension->isNaturalDimension() && random->nextInt(2000) < level->difficulty)
|
||||
{
|
||||
// locate floor
|
||||
int y0 = y;
|
||||
while (!level->isTopSolidBlocking(x, y0, z) && y0 > 0)
|
||||
{
|
||||
y0--;
|
||||
}
|
||||
if (y0 > 0 && !level->isSolidBlockingTile(x, y0 + 1, z))
|
||||
{
|
||||
// spawn a pig man here
|
||||
int result = 0;
|
||||
bool spawned = MonsterPlacerItem::spawnMobAt(level, 57, x + .5, y0 + 1.1, z + .5, &result) != NULL;
|
||||
}
|
||||
}
|
||||
if (level->dimension->isNaturalDimension() &&
|
||||
random->nextInt(2000) < level->difficulty) {
|
||||
// locate floor
|
||||
int y0 = y;
|
||||
while (!level->isTopSolidBlocking(x, y0, z) && y0 > 0) {
|
||||
y0--;
|
||||
}
|
||||
if (y0 > 0 && !level->isSolidBlockingTile(x, y0 + 1, z)) {
|
||||
// spawn a pig man here
|
||||
int result = 0;
|
||||
bool spawned =
|
||||
MonsterPlacerItem::spawnMobAt(level, 57, x + .5, y0 + 1.1,
|
||||
z + .5, &result) != NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AABB *PortalTile::getAABB(Level *level, int x, int y, int z)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
AABB* PortalTile::getAABB(Level* level, int x, int y, int z) { return NULL; }
|
||||
|
||||
void PortalTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, std::shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param
|
||||
void PortalTile::updateShape(
|
||||
LevelSource* level, int x, int y, int z, int forceData,
|
||||
std::shared_ptr<TileEntity>
|
||||
forceEntity) // 4J added forceData, forceEntity param
|
||||
{
|
||||
if (level->getTile(x - 1, y, z) == id || level->getTile(x + 1, y, z) == id)
|
||||
{
|
||||
if (level->getTile(x - 1, y, z) == id ||
|
||||
level->getTile(x + 1, y, z) == id) {
|
||||
float xr = 8 / 16.0f;
|
||||
float yr = 2 / 16.0f;
|
||||
this->setShape(0.5f - xr, 0, 0.5f - yr, 0.5f + xr, 1, 0.5f + yr);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
float xr = 2 / 16.0f;
|
||||
float yr = 8 / 16.0f;
|
||||
this->setShape(0.5f - xr, 0, 0.5f - yr, 0.5f + xr, 1, 0.5f + yr);
|
||||
}
|
||||
}
|
||||
|
||||
bool PortalTile::isSolidRender(bool isServerLevel)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool PortalTile::isSolidRender(bool isServerLevel) { return false; }
|
||||
|
||||
bool PortalTile::isCubeShaped()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool PortalTile::isCubeShaped() { return false; }
|
||||
|
||||
bool PortalTile::trySpawnPortal(Level *level, int x, int y, int z, bool actuallySpawn)
|
||||
{
|
||||
bool PortalTile::trySpawnPortal(Level* level, int x, int y, int z,
|
||||
bool actuallySpawn) {
|
||||
int xd = 0;
|
||||
int zd = 0;
|
||||
if (level->getTile(x - 1, y, z) == Tile::obsidian_Id || level->getTile(x + 1, y, z) == Tile::obsidian_Id) xd = 1;
|
||||
if (level->getTile(x, y, z - 1) == Tile::obsidian_Id || level->getTile(x, y, z + 1) == Tile::obsidian_Id) zd = 1;
|
||||
if (level->getTile(x - 1, y, z) == Tile::obsidian_Id ||
|
||||
level->getTile(x + 1, y, z) == Tile::obsidian_Id)
|
||||
xd = 1;
|
||||
if (level->getTile(x, y, z - 1) == Tile::obsidian_Id ||
|
||||
level->getTile(x, y, z + 1) == Tile::obsidian_Id)
|
||||
zd = 1;
|
||||
|
||||
if (xd == zd) return false;
|
||||
|
||||
if (level->getTile(x - xd, y, z - zd) == 0)
|
||||
{
|
||||
if (level->getTile(x - xd, y, z - zd) == 0) {
|
||||
x -= xd;
|
||||
z -= zd;
|
||||
}
|
||||
|
||||
for (int xx = -1; xx <= 2; xx++)
|
||||
{
|
||||
for (int yy = -1; yy <= 3; yy++)
|
||||
{
|
||||
for (int xx = -1; xx <= 2; xx++) {
|
||||
for (int yy = -1; yy <= 3; yy++) {
|
||||
bool edge = (xx == -1) || (xx == 2) || (yy == -1) || (yy == 3);
|
||||
if ((xx == -1 || xx == 2) && (yy == -1 || yy == 3)) continue;
|
||||
|
||||
int t = level->getTile(x + xd * xx, y + yy, z + zd * xx);
|
||||
|
||||
if (edge)
|
||||
{
|
||||
if (edge) {
|
||||
if (t != Tile::obsidian_Id) return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if (t != 0 && t != Tile::fire_Id) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !actuallySpawn )
|
||||
return true;
|
||||
if (!actuallySpawn) return true;
|
||||
|
||||
level->noNeighborUpdate = true;
|
||||
for (int xx = 0; xx < 2; xx++)
|
||||
{
|
||||
for (int yy = 0; yy < 3; yy++)
|
||||
{
|
||||
level->setTile(x + xd * xx, y + yy, z + zd * xx, Tile::portalTile_Id);
|
||||
for (int xx = 0; xx < 2; xx++) {
|
||||
for (int yy = 0; yy < 3; yy++) {
|
||||
level->setTile(x + xd * xx, y + yy, z + zd * xx,
|
||||
Tile::portalTile_Id);
|
||||
}
|
||||
}
|
||||
level->noNeighborUpdate = false;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
void PortalTile::neighborChanged(Level *level, int x, int y, int z, int type)
|
||||
{
|
||||
void PortalTile::neighborChanged(Level* level, int x, int y, int z, int type) {
|
||||
int xd = 0;
|
||||
int zd = 1;
|
||||
if (level->getTile(x - 1, y, z) == id || level->getTile(x + 1, y, z) == id)
|
||||
{
|
||||
if (level->getTile(x - 1, y, z) == id ||
|
||||
level->getTile(x + 1, y, z) == id) {
|
||||
xd = 1;
|
||||
zd = 0;
|
||||
}
|
||||
|
||||
int yBottom = y;
|
||||
while (level->getTile(x, yBottom - 1, z) == id)
|
||||
yBottom--;
|
||||
while (level->getTile(x, yBottom - 1, z) == id) yBottom--;
|
||||
|
||||
if (level->getTile(x, yBottom - 1, z) != Tile::obsidian_Id)
|
||||
{
|
||||
if (level->getTile(x, yBottom - 1, z) != Tile::obsidian_Id) {
|
||||
level->setTile(x, y, z, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
int height = 1;
|
||||
while (height < 4 && level->getTile(x, yBottom + height, z) == id)
|
||||
height++;
|
||||
while (height < 4 && level->getTile(x, yBottom + height, z) == id) height++;
|
||||
|
||||
if (height != 3 || level->getTile(x, yBottom + height, z) != Tile::obsidian_Id)
|
||||
{
|
||||
if (height != 3 ||
|
||||
level->getTile(x, yBottom + height, z) != Tile::obsidian_Id) {
|
||||
level->setTile(x, y, z, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
bool we = level->getTile(x - 1, y, z) == id || level->getTile(x + 1, y, z) == id;
|
||||
bool ns = level->getTile(x, y, z - 1) == id || level->getTile(x, y, z + 1) == id;
|
||||
if (we && ns)
|
||||
{
|
||||
bool we =
|
||||
level->getTile(x - 1, y, z) == id || level->getTile(x + 1, y, z) == id;
|
||||
bool ns =
|
||||
level->getTile(x, y, z - 1) == id || level->getTile(x, y, z + 1) == id;
|
||||
if (we && ns) {
|
||||
level->setTile(x, y, z, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(//
|
||||
(level->getTile(x + xd, y, z + zd) == Tile::obsidian_Id && level->getTile(x - xd, y, z - zd) == id) || //
|
||||
(level->getTile(x - xd, y, z - zd) == Tile::obsidian_Id && level->getTile(x + xd, y, z + zd) == id)//
|
||||
))
|
||||
{
|
||||
if (!( //
|
||||
(level->getTile(x + xd, y, z + zd) == Tile::obsidian_Id &&
|
||||
level->getTile(x - xd, y, z - zd) == id) || //
|
||||
(level->getTile(x - xd, y, z - zd) == Tile::obsidian_Id &&
|
||||
level->getTile(x + xd, y, z + zd) == id) //
|
||||
)) {
|
||||
level->setTile(x, y, z, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool PortalTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face)
|
||||
{
|
||||
bool PortalTile::shouldRenderFace(LevelSource* level, int x, int y, int z,
|
||||
int face) {
|
||||
if (level->getTile(x, y, z) == id) return false;
|
||||
|
||||
bool w = level->getTile(x - 1, y, z) == id && level->getTile(x - 2, y, z) != id;
|
||||
bool e = level->getTile(x + 1, y, z) == id && level->getTile(x + 2, y, z) != id;
|
||||
bool w =
|
||||
level->getTile(x - 1, y, z) == id && level->getTile(x - 2, y, z) != id;
|
||||
bool e =
|
||||
level->getTile(x + 1, y, z) == id && level->getTile(x + 2, y, z) != id;
|
||||
|
||||
bool n = level->getTile(x, y, z - 1) == id && level->getTile(x, y, z - 2) != id;
|
||||
bool s = level->getTile(x, y, z + 1) == id && level->getTile(x, y, z + 2) != id;
|
||||
bool n =
|
||||
level->getTile(x, y, z - 1) == id && level->getTile(x, y, z - 2) != id;
|
||||
bool s =
|
||||
level->getTile(x, y, z + 1) == id && level->getTile(x, y, z + 2) != id;
|
||||
|
||||
bool we = w || e;
|
||||
bool ns = n || s;
|
||||
@@ -185,29 +172,24 @@ bool PortalTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int f
|
||||
return false;
|
||||
}
|
||||
|
||||
int PortalTile::getResourceCount(Random *random)
|
||||
{
|
||||
return 0;
|
||||
int PortalTile::getResourceCount(Random* random) { return 0; }
|
||||
|
||||
int PortalTile::getRenderLayer() { return 1; }
|
||||
|
||||
void PortalTile::entityInside(Level* level, int x, int y, int z,
|
||||
std::shared_ptr<Entity> entity) {
|
||||
if (entity->riding == NULL && entity->rider.lock() == NULL)
|
||||
entity->handleInsidePortal();
|
||||
}
|
||||
|
||||
int PortalTile::getRenderLayer()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void PortalTile::entityInside(Level *level, int x, int y, int z, std::shared_ptr<Entity> entity)
|
||||
{
|
||||
if (entity->riding == NULL && entity->rider.lock() == NULL) entity->handleInsidePortal();
|
||||
}
|
||||
|
||||
void PortalTile::animateTick(Level *level, int xt, int yt, int zt, Random *random)
|
||||
{
|
||||
if (random->nextInt(100) == 0)
|
||||
{
|
||||
level->playLocalSound(xt + 0.5, yt + 0.5, zt + 0.5, eSoundType_PORTAL_PORTAL, 0.5f, random->nextFloat() * 0.4f + 0.8f);
|
||||
void PortalTile::animateTick(Level* level, int xt, int yt, int zt,
|
||||
Random* random) {
|
||||
if (random->nextInt(100) == 0) {
|
||||
level->playLocalSound(xt + 0.5, yt + 0.5, zt + 0.5,
|
||||
eSoundType_PORTAL_PORTAL, 0.5f,
|
||||
random->nextFloat() * 0.4f + 0.8f);
|
||||
}
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
for (int i = 0; i < 4; i++) {
|
||||
double x = xt + random->nextFloat();
|
||||
double y = yt + random->nextFloat();
|
||||
double z = zt + random->nextFloat();
|
||||
@@ -218,13 +200,11 @@ void PortalTile::animateTick(Level *level, int xt, int yt, int zt, Random *rando
|
||||
xa = (random->nextFloat() - 0.5) * 0.5;
|
||||
ya = (random->nextFloat() - 0.5) * 0.5;
|
||||
za = (random->nextFloat() - 0.5) * 0.5;
|
||||
if (level->getTile(xt - 1, yt, zt) == id || level->getTile(xt + 1, yt, zt) == id)
|
||||
{
|
||||
if (level->getTile(xt - 1, yt, zt) == id ||
|
||||
level->getTile(xt + 1, yt, zt) == id) {
|
||||
z = zt + 0.5 + (0.25) * flip;
|
||||
za = (random->nextFloat() * 2) * flip;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
x = xt + 0.5 + (0.25) * flip;
|
||||
xa = (random->nextFloat() * 2) * flip;
|
||||
}
|
||||
@@ -233,14 +213,8 @@ void PortalTile::animateTick(Level *level, int xt, int yt, int zt, Random *rando
|
||||
}
|
||||
}
|
||||
|
||||
int PortalTile::cloneTileId(Level *level, int x, int y, int z)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int PortalTile::cloneTileId(Level* level, int x, int y, int z) { return 0; }
|
||||
|
||||
// 4J Added - We cannot collect the portal tile, so don't consider it as a hit result
|
||||
// Bug #754 - Riding a minecart into a portal will trap the player
|
||||
bool PortalTile::mayPick()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// 4J Added - We cannot collect the portal tile, so don't consider it as a hit
|
||||
// result Bug #754 - Riding a minecart into a portal will trap the player
|
||||
bool PortalTile::mayPick() { return false; }
|
||||
|
||||
Reference in New Issue
Block a user