Fix chunk damage during terrain gen

This commit is contained in:
Drew DeVault 2017-05-23 18:22:06 -04:00
parent 6fb8ee7ba5
commit 535437f51e

View File

@ -128,7 +128,8 @@ namespace TrueCraft.Core.World
public void SetBlockID(Coordinates3D coordinates, byte value) public void SetBlockID(Coordinates3D coordinates, byte value)
{ {
IsModified = true; IsModified = true;
ParentRegion.DamageChunk(Coordinates); if (ParentRegion != null)
ParentRegion.DamageChunk(Coordinates);
int index = coordinates.Y + (coordinates.Z * Height) + (coordinates.X * Height * Width); int index = coordinates.Y + (coordinates.Z * Height) + (coordinates.X * Height * Width);
Data[index] = value; Data[index] = value;
if (value == AirBlock.BlockID) if (value == AirBlock.BlockID)
@ -166,7 +167,8 @@ namespace TrueCraft.Core.World
public void SetMetadata(Coordinates3D coordinates, byte value) public void SetMetadata(Coordinates3D coordinates, byte value)
{ {
IsModified = true; IsModified = true;
ParentRegion.DamageChunk(Coordinates); if (ParentRegion != null)
ParentRegion.DamageChunk(Coordinates);
int index = coordinates.Y + (coordinates.Z * Height) + (coordinates.X * Height * Width); int index = coordinates.Y + (coordinates.Z * Height) + (coordinates.X * Height * Width);
Metadata[index] = value; Metadata[index] = value;
} }
@ -178,7 +180,8 @@ namespace TrueCraft.Core.World
public void SetSkyLight(Coordinates3D coordinates, byte value) public void SetSkyLight(Coordinates3D coordinates, byte value)
{ {
IsModified = true; IsModified = true;
ParentRegion.DamageChunk(Coordinates); if (ParentRegion != null)
ParentRegion.DamageChunk(Coordinates);
int index = coordinates.Y + (coordinates.Z * Height) + (coordinates.X * Height * Width); int index = coordinates.Y + (coordinates.Z * Height) + (coordinates.X * Height * Width);
SkyLight[index] = value; SkyLight[index] = value;
} }
@ -190,7 +193,8 @@ namespace TrueCraft.Core.World
public void SetBlockLight(Coordinates3D coordinates, byte value) public void SetBlockLight(Coordinates3D coordinates, byte value)
{ {
IsModified = true; IsModified = true;
ParentRegion.DamageChunk(Coordinates); if (ParentRegion != null)
ParentRegion.DamageChunk(Coordinates);
int index = coordinates.Y + (coordinates.Z * Height) + (coordinates.X * Height * Width); int index = coordinates.Y + (coordinates.Z * Height) + (coordinates.X * Height * Width);
BlockLight[index] = value; BlockLight[index] = value;
} }
@ -215,7 +219,8 @@ namespace TrueCraft.Core.World
else else
TileEntities[coordinates] = value; TileEntities[coordinates] = value;
IsModified = true; IsModified = true;
ParentRegion.DamageChunk(Coordinates); if (ParentRegion != null)
ParentRegion.DamageChunk(Coordinates);
} }
/// <summary> /// <summary>