aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/Region.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Minecraft.World/Region.cpp')
-rw-r--r--Minecraft.World/Region.cpp76
1 files changed, 46 insertions, 30 deletions
diff --git a/Minecraft.World/Region.cpp b/Minecraft.World/Region.cpp
index 4c3a454d..e3e91bf0 100644
--- a/Minecraft.World/Region.cpp
+++ b/Minecraft.World/Region.cpp
@@ -3,6 +3,7 @@
#include "net.minecraft.world.level.chunk.h"
#include "net.minecraft.world.level.dimension.h"
#include "net.minecraft.world.level.tile.h"
+#include "net.minecraft.world.level.redstone.h"
#include "Material.h"
#include "Level.h"
@@ -27,14 +28,14 @@ Region::~Region()
}
}
-Region::Region(Level *level, int x1, int y1, int z1, int x2, int y2, int z2)
+Region::Region(Level *level, int x1, int y1, int z1, int x2, int y2, int z2, int r)
{
this->level = level;
- xc1 = x1 >> 4;
- zc1 = z1 >> 4;
- int xc2 = x2 >> 4;
- int zc2 = z2 >> 4;
+ xc1 = (x1 - r) >> 4;
+ zc1 = (z1 - r) >> 4;
+ int xc2 = (x2 + r) >> 4;
+ int zc2 = (z2 + r) >> 4;
chunks = new LevelChunk2DArray(xc2 - xc1 + 1, zc2 - zc1 + 1);
@@ -48,7 +49,17 @@ Region::Region(Level *level, int x1, int y1, int z1, int x2, int y2, int z2)
{
LevelChunkArray *lca = (*chunks)[xc - xc1];
lca->data[zc - zc1] = chunk;
- //(*chunks)[xc - xc1].data[zc - zc1] = level->getChunk(xc, zc);
+ }
+ }
+ }
+ for (int xc = (x1 >> 4); xc <= (x2 >> 4); xc++)
+ {
+ for (int zc = (z1 >> 4); zc <= (z2 >> 4); zc++)
+ {
+ LevelChunkArray *lca = (*chunks)[xc - xc1];
+ LevelChunk *chunk = lca->data[zc - zc1];
+ if (chunk != NULL)
+ {
if (!chunk->isYSpaceEmpty(y1, y2))
{
allEmpty = false;
@@ -147,10 +158,10 @@ shared_ptr<TileEntity> Region::getTileEntity(int x, int y, int z)
int Region::getLightColor(int x, int y, int z, int emitt, int tileId/*=-1*/)
{
- int s = getBrightnessPropagate(LightLayer::Sky, x, y, z, tileId);
- int b = getBrightnessPropagate(LightLayer::Block, x, y, z, tileId);
- if (b < emitt) b = emitt;
- return s << 20 | b << 4;
+ int s = getBrightnessPropagate(LightLayer::Sky, x, y, z, tileId);
+ int b = getBrightnessPropagate(LightLayer::Block, x, y, z, tileId);
+ if (b < emitt) b = emitt;
+ return s << 20 | b << 4;
}
float Region::getBrightness(int x, int y, int z, int emitt)
@@ -289,14 +300,8 @@ bool Region::isSolidBlockingTile(int x, int y, int z)
bool Region::isTopSolidBlocking(int x, int y, int z)
{
- // Temporary workaround until tahgs per-face solidity is finished
Tile *tile = Tile::tiles[getTile(x, y, z)];
- if (tile == NULL) return false;
-
- if (tile->material->isSolidBlocking() && tile->isCubeShaped()) return true;
- if (dynamic_cast<StairTile *>(tile)) return (getData(x, y, z) & StairTile::UPSIDEDOWN_BIT) == StairTile::UPSIDEDOWN_BIT;
- if (dynamic_cast<HalfSlabTile *>(tile)) return (getData(x, y, z) & HalfSlabTile::TOP_SLOT_BIT) == HalfSlabTile::TOP_SLOT_BIT;
- return false;
+ return level->isTopSolidBlocking(tile, getData(x, y, z));
}
bool Region::isEmptyTile(int x, int y, int z)
@@ -309,15 +314,19 @@ bool Region::isEmptyTile(int x, int y, int z)
// 4J - brought forward from 1.8.2
int Region::getBrightnessPropagate(LightLayer::variety layer, int x, int y, int z, int tileId)
{
- if (y < 0) y = 0;
+ if (y < 0) y = 0;
if (y >= Level::maxBuildHeight) y = Level::maxBuildHeight - 1;
- if (y < 0 || y >= Level::maxBuildHeight || x < -Level::MAX_LEVEL_SIZE || z < -Level::MAX_LEVEL_SIZE || x >= Level::MAX_LEVEL_SIZE || z > Level::MAX_LEVEL_SIZE)
+ if (y < 0 || y >= Level::maxBuildHeight || x < -Level::MAX_LEVEL_SIZE || z < -Level::MAX_LEVEL_SIZE || x >= Level::MAX_LEVEL_SIZE || z > Level::MAX_LEVEL_SIZE)
{
// 4J Stu - The java LightLayer was an enum class type with a member "surrounding" which is what we
// were returning here. Surrounding has the same value as the enum value in our C++ code, so just cast
// it to an int
return (int)layer;
- }
+ }
+ if (layer == LightLayer::Sky && level->dimension->hasCeiling)
+ {
+ return 0;
+ }
int id = tileId > -1 ? tileId : getTile(x, y, z);
if (Tile::propagate[id])
@@ -334,31 +343,38 @@ int Region::getBrightnessPropagate(LightLayer::variety layer, int x, int y, int
return br;
}
- int xc = (x >> 4) - xc1;
- int zc = (z >> 4) - zc1;
+ int xc = (x >> 4) - xc1;
+ int zc = (z >> 4) - zc1;
- return (*chunks)[xc]->data[zc]->getBrightness(layer, x & 15, y, z & 15);
+ return (*chunks)[xc]->data[zc]->getBrightness(layer, x & 15, y, z & 15);
}
// 4J - brought forward from 1.8.2
int Region::getBrightness(LightLayer::variety layer, int x, int y, int z)
{
- if (y < 0) y = 0;
- if (y >= Level::maxBuildHeight) y = Level::maxBuildHeight - 1;
- if (y < 0 || y >= Level::maxBuildHeight || x < -Level::MAX_LEVEL_SIZE || z < -Level::MAX_LEVEL_SIZE || x >= Level::MAX_LEVEL_SIZE || z > Level::MAX_LEVEL_SIZE)
+ if (y < 0) y = 0;
+ if (y >= Level::maxBuildHeight) y = Level::maxBuildHeight - 1;
+ if (y < 0 || y >= Level::maxBuildHeight || x < -Level::MAX_LEVEL_SIZE || z < -Level::MAX_LEVEL_SIZE || x >= Level::MAX_LEVEL_SIZE || z > Level::MAX_LEVEL_SIZE)
{
// 4J Stu - The java LightLayer was an enum class type with a member "surrounding" which is what we
// were returning here. Surrounding has the same value as the enum value in our C++ code, so just cast
// it to an int
return (int)layer;
- }
- int xc = (x >> 4) - xc1;
- int zc = (z >> 4) - zc1;
+ }
+ int xc = (x >> 4) - xc1;
+ int zc = (z >> 4) - zc1;
- return (*chunks)[xc]->data[zc]->getBrightness(layer, x & 15, y, z & 15);
+ return (*chunks)[xc]->data[zc]->getBrightness(layer, x & 15, y, z & 15);
}
int Region::getMaxBuildHeight()
{
return Level::maxBuildHeight;
+}
+
+int Region::getDirectSignal(int x, int y, int z, int dir)
+{
+ int t = getTile(x, y, z);
+ if (t == 0) return Redstone::SIGNAL_NONE;
+ return Tile::tiles[t]->getDirectSignal(this, x, y, z, dir);
} \ No newline at end of file