forked from mirrors/NBTExplorer
Some more lighting fixes (transparent, blocking blocks like half-steps and stairs will no longer be partially dark)
This commit is contained in:
parent
02429a92fc
commit
e215ccd7d5
2 changed files with 76 additions and 34 deletions
|
@ -166,6 +166,7 @@ namespace Substrate
|
||||||
private string _name = "";
|
private string _name = "";
|
||||||
private int _opacity = MAX_OPACITY;
|
private int _opacity = MAX_OPACITY;
|
||||||
private int _luminance = MIN_LUMINANCE;
|
private int _luminance = MIN_LUMINANCE;
|
||||||
|
private bool _transmitLight = false;
|
||||||
|
|
||||||
private DataLimits _dataLimits;
|
private DataLimits _dataLimits;
|
||||||
|
|
||||||
|
@ -175,7 +176,7 @@ namespace Substrate
|
||||||
|
|
||||||
public static ItemCache<int> LuminanceTable;
|
public static ItemCache<int> LuminanceTable;
|
||||||
|
|
||||||
public static ItemCache<NBTCompoundNode> SchemaTable;
|
//public static ItemCache<NBTCompoundNode> SchemaTable;
|
||||||
|
|
||||||
public int ID
|
public int ID
|
||||||
{
|
{
|
||||||
|
@ -197,6 +198,11 @@ namespace Substrate
|
||||||
get { return _luminance; }
|
get { return _luminance; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool TransmitsLight
|
||||||
|
{
|
||||||
|
get { return _transmitLight; }
|
||||||
|
}
|
||||||
|
|
||||||
public BlockInfo (int id)
|
public BlockInfo (int id)
|
||||||
{
|
{
|
||||||
_id = id;
|
_id = id;
|
||||||
|
@ -214,6 +220,14 @@ namespace Substrate
|
||||||
{
|
{
|
||||||
_opacity = MIN_OPACITY + opacity;
|
_opacity = MIN_OPACITY + opacity;
|
||||||
_opacityTable[_id] = _opacity;
|
_opacityTable[_id] = _opacity;
|
||||||
|
|
||||||
|
if (opacity == MAX_OPACITY) {
|
||||||
|
_transmitLight = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_transmitLight = true;
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,6 +238,12 @@ namespace Substrate
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BlockInfo SetLightTransmission (bool transmit)
|
||||||
|
{
|
||||||
|
_transmitLight = transmit;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public BlockInfo SetDataLimits (int low, int high, int bitmask)
|
public BlockInfo SetDataLimits (int low, int high, int bitmask)
|
||||||
{
|
{
|
||||||
_dataLimits = new DataLimits(low, high, bitmask);
|
_dataLimits = new DataLimits(low, high, bitmask);
|
||||||
|
@ -374,7 +394,7 @@ namespace Substrate
|
||||||
GoldBlock = new BlockInfo(41, "Gold Block");
|
GoldBlock = new BlockInfo(41, "Gold Block");
|
||||||
IronBlock = new BlockInfo(42, "Iron Block");
|
IronBlock = new BlockInfo(42, "Iron Block");
|
||||||
DoubleSlab = new BlockInfo(43, "Double Slab");
|
DoubleSlab = new BlockInfo(43, "Double Slab");
|
||||||
Slab = new BlockInfo(44, "Slab");
|
Slab = new BlockInfo(44, "Slab").SetOpacity(0);
|
||||||
BrickBlock = new BlockInfo(45, "Brick Block");
|
BrickBlock = new BlockInfo(45, "Brick Block");
|
||||||
TNT = new BlockInfo(46, "TNT");
|
TNT = new BlockInfo(46, "TNT");
|
||||||
Bookshelf = new BlockInfo(47, "Bookshelf");
|
Bookshelf = new BlockInfo(47, "Bookshelf");
|
||||||
|
@ -432,6 +452,15 @@ namespace Substrate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Override default light transmission rules
|
||||||
|
|
||||||
|
Lava.SetLightTransmission(false);
|
||||||
|
StationaryLava.SetLightTransmission(false);
|
||||||
|
Slab.SetLightTransmission(false);
|
||||||
|
WoodStairs.SetLightTransmission(false);
|
||||||
|
Farmland.SetLightTransmission(false);
|
||||||
|
CobbleStairs.SetLightTransmission(false);
|
||||||
|
|
||||||
// Set Tile Entity Data
|
// Set Tile Entity Data
|
||||||
|
|
||||||
Dispenser.SetTileEntity("Trap");
|
Dispenser.SetTileEntity("Trap");
|
||||||
|
|
|
@ -543,7 +543,7 @@ namespace Substrate
|
||||||
SetBlockLight(lx, ly, lz, priLum);
|
SetBlockLight(lx, ly, lz, priLum);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (primaryLight > primary.Luminance - 1) {
|
if (primaryLight > primary.Luminance - 1 || !primary.TransmitsLight) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,6 +575,7 @@ namespace Substrate
|
||||||
if (dimStr > light) {
|
if (dimStr > light) {
|
||||||
cc.SetBlockLight(x, y, z, dimStr);
|
cc.SetBlockLight(x, y, z, dimStr);
|
||||||
|
|
||||||
|
if (info.TransmitsLight) {
|
||||||
spread.Enqueue(new LightRecord(rec.x - 1, rec.y, rec.z, dimStr - 1));
|
spread.Enqueue(new LightRecord(rec.x - 1, rec.y, rec.z, dimStr - 1));
|
||||||
spread.Enqueue(new LightRecord(rec.x + 1, rec.y, rec.z, dimStr - 1));
|
spread.Enqueue(new LightRecord(rec.x + 1, rec.y, rec.z, dimStr - 1));
|
||||||
spread.Enqueue(new LightRecord(rec.x, rec.y - 1, rec.z, dimStr - 1));
|
spread.Enqueue(new LightRecord(rec.x, rec.y - 1, rec.z, dimStr - 1));
|
||||||
|
@ -584,6 +585,7 @@ namespace Substrate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void SpreadSkyLight (ChunkRef[,] chunkMap, int[,] heightMap, int lx, int ly, int lz)
|
private void SpreadSkyLight (ChunkRef[,] chunkMap, int[,] heightMap, int lx, int ly, int lz)
|
||||||
{
|
{
|
||||||
|
@ -595,7 +597,7 @@ namespace Substrate
|
||||||
SetBlockSkyLight(lx, ly, lz, priLum);
|
SetBlockSkyLight(lx, ly, lz, priLum);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (primaryLight > BlockInfo.MAX_LUMINANCE - 1) {
|
if (primaryLight > BlockInfo.MAX_LUMINANCE - 1 || !primary.TransmitsLight) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -650,6 +652,7 @@ namespace Substrate
|
||||||
if (dimStr > light) {
|
if (dimStr > light) {
|
||||||
cc.SetBlockSkyLight(x, y, z, dimStr);
|
cc.SetBlockSkyLight(x, y, z, dimStr);
|
||||||
|
|
||||||
|
if (info.TransmitsLight) {
|
||||||
spread.Enqueue(new LightRecord(rec.x - 1, rec.y, rec.z, dimStr - 1));
|
spread.Enqueue(new LightRecord(rec.x - 1, rec.y, rec.z, dimStr - 1));
|
||||||
spread.Enqueue(new LightRecord(rec.x + 1, rec.y, rec.z, dimStr - 1));
|
spread.Enqueue(new LightRecord(rec.x + 1, rec.y, rec.z, dimStr - 1));
|
||||||
spread.Enqueue(new LightRecord(rec.x, rec.y - 1, rec.z, dimStr - 1));
|
spread.Enqueue(new LightRecord(rec.x, rec.y - 1, rec.z, dimStr - 1));
|
||||||
|
@ -682,6 +685,7 @@ namespace Substrate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void UpdateBlockLight (int lx, int ly, int lz)
|
public void UpdateBlockLight (int lx, int ly, int lz)
|
||||||
{
|
{
|
||||||
|
@ -790,7 +794,7 @@ namespace Substrate
|
||||||
light = Math.Max(light, llu - 1);
|
light = Math.Max(light, llu - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
light = Math.Max(light - info.Opacity, 0);
|
//light = Math.Max(light - info.Opacity, 0);
|
||||||
|
|
||||||
if (light != lightval) {
|
if (light != lightval) {
|
||||||
//Console.WriteLine("Block SkyLight: ({0},{1},{2}) " + lightval + " -> " + light, k.x, k.y, k.z);
|
//Console.WriteLine("Block SkyLight: ({0},{1},{2}) " + lightval + " -> " + light, k.x, k.y, k.z);
|
||||||
|
@ -884,6 +888,10 @@ namespace Substrate
|
||||||
z = (z + ZDim * 2) % ZDim;
|
z = (z + ZDim * 2) % ZDim;
|
||||||
|
|
||||||
BlockInfo info = src.GetBlockInfo(x, y, z);
|
BlockInfo info = src.GetBlockInfo(x, y, z);
|
||||||
|
if (!info.TransmitsLight) {
|
||||||
|
return info.Luminance;
|
||||||
|
}
|
||||||
|
|
||||||
int light = src.GetBlockLight(x, y, z);
|
int light = src.GetBlockLight(x, y, z);
|
||||||
|
|
||||||
return Math.Max(light, info.Luminance);
|
return Math.Max(light, info.Luminance);
|
||||||
|
@ -903,6 +911,11 @@ namespace Substrate
|
||||||
x = (x + XDim * 2) % XDim;
|
x = (x + XDim * 2) % XDim;
|
||||||
z = (z + ZDim * 2) % ZDim;
|
z = (z + ZDim * 2) % ZDim;
|
||||||
|
|
||||||
|
BlockInfo info = src.GetBlockInfo(x, y, z);
|
||||||
|
if (!info.TransmitsLight) {
|
||||||
|
return BlockInfo.MIN_LUMINANCE;
|
||||||
|
}
|
||||||
|
|
||||||
int light = src.GetBlockSkyLight(x, y, z);
|
int light = src.GetBlockSkyLight(x, y, z);
|
||||||
|
|
||||||
return light;
|
return light;
|
||||||
|
|
Loading…
Reference in a new issue