Merge branch 'main' of https://github.com/jonasbraus/Minecraft
This commit is contained in:
@@ -81,6 +81,19 @@ public class Chunk
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ public class Player : MonoBehaviour
|
||||
if (Physics.Raycast(camera.transform.position, camera.transform.forward, out RaycastHit hit))
|
||||
{
|
||||
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");
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user