Compare commits
28
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de9d2c8cb3 | ||
|
|
d950af6735 | ||
|
|
3c765a23dd | ||
|
|
c60d589d19 | ||
|
|
c35c655b5e | ||
|
|
2636b0a224 | ||
|
|
04484f1252 | ||
|
|
b3cd361501 | ||
|
|
8ee82521a0 | ||
|
|
c926777024 | ||
|
|
05eb503927 | ||
|
|
b7f8a517ac | ||
|
|
db5d6eb781 | ||
|
|
6255fcbd9b | ||
|
|
ee55664811 | ||
|
|
9b905de6db | ||
|
|
7e8e0a93f9 | ||
|
|
df176f6898 | ||
|
|
07dc6e72a0 | ||
|
|
856fe1e1c7 | ||
|
|
2eda55ad16 | ||
|
|
57f1e8b958 | ||
|
|
5c45f8b253 | ||
|
|
2df724a4a8 | ||
|
|
2cf099a4d9 | ||
|
|
ed4f60bfdb | ||
|
|
f23fc16f0d | ||
|
|
45aae55fe2 |
@@ -58,3 +58,4 @@ sysinfo.txt
|
||||
# Crashlytics generated file
|
||||
crashlytics-build.properties
|
||||
|
||||
Minecraft Server/Assets/save.world
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 18 KiB |
@@ -87,6 +87,78 @@ TextureImporter:
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: iPhone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Lumin
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: WebGL
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: tvOS
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Windows Store Apps
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -101,7 +101,7 @@ public class Client
|
||||
{
|
||||
for (int z = 0; z < Data.chunkWidth; z++)
|
||||
{
|
||||
blocks[x, y, z] = data[i];
|
||||
blocks[x, y, z] = (byte)(data[i] - 32);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ public class Data
|
||||
{
|
||||
public static int chunkWidth = 15, chunkHeight = 250;
|
||||
public static int textureAtlasSize = 16;
|
||||
public static int viewDistance = 9;
|
||||
public static int viewDistance = 4;
|
||||
|
||||
public static readonly Vector3[] vertices =
|
||||
{
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Options : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Text viewDistanceText;
|
||||
[SerializeField] private Slider viewDistanceSlider;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (PlayerPrefs.HasKey("viewDistance"))
|
||||
{
|
||||
int value = PlayerPrefs.GetInt("viewDistance");
|
||||
viewDistanceText.text = value.ToString();
|
||||
viewDistanceSlider.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void SliderViewDistanceChanged(float value)
|
||||
{
|
||||
viewDistanceText.text = ((int)value).ToString();
|
||||
PlayerPrefs.SetInt("viewDistance", (int)value);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab80d1e654833ae4f88450121509e895
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Player : MonoBehaviour
|
||||
{
|
||||
@@ -14,6 +15,7 @@ public class Player : MonoBehaviour
|
||||
[SerializeField] private float jumpForce;
|
||||
[SerializeField] private World world;
|
||||
[SerializeField] private Hotbar hotbar;
|
||||
[SerializeField] private Text positionText;
|
||||
private float playerWidth = 0.15f;
|
||||
private float playerOffsetWidth = 0.1f;
|
||||
private float horizontal;
|
||||
@@ -81,6 +83,7 @@ public class Player : MonoBehaviour
|
||||
if (lastPosition.x != position.x || lastPosition.y != position.y || lastPosition.z != position.z)
|
||||
{
|
||||
client.SendPositionUpdate(transform.position);
|
||||
positionText.text = "X: " + (int) position.x + " Y: " + (int) position.y + " Z: " + (int) position.z;
|
||||
}
|
||||
|
||||
if (rotation.w != lastRotation.w || rotation.x != lastRotation.x || rotation.y != lastRotation.y ||
|
||||
@@ -101,6 +104,8 @@ public class Player : MonoBehaviour
|
||||
mouseX = Input.GetAxis("Mouse X");
|
||||
mouseY = Input.GetAxis("Mouse Y");
|
||||
|
||||
|
||||
|
||||
//Sprinting
|
||||
if (Input.GetKeyDown(KeyCode.LeftShift) || Input.GetButtonDown("Left Stick Button"))
|
||||
{
|
||||
|
||||
@@ -24,11 +24,13 @@ public class World : MonoBehaviour
|
||||
[SerializeField] private Player player;
|
||||
[SerializeField] private GameObject deadScreen;
|
||||
[SerializeField] private GameObject pauseScreen;
|
||||
[SerializeField] private GameObject optionsScreen;
|
||||
private ChunkCoord lastPlayerChunkCoord = new ChunkCoord(0, 0);
|
||||
|
||||
//chunks
|
||||
private Chunk[,] chunks;
|
||||
private Queue<ChunkCoord> chunksToUpdate = new Queue<ChunkCoord>();
|
||||
private Queue<ChunkCoord> chunksToUpdate1 = new Queue<ChunkCoord>();
|
||||
private List<Chunk> lastActiveChunks = new List<Chunk>();
|
||||
|
||||
//blocks
|
||||
@@ -42,6 +44,12 @@ public class World : MonoBehaviour
|
||||
private void Start()
|
||||
{
|
||||
//get default information
|
||||
|
||||
if (PlayerPrefs.HasKey("viewDistance"))
|
||||
{
|
||||
Data.viewDistance = PlayerPrefs.GetInt("viewDistance");
|
||||
}
|
||||
|
||||
name = PlayerPrefs.GetString("userName");
|
||||
ip = PlayerPrefs.GetString("serverIP");
|
||||
port = int.Parse(PlayerPrefs.GetString("port"));
|
||||
@@ -74,6 +82,13 @@ public class World : MonoBehaviour
|
||||
chunks[chunk.x, chunk.z].Update();
|
||||
}
|
||||
|
||||
//update 1 chunk in list
|
||||
if (chunksToUpdate1.Count > 0)
|
||||
{
|
||||
ChunkCoord chunk = chunksToUpdate1.Dequeue();
|
||||
chunks[chunk.x, chunk.z].Update();
|
||||
}
|
||||
|
||||
//create 1 player in list
|
||||
if (playersToCreate.Count > 0)
|
||||
{
|
||||
@@ -124,22 +139,29 @@ public class World : MonoBehaviour
|
||||
{
|
||||
List<Chunk> checkList = new List<Chunk>();
|
||||
|
||||
for (int x = playerChunk.x - Data.viewDistance; x < playerChunk.x + Data.viewDistance; x++)
|
||||
chunksToUpdate1.Clear();
|
||||
|
||||
for (int x = playerChunk.x - Data.viewDistance; x <= playerChunk.x + Data.viewDistance; x++)
|
||||
{
|
||||
for (int z = playerChunk.z - Data.viewDistance; z < playerChunk.z + Data.viewDistance; z++)
|
||||
for (int z = playerChunk.z - Data.viewDistance; z <= playerChunk.z + Data.viewDistance; z++)
|
||||
{
|
||||
if(z >= 0 && x >= 0 && z < worldSize && x < worldSize)
|
||||
{
|
||||
if (chunks[x, z].gameObject == null)
|
||||
{
|
||||
chunks[x, z].Initialize();
|
||||
chunks[x, z].gameObject.transform.SetParent(gameObject.transform);
|
||||
}
|
||||
|
||||
if (!chunks[x, z].active)
|
||||
{
|
||||
chunksToUpdate.Enqueue(new ChunkCoord(x, z));
|
||||
chunksToUpdate1.Enqueue(new ChunkCoord(x, z));
|
||||
}
|
||||
|
||||
checkList.Add(chunks[x, z]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Chunk c in lastActiveChunks)
|
||||
{
|
||||
@@ -346,8 +368,20 @@ public class World : MonoBehaviour
|
||||
{
|
||||
Cursor.visible = true;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
optionsScreen.SetActive(false);
|
||||
pauseScreen.SetActive(true);
|
||||
Time.timeScale = 0;
|
||||
|
||||
if (PlayerPrefs.HasKey("viewDistance"))
|
||||
{
|
||||
int value = PlayerPrefs.GetInt("viewDistance");
|
||||
if (value != Data.viewDistance)
|
||||
{
|
||||
Data.viewDistance = value;
|
||||
LoadChunks(new ChunkCoord((int)(player.transform.position.x / Data.chunkWidth),
|
||||
(int)(player.transform.position.z / Data.chunkWidth)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RespawnButton()
|
||||
@@ -377,6 +411,12 @@ public class World : MonoBehaviour
|
||||
deadScreen.SetActive(false);
|
||||
}
|
||||
|
||||
public void ShowOptionsScreen()
|
||||
{
|
||||
pauseScreen.SetActive(false);
|
||||
optionsScreen.SetActive(true);
|
||||
}
|
||||
|
||||
public void SaveButton()
|
||||
{
|
||||
client.SaveWorld();
|
||||
|
||||
@@ -313,7 +313,7 @@ public class Server
|
||||
{
|
||||
for (int z = 0; z < Data.chunkWidth; z++)
|
||||
{
|
||||
send[i] = world.chunks[xChunk, zChunk].blocks[x, y, z];
|
||||
send[i] = (byte)(world.chunks[xChunk, zChunk].blocks[x, y, z] + 32);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class World : MonoBehaviour
|
||||
{
|
||||
for (int z = 0; z < Data.chunkWidth; z++)
|
||||
{
|
||||
chunks[xChunk, zChunk].blocks[x, y, z] = save[i];
|
||||
chunks[xChunk, zChunk].blocks[x, y, z] = (byte)(save[i] - 32);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -202,15 +202,33 @@ public class World : MonoBehaviour
|
||||
//underground pass
|
||||
if ((int)positionInWorld.y < height)
|
||||
{
|
||||
//caves
|
||||
//dirt
|
||||
if((int)positionInWorld.y > 6 && (int)positionInWorld.y < height - 3)
|
||||
{
|
||||
if (noise.Get3DPerlin(positionInWorld, 3, 0.28f, 0.65f))
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
//coal
|
||||
if((int)positionInWorld.y > 6 && (int)positionInWorld.y < height - 8)
|
||||
{
|
||||
if (noise.Get3DPerlin(positionInWorld, 0, 0.18f, 0.5f))
|
||||
if (noise.Get3DPerlin(positionInWorld, 5, 0.28f, 0.65f))
|
||||
{
|
||||
return 0;
|
||||
return 12;
|
||||
}
|
||||
}
|
||||
|
||||
// //caves
|
||||
// if((int)positionInWorld.y > 6 && (int)positionInWorld.y < height - 8)
|
||||
// {
|
||||
// if (noise.Get3DPerlin(positionInWorld, 0, 0.18f, 0.5f))
|
||||
// {
|
||||
// return 0;
|
||||
// }
|
||||
// }
|
||||
|
||||
return 4;
|
||||
}
|
||||
|
||||
@@ -289,7 +307,7 @@ public class World : MonoBehaviour
|
||||
{
|
||||
for (int z = 0; z < Data.chunkWidth; z++)
|
||||
{
|
||||
save[i] = chunks[xChunk, zChunk].blocks[x, y, z];
|
||||
save[i] = (byte)(chunks[xChunk, zChunk].blocks[x, y, z] + 32);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -300,6 +318,6 @@ public class World : MonoBehaviour
|
||||
}
|
||||
}
|
||||
writer.Close();
|
||||
Console.WriteLine("world saved! (world.save) \n");
|
||||
Console.WriteLine("world saved! (save.world) \n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 940041af630d8d944ac3b74467aa4ae7
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,40 @@
|
||||
This is an simple Minecraft Multiplayer Clone
|
||||
|
||||
Source code for the client:
|
||||
https://github.com/jonasbraus/Minecraft/tree/main/Minecraft%20Client/Assets/Scripts
|
||||
|
||||
Source code for the server:
|
||||
https://github.com/jonasbraus/Minecraft/tree/main/Minecraft%20Server/Assets/Game
|
||||
|
||||
1. You can download the installer under: https://github.com/jonasbraus/Minecraft/releases/download/Caves-and-Chunk-Loading/Minecraft.Clone.Online.Installer.exe
|
||||
|
||||
2. Just keep default settings in the installer
|
||||
|
||||
3. You should get this two icons on your desktop:
|
||||
|
||||

|
||||
|
||||
4. Start the server application
|
||||
|
||||
5. If the server has been started you should get a window looking like this:
|
||||
|
||||

|
||||
|
||||
6. Now start the Minecraft Clone application
|
||||
|
||||

|
||||
|
||||
7. For "User Name" you can enter any name you want
|
||||
|
||||
8. If you play on your pc you can set "Server IP" to "localhost". To let others join, give them your computers IP
|
||||
|
||||
9. For "Port" you can enter "8051" by default
|
||||
|
||||

|
||||
|
||||
10. Click "Play" and wait until the world has been loaded
|
||||
|
||||
11. Ready to Play
|
||||
|
||||

|
||||
|
||||
Reference in New Issue
Block a user