Merge branch 'main' of https://github.com/jonasbraus/Minecraft
This commit is contained in:
@@ -130,7 +130,7 @@ public class Player : MonoBehaviour
|
|||||||
//send destroy block request to server
|
//send destroy block request to server
|
||||||
if (Input.GetMouseButtonDown(0))
|
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;
|
hit.point += camera.transform.forward / 10;
|
||||||
client.EditBlock(hit.point, 0);
|
client.EditBlock(hit.point, 0);
|
||||||
@@ -140,7 +140,7 @@ public class Player : MonoBehaviour
|
|||||||
//send build block request to server
|
//send build block request to server
|
||||||
if (Input.GetMouseButtonDown(1))
|
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;
|
hit.point -= camera.transform.forward / 10;
|
||||||
client.EditBlock(hit.point, 6);
|
client.EditBlock(hit.point, 6);
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ public class World : MonoBehaviour
|
|||||||
[SerializeField] public int worldSize;
|
[SerializeField] public int worldSize;
|
||||||
private int randomOffsetX, randomOffsetZ;
|
private int randomOffsetX, randomOffsetZ;
|
||||||
private int seed = 0;
|
private int seed = 0;
|
||||||
|
private string dataPath;
|
||||||
|
|
||||||
//chunks
|
//chunks
|
||||||
public Chunk[,] chunks;
|
public Chunk[,] chunks;
|
||||||
|
|
||||||
@@ -21,8 +22,10 @@ public class World : MonoBehaviour
|
|||||||
[SerializeField] private int transferDelay;
|
[SerializeField] private int transferDelay;
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
// randomOffsetX = Random.Range(0, 10000);
|
dataPath = Application.dataPath;
|
||||||
// randomOffsetZ = Random.Range(0, 10000);
|
|
||||||
|
randomOffsetX = Random.Range(0, 10000);
|
||||||
|
randomOffsetZ = Random.Range(0, 10000);
|
||||||
|
|
||||||
if (File.Exists(Application.dataPath + "\\save.world"))
|
if (File.Exists(Application.dataPath + "\\save.world"))
|
||||||
{
|
{
|
||||||
@@ -167,7 +170,7 @@ public class World : MonoBehaviour
|
|||||||
//return the ID of a block
|
//return the ID of a block
|
||||||
public byte GetBlockID(Vector3 positionInWorld)
|
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
|
//world pass
|
||||||
if (positionInWorld.x < 0 || positionInWorld.y < 0 || positionInWorld.z < 0 ||
|
if (positionInWorld.x < 0 || positionInWorld.y < 0 || positionInWorld.z < 0 ||
|
||||||
@@ -243,7 +246,7 @@ public class World : MonoBehaviour
|
|||||||
byte perlinHeight = 10;
|
byte perlinHeight = 10;
|
||||||
byte groundHeight = 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;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,7 +286,7 @@ public class World : MonoBehaviour
|
|||||||
|
|
||||||
public void SaveWorld()
|
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 xChunk = 0; xChunk < worldSize; xChunk++)
|
||||||
{
|
{
|
||||||
for (int zChunk = 0; zChunk < worldSize; zChunk++)
|
for (int zChunk = 0; zChunk < worldSize; zChunk++)
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 940041af630d8d944ac3b74467aa4ae7
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Reference in New Issue
Block a user