diff --git a/ClassicalSharp/Blocks/BlockInfo.cs b/ClassicalSharp/Blocks/BlockInfo.cs index 882c70692..20409da2c 100644 --- a/ClassicalSharp/Blocks/BlockInfo.cs +++ b/ClassicalSharp/Blocks/BlockInfo.cs @@ -41,7 +41,7 @@ namespace ClassicalSharp { public float[] FogDensity = new float[BlocksCount]; - public BlockCollideType[] CollideType = new BlockCollideType[BlocksCount]; + public CollideType[] Collide = new CollideType[BlocksCount]; public float[] SpeedMultiplier = new float[BlocksCount]; @@ -64,7 +64,7 @@ namespace ClassicalSharp { BlocksLight[tile] = true; IsOpaque[tile] = true; IsOpaqueY[tile] = true; - CollideType[tile] = BlockCollideType.Solid; + Collide[tile] = CollideType.Solid; SpeedMultiplier[tile] = 1; CullWithNeighbours[tile] = true; } @@ -79,7 +79,7 @@ namespace ClassicalSharp { 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; + Collide[(byte)Block.Snow] = CollideType.WalkThrough; SpeedMultiplier[0] = 1f; CullWithNeighbours[(byte)Block.Leaves] = false; SetupTextures(); @@ -142,7 +142,7 @@ namespace ClassicalSharp { BlocksLight[(int)id] = false; IsOpaque[(int)id] = false; IsOpaqueY[(int)id] = false; - CollideType[(int)id] = BlockCollideType.WalkThrough; + Collide[(int)id] = CollideType.WalkThrough; } void MarkTranslucent( Block id ) { @@ -153,7 +153,7 @@ namespace ClassicalSharp { void SetIsLiquid( Block id ) { IsLiquid[(int)id] = true; - CollideType[(int)id] = BlockCollideType.SwimThrough; + Collide[(int)id] = CollideType.SwimThrough; } void SetBlockHeight( Block id, float height ) { @@ -179,7 +179,7 @@ namespace ClassicalSharp { Name[id] = "Invalid"; FogColour[id] = default( FastColour ); FogDensity[id] = 0; - CollideType[id] = BlockCollideType.Solid; + Collide[id] = CollideType.Solid; SpeedMultiplier[id] = 1; SetAll( 0, (Block)id ); if( updateCulling ) @@ -191,7 +191,7 @@ namespace ClassicalSharp { } } - public enum BlockCollideType : byte { + public enum CollideType : byte { WalkThrough, // i.e. gas or sprite SwimThrough, // i.e. liquid Solid, // i.e. solid diff --git a/ClassicalSharp/Entities/Components/PhysicsComponent.cs b/ClassicalSharp/Entities/Components/PhysicsComponent.cs index 9b862f59b..30bd41ff4 100644 --- a/ClassicalSharp/Entities/Components/PhysicsComponent.cs +++ b/ClassicalSharp/Entities/Components/PhysicsComponent.cs @@ -30,7 +30,7 @@ namespace ClassicalSharp.Entities { } bool GetBoundingBox( byte block, int x, int y, int z, ref BoundingBox box ) { - if( info.CollideType[block] != BlockCollideType.Solid ) return false; + if( info.Collide[block] != CollideType.Solid ) return false; Add( x, y, z, ref info.MinBB[block], ref box.Min ); Add( x, y, z, ref info.MaxBB[block], ref box.Max ); return true; @@ -243,7 +243,7 @@ namespace ClassicalSharp.Entities { BoundingBox blockBB = new BoundingBox( min, max ); if( !blockBB.Intersects( adjFinalBB ) ) continue; - if( info.CollideType[GetPhysicsBlockId( x, y, z )] == BlockCollideType.Solid ) + if( info.Collide[GetPhysicsBlockId( x, y, z )] == CollideType.Solid ) return false; } return true; diff --git a/ClassicalSharp/Entities/LocalPlayer.Physics.cs b/ClassicalSharp/Entities/LocalPlayer.Physics.cs index 661c1c1a0..1bbf27951 100644 --- a/ClassicalSharp/Entities/LocalPlayer.Physics.cs +++ b/ClassicalSharp/Entities/LocalPlayer.Physics.cs @@ -78,7 +78,7 @@ namespace ClassicalSharp.Entities { } bool StandardLiquid( byte block ) { - return info.CollideType[block] == BlockCollideType.SwimThrough; + return info.Collide[block] == CollideType.SwimThrough; } static Vector3 waterDrag = new Vector3( 0.8f, 0.8f, 0.8f ), @@ -204,8 +204,8 @@ namespace ClassicalSharp.Entities { { byte block = game.World.SafeGetBlock( x, y, z ); if( block == 0 ) continue; - BlockCollideType type = info.CollideType[block]; - if( type == BlockCollideType.Solid && !checkSolid ) + CollideType type = info.Collide[block]; + if( type == CollideType.Solid && !checkSolid ) continue; Vector3 min = new Vector3( x, y, z ) + info.MinBB[block]; @@ -214,7 +214,7 @@ namespace ClassicalSharp.Entities { if( !blockBB.Intersects( bounds ) ) continue; modifier = Math.Min( modifier, info.SpeedMultiplier[block] ); - if( block >= BlockInfo.CpeBlocksCount && type == BlockCollideType.SwimThrough ) + if( block >= BlockInfo.CpeBlocksCount && type == CollideType.SwimThrough ) useLiquidGravity = true; } return modifier; diff --git a/ClassicalSharp/Entities/LocalPlayer.cs b/ClassicalSharp/Entities/LocalPlayer.cs index 650c66cfc..a12371c7c 100644 --- a/ClassicalSharp/Entities/LocalPlayer.cs +++ b/ClassicalSharp/Entities/LocalPlayer.cs @@ -103,8 +103,8 @@ namespace ClassicalSharp.Entities { // then check block standing on byte blockUnder = (byte)BlockUnderFeet; SoundType typeUnder = game.BlockInfo.StepSounds[blockUnder]; - BlockCollideType collideType = game.BlockInfo.CollideType[blockUnder]; - if( collideType == BlockCollideType.Solid && typeUnder != SoundType.None ) { + CollideType collideType = game.BlockInfo.Collide[blockUnder]; + if( collideType == CollideType.Solid && typeUnder != SoundType.None ) { anyNonAir = true; sndType = typeUnder; return; } @@ -116,8 +116,8 @@ namespace ClassicalSharp.Entities { bool CheckSoundNonSolid( byte b ) { SoundType newType = game.BlockInfo.StepSounds[b]; - BlockCollideType collide = game.BlockInfo.CollideType[b]; - if( newType != SoundType.None && collide != BlockCollideType.Solid ) + CollideType collide = game.BlockInfo.Collide[b]; + if( newType != SoundType.None && collide != CollideType.Solid ) sndType = newType; if( b != 0 ) anyNonAir = true; return false; @@ -244,8 +244,8 @@ namespace ClassicalSharp.Entities { for( int y = p.Y; y <= game.World.Height; y++ ) { byte block1 = physics.GetPhysicsBlockId( p.X, y, p.Z ); byte block2 = physics.GetPhysicsBlockId( p.X, y + 1, p.Z ); - if( info.CollideType[block1] != BlockCollideType.Solid && - info.CollideType[block2] != BlockCollideType.Solid ) { + if( info.Collide[block1] != CollideType.Solid && + info.Collide[block2] != CollideType.Solid ) { p.Y = y; break; } diff --git a/ClassicalSharp/Game/Game.cs b/ClassicalSharp/Game/Game.cs index bf0e61fb8..57478d468 100644 --- a/ClassicalSharp/Game/Game.cs +++ b/ClassicalSharp/Game/Game.cs @@ -498,9 +498,9 @@ namespace ClassicalSharp { } internal bool CanPick( byte block ) { - if( BlockInfo.IsAir[block] ) - return false; - if( !BlockInfo.IsLiquid[block] ) return true; + if( BlockInfo.IsAir[block] ) return false; + if( !BlockInfo.IsTranslucent[block] || + BlockInfo.Collide[block] == CollideType.Solid ) return true; return !ModifiableLiquids ? false : Inventory.CanPlace[block] && Inventory.CanDelete[block]; diff --git a/ClassicalSharp/Game/InputHandler.cs b/ClassicalSharp/Game/InputHandler.cs index c6c9e19c7..cb7b2e3c5 100644 --- a/ClassicalSharp/Game/InputHandler.cs +++ b/ClassicalSharp/Game/InputHandler.cs @@ -175,7 +175,7 @@ namespace ClassicalSharp { } bool CannotPassThrough( byte block ) { - return game.BlockInfo.CollideType[block] == BlockCollideType.Solid; + return game.BlockInfo.Collide[block] == CollideType.Solid; } bool IntersectsOtherPlayers( Vector3 pos, byte newType ) { diff --git a/ClassicalSharp/Map/ChunkMeshBuilder.cs b/ClassicalSharp/Map/ChunkMeshBuilder.cs index 214431b4f..dd4500f69 100644 --- a/ClassicalSharp/Map/ChunkMeshBuilder.cs +++ b/ClassicalSharp/Map/ChunkMeshBuilder.cs @@ -144,7 +144,7 @@ namespace ClassicalSharp { Vector3 min = info.MinBB[tile], max = info.MaxBB[tile]; x1 = x + min.X; y1 = y + min.Y; z1 = z + min.Z; x2 = x + max.X; y2 = y + max.Y; z2 = z + max.Z; - if( isTranslucent && info.CollideType[tile] != BlockCollideType.Solid ) { + if( isTranslucent && info.Collide[tile] != CollideType.Solid ) { x1 -= 0.1f/16; x2 -= 0.1f/16f; z1 -= 0.1f/16f; z2 -= 0.1f/16f; y1 -= 0.1f/16; y2 -= 0.1f/16f; } diff --git a/ClassicalSharp/Map/Formats/MapCw.Exporter.cs b/ClassicalSharp/Map/Formats/MapCw.Exporter.cs index 03d69d957..5c21dcfcd 100644 --- a/ClassicalSharp/Map/Formats/MapCw.Exporter.cs +++ b/ClassicalSharp/Map/Formats/MapCw.Exporter.cs @@ -142,7 +142,7 @@ namespace ClassicalSharp.Map { WriteTag( NbtTagType.String ); WriteString( "Name" ); WriteString( info.Name[id] ); WriteTag( NbtTagType.Int8 ); - WriteString( "CollideType" ); WriteUInt8( (byte)info.CollideType[id] ); + WriteString( "CollideType" ); WriteUInt8( (byte)info.Collide[id] ); float speed = info.SpeedMultiplier[id]; WriteTag( NbtTagType.Real32 ); WriteString( "Speed" ); WriteInt32( *((int*)&speed) ); diff --git a/ClassicalSharp/Map/Formats/MapCw.Importer.cs b/ClassicalSharp/Map/Formats/MapCw.Importer.cs index 32f8207c9..099578e2c 100644 --- a/ClassicalSharp/Map/Formats/MapCw.Importer.cs +++ b/ClassicalSharp/Map/Formats/MapCw.Importer.cs @@ -128,7 +128,7 @@ namespace ClassicalSharp.Map { byte id = (byte)compound["ID"].Value; BlockInfo info = game.BlockInfo; info.Name[id] = (string)compound["Name"].Value; - info.CollideType[id] = (BlockCollideType)compound["CollideType"].Value; + info.Collide[id] = (CollideType)compound["CollideType"].Value; info.SpeedMultiplier[id] = (float)compound["Speed"].Value; byte[] data = (byte[])compound["Textures"].Value; @@ -155,7 +155,7 @@ namespace ClassicalSharp.Map { info.MinBB[id] = new Vector3( data[0] / 16f, data[1] / 16f, data[2] / 16f ); info.MaxBB[id] = new Vector3( data[3] / 16f, data[4] / 16f, data[5] / 16f ); - if( info.CollideType[id] != BlockCollideType.Solid ) { + if( info.Collide[id] != CollideType.Solid ) { info.IsTransparent[id] = true; info.IsOpaque[id] = false; } diff --git a/ClassicalSharp/Math/Picking.cs b/ClassicalSharp/Math/Picking.cs index cc6f219b4..e61031d8c 100644 --- a/ClassicalSharp/Math/Picking.cs +++ b/ClassicalSharp/Math/Picking.cs @@ -94,7 +94,7 @@ namespace ClassicalSharp { return; } - if( info.CollideType[block] == BlockCollideType.Solid && !info.IsAir[block] ) { + if( info.Collide[block] == CollideType.Solid && !info.IsAir[block] ) { float t0, t1; const float adjust = 0.1f; if( Intersection.RayIntersectsBox( origin, dir, min, max, out t0, out t1 ) ) { diff --git a/ClassicalSharp/Network/NetworkProcessor.CPECustom.cs b/ClassicalSharp/Network/NetworkProcessor.CPECustom.cs index 2cbb08a68..ebc39848c 100644 --- a/ClassicalSharp/Network/NetworkProcessor.CPECustom.cs +++ b/ClassicalSharp/Network/NetworkProcessor.CPECustom.cs @@ -67,8 +67,8 @@ namespace ClassicalSharp.Net { info.ResetBlockInfo( block, false ); info.Name[block] = reader.ReadAsciiString(); - info.CollideType[block] = (BlockCollideType)reader.ReadUInt8(); - if( info.CollideType[block] != BlockCollideType.Solid ) { + info.Collide[block] = (CollideType)reader.ReadUInt8(); + if( info.Collide[block] != CollideType.Solid ) { info.IsTransparent[block] = true; info.IsOpaque[block] = false; } diff --git a/ClassicalSharp/Rendering/BlockHandRenderer.cs b/ClassicalSharp/Rendering/BlockHandRenderer.cs index 8e1bb2c6f..d06ad4fed 100644 --- a/ClassicalSharp/Rendering/BlockHandRenderer.cs +++ b/ClassicalSharp/Rendering/BlockHandRenderer.cs @@ -34,12 +34,8 @@ namespace ClassicalSharp.Renderers { } public void Render( double delta, float t ) { - if( game.Camera.IsThirdPerson || !game.ShowBlockInHand ) - return; - game.Graphics.Texturing = true; - game.Graphics.DepthTest = false; - game.Graphics.AlphaTest = true; - + if( game.Camera.IsThirdPerson || !game.ShowBlockInHand ) return; + fakeP.Position = Vector3.Zero; type = (byte)game.Inventory.HeldBlock; if( playAnimation ) @@ -53,15 +49,23 @@ namespace ClassicalSharp.Renderers { game.Graphics.LoadMatrix( ref normalMat ); game.Graphics.SetMatrixMode( MatrixType.Projection ); game.Graphics.LoadMatrix( ref game.HeldBlockProjection ); + bool translucent = game.BlockInfo.IsTranslucent[type]; + + game.Graphics.Texturing = true; + game.Graphics.DepthTest = false; + if( translucent ) game.Graphics.AlphaBlending = true; + else game.Graphics.AlphaTest = true; fakeP.Block = type; block.Render( fakeP ); game.Graphics.LoadMatrix( ref game.Projection ); game.Graphics.SetMatrixMode( MatrixType.Modelview ); game.Graphics.LoadMatrix( ref game.View ); + game.Graphics.Texturing = false; game.Graphics.DepthTest = true; - game.Graphics.AlphaTest = false; + if( translucent ) game.Graphics.AlphaBlending = false; + else game.Graphics.AlphaTest = false; } double animPeriod = 0.25, animSpeed = Math.PI / 0.25; diff --git a/ClassicalSharp/Rendering/MapBordersRenderer.cs b/ClassicalSharp/Rendering/MapBordersRenderer.cs index 1b408cae4..20a23014f 100644 --- a/ClassicalSharp/Rendering/MapBordersRenderer.cs +++ b/ClassicalSharp/Rendering/MapBordersRenderer.cs @@ -148,7 +148,7 @@ namespace ClassicalSharp.Renderers { fullColSides = game.BlockInfo.FullBright[(byte)game.World.SidesBlock]; FastColour col = fullColSides ? FastColour.White : map.Shadowlight; foreach( Rectangle rec in rects ) { - DrawY( rec.X, rec.Y, rec.X + rec.Width, rec.Y + rec.Height, groundLevel, axisSize, col, ref vertices ); + DrawY( rec.X, rec.Y, rec.X + rec.Width, rec.Y + rec.Height, groundLevel, axisSize, col, 0, ref vertices ); } // Work properly for when ground level is below 0 int y1 = 0, y2 = groundLevel; @@ -156,7 +156,7 @@ namespace ClassicalSharp.Renderers { y1 = groundLevel; y2 = 0; } - DrawY( 0, 0, map.Width, map.Length, 0, axisSize, col, ref vertices ); + DrawY( 0, 0, map.Width, map.Length, 0, axisSize, col, 0, ref vertices ); DrawZ( 0, 0, map.Width, y1, y2, axisSize, col, ref vertices ); DrawZ( map.Length, 0, map.Width, y1, y2, axisSize, col, ref vertices ); DrawX( 0, 0, map.Length, y1, y2, axisSize, col, ref vertices ); @@ -175,7 +175,7 @@ namespace ClassicalSharp.Renderers { fullColEdge = game.BlockInfo.FullBright[(byte)game.World.EdgeBlock]; FastColour col = fullColEdge ? FastColour.White : map.Sunlight; foreach( Rectangle rec in rects ) { - DrawY( rec.X, rec.Y, rec.X + rec.Width, rec.Y + rec.Height, waterLevel - 0.1f/16f, axisSize, col, ref vertices ); + DrawY( rec.X, rec.Y, rec.X + rec.Width, rec.Y + rec.Height, waterLevel, axisSize, col, -0.1f/16f, ref vertices ); } edgesVb = graphics.CreateVb( ptr, VertexFormat.Pos3fTex2fCol4b, edgesVertices ); } @@ -218,7 +218,7 @@ namespace ClassicalSharp.Renderers { } } - void DrawY( int x1, int z1, int x2, int z2, float y, int axisSize, FastColour col, ref VertexPos3fTex2fCol4b* vertices ) { + void DrawY( int x1, int z1, int x2, int z2, float y, int axisSize, FastColour col, float offset, ref VertexPos3fTex2fCol4b* vertices ) { int endX = x2, endZ = z2, startZ = z1; for( ; x1 < endX; x1 += axisSize ) { x2 = x1 + axisSize; @@ -229,10 +229,10 @@ namespace ClassicalSharp.Renderers { if( z2 > endZ ) z2 = endZ; TextureRec rec = new TextureRec( 0, 0, x2 - x1, z2 - z1 ); - *vertices++ = new VertexPos3fTex2fCol4b( x1, y, z1, rec.U1, rec.V1, col ); - *vertices++ = new VertexPos3fTex2fCol4b( x1, y, z2, rec.U1, rec.V2, col ); - *vertices++ = new VertexPos3fTex2fCol4b( x2, y, z2, rec.U2, rec.V2, col ); - *vertices++ = new VertexPos3fTex2fCol4b( x2, y, z1, rec.U2, rec.V1, col ); + *vertices++ = new VertexPos3fTex2fCol4b( x1 + offset, y + offset, z1 + offset, rec.U1, rec.V1, col ); + *vertices++ = new VertexPos3fTex2fCol4b( x1 + offset, y + offset, z2 + offset, rec.U1, rec.V2, col ); + *vertices++ = new VertexPos3fTex2fCol4b( x2 + offset, y + offset, z2 + offset, rec.U2, rec.V2, col ); + *vertices++ = new VertexPos3fTex2fCol4b( x2 + offset, y + offset, z1 + offset, rec.U2, rec.V1, col ); } } } diff --git a/ClassicalSharp/Singleplayer/Physics.cs b/ClassicalSharp/Singleplayer/Physics.cs index dcccd1b98..61bfe4357 100644 --- a/ClassicalSharp/Singleplayer/Physics.cs +++ b/ClassicalSharp/Singleplayer/Physics.cs @@ -209,7 +209,7 @@ namespace ClassicalSharp.Singleplayer { byte block = map.mapData[posIndex]; if( block == (byte)Block.Water || block == (byte)Block.StillWater ) { game.UpdateBlock( x, y, z, (byte)Block.Stone ); - } else if( info.CollideType[block] == BlockCollideType.WalkThrough ) { + } else if( info.Collide[block] == CollideType.WalkThrough ) { Lava.Enqueue( defLavaTick | (uint)posIndex ); game.UpdateBlock( x, y, z, (byte)Block.Lava ); } @@ -250,7 +250,7 @@ namespace ClassicalSharp.Singleplayer { byte block = map.mapData[posIndex]; if( block == (byte)Block.Lava || block == (byte)Block.StillLava ) { game.UpdateBlock( x, y, z, (byte)Block.Stone ); - } else if( info.CollideType[block] == BlockCollideType.WalkThrough && block != (byte)Block.Rope ) { + } else if( info.Collide[block] == CollideType.WalkThrough && block != (byte)Block.Rope ) { if( CheckIfSponge( x, y, z ) ) return; Water.Enqueue( defWaterTick | (uint)posIndex ); game.UpdateBlock( x, y, z, (byte)Block.Water );