diff --git a/2D/Screens/BlockSelectScreen.cs b/2D/Screens/BlockSelectScreen.cs
index 707b2c1ea..ecd5b8942 100644
--- a/2D/Screens/BlockSelectScreen.cs
+++ b/2D/Screens/BlockSelectScreen.cs
@@ -145,7 +145,7 @@ namespace ClassicalSharp {
void RecreateBlockTextures() {
int blocksCount = 0;
- for( int i = 0; i < BlockInfo.BlocksCount; i++ ) {
+ for( int i = 0; i < Window.BlockInfo.BlocksCount; i++ ) {
if( Window.CanPlace[i] || Window.CanDelete[i] ) {
blocksCount++;
}
@@ -158,7 +158,7 @@ namespace ClassicalSharp {
blocksTable = new BlockDrawInfo[blocksCount];
int tableIndex = 0;
- for( int tile = 1; tile < BlockInfo.BlocksCount; tile++ ) {
+ for( int tile = 1; tile < Window.BlockInfo.BlocksCount; tile++ ) {
if( Window.CanPlace[tile] || Window.CanDelete[tile] ) {
Block block = (Block)tile;
int texId = Window.BlockInfo.GetOptimTextureLoc( (byte)block, TileSide.Left );
diff --git a/Blocks/BlockInfo.cs b/Blocks/BlockInfo.cs
index e0783a1bc..286ddf1e0 100644
--- a/Blocks/BlockInfo.cs
+++ b/Blocks/BlockInfo.cs
@@ -2,149 +2,55 @@
namespace ClassicalSharp {
- public partial class BlockInfo {
-
- bool[] isTransparent = new bool[BlocksCount];
- bool[] isTranslucent = new bool[BlocksCount];
- bool[] isOpaque = new bool[BlocksCount];
- bool[] isSprite = new bool[BlocksCount];
- bool[] isLiquid = new bool[BlocksCount];
- float[] heights = new float[BlocksCount];
- bool[] blocksLight = new bool[BlocksCount];
- public const byte MaxDefinedBlock = (byte)Block.StoneBrick;
- public const byte BlocksCount = MaxDefinedBlock + 1;
+ public abstract class BlockInfo {
- public void Init() {
- for( int tile = 1; tile < BlocksCount; tile++ ) {
- heights[tile] = 1f;
- blocksLight[tile] = true;
- isOpaque[tile] = true;
- }
- SetupOptimTextures();
-
- SetIsTranslucent( Block.StillWater, Block.Water );
- SetIsTransparent( Block.Glass, Block.Leaves, Block.Sapling,
- Block.RedMushroom, Block.BrownMushroom, Block.Rose,
- Block.Dandelion, Block.Slab );
- SetIsSprite( Block.Rose, Block.Sapling, Block.Dandelion,
- Block.BrownMushroom, Block.RedMushroom );
- SetBlockHeight( 8 / 16f, Block.Slab );
- SetBlocksLight( false, Block.Glass, Block.Leaves, Block.Sapling,
- Block.RedMushroom, Block.BrownMushroom, Block.Rose,
- Block.Dandelion );
- SetIsLiquid( Block.StillWater, Block.Water, Block.StillLava, Block.Lava );
-
- SetIsTransparent( Block.Snow, Block.Fire, Block.Rope, Block.CobblestoneSlab );
- SetBlocksLight( false, Block.Fire, Block.Rope );
- SetIsTranslucent( Block.Ice );
- SetIsSprite( Block.Rope, Block.Fire );
- SetBlockHeight( 8 / 16f, Block.CobblestoneSlab );
- SetBlockHeight( 2 / 16f, Block.Snow );
- SetupCullingCache();
+ public BlockInfo( Game window ) {
}
- public void SetDefaultBlockPermissions( bool[] canPlace, bool[] canDelete ) {
- for( int tile = (int)Block.Stone; tile <= (int)Block.Obsidian; tile++ ) {
- canPlace[tile] = true;
- canDelete[tile] = true;
- }
- canPlace[(int)Block.Grass] = false;
- canPlace[(int)Block.Lava] = false;
- canPlace[(int)Block.Water] = false;
- canPlace[(int)Block.StillLava] = false;
- canPlace[(int)Block.StillWater] = false;
- canPlace[(int)Block.Bedrock] = false;
-
- canDelete[(int)Block.Bedrock] = false;
- canDelete[(int)Block.Lava] = false;
- canDelete[(int)Block.Water] = false;
- canDelete[(int)Block.StillWater] = false;
- canDelete[(int)Block.StillLava] = false;
- }
+ public abstract byte BlocksCount { get; }
- void SetIsTransparent( params Block[] ids ) {
- for( int i = 0; i < ids.Length; i++ ) {
- isTransparent[(int)ids[i]] = true;
- isOpaque[(int)ids[i]] = false;
- }
- }
+ public abstract void Init();
- void SetIsSprite( params Block[] ids ) {
- for( int i = 0; i < ids.Length; i++ ) {
- isSprite[(int)ids[i]] = true;
- }
- }
-
- void SetIsTranslucent( params Block[] ids ) {
- for( int i = 0; i < ids.Length; i++ ) {
- isTranslucent[(int)ids[i]] = true;
- isOpaque[(int)ids[i]] = false;
- }
- }
-
- void SetIsLiquid( params Block[] ids ) {
- for( int i = 0; i < ids.Length; i++ ) {
- isLiquid[(int)ids[i]] = true;
- }
- }
-
- void SetBlockHeight( float height, params Block[] ids ) {
- for( int i = 0; i < ids.Length; i++ ) {
- heights[(int)ids[i]] = height;
- }
- }
-
- void SetBlocksLight( bool blocks, params Block[] ids ) {
- for( int i = 0; i < ids.Length; i++ ) {
- blocksLight[(int)ids[i]] = blocks;
- }
- }
+ public abstract void SetDefaultBlockPermissions( bool[] canPlace, bool[] canDelete );
/// Gets whether the given block id is opaque/not see through.
- public bool IsOpaque( byte id ) {
- return isOpaque[id];
- }
+ public abstract bool IsOpaque( byte 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;
- }
+ public abstract bool IsFullAndOpaque( byte id );
/// Gets whether the given block id is transparent/fully see through.
/// Note that these blocks's alpha values are treated as either 'fully see through'
/// or 'fully solid'.
- public bool IsTransparent( byte id ) {
- return isTransparent[id];
- }
+ public abstract bool IsTransparent( byte id );
/// Gets the tile height of the given block id.
- public float BlockHeight( byte id ) {
- return heights[id];
- }
+ public abstract float BlockHeight( byte id );
/// Gets whether the given block id is translucent/partially see through.
/// Note that these blocks's colour values are blended into both
/// the transparent and opaque blocks behind them.
- public bool IsTranslucent( byte id ) {
- return isTranslucent[id];
- }
+ public abstract bool IsTranslucent( byte id );
/// Gets whether the given block blocks sunlight.
- public bool BlocksLight( byte id ) {
- return blocksLight[id];
- }
+ public abstract bool BlocksLight( byte id );
/// Gets whether the given block id is a sprite.
/// (flowers, saplings, fire, etc)
- public bool IsSprite( byte id ) {
- return isSprite[id];
- }
+ public abstract bool IsSprite( byte id );
/// Gets whether the given block id is a liquid.
/// (water or lava)
- public bool IsLiquid( byte id ) {
- return isLiquid[id];
- }
+ public abstract bool IsLiquid( byte id );
+
+ public abstract bool IsFaceHidden( byte tile, byte block, int tileSide );
+
+ /// Gets the index in the ***optimised*** 2D terrain atlas for the
+ /// texture of the face of the given block.
+ /// Block ID.
+ /// Face of the given block, see TileSide constants.
+ /// The index of the texture within the terrain atlas.
+ public abstract int GetOptimTextureLoc( byte block, int face );
}
}
\ No newline at end of file
diff --git a/ClassicalSharp.csproj b/ClassicalSharp.csproj
index 9b832dfa2..a6d30a323 100644
--- a/ClassicalSharp.csproj
+++ b/ClassicalSharp.csproj
@@ -107,8 +107,6 @@
-
-
diff --git a/Blocks/BlockInfo.Culling.cs b/DefaultPlugin/Blocks/BlockInfo.Culling.cs
similarity index 61%
rename from Blocks/BlockInfo.Culling.cs
rename to DefaultPlugin/Blocks/BlockInfo.Culling.cs
index 43296f48d..bfda529af 100644
--- a/Blocks/BlockInfo.Culling.cs
+++ b/DefaultPlugin/Blocks/BlockInfo.Culling.cs
@@ -1,14 +1,15 @@
using System;
+using ClassicalSharp;
-namespace ClassicalSharp {
+namespace DefaultPlugin {
- public partial class BlockInfo {
+ public partial class ClassicBlockInfo : BlockInfo {
- bool[] hidden = new bool[BlocksCount * BlocksCount * 6];
+ bool[] hidden = new bool[blocksCount * blocksCount * 6];
void SetupCullingCache() {
- for( byte tile = 1; tile < BlocksCount; tile++ ) {
- for( byte neighbour = 1; neighbour < BlocksCount; neighbour++ ) {
+ for( byte tile = 1; tile < blocksCount; tile++ ) {
+ for( byte neighbour = 1; neighbour < blocksCount; neighbour++ ) {
bool hidden = IsHidden( tile, neighbour );
if( hidden ) {
SetHidden( tile, neighbour, TileSide.Left, true );
@@ -29,11 +30,11 @@ namespace ClassicalSharp {
}
void SetHidden( byte tile, byte block, int tileSide, bool value ) {
- hidden[( tile * BlocksCount + block ) * 6 + tileSide] = value;
+ hidden[( tile * blocksCount + block ) * 6 + tileSide] = value;
}
- public bool IsFaceHidden( byte tile, byte block, int tileSide ) {
- return hidden[( tile * BlocksCount + block ) * 6 + tileSide];
+ public override bool IsFaceHidden( byte tile, byte block, int tileSide ) {
+ return hidden[( tile * blocksCount + block ) * 6 + tileSide];
}
}
}
\ No newline at end of file
diff --git a/Blocks/BlockInfo.Optimised.cs b/DefaultPlugin/Blocks/BlockInfo.Optimised.cs
similarity index 96%
rename from Blocks/BlockInfo.Optimised.cs
rename to DefaultPlugin/Blocks/BlockInfo.Optimised.cs
index 37f88ff2c..1b67e37eb 100644
--- a/Blocks/BlockInfo.Optimised.cs
+++ b/DefaultPlugin/Blocks/BlockInfo.Optimised.cs
@@ -1,13 +1,14 @@
using System;
+using ClassicalSharp;
-namespace ClassicalSharp {
+namespace DefaultPlugin {
- public partial class BlockInfo {
+ public partial class ClassicBlockInfo : BlockInfo {
// The designation used is as follows:
// 0 - left 1 - right 2 - front
// 3 - back 4 - bottom 5 - top
- int[] optimTextures = new int[BlocksCount * 6];
+ int[] optimTextures = new int[blocksCount * 6];
const int Row1 = 0, Row2 = 16, Row3 = 32, Row4 = 48,
Row5 = 64, Row6 = 80, Row7 = 96, Row8 = 112, Row9 = 128;
@@ -128,7 +129,7 @@ namespace ClassicalSharp {
/// Block ID.
/// Face of the given block, see TileSide constants.
/// The index of the texture within the terrain atlas.
- public int GetOptimTextureLoc( byte block, int face ) {
+ public override int GetOptimTextureLoc( byte block, int face ) {
return optimTextures[block * 6 + face];
}
}
diff --git a/DefaultPlugin/Blocks/BlockInfo.cs b/DefaultPlugin/Blocks/BlockInfo.cs
new file mode 100644
index 000000000..c820cf52c
--- /dev/null
+++ b/DefaultPlugin/Blocks/BlockInfo.cs
@@ -0,0 +1,157 @@
+using System;
+using ClassicalSharp;
+
+namespace DefaultPlugin {
+
+ public partial class ClassicBlockInfo : BlockInfo {
+
+ public ClassicBlockInfo( Game window ) : base( window ) {
+ }
+
+ bool[] isTransparent = new bool[blocksCount];
+ bool[] isTranslucent = new bool[blocksCount];
+ bool[] isOpaque = new bool[blocksCount];
+ bool[] isSprite = new bool[blocksCount];
+ bool[] isLiquid = new bool[blocksCount];
+ float[] heights = new float[blocksCount];
+ bool[] blocksLight = new bool[blocksCount];
+ const byte blocksCount = (byte)Block.StoneBrick + 1;
+
+ public override byte BlocksCount {
+ get { return blocksCount; }
+ }
+
+ public override void Init() {
+ for( int tile = 1; tile < blocksCount; tile++ ) {
+ heights[tile] = 1f;
+ blocksLight[tile] = true;
+ isOpaque[tile] = true;
+ }
+ SetupOptimTextures();
+
+ SetIsTranslucent( Block.StillWater, Block.Water );
+ SetIsTransparent( Block.Glass, Block.Leaves, Block.Sapling,
+ Block.RedMushroom, Block.BrownMushroom, Block.Rose,
+ Block.Dandelion, Block.Slab );
+ SetIsSprite( Block.Rose, Block.Sapling, Block.Dandelion,
+ Block.BrownMushroom, Block.RedMushroom );
+ SetBlockHeight( 8 / 16f, Block.Slab );
+ SetBlocksLight( false, Block.Glass, Block.Leaves, Block.Sapling,
+ Block.RedMushroom, Block.BrownMushroom, Block.Rose,
+ Block.Dandelion );
+ SetIsLiquid( Block.StillWater, Block.Water, Block.StillLava, Block.Lava );
+
+ SetIsTransparent( Block.Snow, Block.Fire, Block.Rope, Block.CobblestoneSlab );
+ SetBlocksLight( false, Block.Fire, Block.Rope );
+ SetIsTranslucent( Block.Ice );
+ SetIsSprite( Block.Rope, Block.Fire );
+ SetBlockHeight( 8 / 16f, Block.CobblestoneSlab );
+ SetBlockHeight( 2 / 16f, Block.Snow );
+ SetupCullingCache();
+ }
+
+ public override void SetDefaultBlockPermissions( bool[] canPlace, bool[] canDelete ) {
+ for( int tile = (int)Block.Stone; tile <= (int)Block.Obsidian; tile++ ) {
+ canPlace[tile] = true;
+ canDelete[tile] = true;
+ }
+ canPlace[(int)Block.Grass] = false;
+ canPlace[(int)Block.Lava] = false;
+ canPlace[(int)Block.Water] = false;
+ canPlace[(int)Block.StillLava] = false;
+ canPlace[(int)Block.StillWater] = false;
+ canPlace[(int)Block.Bedrock] = false;
+
+ canDelete[(int)Block.Bedrock] = false;
+ canDelete[(int)Block.Lava] = false;
+ canDelete[(int)Block.Water] = false;
+ canDelete[(int)Block.StillWater] = false;
+ canDelete[(int)Block.StillLava] = false;
+ }
+
+ void SetIsTransparent( params Block[] ids ) {
+ for( int i = 0; i < ids.Length; i++ ) {
+ isTransparent[(int)ids[i]] = true;
+ isOpaque[(int)ids[i]] = false;
+ }
+ }
+
+ void SetIsSprite( params Block[] ids ) {
+ for( int i = 0; i < ids.Length; i++ ) {
+ isSprite[(int)ids[i]] = true;
+ }
+ }
+
+ void SetIsTranslucent( params Block[] ids ) {
+ for( int i = 0; i < ids.Length; i++ ) {
+ isTranslucent[(int)ids[i]] = true;
+ isOpaque[(int)ids[i]] = false;
+ }
+ }
+
+ void SetIsLiquid( params Block[] ids ) {
+ for( int i = 0; i < ids.Length; i++ ) {
+ isLiquid[(int)ids[i]] = true;
+ }
+ }
+
+ void SetBlockHeight( float height, params Block[] ids ) {
+ for( int i = 0; i < ids.Length; i++ ) {
+ heights[(int)ids[i]] = height;
+ }
+ }
+
+ void SetBlocksLight( bool blocks, params Block[] ids ) {
+ for( int i = 0; i < ids.Length; i++ ) {
+ blocksLight[(int)ids[i]] = blocks;
+ }
+ }
+
+ /// Gets whether the given block id is opaque/not see through.
+ public override bool IsOpaque( byte id ) {
+ return isOpaque[id];
+ }
+
+ /// Gets whether the given block id is opaque/not see through,
+ /// and occupies a full block.
+ public override bool IsFullAndOpaque( byte id ) {
+ return isOpaque[id] && heights[id] == 1;
+ }
+
+ /// Gets whether the given block id is transparent/fully see through.
+ /// Note that these blocks's alpha values are treated as either 'fully see through'
+ /// or 'fully solid'.
+ public override bool IsTransparent( byte id ) {
+ return isTransparent[id];
+ }
+
+ /// Gets the tile height of the given block id.
+ public override float BlockHeight( byte id ) {
+ return heights[id];
+ }
+
+ /// Gets whether the given block id is translucent/partially see through.
+ /// Note that these blocks's colour values are blended into both
+ /// the transparent and opaque blocks behind them.
+ public override bool IsTranslucent( byte id ) {
+ return isTranslucent[id];
+ }
+
+ /// Gets whether the given block blocks sunlight.
+ public override bool BlocksLight( byte id ) {
+ return blocksLight[id];
+ }
+
+ /// Gets whether the given block id is a sprite.
+ /// (flowers, saplings, fire, etc)
+ public override bool IsSprite( byte id ) {
+ return isSprite[id];
+ }
+
+ /// Gets whether the given block id is a liquid.
+ /// (water or lava)
+ public override bool IsLiquid( byte id ) {
+ return isLiquid[id];
+ }
+ }
+}
\ No newline at end of file
diff --git a/DefaultPlugin/DefaultPlugin.cs b/DefaultPlugin/DefaultPlugin.cs
index 5f39736cb..8a4a271fd 100644
--- a/DefaultPlugin/DefaultPlugin.cs
+++ b/DefaultPlugin/DefaultPlugin.cs
@@ -50,6 +50,7 @@ namespace DefaultPlugin {
new PluginModule( PluginModuleType.PostProcessingShader, typeof( GrayscaleFilter ) ),
new PluginModule( PluginModuleType.NetworkProcessor, typeof( ClassicNetworkProcessor ) ),
+ new PluginModule( PluginModuleType.BlockInfo, typeof( ClassicBlockInfo ) ),
};
}
}
diff --git a/DefaultPlugin/DefaultPlugin.csproj b/DefaultPlugin/DefaultPlugin.csproj
index 388f19aae..9a5c95c5c 100644
--- a/DefaultPlugin/DefaultPlugin.csproj
+++ b/DefaultPlugin/DefaultPlugin.csproj
@@ -47,6 +47,9 @@
+
+
+
@@ -78,6 +81,7 @@
+
diff --git a/DefaultPlugin/Network/Enums.cs b/DefaultPlugin/Network/Enums.cs
index 31946ed97..e65048095 100644
--- a/DefaultPlugin/Network/Enums.cs
+++ b/DefaultPlugin/Network/Enums.cs
@@ -1,6 +1,6 @@
using System;
-namespace ClassicalSharp {
+namespace DefaultPlugin.Network {
public enum PacketId {
ServerIdentification = 0,
@@ -39,15 +39,4 @@ namespace ClassicalSharp {
CpeHackControl = 32,
CpeExtAddEntity2 = 33,
}
-
- public enum CpeMessageType {
- Normal = 0,
- Status1 = 1,
- Status2 = 2,
- Status3 = 3,
- BottomRight1 = 11,
- BottomRight2 = 12,
- BottomRight3 = 13,
- Announcement = 100,
- }
}
diff --git a/DefaultPlugin/Network/FastNetReader.cs b/DefaultPlugin/Network/FastNetReader.cs
index 2c1f7fcb9..8eb9ac4b9 100644
--- a/DefaultPlugin/Network/FastNetReader.cs
+++ b/DefaultPlugin/Network/FastNetReader.cs
@@ -2,7 +2,7 @@
using System.Net.Sockets;
using System.Text;
-namespace ClassicalSharp {
+namespace DefaultPlugin.Network {
// Basically a much faster version of List( capacity )
internal class FastNetReader {
diff --git a/DefaultPlugin/Network/FixedBufferStream.cs b/DefaultPlugin/Network/FixedBufferStream.cs
index 6dc3ec7dd..e8b93ae51 100644
--- a/DefaultPlugin/Network/FixedBufferStream.cs
+++ b/DefaultPlugin/Network/FixedBufferStream.cs
@@ -1,7 +1,7 @@
using System;
using System.IO;
-namespace ClassicalSharp {
+namespace DefaultPlugin.Network {
internal class FixedBufferStream : Stream {
diff --git a/DefaultPlugin/Network/GZipHeaderReader.cs b/DefaultPlugin/Network/GZipHeaderReader.cs
index d4de309f4..a3b4d11d3 100644
--- a/DefaultPlugin/Network/GZipHeaderReader.cs
+++ b/DefaultPlugin/Network/GZipHeaderReader.cs
@@ -1,7 +1,7 @@
using System;
using System.IO;
-namespace ClassicalSharp {
+namespace DefaultPlugin.Network {
internal class GZipHeaderReader {
diff --git a/DefaultPlugin/StandardChunkMeshBuilder.cs b/DefaultPlugin/StandardChunkMeshBuilder.cs
index fae0282cb..c9d83a7cd 100644
--- a/DefaultPlugin/StandardChunkMeshBuilder.cs
+++ b/DefaultPlugin/StandardChunkMeshBuilder.cs
@@ -1,7 +1,8 @@
using System;
+using ClassicalSharp;
using ClassicalSharp.GraphicsAPI;
-namespace ClassicalSharp {
+namespace DefaultPlugin {
public class StandardChunkMeshBuilder : ChunkMeshBuilder {
diff --git a/Game/Game.cs b/Game/Game.cs
index f8cb4d83b..33e0ce601 100644
--- a/Game/Game.cs
+++ b/Game/Game.cs
@@ -29,6 +29,7 @@ namespace ClassicalSharp {
public Camera Camera;
Camera firstPersonCam, thirdPersonCam;
public BlockInfo BlockInfo;
+ public List BlockInfoTypes = new List();
public double accumulator;
public TerrainAtlas2D TerrainAtlas;
public SkinType DefaultPlayerSkinType;
@@ -127,23 +128,6 @@ namespace ClassicalSharp {
Bitmap terrainBmp = new Bitmap( "terrain.png" );
TerrainAtlas = new TerrainAtlas2D( Graphics );
LoadAtlas( terrainBmp );
- BlockInfo = new BlockInfo();
- BlockInfo.Init();
- BlockInfo.SetDefaultBlockPermissions( CanPlace, CanDelete );
- Map = new Map( this );
- LocalPlayer = new LocalPlayer( 255, this );
- width = Width;
- height = Height;
- firstPersonCam = new FirstPersonCamera( this );
- thirdPersonCam = new ThirdPersonCamera( this );
- Camera = firstPersonCam;
- CommandManager = new CommandManager();
- CommandManager.Init( this );
- SelectionManager = new SelectionManager( this );
- SelectionManager.Init();
- ParticleManager = new ParticleManager( this );
- ParticleManager.Init();
- Picking = new PickingRenderer( this );
VSync = VSyncMode.On;
Graphics.DepthTest = true;
@@ -155,6 +139,13 @@ namespace ClassicalSharp {
fpsScreen = new FpsScreen( this );
fpsScreen.Init();
Culling = new FrustumCulling();
+ width = Width;
+ height = Height;
+ firstPersonCam = new FirstPersonCamera( this );
+ thirdPersonCam = new ThirdPersonCamera( this );
+ Camera = firstPersonCam;
+ CommandManager = new CommandManager();
+ CommandManager.Init( this );
string defaultPlugin = Path.Combine( "plugins", "defaultplugin.dll" );
if( !Directory.Exists( "plugins" ) || !File.Exists( defaultPlugin ) ) {
@@ -171,6 +162,17 @@ namespace ClassicalSharp {
}
}
+ BlockInfo = Utils.New( BlockInfoTypes[0], this );
+ BlockInfo.Init();
+ BlockInfo.SetDefaultBlockPermissions( CanPlace, CanDelete );
+ Map = new Map( this );
+ LocalPlayer = new LocalPlayer( 255, this );
+ SelectionManager = new SelectionManager( this );
+ SelectionManager.Init();
+ ParticleManager = new ParticleManager( this );
+ ParticleManager.Init();
+ Picking = new PickingRenderer( this );
+
MapBordersRenderer = Utils.New( MapBordersRendererTypes[0], this );
MapBordersRenderer.Init();
EnvRenderer = Utils.New( EnvRendererTypes[0], this );
diff --git a/Model/ModelCache.cs b/Model/ModelCache.cs
index 4d988543a..4a6267814 100644
--- a/Model/ModelCache.cs
+++ b/Model/ModelCache.cs
@@ -30,7 +30,7 @@ namespace ClassicalSharp.Model {
byte blockId;
if( Byte.TryParse( modelName, out blockId ) ) {
modelName = "block";
- if( blockId == 0 || blockId > BlockInfo.MaxDefinedBlock )
+ if( blockId == 0 || blockId >= window.BlockInfo.BlocksCount )
return cache["humanoid"];
}
diff --git a/Plugin/Plugin.cs b/Plugin/Plugin.cs
index 898555a6f..1709e11f0 100644
--- a/Plugin/Plugin.cs
+++ b/Plugin/Plugin.cs
@@ -69,6 +69,10 @@ namespace ClassicalSharp.Plugins {
case PluginModuleType.NetworkProcessor:
game.NetworkProcessorTypes.Add( module.Type );
break;
+
+ case PluginModuleType.BlockInfo:
+ game.BlockInfoTypes.Add( module.Type );
+ break;
}
}
}
@@ -82,6 +86,7 @@ namespace ClassicalSharp.Plugins {
MapRenderer,
PostProcessingShader,
NetworkProcessor,
+ BlockInfo,
}
public class PluginModule {
diff --git a/Utils/Camera.cs b/Utils/Camera.cs
index 1cc491243..1ad8e03e9 100644
--- a/Utils/Camera.cs
+++ b/Utils/Camera.cs
@@ -29,12 +29,10 @@ namespace ClassicalSharp {
public abstract class PerspectiveCamera : Camera {
- protected Player player;
IInputDriver driver;
public PerspectiveCamera( Game window ) {
Window = window;
driver = window.InputDriver;
- player = Window.LocalPlayer;
}
public override Matrix4 GetProjection() {
@@ -44,6 +42,7 @@ namespace ClassicalSharp {
}
public override void GetPickedBlock( PickedPos pos ) {
+ Player player = Window.LocalPlayer;
Vector3 dir = Utils.GetDirectionVector( player.YawRadians, player.PitchRadians + Math.PI );
Vector3 eyePos = player.EyePosition;
float reach = Window.LocalPlayer.ReachDistance;
@@ -107,6 +106,7 @@ namespace ClassicalSharp {
}
public override Matrix4 GetView() {
+ Player player = Window.LocalPlayer;
Vector3 eyePos = player.EyePosition;
Vector3 cameraPos = eyePos - Utils.GetDirectionVector( player.YawRadians, player.PitchRadians + Math.PI ) * distance;
return Matrix4.LookAt( cameraPos, eyePos, Vector3.UnitY );
@@ -123,6 +123,7 @@ namespace ClassicalSharp {
}
public override Matrix4 GetView() {
+ Player player = Window.LocalPlayer;
Vector3 eyePos = player.EyePosition;
Vector3 cameraDir = Utils.GetDirectionVector( player.YawRadians, player.PitchRadians + Math.PI );
return Matrix4.LookAt( eyePos, eyePos + cameraDir, Vector3.UnitY );