diff --git a/Minecraft Client/Assets/Scripts/Game/Player.cs b/Minecraft Client/Assets/Scripts/Game/Player.cs index bb92e05..6911c89 100644 --- a/Minecraft Client/Assets/Scripts/Game/Player.cs +++ b/Minecraft Client/Assets/Scripts/Game/Player.cs @@ -130,7 +130,7 @@ public class Player : MonoBehaviour //send destroy block request to server if (Input.GetMouseButtonDown(0)) { - if (Physics.Raycast(camera.transform.position, camera.transform.forward, out RaycastHit hit)) + if (Physics.Raycast(camera.transform.position, camera.transform.forward, out RaycastHit hit, 8)) { hit.point += camera.transform.forward / 10; client.EditBlock(hit.point, 0); @@ -140,7 +140,7 @@ public class Player : MonoBehaviour //send build block request to server if (Input.GetMouseButtonDown(1)) { - if (Physics.Raycast(camera.transform.position, camera.transform.forward, out RaycastHit hit)) + if (Physics.Raycast(camera.transform.position, camera.transform.forward, out RaycastHit hit, 8)) { hit.point -= camera.transform.forward / 10; client.EditBlock(hit.point, 6); diff --git a/Minecraft Server/Assets/Game/World.cs b/Minecraft Server/Assets/Game/World.cs index e51cebf..3371c84 100644 --- a/Minecraft Server/Assets/Game/World.cs +++ b/Minecraft Server/Assets/Game/World.cs @@ -12,7 +12,8 @@ public class World : MonoBehaviour [SerializeField] public int worldSize; private int randomOffsetX, randomOffsetZ; private int seed = 0; - + private string dataPath; + //chunks public Chunk[,] chunks; @@ -21,8 +22,10 @@ public class World : MonoBehaviour [SerializeField] private int transferDelay; private void Start() { - // randomOffsetX = Random.Range(0, 10000); - // randomOffsetZ = Random.Range(0, 10000); + dataPath = Application.dataPath; + + randomOffsetX = Random.Range(0, 10000); + randomOffsetZ = Random.Range(0, 10000); if (File.Exists(Application.dataPath + "\\save.world")) { @@ -167,7 +170,7 @@ public class World : MonoBehaviour //return the ID of a block public byte GetBlockID(Vector3 positionInWorld) { - byte height = GetHeight((int)positionInWorld.x + randomOffsetX, (int)positionInWorld.z + randomOffsetZ); + byte height = GetHeight((int)positionInWorld.x, (int)positionInWorld.z); //world pass if (positionInWorld.x < 0 || positionInWorld.y < 0 || positionInWorld.z < 0 || @@ -243,7 +246,7 @@ public class World : MonoBehaviour byte perlinHeight = 10; byte groundHeight = 10; - byte height = (byte)(Mathf.PerlinNoise((x) * scale + 0.1f, (z) * scale + 0.1f) * perlinHeight + groundHeight); + byte height = (byte)(Mathf.PerlinNoise((x + randomOffsetX) * scale + 0.1f, (z + randomOffsetZ) * scale + 0.1f) * perlinHeight + groundHeight); return height; } @@ -283,7 +286,7 @@ public class World : MonoBehaviour public void SaveWorld() { - StreamWriter writer = new StreamWriter(Application.dataPath + "\\save.world", false); + StreamWriter writer = new StreamWriter(dataPath + "\\save.world", false); for (int xChunk = 0; xChunk < worldSize; xChunk++) { for (int zChunk = 0; zChunk < worldSize; zChunk++) diff --git a/Minecraft Server/Assets/save.world b/Minecraft Server/Assets/save.world new file mode 100644 index 0000000..a370d5a Binary files /dev/null and b/Minecraft Server/Assets/save.world differ diff --git a/Minecraft Server/Assets/save.world.meta b/Minecraft Server/Assets/save.world.meta new file mode 100644 index 0000000..69f851e --- /dev/null +++ b/Minecraft Server/Assets/save.world.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 940041af630d8d944ac3b74467aa4ae7 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: