Author SHA1 Message Date
brausjonas de9d2c8cb3 Update README.md 2022-10-17 23:09:56 +02:00
brausjonas d950af6735 Update README.md 2022-10-17 23:09:24 +02:00
brausjonas 3c765a23dd Update README.md 2022-10-17 23:07:45 +02:00
brausjonas c60d589d19 Update README.md 2022-10-17 23:05:11 +02:00
brausjonas c35c655b5e Update README.md 2022-10-17 23:04:43 +02:00
brausjonas 2636b0a224 Update README.md 2022-10-17 23:04:06 +02:00
brausjonas 04484f1252 Update README.md 2022-10-17 23:03:21 +02:00
brausjonas b3cd361501 Update README.md 2022-10-17 22:59:51 +02:00
brausjonas 8ee82521a0 Create README.md 2022-10-17 22:59:11 +02:00
brausjonas c926777024 Add files via upload 2022-05-18 10:38:20 +02:00
brausjonas 05eb503927 Chunk View Distance fix 2022-05-18 00:43:38 +02:00
brausjonas b7f8a517ac fdsafsdaf 2022-05-18 00:35:16 +02:00
brausjonas db5d6eb781 Revert "show other names"
This reverts commit ee55664811.
2022-05-18 00:34:52 +02:00
brausjonas 6255fcbd9b Merge branch 'main' of https://github.com/jonasbraus/Minecraft 2022-05-18 00:29:14 +02:00
brausjonas ee55664811 show other names 2022-05-18 00:29:12 +02:00
Noah 9b905de6db coal fix 2022-05-18 00:12:23 +02:00
Noah 7e8e0a93f9 Merge branch 'main' of https://github.com/jonasbraus/Minecraft 2022-05-18 00:04:58 +02:00
Noah df176f6898 mipmap 2022-05-18 00:04:47 +02:00
brausjonas 07dc6e72a0 Update BlockAtlas.png.meta 2022-05-18 00:04:34 +02:00
Noah 856fe1e1c7 update 2022-05-17 23:58:00 +02:00
brausjonas 2eda55ad16 BlockAtlas Fix 2022-05-17 23:35:17 +02:00
brausjonas 57f1e8b958 Merge branch 'main' of https://github.com/jonasbraus/Minecraft 2022-05-17 23:33:42 +02:00
brausjonas 5c45f8b253 Update Game.unity 2022-05-17 23:33:34 +02:00
Noah 2df724a4a8 Merge branch 'main' of https://github.com/jonasbraus/Minecraft 2022-05-17 23:30:16 +02:00
Noah 2cf099a4d9 Erzadern, Player Pos 2022-05-17 23:30:12 +02:00
brausjonas ed4f60bfdb Index out... Fix 2022-05-17 23:13:22 +02:00
brausjonas f23fc16f0d save bug fix
ascii 10 ist ein line feed. Einen line feed aus einer datei dann zurück umzuwandeln ist nicht möglich. Daher jeder ascii wert +32 am nur zeichen zu speichern.
2022-05-17 16:51:35 +02:00
brausjonas 45aae55fe2 View distance settings 2022-05-17 10:39:01 +02:00
16 changed files with 1487 additions and 36 deletions
+1
View File
@@ -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++;
}
}
+1 -1
View File
@@ -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"))
{
+50 -10
View File
@@ -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,20 +139,27 @@ 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(chunks[x, z].gameObject == null)
if(z >= 0 && x >= 0 && z < worldSize && x < worldSize)
{
chunks[x, z].Initialize();
chunks[x, z].gameObject.transform.SetParent(gameObject.transform);
if (chunks[x, z].gameObject == null)
{
chunks[x, z].Initialize();
chunks[x, z].gameObject.transform.SetParent(gameObject.transform);
}
if (!chunks[x, z].active)
{
chunksToUpdate1.Enqueue(new ChunkCoord(x, z));
}
checkList.Add(chunks[x, z]);
}
if(!chunks[x, z].active)
{
chunksToUpdate.Enqueue(new ChunkCoord(x, z));
}
checkList.Add(chunks[x, z]);
}
}
@@ -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();
+1 -1
View File
@@ -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++;
}
}
+25 -7
View File
@@ -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
if((int)positionInWorld.y > 6 && (int)positionInWorld.y < height - 8)
//dirt
if((int)positionInWorld.y > 6 && (int)positionInWorld.y < height - 3)
{
if (noise.Get3DPerlin(positionInWorld, 0, 0.18f, 0.5f))
if (noise.Get3DPerlin(positionInWorld, 3, 0.28f, 0.65f))
{
return 0;
return 2;
}
}
//coal
if((int)positionInWorld.y > 6 && (int)positionInWorld.y < height - 8)
{
if (noise.Get3DPerlin(positionInWorld, 5, 0.28f, 0.65f))
{
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");
}
}
View File
-7
View File
@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 940041af630d8d944ac3b74467aa4ae7
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
+40
View File
@@ -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:
![image](https://user-images.githubusercontent.com/47791011/196282281-8f06e0f8-e270-409d-a42e-836d70208191.png)
4. Start the server application
5. If the server has been started you should get a window looking like this:
![image](https://user-images.githubusercontent.com/47791011/196282414-16bf8441-bc08-4d2f-ab57-da2bb955d567.png)
6. Now start the Minecraft Clone application
![image](https://user-images.githubusercontent.com/47791011/196282539-55600bdc-e270-40db-9ad3-21618e8f6bb0.png)
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
![image](https://user-images.githubusercontent.com/47791011/196283127-acd485b6-e08c-45a5-ace6-b933bf9c9cd6.png)
10. Click "Play" and wait until the world has been loaded
11. Ready to Play
![image](https://user-images.githubusercontent.com/47791011/196283573-a882f1a6-cf7a-42d8-a3ed-caede89216d8.png)