Client: Start moving stuff into separate DefaultSet class for block properties.

This commit is contained in:
UnknownShadow200 2016-10-04 09:34:21 +11:00
parent b299a48fcc
commit be619e29f0
3 changed files with 60 additions and 31 deletions

View file

@ -1,5 +1,6 @@
// ClassicalSharp copyright 2014-2016 UnknownShadow200 | Licensed under MIT
using System;
using ClassicalSharp.Blocks;
using OpenTK;
namespace ClassicalSharp {
@ -97,10 +98,15 @@ namespace ClassicalSharp {
public void Init() {
for( int block = 1; block < BlocksCount; block++ ) {
MaxBB[block].Y = 1;
byte b = (byte)block;
MaxBB[b].Y = DefaultSet.Height( b );
FullBright[b] = DefaultSet.FullBright( b );
FogDensity[b] = DefaultSet.FogDensity( b );
FogColour[b] = DefaultSet.FogColour( b );
Collide[b] = DefaultSet.Collide( b );
BlocksLight[block] = true;
IsOpaque[block] = true;
//IsOpaqueY[block] = true;
Collide[block] = CollideType.Solid;
SpeedMultiplier[block] = 1;
CullWithNeighbours[block] = true;
@ -109,22 +115,10 @@ namespace ClassicalSharp {
Name[block] = "Invalid";
MakeNormalNames();
FogDensity[Block.StillWater] = 0.1f;
FogColour[Block.StillWater] = new FastColour( 5, 5, 51 );
FogDensity[Block.Water] = 0.1f;
FogColour[Block.Water] = new FastColour( 5, 5, 51 );
FogDensity[Block.StillLava] = 2f;
FogColour[Block.StillLava] = new FastColour( 153, 25, 0 );
FogDensity[Block.Lava] = 2f;
FogColour[Block.Lava] = new FastColour( 153, 25, 0 );
Collide[Block.Snow] = CollideType.WalkThrough;
SpeedMultiplier[0] = 1f;
CullWithNeighbours[Block.Leaves] = false;
SetupTextures();
SetBlockHeight( Block.Slab, 8/16f );
SetBlockHeight( Block.CobblestoneSlab, 8/16f );
SetBlockHeight( Block.Snow, 2/16f );
MarkTranslucent( Block.StillWater ); MarkTranslucent( Block.Water );
MarkTranslucent( Block.Ice );
MarkTransparent( Block.Glass, false ); MarkTransparent( Block.Leaves, false );
@ -134,10 +128,6 @@ namespace ClassicalSharp {
MarkSprite( Block.Dandelion ); MarkSprite( Block.BrownMushroom );
MarkSprite( Block.RedMushroom ); MarkSprite( Block.Rope );
MarkSprite( Block.Fire );
SetIsLiquid( Block.StillWater ); SetIsLiquid( Block.Water );
SetIsLiquid( Block.StillLava ); SetIsLiquid( Block.Lava );
SetFullBright( Block.Lava, true ); SetFullBright( Block.StillLava, true );
SetFullBright( Block.Magma, true ); SetFullBright( Block.Fire, true );
InitBoundingBoxes();
InitSounds();
@ -176,7 +166,6 @@ namespace ClassicalSharp {
BlocksLight[id] = false;
IsOpaque[id] = false;
//IsOpaqueY[id] = false;
Collide[id] = CollideType.WalkThrough;
}
void MarkTranslucent( byte id ) {
@ -185,18 +174,6 @@ namespace ClassicalSharp {
//IsOpaqueY[id] = false;
}
void SetIsLiquid( byte id ) {
Collide[id] = CollideType.SwimThrough;
}
void SetBlockHeight( byte id, float height ) {
MaxBB[id].Y = height;
}
void SetFullBright( byte id, bool emits ) {
FullBright[id] = emits;
}
public void ResetBlockInfo( byte id, bool updateCulling ) {
DefinedCustomBlocks[id >> 5] &= ~(1u << (id & 0x1F));
IsTransparent[id] = false;

View file

@ -0,0 +1,51 @@
// ClassicalSharp copyright 2014-2016 UnknownShadow200 | Licensed under MIT
using System;
using OpenTK;
namespace ClassicalSharp.Blocks {
/// <summary> Stores default properties for blocks in Minecraft Classic. </summary>
public static class DefaultSet {
public static float Height( byte block ) {
if( block == Block.Slab ) return 8/16f;
if( block == Block.CobblestoneSlab ) return 8/16f;
if( block == Block.Snow ) return 2/16f;
return 1;
}
public static bool FullBright( byte block ) {
return block == Block.Lava || block == Block.StillLava
|| block == Block.Magma || block == Block.Fire;
}
public static float FogDensity( byte block ) {
if( block == Block.Water || block == Block.StillWater )
return 0.1f;
if( block == Block.Lava || block == Block.StillLava )
return 2f;
return 0;
}
public static FastColour FogColour( byte block ) {
if( block == Block.Water || block == Block.StillWater )
return new FastColour( 5, 5, 51 );
if( block == Block.Lava || block == Block.StillLava )
return new FastColour( 153, 25, 0 );
return default(FastColour);
}
public static CollideType Collide( byte block ) {
if( block >= Block.Water && block <= Block.StillLava )
return CollideType.SwimThrough;
if( block >= Block.Dandelion && block <= Block.RedMushroom )
return CollideType.WalkThrough;
if( block == Block.Sapling || block == Block.Rope )
return CollideType.WalkThrough;
if( block == Block.Fire || block == Block.Snow )
return CollideType.WalkThrough;
return CollideType.Solid;
}
}
}

View file

@ -146,6 +146,7 @@
<Compile Include="Blocks\BlockInfo.Culling.cs" />
<Compile Include="Blocks\BlockInfo.Atlas.cs" />
<Compile Include="Blocks\BlockInfo.Sounds.cs" />
<Compile Include="Blocks\DefaultSet.cs" />
<Compile Include="Commands\SinglePlayerCommands.cs" />
<Compile Include="Entities\AI\AI.cs" />
<Compile Include="Entities\AI\FleeAI.cs" />