This commit is contained in:
Noah
2022-05-15 21:52:14 +02:00
5 changed files with 42 additions and 6 deletions
+6 -5
View File
@@ -9,12 +9,13 @@ Material:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: Blocks m_Name: Blocks
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: m_ShaderKeywords: _ALPHATEST_ON
m_LightmapFlags: 4 m_LightmapFlags: 4
m_EnableInstancingVariants: 0 m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0 m_DoubleSidedGI: 0
m_CustomRenderQueue: -1 m_CustomRenderQueue: 2450
stringTagMap: {} stringTagMap:
RenderType: TransparentCutout
disabledShaderPasses: [] disabledShaderPasses: []
m_SavedProperties: m_SavedProperties:
serializedVersion: 3 serializedVersion: 3
@@ -57,14 +58,14 @@ Material:
m_Offset: {x: 0, y: 0} m_Offset: {x: 0, y: 0}
m_Floats: m_Floats:
- _BumpScale: 1 - _BumpScale: 1
- _Cutoff: 0.5 - _Cutoff: 1
- _DetailNormalMapScale: 1 - _DetailNormalMapScale: 1
- _DstBlend: 0 - _DstBlend: 0
- _GlossMapScale: 1 - _GlossMapScale: 1
- _Glossiness: 0 - _Glossiness: 0
- _GlossyReflections: 1 - _GlossyReflections: 1
- _Metallic: 0 - _Metallic: 0
- _Mode: 0 - _Mode: 1
- _OcclusionStrength: 1 - _OcclusionStrength: 1
- _Parallax: 0.02 - _Parallax: 0.02
- _SmoothnessTextureChannel: 0 - _SmoothnessTextureChannel: 0
@@ -539,6 +539,8 @@ MonoBehaviour:
textures: 000000000000 textures: 000000000000
- name: Sand - name: Sand
textures: 0a0a0a0a0a0a textures: 0a0a0a0a0a0a
- name: Leafs
textures: 101010101010
--- !u!1 &1353507538 --- !u!1 &1353507538
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -81,6 +81,19 @@ public class Chunk
triangleIndex++; triangleIndex++;
} }
AddUV(textures[f]);
}
else if(world.GetBlockID(new Vector3(x + Data.faceChecks[f].x + chunkPosition.x * Data.chunkWidth,
y + Data.faceChecks[f].y,
z + Data.faceChecks[f].z + chunkPosition.z * Data.chunkWidth)) == 6)
{
for (int v = 0; v < 6; v++)
{
vertices.Add(Data.vertices[Data.triangles[f, v]] + new Vector3(x, y, z));
triangles.Add(triangleIndex);
triangleIndex++;
}
AddUV(textures[f]); AddUV(textures[f]);
} }
} }
@@ -143,7 +143,7 @@ public class Player : MonoBehaviour
if (Physics.Raycast(camera.transform.position, camera.transform.forward, out RaycastHit hit)) if (Physics.Raycast(camera.transform.position, camera.transform.forward, out RaycastHit hit))
{ {
hit.point -= camera.transform.forward / 10; hit.point -= camera.transform.forward / 10;
client.EditBlock(hit.point, 5); client.EditBlock(hit.point, 6);
} }
} }
@@ -297,4 +297,24 @@ public class World : MonoBehaviour
SceneManager.LoadScene("Login"); SceneManager.LoadScene("Login");
deadScreen.SetActive(false); deadScreen.SetActive(false);
} }
//return the ID of a block
public byte GetBlockID(Vector3 positionInWorld)
{
if (!(positionInWorld.x < 0 || positionInWorld.y < 0 || positionInWorld.z < 0 ||
positionInWorld.x >= worldSize * Data.chunkWidth || positionInWorld.y >= Data.chunkHeight ||
positionInWorld.z >= worldSize * Data.chunkWidth))
{
ChunkCoord chunk = new ChunkCoord((int)(positionInWorld.x / Data.chunkWidth),
(int)(positionInWorld.z / Data.chunkWidth));
int xInChunk = (int)(positionInWorld.x - chunk.x * Data.chunkWidth);
int yInChunk = (int)positionInWorld.y;
int zInChunk = (int)(positionInWorld.z - chunk.z * Data.chunkWidth);
return chunks[chunk.x, chunk.z].blocks[xInChunk, yInChunk, zInChunk];
}
return 0;
}
} }