diff --git a/ClassicalSharp/2D/Screens/BlockSelectScreen.cs b/ClassicalSharp/2D/Screens/BlockSelectScreen.cs
index 098a087aa..a39f36092 100644
--- a/ClassicalSharp/2D/Screens/BlockSelectScreen.cs
+++ b/ClassicalSharp/2D/Screens/BlockSelectScreen.cs
@@ -102,7 +102,7 @@ namespace ClassicalSharp {
if( block == Block.TNT ) {
buffer.Append( ref ptr2, "TNT" );
} else {
- string value = game.BlockInfo.GetName( (byte)block );
+ string value = game.BlockInfo.Name[(byte)block];
if( (byte)block < BlockInfo.CpeBlocksCount ) {
SplitUppercase( value, ref ptr2 );
} else {
@@ -175,7 +175,7 @@ namespace ClassicalSharp {
int texId = game.BlockInfo.GetTextureLoc( (byte)block, TileSide.Left );
TextureRectangle rec = game.TerrainAtlas.GetTexRec( texId );
int verSize = blockSize;
- float height = game.BlockInfo.BlockHeight( (byte)block );
+ float height = game.BlockInfo.Height[(byte)block];
int blockY = y;
if( height != 1 ) {
rec.V1 = rec.V1 + TerrainAtlas2D.invElementSize * height;
diff --git a/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs b/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs
index bbf9d731b..d44e6b25c 100644
--- a/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs
+++ b/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs
@@ -80,7 +80,7 @@ namespace ClassicalSharp {
TextureRectangle rec = game.TerrainAtlas.GetTexRec( texId );
int verSize = blockSize;
- float height = game.BlockInfo.BlockHeight( (byte)block );
+ float height = game.BlockInfo.Height[(byte)block];
int blockY = y;
if( height != 1 ) {
rec.V1 = rec.V1 + TerrainAtlas2D.invElementSize * height;
diff --git a/ClassicalSharp/Blocks/BlockInfo.Culling.cs b/ClassicalSharp/Blocks/BlockInfo.Culling.cs
index 75444a2e5..f8c360c00 100644
--- a/ClassicalSharp/Blocks/BlockInfo.Culling.cs
+++ b/ClassicalSharp/Blocks/BlockInfo.Culling.cs
@@ -16,8 +16,8 @@ namespace ClassicalSharp {
SetHidden( tile, neighbour, TileSide.Right, true );
SetHidden( tile, neighbour, TileSide.Front, true );
SetHidden( tile, neighbour, TileSide.Back, true );
- SetHidden( tile, neighbour, TileSide.Top, BlockHeight( tile ) == 1 );
- SetHidden( tile, neighbour, TileSide.Bottom, BlockHeight( neighbour ) == 1 );
+ SetHidden( tile, neighbour, TileSide.Top, Height[tile] == 1 );
+ SetHidden( tile, neighbour, TileSide.Bottom, Height[neighbour] == 1 );
}
}
}
@@ -25,8 +25,8 @@ namespace ClassicalSharp {
bool IsHidden( byte tile, byte block ) {
return
- ( ( tile == block || ( IsOpaque( block ) && !IsLiquid( block ) ) ) && !IsSprite( tile ) ) ||
- ( IsLiquid( tile ) && block == (byte)Block.Ice );
+ ((tile == block || (IsOpaque[block] && !IsLiquid[block])) && !IsSprite[tile]) ||
+ (IsLiquid[tile] && block == (byte)Block.Ice);
}
void SetHidden( byte tile, byte block, int tileSide, bool value ) {
diff --git a/ClassicalSharp/Blocks/BlockInfo.cs b/ClassicalSharp/Blocks/BlockInfo.cs
index bddadf632..ff8a50d05 100644
--- a/ClassicalSharp/Blocks/BlockInfo.cs
+++ b/ClassicalSharp/Blocks/BlockInfo.cs
@@ -5,17 +5,38 @@ namespace ClassicalSharp {
/// Stores various properties about the blocks in Minecraft Classic.
public partial class BlockInfo {
- internal bool[] isTransparent = new bool[BlocksCount];
- internal bool[] isTranslucent = new bool[BlocksCount];
- internal bool[] isOpaque = new bool[BlocksCount];
- internal bool[] isSprite = new bool[BlocksCount];
- internal bool[] isLiquid = new bool[BlocksCount];
- internal float[] heights = new float[BlocksCount];
- internal bool[] blocksLight = new bool[BlocksCount];
- internal bool[] emitsLight = new bool[BlocksCount];
- internal string[] names = new string[BlocksCount];
- internal FastColour[] fogColours = new FastColour[BlocksCount];
- internal float[] fogDensities = new float[BlocksCount];
+ /// Gets whether the given block id is transparent/fully see through.
+ /// Alpha values are treated as either 'fully see through' or 'fully solid'.
+ public bool[] IsTransparent = new bool[BlocksCount];
+
+ /// Gets whether the given block id is translucent/partially see through.
+ /// Colour values are blended into both the transparent and opaque blocks behind them.
+ public bool[] IsTranslucent = new bool[BlocksCount];
+
+ /// Gets whether the given block id is opaque/not partially see through.
+ public bool[] IsOpaque = new bool[BlocksCount];
+
+ /// Gets whether the given block id is a sprite. (e.g. flowers, saplings, fire)
+ public bool[] IsSprite = new bool[BlocksCount];
+
+ /// Gets whether the given block id is a liquid. (e.g. water and lava)
+ public bool[] IsLiquid = new bool[BlocksCount];
+
+ /// Gets the block height of the given block id.
+ public float[] Height = new float[BlocksCount];
+
+ /// Gets whether the given block blocks sunlight.
+ public bool[] BlocksLight = new bool[BlocksCount];
+
+ public bool[] EmitsLight = new bool[BlocksCount];
+
+ public string[] Name = new string[BlocksCount];
+
+ public FastColour[] FogColour = new FastColour[BlocksCount];
+
+ public float[] FogDensity = new float[BlocksCount];
+
+ public BlockCollideType[] CollideType = new BlockCollideType[BlocksCount];
public const byte MaxDefinedCpeBlock = (byte)Block.StoneBrick;
public const int CpeBlocksCount = MaxDefinedCpeBlock + 1;
@@ -24,26 +45,27 @@ namespace ClassicalSharp {
public void Init() {
for( int tile = 1; tile < BlocksCount; tile++ ) {
- heights[tile] = 1f;
- blocksLight[tile] = true;
- isOpaque[tile] = true;
+ Height[tile] = 1f;
+ BlocksLight[tile] = true;
+ IsOpaque[tile] = true;
+ CollideType[tile] = BlockCollideType.Solid;
}
for( int i = 0; i < CpeBlocksCount; i++ ) {
- names[i] = Enum.GetName( typeof( Block ), (byte)i );
+ Name[i] = Enum.GetName( typeof( Block ), (byte)i );
}
for( int i = CpeBlocksCount; i < BlocksCount; i++ ) {
- names[i] = "Invalid";
+ Name[i] = "Invalid";
}
- fogDensities[(byte)Block.StillWater] = 0.1f;
- fogColours[(byte)Block.StillWater] = new FastColour( 5, 5, 51 );
- fogDensities[(byte)Block.Water] = 0.1f;
- fogColours[(byte)Block.Water] = new FastColour( 5, 5, 51 );
- fogDensities[(byte)Block.StillLava] = 2f;
- fogColours[(byte)Block.StillLava] = new FastColour( 153, 25, 0 );
- fogDensities[(byte)Block.Lava] = 2f;
- fogColours[(byte)Block.Lava] = new FastColour( 153, 25, 0 );
-
+ FogDensity[(byte)Block.StillWater] = 0.1f;
+ FogColour[(byte)Block.StillWater] = new FastColour( 5, 5, 51 );
+ FogDensity[(byte)Block.Water] = 0.1f;
+ FogColour[(byte)Block.Water] = new FastColour( 5, 5, 51 );
+ FogDensity[(byte)Block.StillLava] = 2f;
+ FogColour[(byte)Block.StillLava] = new FastColour( 153, 25, 0 );
+ FogDensity[(byte)Block.Lava] = 2f;
+ FogColour[(byte)Block.Lava] = new FastColour( 153, 25, 0 );
+ CollideType[(byte)Block.Snow] = BlockCollideType.WalkThrough;
SetupTextures();
SetBlockHeight( Block.Slab, 8/16f );
@@ -85,111 +107,62 @@ namespace ClassicalSharp {
}
void MarkTransparent( Block id, bool blocks ) {
- isTransparent[(int)id] = true;
- blocksLight[(int)id] = blocks;
- isOpaque[(int)id] = false;
+ IsTransparent[(int)id] = true;
+ BlocksLight[(int)id] = blocks;
+ IsOpaque[(int)id] = false;
}
void MarkSprite( Block id ) {
- isSprite[(int)id] = true;
- isTransparent[(int)id] = true;
- blocksLight[(int)id] = false;
- isOpaque[(int)id] = false;
+ IsSprite[(int)id] = true;
+ IsTransparent[(int)id] = true;
+ BlocksLight[(int)id] = false;
+ IsOpaque[(int)id] = false;
+ CollideType[(int)id] = BlockCollideType.WalkThrough;
}
void MarkTranslucent( Block id ) {
- isTranslucent[(int)id] = true;
- isOpaque[(int)id] = false;
+ IsTranslucent[(int)id] = true;
+ IsOpaque[(int)id] = false;
}
void SetIsLiquid( Block id ) {
- isLiquid[(int)id] = true;
+ IsLiquid[(int)id] = true;
+ CollideType[(int)id] = BlockCollideType.SwimThrough;
}
void SetBlockHeight( Block id, float height ) {
- heights[(int)id] = height;
+ Height[(int)id] = height;
}
void SetBlocksLight( Block id, bool blocks ) {
- blocksLight[(int)id] = blocks;
+ BlocksLight[(int)id] = blocks;
}
void SetEmitsLight( Block id, bool emits ) {
- emitsLight[(int)id] = emits;
- }
-
- /// Gets whether the given block id is opaque/not see through.
- public bool IsOpaque( byte id ) {
- return isOpaque[id];
- }
-
- /// Gets whether the given block id is opaque/not see through, and occupies a full block.
- public bool IsFullAndOpaque( byte id ) {
- return isOpaque[id] && heights[id] == 1;
- }
-
- /// Gets whether the given block id is transparent/fully see through.
- /// Alpha values are treated as either 'fully see through' or 'fully solid'.
- public bool IsTransparent( byte id ) {
- return isTransparent[id];
- }
-
- /// Gets the tile height of the given block id.
- public float BlockHeight( byte id ) {
- return heights[id];
- }
-
- /// Gets whether the given block id is translucent/partially see through.
- /// Colour values are blended into both the transparent and opaque blocks behind them.
- public bool IsTranslucent( byte id ) {
- return isTranslucent[id];
- }
-
- /// Gets whether the given block blocks sunlight.
- public bool BlocksLight( byte id ) {
- return blocksLight[id];
- }
-
- /// Gets whether the given block id is a sprite. (flowers, saplings, fire, etc)
- public bool IsSprite( byte id ) {
- return isSprite[id];
- }
-
- /// Gets whether the given block id is a liquid. (water or lava)
- public bool IsLiquid( byte id ) {
- return isLiquid[id];
- }
-
- public bool EmitsLight( byte id ) {
- return emitsLight[id];
- }
-
- public float FogDensity( byte id ) {
- return fogDensities[id];
- }
-
- public FastColour FogColour( byte id ) {
- return fogColours[id];
- }
-
- public string GetName( byte id ) {
- return names[id];
+ EmitsLight[(int)id] = emits;
}
public void ResetBlockInfo( byte id ) {
- isTransparent[id] = false;
- isTranslucent[id] = false;
- isOpaque[id] = true;
- isSprite[id] = false;
- isLiquid[id] = false;
- heights[id] = 1;
- blocksLight[id] = true;
- emitsLight[id] = true;
- names[id] = "Invalid";
- fogColours[id] = default( FastColour );
- fogDensities[id] = 0;
+ IsTransparent[id] = false;
+ IsTranslucent[id] = false;
+ IsOpaque[id] = true;
+ IsSprite[id] = false;
+ IsLiquid[id] = false;
+ Height[id] = 1;
+ BlocksLight[id] = true;
+ EmitsLight[id] = false;
+ Name[id] = "Invalid";
+ FogColour[id] = default( FastColour );
+ FogDensity[id] = 0;
+ CollideType[id] = BlockCollideType.Solid;
SetAll( 0, (Block)id );
SetupCullingCache();
}
}
+
+ public enum BlockCollideType : byte {
+ WalkThrough, // i.e. gas or sprite
+ SwimThrough, // i.e. liquid
+ Solid, // i.e. solid
+ }
}
\ No newline at end of file
diff --git a/ClassicalSharp/Entities/Entity.cs b/ClassicalSharp/Entities/Entity.cs
index d061ded63..ed4f3023e 100644
--- a/ClassicalSharp/Entities/Entity.cs
+++ b/ClassicalSharp/Entities/Entity.cs
@@ -78,7 +78,7 @@ namespace ClassicalSharp {
if( !map.IsValidPos( x, y, z ) ) continue;
byte block = map.GetBlock( x, y, z );
if( condition( block ) ) {
- float blockHeight = info.BlockHeight( block );
+ float blockHeight = info.Height[block];
Vector3 min = new Vector3( x, y, z );
Vector3 max = new Vector3( x + 1, y + blockHeight, z + 1 );
BoundingBox blockBB = new BoundingBox( min, max );
diff --git a/ClassicalSharp/Entities/Particles/ParticleManager.cs b/ClassicalSharp/Entities/Particles/ParticleManager.cs
index cbe44de2f..0c0463a52 100644
--- a/ClassicalSharp/Entities/Particles/ParticleManager.cs
+++ b/ClassicalSharp/Entities/Particles/ParticleManager.cs
@@ -72,7 +72,7 @@ namespace ClassicalSharp.Particles {
for( int i = 0; i < 25; i++ ) {
double velX = ( rnd.NextDouble() * 0.8/*5*/ ) - 0.4/*0.25*/;
double velZ = ( rnd.NextDouble() * 0.8/*5*/ ) - 0.4/*0.25*/;
- double velY = ( rnd.NextDouble() + 0.25 ) * game.BlockInfo.BlockHeight( block );
+ double velY = ( rnd.NextDouble() + 0.25 ) * game.BlockInfo.Height[block];
Vector3 velocity = new Vector3( (float)velX, (float)velY, (float)velZ );
double xOffset = rnd.NextDouble() - 0.125;
double yOffset = rnd.NextDouble() - 0.125;
diff --git a/ClassicalSharp/Entities/Particles/TerrainParticle.cs b/ClassicalSharp/Entities/Particles/TerrainParticle.cs
index cbfd44ac8..7286fff1d 100644
--- a/ClassicalSharp/Entities/Particles/TerrainParticle.cs
+++ b/ClassicalSharp/Entities/Particles/TerrainParticle.cs
@@ -65,7 +65,7 @@ namespace ClassicalSharp.Particles {
float collideY = y;
if( topFace )
- collideY += game.BlockInfo.BlockHeight( block );
+ collideY += game.BlockInfo.Height[block];
bool collide = topFace ? (Position.Y < collideY) : (Position.Y > collideY );
if( collide ) {
@@ -78,7 +78,7 @@ namespace ClassicalSharp.Particles {
}
bool CanPassThrough( byte block ) {
- return block == 0 || game.BlockInfo.IsSprite( block ) || game.BlockInfo.IsLiquid( block );
+ return block == 0 || game.BlockInfo.IsSprite[block] || game.BlockInfo.IsLiquid[block];
}
public override void Dispose() {
diff --git a/ClassicalSharp/Game/Game.InputHandling.cs b/ClassicalSharp/Game/Game.InputHandling.cs
index ae0b32b9a..eb864f442 100644
--- a/ClassicalSharp/Game/Game.InputHandling.cs
+++ b/ClassicalSharp/Game/Game.InputHandling.cs
@@ -187,7 +187,7 @@ namespace ClassicalSharp {
}
internal bool CanPick( byte block ) {
- return !(block == 0 || (BlockInfo.IsLiquid( block ) && !(CanPlace[block] && CanDelete[block])));
+ return !(block == 0 || (BlockInfo.IsLiquid[block] && !(CanPlace[block] && CanDelete[block])));
}
public KeyMap Keys = new KeyMap();
diff --git a/ClassicalSharp/Map/ChunkMeshBuilder.cs b/ClassicalSharp/Map/ChunkMeshBuilder.cs
index e89262e2f..e76db36e3 100644
--- a/ClassicalSharp/Map/ChunkMeshBuilder.cs
+++ b/ClassicalSharp/Map/ChunkMeshBuilder.cs
@@ -86,7 +86,7 @@ namespace ClassicalSharp {
if( block == 11 ) block = 10; // Still lava --> Lava
if( allAir && block != 0 ) allAir = false;
- if( allSolid && !info.isOpaque[block] ) allSolid = false;
+ if( allSolid && !info.IsOpaque[block] ) allSolid = false;
chunkPtr[chunkIndex] = block;
}
}
@@ -115,10 +115,10 @@ namespace ClassicalSharp {
X = x; Y = y; Z = z;
int index = ( ( yy << 8 ) + ( zz << 4 ) + xx ) * TileSide.Sides;
- if( info.isSprite[tile] ) {
+ if( info.IsSprite[tile] ) {
int count = counts[index + TileSide.Top];
if( count != 0 ) {
- blockHeight = info.heights[tile];
+ blockHeight = info.Height[tile];
DrawSprite( count );
}
return;
@@ -130,9 +130,9 @@ namespace ClassicalSharp {
if( leftCount == 0 && rightCount == 0 && frontCount == 0 &&
backCount == 0 && bottomCount == 0 && topCount == 0 ) return;
- emitsLight = info.emitsLight[tile];
- blockHeight = info.heights[tile];
- isTranslucent = info.isTranslucent[tile];
+ emitsLight = info.EmitsLight[tile];
+ blockHeight = info.Height[tile];
+ isTranslucent = info.IsTranslucent[tile];
if( leftCount != 0 )
DrawLeftFace( leftCount );
@@ -168,7 +168,7 @@ namespace ClassicalSharp {
// Sprites only use one face to indicate stretching count, so we can take a shortcut here.
// Note that sprites are not drawn with any of the DrawXFace, they are drawn using DrawSprite.
- if( info.IsSprite( tile ) ) {
+ if( info.IsSprite[tile] ) {
countIndex += TileSide.Top;
if( counts[countIndex] != 0 ) {
X = x; Y = y; Z = z;
@@ -178,7 +178,7 @@ namespace ClassicalSharp {
}
} else {
X = x; Y = y; Z = z;
- emitsLight = info.emitsLight[tile];
+ emitsLight = info.EmitsLight[tile];
TestAndStretchZ( zz, countIndex, tile, chunkIndex, x, 0, TileSide.Left, -1 );
TestAndStretchZ( zz, countIndex, tile, chunkIndex, x, maxX, TileSide.Right, 1 );
TestAndStretchX( xx, countIndex, tile, chunkIndex, z, 0, TileSide.Front, -extChunkSize );
diff --git a/ClassicalSharp/Map/ChunkMeshBuilderTex2Col4.cs b/ClassicalSharp/Map/ChunkMeshBuilderTex2Col4.cs
index 62d76bf0f..341d3a8b3 100644
--- a/ClassicalSharp/Map/ChunkMeshBuilderTex2Col4.cs
+++ b/ClassicalSharp/Map/ChunkMeshBuilderTex2Col4.cs
@@ -155,7 +155,7 @@ namespace ClassicalSharp {
unsafe void AddVertices( byte tile, int count, int face ) {
int i = atlas.Get1DIndex( info.GetTextureLoc( tile, face ) );
- DrawInfo part = info.IsTranslucent( tile ) ? drawInfoTranslucent[i] : drawInfoNormal[i];
+ DrawInfo part = info.IsTranslucent[tile] ? drawInfoTranslucent[i] : drawInfoNormal[i];
part.iCount += 6;
DrawInfoFaceData counts = part.Count;
diff --git a/ClassicalSharp/Map/Map.cs b/ClassicalSharp/Map/Map.cs
index 42e96476b..656353958 100644
--- a/ClassicalSharp/Map/Map.cs
+++ b/ClassicalSharp/Map/Map.cs
@@ -130,7 +130,7 @@ namespace ClassicalSharp {
int mapIndex = ( maxY * Length + z ) * Width + x;
for( int y = maxY; y >= 0; y-- ) {
byte block = mapData[mapIndex];
- if( info.BlocksLight( block ) ) {
+ if( info.BlocksLight[block] ) {
heightmap[index] = (short)( y - 1 );
return y;
}
@@ -142,8 +142,8 @@ namespace ClassicalSharp {
}
void UpdateHeight( int x, int y, int z, byte oldBlock, byte newBlock ) {
- bool didBlock = info.BlocksLight( oldBlock );
- bool nowBlocks = info.BlocksLight( newBlock );
+ bool didBlock = info.BlocksLight[oldBlock];
+ bool nowBlocks = info.BlocksLight[newBlock];
if( didBlock == nowBlocks ) return;
int index = ( z * Width ) + x;
@@ -276,7 +276,7 @@ namespace ClassicalSharp {
int curRunCount = skip[index];
x += curRunCount; mapIndex += curRunCount; index += curRunCount;
- if( x < xCount && info.blocksLight[mapPtr[mapIndex]] ) {
+ if( x < xCount && info.BlocksLight[mapPtr[mapIndex]] ) {
heightmap[heightmapIndex + x] = (short)( y - 1 );
elemsLeft--;
skip[index] = 0;
diff --git a/ClassicalSharp/Model/BlockModel.cs b/ClassicalSharp/Model/BlockModel.cs
index 533f187eb..a1531b0a8 100644
--- a/ClassicalSharp/Model/BlockModel.cs
+++ b/ClassicalSharp/Model/BlockModel.cs
@@ -16,7 +16,7 @@ namespace ClassicalSharp.Model {
public override float GetEyeY( Player player ) {
byte block = Byte.Parse( player.ModelName );
- return block == 0 ? 1 : game.BlockInfo.BlockHeight( block );
+ return block == 0 ? 1 : game.BlockInfo.Height[block];
}
const float adjust = 0.1f;
@@ -38,11 +38,11 @@ namespace ClassicalSharp.Model {
}
graphics.BindTexture( game.TerrainAtlas.TexId );
- blockHeight = game.BlockInfo.BlockHeight( block );
+ blockHeight = game.BlockInfo.Height[block];
atlas = game.TerrainAtlas;
BlockInfo = game.BlockInfo;
- if( BlockInfo.IsSprite( block ) ) {
+ if( BlockInfo.IsSprite[block] ) {
DrawXFace( 0f, TileSide.Right, false );
DrawZFace( 0f, TileSide.Back, false );
} else {
diff --git a/ClassicalSharp/Network/NetworkProcessor.cs b/ClassicalSharp/Network/NetworkProcessor.cs
index 5962f8c23..bdc6386cc 100644
--- a/ClassicalSharp/Network/NetworkProcessor.cs
+++ b/ClassicalSharp/Network/NetworkProcessor.cs
@@ -643,35 +643,36 @@ namespace ClassicalSharp {
BlockInfo info = game.BlockInfo;
info.ResetBlockInfo( block );
- info.names[block] = reader.ReadAsciiString();
- byte solidity = reader.ReadUInt8();
+ info.Name[block] = reader.ReadAsciiString();
+ info.CollideType[block] = (BlockCollideType)reader.ReadUInt8();
byte movementSpeed = reader.ReadUInt8();
info.SetTop( reader.ReadUInt8(), (Block)block );
info.SetSide( reader.ReadUInt8(), (Block)block );
info.SetBottom( reader.ReadUInt8(), (Block)block );
reader.ReadUInt8(); // opacity hint, but we ignore this.
- info.blocksLight[block] = reader.ReadUInt8() == 0;
+ info.BlocksLight[block] = reader.ReadUInt8() == 0;
reader.ReadUInt8(); // walk sound, but we ignore this.
+ info.EmitsLight[block] = reader.ReadUInt8() != 0;
if( opcode == (byte)PacketId.CpeDefineBlock ) {
byte shape = reader.ReadUInt8();
- if( shape == 1 ) info.heights[block] = 1;
- else if( shape == 2 ) info.heights[block] = 0.5f;
+ if( shape == 1 ) info.Height[block] = 1;
+ else if( shape == 2 ) info.Height[block] = 0.5f;
// TODO: upside down slab not properly supported
- else if( shape == 3 ) info.heights[block] = 0.5f;
- else if( shape == 4 ) info.isSprite[block] = true;
+ else if( shape == 3 ) info.Height[block] = 0.5f;
+ else if( shape == 4 ) info.IsSprite[block] = true;
byte blockDraw = reader.ReadUInt8();
- if( blockDraw == 0 ) info.isOpaque[block] = true;
- else if( blockDraw == 1 ) info.isTransparent[block] = true;
- else if( blockDraw == 2 ) info.isTranslucent[block] = true;
- else if( blockDraw == 3 ) info.isTranslucent[block] = true;
+ if( blockDraw == 0 ) info.IsOpaque[block] = true;
+ else if( blockDraw == 1 ) info.IsTransparent[block] = true;
+ else if( blockDraw == 2 ) info.IsTranslucent[block] = true;
+ else if( blockDraw == 3 ) info.IsTranslucent[block] = true;
Console.WriteLine( shape + "," + blockDraw );
} else {
byte fogDensity = reader.ReadUInt8();
- info.fogDensities[block] = fogDensity == 0 ? 0 : (fogDensity + 1) / 128f;
- info.fogColours[block] = new FastColour(
+ info.FogDensity[block] = fogDensity == 0 ? 0 : (fogDensity + 1) / 128f;
+ info.FogColour[block] = new FastColour(
reader.ReadUInt8(), reader.ReadUInt8(), reader.ReadUInt8() );
}
info.SetupCullingCache();
diff --git a/ClassicalSharp/Physics/Entity.Physics.cs b/ClassicalSharp/Physics/Entity.Physics.cs
index 908b6e1c6..6e6e381be 100644
--- a/ClassicalSharp/Physics/Entity.Physics.cs
+++ b/ClassicalSharp/Physics/Entity.Physics.cs
@@ -19,9 +19,9 @@ namespace ClassicalSharp {
bool GetBoundingBox( byte block, int x, int y, int z, out BoundingBox box ) {
box = new BoundingBox( Vector3.Zero, Vector3.Zero );
- if( CanWalkThrough( block ) ) return false;
+ if( info.CollideType[block] != BlockCollideType.Solid ) return false;
Vector3 min = new Vector3( x, y, z );
- Vector3 max = new Vector3( x + 1, y + info.BlockHeight( block ), z + 1 );
+ Vector3 max = new Vector3( x + 1, y + info.Height[block], z + 1 );
box = new BoundingBox( min, max );
return true;
}
@@ -38,10 +38,6 @@ namespace ClassicalSharp {
}
}
- bool CanWalkThrough( byte block ) {
- return block == 0 || info.IsSprite( block ) || info.IsLiquid( block ) || block == (byte)Block.Snow;
- }
-
// TODO: test for corner cases, and refactor this.
static State[] stateCache = new State[0];
class StateComparer : IComparer {
@@ -171,7 +167,7 @@ namespace ClassicalSharp {
for( int x = min.X; x <= max.X; x++ ) {
for( int y = min.Y; y <= max.Y; y++ ) {
for( int z = min.Z; z <= max.Z; z++ ) {
- if( !CanWalkThrough( GetPhysicsBlockId( x, y, z ) ) )
+ if( info.CollideType[GetPhysicsBlockId( x, y, z )] == BlockCollideType.Solid )
return false;
}
}
diff --git a/ClassicalSharp/Physics/Picking.cs b/ClassicalSharp/Physics/Picking.cs
index 6e6c5e313..ca9271bb4 100644
--- a/ClassicalSharp/Physics/Picking.cs
+++ b/ClassicalSharp/Physics/Picking.cs
@@ -73,7 +73,7 @@ namespace ClassicalSharp {
while( iterations < 10000 ) {
byte block = map.IsValidPos( x, y, z ) ? map.GetBlock( x, y, z ) : (byte)0;
Vector3 min = new Vector3( x, y, z );
- Vector3 max = min + new Vector3( 1, block == 0 ? 1 : info.BlockHeight( block ), 1 );
+ Vector3 max = min + new Vector3( 1, block == 0 ? 1 : info.Height[block], 1 );
float dx = Math.Min( Math.Abs( origin.X - min.X ), Math.Abs( origin.X - max.X ) );
float dy = Math.Min( Math.Abs( origin.Y - min.Y ), Math.Abs( origin.Y - max.Y ) );
diff --git a/ClassicalSharp/Rendering/StandardEnvRenderer.cs b/ClassicalSharp/Rendering/StandardEnvRenderer.cs
index fdcd78fa8..5e8fd2f53 100644
--- a/ClassicalSharp/Rendering/StandardEnvRenderer.cs
+++ b/ClassicalSharp/Rendering/StandardEnvRenderer.cs
@@ -121,10 +121,10 @@ namespace ClassicalSharp.Renderers {
Block headBlock = game.LocalPlayer.BlockAtHead;
BlockInfo info = game.BlockInfo;
- if( info.FogDensity( (byte)headBlock ) != 0 ) {
+ if( info.FogDensity[(byte)headBlock] != 0 ) {
graphics.SetFogMode( Fog.Exp );
- graphics.SetFogDensity( info.FogDensity( (byte)headBlock ) );
- adjFogCol = info.FogColour( (byte)headBlock );
+ graphics.SetFogDensity( info.FogDensity[(byte)headBlock] );
+ adjFogCol = info.FogColour[(byte)headBlock];
} else {
// Blend fog and sky together
FastColour fogCol = map.FogCol;
diff --git a/ClassicalSharp/Rendering/WeatherRenderer.cs b/ClassicalSharp/Rendering/WeatherRenderer.cs
index dbf433622..3b3939bfb 100644
--- a/ClassicalSharp/Rendering/WeatherRenderer.cs
+++ b/ClassicalSharp/Rendering/WeatherRenderer.cs
@@ -120,7 +120,7 @@ namespace ClassicalSharp {
}
bool BlocksRain( byte block ) {
- return !( block == 0 || info.IsSprite( block ) || info.IsLiquid( block ) );
+ return !(block == 0 || info.IsSprite[block] || info.IsLiquid[block]);
}
internal void UpdateHeight( int x, int y, int z, byte oldBlock, byte newBlock ) {
diff --git a/OpenTK/DisplayDevice.cs b/OpenTK/DisplayDevice.cs
index 81174016b..503e79761 100644
--- a/OpenTK/DisplayDevice.cs
+++ b/OpenTK/DisplayDevice.cs
@@ -28,7 +28,6 @@ namespace OpenTK {
static readonly List available_displays = new List();
static readonly IList available_displays_readonly;
- static readonly object display_lock = new object();
static DisplayDevice primary_display;
static Platform.IDisplayDeviceDriver implementation;
@@ -38,10 +37,7 @@ namespace OpenTK {
}
internal DisplayDevice() {
- lock (display_lock) {
- available_displays.Add(this);
- }
-
+ available_displays.Add(this);
available_resolutions_readonly = available_resolutions.AsReadOnly();
}
@@ -92,11 +88,9 @@ namespace OpenTK {
if (value && primary_display != null && primary_display != this)
primary_display.IsPrimary = false;
- lock (display_lock) {
- primary = value;
- if (value)
- primary_display = this;
- }
+ primary = value;
+ if (value)
+ primary_display = this;
}
}
diff --git a/OpenTK/Graphics/GraphicsMode.cs b/OpenTK/Graphics/GraphicsMode.cs
index 9d6a78cbb..c0a2ac415 100644
--- a/OpenTK/Graphics/GraphicsMode.cs
+++ b/OpenTK/Graphics/GraphicsMode.cs
@@ -19,12 +19,9 @@ namespace OpenTK.Graphics {
static GraphicsMode defaultMode;
static IGraphicsMode implementation;
- static readonly object SyncRoot = new object();
static GraphicsMode() {
- lock (SyncRoot) {
- implementation = Platform.Factory.Default.CreateGraphicsMode();
- }
+ implementation = Platform.Factory.Default.CreateGraphicsMode();
}
internal GraphicsMode(IntPtr? index, ColorFormat color, int depth, int stencil, int buffers) {
@@ -80,14 +77,11 @@ namespace OpenTK.Graphics {
/// Returns an OpenTK.GraphicsFormat compatible with the underlying platform.
public static GraphicsMode Default {
get {
- lock (SyncRoot) {
- if (defaultMode == null) {
- Debug.Print("Creating default GraphicsMode ({0}, {1}, {2}, {3}).", DisplayDevice.Default.BitsPerPixel,
- 16, 0, 2);
- defaultMode = new GraphicsMode(DisplayDevice.Default.BitsPerPixel, 16, 0, 2);
- }
- return defaultMode;
- }
+ if (defaultMode == null) {
+ Debug.Print("Creating default GraphicsMode ({0}, {1}, {2}, {3}).", DisplayDevice.Default.BitsPerPixel, 16, 0, 2);
+ defaultMode = new GraphicsMode(DisplayDevice.Default.BitsPerPixel, 16, 0, 2);
+ }
+ return defaultMode;
}
}
diff --git a/OpenTK/Graphics/OpenGL/GLHelper.cs b/OpenTK/Graphics/OpenGL/GLHelper.cs
index 4be904814..30dd45004 100644
--- a/OpenTK/Graphics/OpenGL/GLHelper.cs
+++ b/OpenTK/Graphics/OpenGL/GLHelper.cs
@@ -8,14 +8,11 @@
using System;
-namespace OpenTK.Graphics.OpenGL
-{
- ///
- /// OpenGL bindings for .NET, implementing the full OpenGL API, including extensions.
- ///
- public sealed partial class GL : BindingsBase
- {
- static readonly object sync_root = new object();
+namespace OpenTK.Graphics.OpenGL {
+
+ /// OpenGL bindings for .NET, implementing the full OpenGL API, including extensions.
+ public sealed partial class GL : BindingsBase {
+
static GL() { }
GraphicsContextBase context;
diff --git a/OpenTK/Platform/MacOS/QuartzDisplayDeviceDriver.cs b/OpenTK/Platform/MacOS/QuartzDisplayDeviceDriver.cs
index 6da50a65c..bbc8b4481 100644
--- a/OpenTK/Platform/MacOS/QuartzDisplayDeviceDriver.cs
+++ b/OpenTK/Platform/MacOS/QuartzDisplayDeviceDriver.cs
@@ -7,8 +7,6 @@ namespace OpenTK.Platform.MacOS
{
class QuartzDisplayDeviceDriver : IDisplayDeviceDriver
{
- static object display_lock = new object();
-
static Dictionary displayMap =
new Dictionary();
diff --git a/OpenTK/Platform/Windows/Wgl.cs b/OpenTK/Platform/Windows/Wgl.cs
index f08767b34..c4228d738 100644
--- a/OpenTK/Platform/Windows/Wgl.cs
+++ b/OpenTK/Platform/Windows/Wgl.cs
@@ -7,17 +7,14 @@ namespace OpenTK.Platform.Windows {
internal partial class Wgl : BindingsBase {
const string Library = "OPENGL32.DLL";
- static readonly object sync_root = new object();
protected override IntPtr GetAddress( string funcname ) {
return Wgl.wglGetProcAddress( funcname );
}
internal void LoadEntryPoints() {
- lock( sync_root ) {
- LoadDelegate( "wglGetSwapIntervalEXT", out wglGetSwapIntervalEXT );
- LoadDelegate( "wglSwapIntervalEXT", out wglSwapIntervalEXT );
- }
+ LoadDelegate( "wglGetSwapIntervalEXT", out wglGetSwapIntervalEXT );
+ LoadDelegate( "wglSwapIntervalEXT", out wglSwapIntervalEXT );
}
[SuppressUnmanagedCodeSecurity]
diff --git a/OpenTK/Platform/X11/API.cs b/OpenTK/Platform/X11/API.cs
index ffd658570..13ae20ede 100644
--- a/OpenTK/Platform/X11/API.cs
+++ b/OpenTK/Platform/X11/API.cs
@@ -40,19 +40,6 @@ namespace OpenTK.Platform.X11 {
internal int MWidth, MHeight;
}
- [StructLayout(LayoutKind.Sequential)]
- internal struct MotifWmHints {
- internal IntPtr flags;
- internal IntPtr functions;
- internal IntPtr decorations;
- internal IntPtr input_mode;
- internal IntPtr status;
-
- public override string ToString () {
- return string.Format("MotifWmHints