From 92fd42acb67d03e1b2ee1cad1234416656945e18 Mon Sep 17 00:00:00 2001 From: Noah Date: Mon, 16 May 2022 01:00:30 +0200 Subject: [PATCH] Choose Block to build --- .../Assets/Scripts/Game/Player.cs | 32 ++++++++++++++++-- Minecraft Client/Assets/Scripts/Game/World.cs | 2 +- Minecraft Server/Assets/save.world | Bin 22500800 -> 22500800 bytes 3 files changed, 31 insertions(+), 3 deletions(-) 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 a370d5aa37932b6305974b639f29ac5ec952b747..f6cc5e99e70203fdf1da67e23199560e65e4cee9 100644 GIT binary patch delta 1179 zcmW;Jd3?_W0LJmxZ`hC7W}7khF!zQzXYO-m_}LsIx(^Y;j}Aqx`b3#hslGaOI#M~B zbX%!(=ggH#?jtE3j;`nFkI(z{{Qs1%+!t4_N(d1{1u9aBSi)4M3UO2=o&*x9MiR-S zP@Pn2P?I!jQJXr{r5^QZKspU+L}M~&LQ|U2oEEgC6`5qwnl`j0n|8FP10Cr^XL9I5 zE?wzHcY4s1Ui799ed$Mk29U=<@)<+{gBik5A`GLDB8D@9k&L34(Tw3D#xjnJxr9r( zjLW%#E4hlRxrXsv%LFEJ9g~>M6s~6~)0j?_8O-DcZsaCzW)`<_E3=uyZQM=?cW@_n z0e3T(dECRj%%_wE+{gVa=4hnOlsX@}lP;4l6ee(XC(wLwmGe3P^G*YJ4sn^wd^@e&=y`|n(@2Gdx zduoF!SMRG2)JFB8`bd4OHmOh4r|L8Hx%xtVslHNQtIcYQ+N!px?P`bmM(tF))NZv$ z?N#5Zed;^)z4}4zS3jx)>YzHL4yz;Ts5+*Os}t&^`bnKqKdaN~7xk+;qkdDrt3TAA z>a04a&Z`URFZH+jNBvtGjf55|6Jsivil&l@HDOcPR55X;s);uVCec(gNhaB(nCd3g z)G#$onyF=Kn>wbhsb}h&1}5D!G>uGSlVO^erly%`Zd#a@rj^MwS*EpVW7?W*)6TRv z9ZW~l$#gb3ri;lnT}?OB-SjX$O)t~i^f7%+Khxg~FnMO6$v1;cff;Oun4#wX7lwHi Xnj$mYj4&h3C{rBT5RHruMZ*69csbtL delta 1183 zcm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