diff --git a/Minecraft Client/.idea/.idea.Minecraft Client/.idea/vcs.xml b/Minecraft Client/.idea/.idea.Minecraft Client/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/Minecraft Client/.idea/.idea.Minecraft Client/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Minecraft Client/Assets/Content/28-282231_minecraft-curseforge-round-minecraft-icon.png b/Minecraft Client/Assets/Content/28-282231_minecraft-curseforge-round-minecraft-icon.png
index 63a14a2..0447cec 100644
Binary files a/Minecraft Client/Assets/Content/28-282231_minecraft-curseforge-round-minecraft-icon.png and b/Minecraft Client/Assets/Content/28-282231_minecraft-curseforge-round-minecraft-icon.png differ
diff --git a/Minecraft Client/Assets/Content/28-282231_minecraft-curseforge-round-minecraft-icon.png.meta b/Minecraft Client/Assets/Content/28-282231_minecraft-curseforge-round-minecraft-icon.png.meta
index f68b4bf..4895022 100644
--- a/Minecraft Client/Assets/Content/28-282231_minecraft-curseforge-round-minecraft-icon.png.meta
+++ b/Minecraft Client/Assets/Content/28-282231_minecraft-curseforge-round-minecraft-icon.png.meta
@@ -50,7 +50,7 @@ TextureImporter:
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
- alphaIsTransparency: 0
+ alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
diff --git a/Minecraft Client/Assets/Scripts/Game/Client.cs b/Minecraft Client/Assets/Scripts/Game/Client.cs
index e8e55f0..d6484f0 100644
--- a/Minecraft Client/Assets/Scripts/Game/Client.cs
+++ b/Minecraft Client/Assets/Scripts/Game/Client.cs
@@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Generic;
+using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
@@ -26,9 +27,8 @@ public class Client
//setup client
client = new UdpClient();
client.DontFragment = false;
-
- IPAddress address;
- if (IPAddress.TryParse(hostname, out address))
+
+ if (IPAddress.TryParse(hostname, out IPAddress address))
{
address = IPAddress.Parse(hostname);
client.Connect(address, port);
@@ -50,7 +50,7 @@ public class Client
}
Send(sendList.ToArray());
- IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, 0);
+ IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, 8051);
byte[] data = client.Receive(ref endPoint);
if (data[0] == 2)
{
@@ -64,10 +64,23 @@ public class Client
byte xChunk = 0;
byte zChunk = 0;
+
+ TcpClient tcpClient = new TcpClient();
+ if (address != null)
+ {
+ address = IPAddress.Parse(hostname);
+ tcpClient.Connect(address, port);
+ }
+ else
+ {
+ tcpClient.Connect(hostname, port);
+ }
+
+ StreamReader reader = new StreamReader(tcpClient.GetStream());
+
while (true)
{
- endPoint = new IPEndPoint(IPAddress.Any, 0);
- data = client.Receive(ref endPoint);
+ data = Encoding.ASCII.GetBytes(reader.ReadLine());
if (data[0] == 1)
{
@@ -102,23 +115,26 @@ public class Client
zChunk = 0;
}
}
-
- Send(new byte[]{5});
}
+ reader.Close();
+ tcpClient.Close();
+
world.CreateChunks();
//world transfer finished
//start listening
receiveThread = new Thread(Receive);
receiveThread.Start();
+
+ Send(new byte[]{6});
}
private void Receive()
{
while(true)
{
- IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, 0);
+ IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, 8051);
byte[] data = client.Receive(ref endPoint);
if (data[0] == 3)
diff --git a/Minecraft Client/ProjectSettings/ProjectSettings.asset b/Minecraft Client/ProjectSettings/ProjectSettings.asset
index abeec1f..e498bcb 100644
--- a/Minecraft Client/ProjectSettings/ProjectSettings.asset
+++ b/Minecraft Client/ProjectSettings/ProjectSettings.asset
@@ -42,8 +42,8 @@ PlayerSettings:
m_SplashScreenLogos: []
m_VirtualRealitySplashScreen: {fileID: 0}
m_HolographicTrackingLossScreen: {fileID: 0}
- defaultScreenWidth: 1024
- defaultScreenHeight: 768
+ defaultScreenWidth: 512
+ defaultScreenHeight: 384
defaultScreenWidthWeb: 960
defaultScreenHeightWeb: 600
m_StereoRenderingPath: 0
@@ -88,7 +88,7 @@ PlayerSettings:
bakeCollisionMeshes: 0
forceSingleInstance: 0
useFlipModelSwapchain: 1
- resizableWindow: 0
+ resizableWindow: 1
useMacAppStoreValidation: 0
macAppStoreCategory: public.app-category.games
gpuSkinning: 1
@@ -99,7 +99,7 @@ PlayerSettings:
xboxEnableFitness: 0
visibleInBackground: 1
allowFullscreenSwitch: 1
- fullscreenMode: 1
+ fullscreenMode: 3
xboxSpeechDB: 0
xboxEnableHeadOrientation: 0
xboxEnableGuest: 0
@@ -134,7 +134,7 @@ PlayerSettings:
16:10: 1
16:9: 1
Others: 1
- bundleVersion: 0.1
+ bundleVersion: 0.2
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
diff --git a/Minecraft Server/Assets/Content/png-transparent-computer-terminal-linux-console-computer-icons-command-line-interface-linux-commandline-interface-linux-ssh.png b/Minecraft Server/Assets/Content/png-transparent-computer-terminal-linux-console-computer-icons-command-line-interface-linux-commandline-interface-linux-ssh.png
index e7ebe95..7563dbb 100644
Binary files a/Minecraft Server/Assets/Content/png-transparent-computer-terminal-linux-console-computer-icons-command-line-interface-linux-commandline-interface-linux-ssh.png and b/Minecraft Server/Assets/Content/png-transparent-computer-terminal-linux-console-computer-icons-command-line-interface-linux-commandline-interface-linux-ssh.png differ
diff --git a/Minecraft Server/Assets/Content/png-transparent-computer-terminal-linux-console-computer-icons-command-line-interface-linux-commandline-interface-linux-ssh.png.meta b/Minecraft Server/Assets/Content/png-transparent-computer-terminal-linux-console-computer-icons-command-line-interface-linux-commandline-interface-linux-ssh.png.meta
index 105c416..4f9aa57 100644
--- a/Minecraft Server/Assets/Content/png-transparent-computer-terminal-linux-console-computer-icons-command-line-interface-linux-commandline-interface-linux-ssh.png.meta
+++ b/Minecraft Server/Assets/Content/png-transparent-computer-terminal-linux-console-computer-icons-command-line-interface-linux-commandline-interface-linux-ssh.png.meta
@@ -50,7 +50,7 @@ TextureImporter:
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
- alphaIsTransparency: 0
+ alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
diff --git a/Minecraft Server/Assets/Game/Server.cs b/Minecraft Server/Assets/Game/Server.cs
index e3b8e8a..95352d1 100644
--- a/Minecraft Server/Assets/Game/Server.cs
+++ b/Minecraft Server/Assets/Game/Server.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
@@ -17,9 +18,7 @@ public class Server
private int transferDelay;
private List players = new List();
private List playerNames = new List();
- private List nextTransfer = new List();
private Thread receiveThread;
- private List transferThreads = new List();
public Server(World world, int transferDelay)
{
@@ -31,9 +30,9 @@ public class Server
client.DontFragment = false;
//start listening
- receiveThread = new Thread(Receive); //info:
+ receiveThread = new Thread(Receive);
receiveThread.Start();
- //0: init message
+ Console.WriteLine("server running on port 8051" + "\n");
}
//info:
@@ -42,23 +41,19 @@ public class Server
//[0] = 2: world size
//[0] = 3: edit block
//[0] = 4: disconnect player
- //[0] = 5: next transfer
+ //[0] = 5:
+ //[0] = 6: player ready
+ //[0] = 7:
private void Receive()
{
- try
+ while (true)
{
- while (true)
+ try
{
- IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, 0);
+ IPEndPoint endPoint = new IPEndPoint(IPAddress.Any, 8051);
byte[] data = client.Receive(ref endPoint);
- if (data[0] == 5)
- {
- int id = GetPlayerID(endPoint);
- nextTransfer[id] = true;
- }
-
if (data[0] == 4)
{
IPEndPoint tempEndPoint = null;
@@ -78,17 +73,15 @@ public class Server
if (tempEndPoint != null)
{
players.Remove(tempEndPoint);
- Console.WriteLine(playerNames[i] + " left the game");
+ Console.WriteLine(playerNames[i] + " left the game" + "\n");
playerNames.RemoveAt(i);
- nextTransfer.RemoveAt(i);
+
}
-
}
if (data[0] == 0)
{
Thread t = new Thread(TransferWorld);
- transferThreads.Add(t);
t.Start(endPoint);
}
@@ -106,8 +99,6 @@ public class Server
//add player
players.Add(endPoint);
playerNames.Add(name);
- nextTransfer.Add(false);
- Console.WriteLine(name + " joined the game");
}
if (data[0] == 3)
@@ -127,11 +118,19 @@ public class Server
}, e);
}
}
+
+ if (data[0] == 6)
+ {
+ int id = GetPlayerID(endPoint);
+ Console.WriteLine(playerNames[id] + " joined" + "\n");
+
+
+ }
+ }
+ catch (Exception e)
+ {
+
}
- }
- catch (Exception e)
- {
-
}
}
@@ -153,44 +152,53 @@ public class Server
private void TransferWorld(object o)
{
- IPEndPoint endPoint = (IPEndPoint)o;
- int id = GetPlayerID(endPoint);
-
- Console.WriteLine("begin world transfer for " + playerNames[id]);
- for (int xChunk = 0; xChunk < world.worldSize; xChunk++)
+ try
{
- for (int zChunk = 0; zChunk < world.worldSize; zChunk++)
+ IPEndPoint endPoint = (IPEndPoint)o;
+ int id = GetPlayerID(endPoint);
+
+ TcpListener listener = new TcpListener(IPAddress.Any, 8051);
+ listener.Start();
+ TcpClient tcpClient = listener.AcceptTcpClient();
+ listener.Stop();
+ // Console.WriteLine("tcp connected for " + playerNames[id] + "\n");
+ StreamWriter writer = new StreamWriter(tcpClient.GetStream());
+ writer.AutoFlush = true;
+
+ Console.WriteLine("begin world transfer for " + playerNames[id] + "\n");
+ for (int xChunk = 0; xChunk < world.worldSize; xChunk++)
{
- nextTransfer[id] = false;
-
- byte[] send = new byte[Data.chunkWidth * Data.chunkWidth * Data.chunkHeight + 2];
- send[0] = 1;
- send[1] = 0;
- int i = 2;
-
- for (int y = 0; y < Data.chunkHeight; y++)
+ for (int zChunk = 0; zChunk < world.worldSize; zChunk++)
{
- for (int x = 0; x < Data.chunkWidth; x++)
+ byte[] send = new byte[Data.chunkWidth * Data.chunkWidth * Data.chunkHeight + 2];
+ send[0] = 1;
+ send[1] = 0;
+ int i = 2;
+
+ for (int y = 0; y < Data.chunkHeight; y++)
{
- for (int z = 0; z < Data.chunkWidth; z++)
+ for (int x = 0; x < Data.chunkWidth; x++)
{
- send[i] = world.chunks[xChunk, zChunk].blocks[x, y, z];
- i++;
+ for (int z = 0; z < Data.chunkWidth; z++)
+ {
+ send[i] = world.chunks[xChunk, zChunk].blocks[x, y, z];
+ i++;
+ }
}
}
+ writer.WriteLine(Encoding.ASCII.GetString(send));
}
- Send(send, endPoint);
-
- while (!nextTransfer[id])
- {
- }
-
- nextTransfer[id] = false;
}
- }
- Send(new byte[] { 1, 1 }, endPoint);
- Console.WriteLine("world transfer finished for " + playerNames[id]);
+ writer.WriteLine(Encoding.ASCII.GetString(new byte[] { 1, 1 }));
+ Console.WriteLine("world transfer finished for " + playerNames[id] + "\n");
+ writer.Close();
+ tcpClient.Close();
+ }
+ catch (Exception e)
+ {
+
+ }
}
private void Send(byte[] data, IPEndPoint endPoint)
@@ -201,13 +209,7 @@ public class Server
public void Disconnect()
{
receiveThread.Abort();
- for (int i = 0; i < transferThreads.Count; i++)
- {
- if (transferThreads[i] != null)
- {
- transferThreads[i].Abort();
- }
- }
+
client.Close();
}
}
\ No newline at end of file
diff --git a/Minecraft Server/Assets/Game/World.cs b/Minecraft Server/Assets/Game/World.cs
index 597f9a8..d465fc0 100644
--- a/Minecraft Server/Assets/Game/World.cs
+++ b/Minecraft Server/Assets/Game/World.cs
@@ -58,6 +58,7 @@ public class World : MonoBehaviour
{
CreateChunks();
}
+ Console.WriteLine("world loaded! \n");
server = new Server(this, transferDelay);
}
@@ -214,5 +215,6 @@ public class World : MonoBehaviour
}
}
writer.Close();
+ Console.WriteLine("world saved! \n");
}
}
diff --git a/Minecraft Server/Assets/save.world b/Minecraft Server/Assets/save.world
index ac9f586..5a6fb39 100644
Binary files a/Minecraft Server/Assets/save.world and b/Minecraft Server/Assets/save.world differ
diff --git a/Minecraft Server/ProjectSettings/ProjectSettings.asset b/Minecraft Server/ProjectSettings/ProjectSettings.asset
index 7e27559..6cfa695 100644
--- a/Minecraft Server/ProjectSettings/ProjectSettings.asset
+++ b/Minecraft Server/ProjectSettings/ProjectSettings.asset
@@ -134,7 +134,7 @@ PlayerSettings:
16:10: 1
16:9: 1
Others: 1
- bundleVersion: 0.1
+ bundleVersion: 0.2
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0