diff --git a/Minecraft Client/Assets/Scripts/Game/Player.cs b/Minecraft Client/Assets/Scripts/Game/Player.cs index 6911c89..40a19e7 100644 --- a/Minecraft Client/Assets/Scripts/Game/Player.cs +++ b/Minecraft Client/Assets/Scripts/Game/Player.cs @@ -29,7 +29,8 @@ public class Player : MonoBehaviour private Camera camera = null; private Vector3 lastPosition = new Vector3(); private Quaternion lastRotation = new Quaternion(); - + + private byte currentBlock = 0; //network private Client client = null; @@ -136,6 +137,33 @@ public class Player : MonoBehaviour client.EditBlock(hit.point, 0); } } + + if (currentBlock == 1) + { + if (Input.GetAxisRaw("Mouse ScrollWheel") < 0) + { + currentBlock = (byte)(world.blockData.Length - 1); + } + else + { + currentBlock += (byte)(Input.GetAxisRaw("Mouse ScrollWheel") * 10); + } + } + else if (currentBlock == world.blockData.Length - 1) + { + if (Input.GetAxisRaw("Mouse ScrollWheel") > 0) + { + currentBlock = (byte)(1); + } + else + { + currentBlock += (byte)(Input.GetAxisRaw("Mouse ScrollWheel") * 10); + } + } + else + { + currentBlock += (byte)(Input.GetAxisRaw("Mouse ScrollWheel") * 10); + } //send build block request to server if (Input.GetMouseButtonDown(1)) @@ -143,7 +171,7 @@ public class Player : MonoBehaviour if (Physics.Raycast(camera.transform.position, camera.transform.forward, out RaycastHit hit, 8)) { hit.point -= camera.transform.forward / 10; - client.EditBlock(hit.point, 6); + client.EditBlock(hit.point, currentBlock); } } diff --git a/Minecraft Client/Assets/Scripts/Game/World.cs b/Minecraft Client/Assets/Scripts/Game/World.cs index 662971d..d4997be 100644 --- a/Minecraft Client/Assets/Scripts/Game/World.cs +++ b/Minecraft Client/Assets/Scripts/Game/World.cs @@ -29,7 +29,7 @@ public class World : MonoBehaviour private Queue chunksToUpdate = new Queue(); //blocks - [SerializeField] private BlockData[] blockData; + [SerializeField] public BlockData[] blockData; //network private Client client; diff --git a/Minecraft Server/Assets/save.world b/Minecraft Server/Assets/save.world index a370d5a..f6cc5e9 100644 Binary files a/Minecraft Server/Assets/save.world and b/Minecraft Server/Assets/save.world differ