diff --git a/client/src/main/java/nl/andrewl/aos2_client/render/GameRenderer.java b/client/src/main/java/nl/andrewl/aos2_client/render/GameRenderer.java index 812860e..46cee6a 100644 --- a/client/src/main/java/nl/andrewl/aos2_client/render/GameRenderer.java +++ b/client/src/main/java/nl/andrewl/aos2_client/render/GameRenderer.java @@ -8,6 +8,7 @@ import nl.andrewl.aos2_client.render.chunk.ChunkRenderer; import nl.andrewl.aos2_client.render.gui.GUIRenderer; import nl.andrewl.aos2_client.render.gui.GUITexture; import nl.andrewl.aos2_client.render.model.Model; +import nl.andrewl.aos_core.model.Team; import nl.andrewl.aos_core.model.item.BlockItemStack; import nl.andrewl.aos_core.model.item.Gun; import nl.andrewl.aos_core.model.item.GunItemStack; @@ -49,6 +50,8 @@ public class GameRenderer { private Model rifleModel; private Model blockModel; private Model bulletModel; + private Model smgModel; + private Model flagModel; // Standard GUI textures. private GUITexture crosshairTexture; @@ -141,8 +144,10 @@ public class GameRenderer { try { playerModel = new Model("model/player_simple.obj", "model/simple_player.png"); rifleModel = new Model("model/rifle.obj", "model/rifle.png"); + smgModel = new Model("model/smg.obj", "model/smg.png"); blockModel = new Model("model/block.obj", "model/block.png"); bulletModel = new Model("model/bullet.obj", "model/bullet.png"); + flagModel = new Model("model/flag.obj", "model/flag.png"); } catch (IOException e) { throw new RuntimeException(e); } @@ -204,6 +209,7 @@ public class GameRenderer { } playerModel.unbind(); + // Render guns! rifleModel.bind(); if (myPlayer.getInventory().getSelectedItemStack().getType().getId() == ItemTypes.RIFLE.getId()) { modelRenderer.render(rifleModel, myPlayer.getHeldItemTransformData(), myPlayer.getHeldItemNormalTransformData()); @@ -214,6 +220,16 @@ public class GameRenderer { } } rifleModel.unbind(); + smgModel.bind(); + if (myPlayer.getInventory().getSelectedItemStack().getType().getId() == ItemTypes.AK_47.getId()) { + modelRenderer.render(smgModel, myPlayer.getHeldItemTransformData(), myPlayer.getHeldItemNormalTransformData()); + } + for (var player : client.getPlayers().values()) { + if (player.getHeldItemId() == ItemTypes.AK_47.getId()) { + modelRenderer.render(smgModel, player.getHeldItemTransformData(), player.getHeldItemNormalTransformData()); + } + } + smgModel.unbind(); blockModel.bind(); if (client.getMyPlayer().getInventory().getSelectedItemStack().getType().getId() == ItemTypes.BLOCK.getId()) { @@ -230,17 +246,27 @@ public class GameRenderer { blockModel.unbind(); bulletModel.bind(); - Matrix4f projectileTransform = new Matrix4f(); - Matrix3f projectileNormalTransform = new Matrix3f(); + Matrix4f modelTransform = new Matrix4f(); + Matrix3f normalTransform = new Matrix3f(); for (var projectile : client.getProjectiles().values()) { - projectileTransform.identity() + modelTransform.identity() .translate(projectile.getPosition()) .rotateTowards(projectile.getVelocity(), Camera.UP) .scale(1, 1, projectile.getVelocity().length() / 5); - projectileTransform.normal(projectileNormalTransform); - modelRenderer.render(bulletModel, projectileTransform, projectileNormalTransform); + modelTransform.normal(normalTransform); + modelRenderer.render(bulletModel, modelTransform, normalTransform); } bulletModel.unbind(); + // Draw team bases. + flagModel.bind(); + for (Team team : client.getTeams().values()) { + modelTransform.identity() + .translate(team.getSpawnPoint()); + modelTransform.normal(normalTransform); + modelRenderer.setAspectColor(team.getColor()); + modelRenderer.render(flagModel, modelTransform, normalTransform); + } + flagModel.unbind(); modelRenderer.end(); diff --git a/client/src/main/java/nl/andrewl/aos2_client/sound/SoundManager.java b/client/src/main/java/nl/andrewl/aos2_client/sound/SoundManager.java index 8711744..d8fb897 100644 --- a/client/src/main/java/nl/andrewl/aos2_client/sound/SoundManager.java +++ b/client/src/main/java/nl/andrewl/aos2_client/sound/SoundManager.java @@ -76,6 +76,8 @@ public class SoundManager { load("hurt_1", "sound/m_hurt_1.wav"); load("hurt_2", "sound/m_hurt_2.wav"); load("hurt_3", "sound/m_hurt_3.wav"); + load("block_break_1", "sound/m_block_break_1.wav"); + load("block_place_1", "sound/m_block_place_1.wav"); } public void load(String name, String resource) { diff --git a/client/src/main/resources/model/flag.mtl b/client/src/main/resources/model/flag.mtl new file mode 100644 index 0000000..c31ea8c --- /dev/null +++ b/client/src/main/resources/model/flag.mtl @@ -0,0 +1,13 @@ +# Blender MTL File: 'flag.blend' +# Material Count: 1 + +newmtl Material +Ns 323.999994 +Ka 1.000000 1.000000 1.000000 +Kd 0.800000 0.800000 0.800000 +Ks 0.500000 0.500000 0.500000 +Ke 0.000000 0.000000 0.000000 +Ni 1.450000 +d 1.000000 +illum 2 +map_Kd flag.png diff --git a/client/src/main/resources/model/flag.obj b/client/src/main/resources/model/flag.obj new file mode 100644 index 0000000..fd39602 --- /dev/null +++ b/client/src/main/resources/model/flag.obj @@ -0,0 +1,126 @@ +# Blender v2.82 (sub 7) OBJ File: 'flag.blend' +# www.blender.org +mtllib flag.mtl +o Cube +v 0.021753 -0.000523 -0.021753 +v 0.021753 -0.000523 0.021753 +v -0.021753 -0.000523 -0.021753 +v -0.021753 -0.000523 0.021753 +v 0.021753 2.024803 -0.021753 +v -0.021753 2.024803 0.021753 +v 0.021753 2.024803 0.021753 +v -0.021753 2.024803 -0.021753 +v -0.021753 2.490187 0.021753 +v 0.021753 2.490187 -0.021753 +v 0.021753 2.490187 0.021753 +v -0.021753 2.490187 -0.021753 +v 0.021753 2.032514 -0.012643 +v 0.021753 2.032514 0.012643 +v 0.021753 2.482476 -0.012643 +v 0.021753 2.482476 0.012643 +v 0.860993 2.268260 -0.012643 +v 0.860993 2.268260 0.012643 +v 0.860993 2.334399 -0.012643 +v 0.860993 2.334399 0.012643 +vt 0.040124 0.353694 +vt 0.075286 0.337669 +vt 0.075286 0.353694 +vt 0.801868 0.212704 +vt 0.837362 0.958716 +vt 0.801868 0.958716 +vt 0.917935 0.212704 +vt 0.953429 0.958716 +vt 0.917935 0.958716 +vt 0.914740 0.787296 +vt 0.879246 0.041284 +vt 0.914740 0.041284 +vt 0.840557 0.212704 +vt 0.876051 0.958716 +vt 0.840557 0.958716 +vt 0.801868 0.041284 +vt 0.837362 0.212704 +vt 0.953429 0.212704 +vt 0.945997 0.044125 +vt 0.953429 0.041284 +vt 0.914740 0.958716 +vt 0.879246 0.787296 +vt 0.840557 0.041284 +vt 0.876051 0.212704 +vt 0.955955 0.332400 +vt 0.976585 0.014314 +vt 0.976585 0.332400 +vt 0.925367 0.044125 +vt 0.917935 0.041284 +vt 0.925367 0.209864 +vt 0.945997 0.209864 +vt 0.098426 0.362406 +vt 0.077796 0.338044 +vt 0.098426 0.338044 +vt 0.416654 0.323037 +vt 0.591421 0.013911 +vt 0.783751 0.323037 +vt 0.999072 0.014072 +vt 0.978442 0.326777 +vt 0.978442 0.014072 +vt 0.383616 0.323037 +vt 0.208850 0.013911 +vt 0.262809 0.013911 +vt 0.036950 0.353694 +vt 0.001591 0.337669 +vt 0.036950 0.337669 +vt 0.040124 0.337669 +vt 0.837362 0.041284 +vt 0.879246 0.958716 +vt 0.876051 0.041284 +vt 0.955955 0.014314 +vt 0.077796 0.362406 +vt 0.537462 0.013911 +vt 0.999072 0.326777 +vt 0.016519 0.323037 +vt 0.001591 0.353694 +vn 0.0000 -1.0000 0.0000 +vn 0.0000 0.0000 -1.0000 +vn 1.0000 0.0000 0.0000 +vn -1.0000 0.0000 0.0000 +vn 0.0000 0.0000 1.0000 +vn 0.2704 -0.9627 0.0000 +vn 0.1738 0.9848 0.0000 +vn 0.0000 1.0000 0.0000 +usemtl Material +s off +f 1/1/1 4/2/1 3/3/1 +f 8/4/2 1/5/2 3/6/2 +f 5/7/3 2/8/3 1/9/3 +f 6/10/4 3/11/4 4/12/4 +f 7/13/5 4/14/5 2/15/5 +f 12/16/2 5/17/2 8/4/2 +f 7/18/3 16/19/3 11/20/3 +f 9/21/4 8/22/4 6/10/4 +f 11/23/5 6/24/5 7/13/5 +f 13/25/6 18/26/6 14/27/6 +f 11/20/3 15/28/3 10/29/3 +f 10/29/3 13/30/3 5/7/3 +f 5/7/3 14/31/3 7/18/3 +f 19/32/3 18/33/3 17/34/3 +f 15/35/2 17/36/2 13/37/2 +f 16/38/7 19/39/7 15/40/7 +f 16/41/5 18/42/5 20/43/5 +f 9/44/8 10/45/8 12/46/8 +f 1/1/1 2/47/1 4/2/1 +f 8/4/2 5/17/2 1/5/2 +f 5/7/3 7/18/3 2/8/3 +f 6/10/4 8/22/4 3/11/4 +f 7/13/5 6/24/5 4/14/5 +f 12/16/2 10/48/2 5/17/2 +f 7/18/3 14/31/3 16/19/3 +f 9/21/4 12/49/4 8/22/4 +f 11/23/5 9/50/5 6/24/5 +f 13/25/6 17/51/6 18/26/6 +f 11/20/3 16/19/3 15/28/3 +f 10/29/3 15/28/3 13/30/3 +f 5/7/3 13/30/3 14/31/3 +f 19/32/3 20/52/3 18/33/3 +f 15/35/2 19/53/2 17/36/2 +f 16/38/7 20/54/7 19/39/7 +f 16/41/5 14/55/5 18/42/5 +f 9/44/8 11/56/8 10/45/8 diff --git a/client/src/main/resources/model/flag.png b/client/src/main/resources/model/flag.png new file mode 100644 index 0000000..581ca33 Binary files /dev/null and b/client/src/main/resources/model/flag.png differ diff --git a/client/src/main/resources/model/smg.mtl b/client/src/main/resources/model/smg.mtl new file mode 100644 index 0000000..974311a --- /dev/null +++ b/client/src/main/resources/model/smg.mtl @@ -0,0 +1,13 @@ +# Blender MTL File: 'None' +# Material Count: 1 + +newmtl Material +Ns 323.999994 +Ka 1.000000 1.000000 1.000000 +Kd 0.800000 0.800000 0.800000 +Ks 0.500000 0.500000 0.500000 +Ke 0.000000 0.000000 0.000000 +Ni 1.450000 +d 1.000000 +illum 2 +map_Kd smg.png diff --git a/client/src/main/resources/model/smg.obj b/client/src/main/resources/model/smg.obj new file mode 100644 index 0000000..94f7932 --- /dev/null +++ b/client/src/main/resources/model/smg.obj @@ -0,0 +1,429 @@ +# Blender v2.82 (sub 7) OBJ File: '' +# www.blender.org +mtllib smg.mtl +o Cube +v 0.044780 0.044780 -0.487616 +v 0.044780 -0.044780 -0.487616 +v 0.066336 0.066336 0.299058 +v 0.066336 -0.066336 0.299058 +v -0.044780 0.044780 -0.487616 +v -0.044780 -0.044780 -0.487616 +v -0.066336 0.066336 0.299058 +v -0.066336 -0.066336 0.299058 +v 0.041998 0.041998 0.350292 +v 0.041998 -0.041998 0.350292 +v -0.041998 0.041998 0.350292 +v -0.041998 -0.041998 0.350292 +v 0.041998 0.041998 0.568729 +v 0.041998 -0.041998 0.568729 +v -0.041998 0.041998 0.568729 +v -0.041998 -0.041998 0.568729 +v 0.027950 0.035810 0.590048 +v 0.027950 -0.020089 0.590048 +v -0.027950 0.035810 0.590048 +v -0.027950 -0.020089 0.590048 +v 0.027950 0.035810 0.922111 +v 0.027950 -0.020089 0.922111 +v -0.027950 0.035810 0.922111 +v -0.027950 -0.020089 0.922111 +v -0.066336 -0.066336 -0.183615 +v 0.066336 0.066336 -0.183615 +v -0.066336 0.066336 -0.183615 +v 0.066336 -0.066336 -0.183615 +v -0.066336 -0.066336 0.040061 +v 0.066336 0.066336 0.040061 +v -0.066336 0.066336 0.040061 +v 0.066336 -0.066336 0.040061 +v -0.066336 -0.066336 0.200724 +v 0.066336 0.066336 0.200724 +v -0.066336 0.066336 0.200724 +v 0.066336 -0.066336 0.200724 +v -0.066336 0.066336 -0.290947 +v 0.066336 -0.066336 -0.290947 +v -0.066336 -0.066336 -0.290947 +v 0.066336 0.066336 -0.290947 +v -0.020125 -0.080748 0.040061 +v 0.020125 -0.080748 0.040061 +v -0.020125 -0.080748 0.200724 +v 0.020125 -0.080748 0.200724 +v 0.020125 -0.245565 0.171517 +v 0.020125 -0.262304 0.040061 +v -0.020125 -0.262304 0.040061 +v -0.020125 -0.245565 0.171517 +v -0.031249 -0.080797 -0.183615 +v 0.031249 -0.080797 -0.183615 +v 0.031249 -0.080797 -0.290947 +v -0.031249 -0.080797 -0.290947 +v -0.016961 -0.121090 -0.183615 +v 0.016961 -0.121090 -0.183615 +v 0.016961 -0.121090 -0.233439 +v -0.016961 -0.121090 -0.233439 +v -0.016961 -0.156442 -0.200395 +v 0.016961 -0.156442 -0.200395 +v 0.016961 -0.145722 -0.233439 +v -0.016961 -0.145722 -0.233439 +v -0.022327 -0.173212 -0.211049 +v 0.022327 -0.173212 -0.211049 +v 0.022327 -0.165553 -0.234659 +v -0.022327 -0.165553 -0.234659 +v -0.014615 -0.178125 -0.236704 +v 0.014615 -0.178125 -0.236704 +v 0.014615 -0.173111 -0.239652 +v -0.014615 -0.173111 -0.239652 +vt 0.478133 0.487153 +vt 0.329777 0.550995 +vt 0.329777 0.487153 +vt 0.168220 0.447060 +vt 0.288039 0.413466 +vt 0.316431 0.447008 +vt 0.316431 0.830900 +vt 0.191235 0.958715 +vt 0.168220 0.830952 +vt 0.639842 0.010799 +vt 0.491486 0.074692 +vt 0.491486 0.010799 +vt 0.154881 0.489010 +vt 0.006670 0.552940 +vt 0.006670 0.488958 +vt 0.812724 0.557650 +vt 0.912661 0.499372 +vt 0.912661 0.557650 +vt 0.450919 0.585326 +vt 0.356992 0.727143 +vt 0.356992 0.585326 +vt 0.612627 0.108843 +vt 0.518700 0.108843 +vt 0.154881 0.552992 +vt 0.032654 0.586501 +vt 0.991137 0.151220 +vt 0.963002 0.105703 +vt 0.991137 0.096562 +vt 0.194204 0.413499 +vt 0.288039 0.271338 +vt 0.518700 0.250774 +vt 0.126489 0.586534 +vt 0.032654 0.728629 +vt 0.435209 0.741256 +vt 0.372701 0.956844 +vt 0.372701 0.741256 +vt 0.126489 0.728662 +vt 0.056435 0.742634 +vt 0.450919 0.727143 +vt 0.217985 0.257366 +vt 0.280431 0.257344 +vt 0.710922 0.540368 +vt 0.649292 0.576742 +vt 0.649292 0.540368 +vt 0.280431 0.041284 +vt 0.811040 0.487040 +vt 0.873547 0.271282 +vt 0.873547 0.487040 +vt 0.118881 0.742656 +vt 0.056435 0.958694 +vt 0.154881 0.169100 +vt 0.006670 0.238885 +vt 0.006670 0.169048 +vt 0.973685 0.428221 +vt 0.934450 0.358994 +vt 0.973685 0.358481 +vt 0.316431 0.615526 +vt 0.168220 0.761115 +vt 0.168220 0.615578 +vt 0.478133 0.167942 +vt 0.329777 0.237626 +vt 0.329777 0.167942 +vt 0.316431 0.510990 +vt 0.168220 0.511042 +vt 0.154881 0.238937 +vt 0.006670 0.384421 +vt 0.491486 0.413447 +vt 0.639842 0.268113 +vt 0.639842 0.413447 +vt 0.478133 0.237626 +vt 0.329777 0.382845 +vt 0.154881 0.384474 +vt 0.878685 0.266293 +vt 0.930360 0.371195 +vt 0.878685 0.370684 +vt 0.478133 0.382845 +vt 0.454029 0.041204 +vt 0.353881 0.041204 +vt 0.677299 0.533015 +vt 0.801551 0.405993 +vt 0.777446 0.533015 +vt 0.129733 0.041320 +vt 0.029684 0.041284 +vt 0.316431 0.761063 +vt 0.588168 0.434551 +vt 0.543160 0.543468 +vt 0.543160 0.434551 +vt 0.639842 0.425304 +vt 0.491486 0.425304 +vt 0.878685 0.381147 +vt 0.930360 0.485027 +vt 0.878685 0.485538 +vt 0.801551 0.267299 +vt 0.704868 0.276657 +vt 0.653194 0.267299 +vt 0.934710 0.351450 +vt 0.979718 0.265443 +vt 0.979718 0.351450 +vt 0.749876 0.276657 +vt 0.704868 0.394551 +vt 0.834242 0.134095 +vt 0.687259 0.241187 +vt 0.654602 0.134032 +vt 0.834242 0.123340 +vt 0.687259 0.016248 +vt 0.834242 0.005314 +vt 0.956806 0.167086 +vt 0.911086 0.134779 +vt 0.956806 0.097250 +vt 0.962462 0.157564 +vt 0.978598 0.221065 +vt 0.962462 0.243896 +vt 0.847858 0.003885 +vt 0.863802 0.067385 +vt 0.847858 0.090217 +vt 0.973685 0.505309 +vt 0.934450 0.435056 +vt 0.973685 0.435569 +vt 0.759876 0.540391 +vt 0.721943 0.556386 +vt 0.721943 0.540391 +vt 0.956806 0.173604 +vt 0.911086 0.205911 +vt 0.911086 0.173493 +vt 0.997221 0.550969 +vt 0.935464 0.519597 +vt 0.997221 0.510300 +vt 0.863802 0.026717 +vt 0.908227 0.058088 +vt 0.883569 0.134769 +vt 0.853125 0.149279 +vt 0.861681 0.133920 +vt 0.908227 0.036014 +vt 0.950336 0.058088 +vt 0.871594 0.156265 +vt 0.871594 0.184425 +vt 0.847255 0.132653 +vt 0.852856 0.130737 +vt 0.883569 0.205921 +vt 0.853125 0.191412 +vt 0.759876 0.556386 +vt 0.715943 0.569211 +vt 0.950336 0.036014 +vt 0.970813 0.061580 +vt 0.757253 0.573909 +vt 0.724566 0.577289 +vt 0.724566 0.573909 +vt 0.861682 0.206770 +vt 0.847255 0.208037 +vt 0.765877 0.569211 +vt 0.798370 0.569096 +vt 0.769426 0.545057 +vt 0.798370 0.540039 +vt 0.478133 0.550995 +vt 0.291284 0.958680 +vt 0.639842 0.074692 +vt 0.812724 0.499372 +vt 0.963002 0.142078 +vt 0.194204 0.271371 +vt 0.612627 0.250774 +vt 0.435209 0.956844 +vt 0.710922 0.576742 +vt 0.217985 0.041306 +vt 0.811040 0.271282 +vt 0.118881 0.958716 +vt 0.934451 0.428734 +vt 0.491486 0.268113 +vt 0.930360 0.266804 +vt 0.653194 0.405993 +vt 0.588168 0.543468 +vt 0.930360 0.380636 +vt 0.934710 0.265443 +vt 0.749877 0.394551 +vt 0.834242 0.252121 +vt 0.654602 0.123404 +vt 0.911086 0.167198 +vt 0.978598 0.180396 +vt 0.934450 0.504796 +vt 0.956806 0.243441 +vt 0.935464 0.541672 +vt 0.970813 0.032522 +vt 0.757253 0.577289 +vt 0.852856 0.209954 +vt 0.769426 0.564078 +vn 0.0000 1.0000 0.0000 +vn -0.9033 0.0000 0.4291 +vn -0.9940 0.0000 -0.1090 +vn 0.0000 -1.0000 0.0000 +vn 1.0000 0.0000 0.0000 +vn 0.0000 0.0000 -1.0000 +vn 0.0000 -0.9033 0.4291 +vn 0.0000 0.9033 0.4291 +vn 0.9033 0.0000 0.4291 +vn 0.0000 -0.6974 0.7167 +vn -1.0000 0.0000 0.0000 +vn 0.8350 0.0000 0.5502 +vn 0.0000 0.9604 0.2788 +vn -0.8350 0.0000 0.5502 +vn 0.0000 0.0000 1.0000 +vn -0.3810 -0.9246 0.0000 +vn 0.2977 -0.9546 0.0000 +vn 0.0000 0.9940 -0.1090 +vn 0.0000 -0.9940 -0.1090 +vn 0.9940 0.0000 -0.1090 +vn 0.0000 -0.1745 0.9847 +vn -0.2977 -0.9546 0.0000 +vn 0.0000 -0.9920 0.1263 +vn 0.9425 -0.3342 0.0000 +vn 0.3810 -0.9246 0.0000 +vn -0.9425 -0.3342 0.0000 +vn 0.0000 -0.8190 -0.5738 +vn 0.9632 0.2555 0.0829 +vn 0.0000 -0.4288 0.9034 +vn 0.7258 -0.3487 -0.5930 +vn -0.9632 0.2555 0.0829 +vn 0.0000 0.0614 -0.9981 +vn 0.0000 -0.5362 0.8441 +vn 0.0000 -0.5069 -0.8620 +vn -0.8527 -0.4969 -0.1612 +vn 0.0000 0.5512 -0.8344 +vn 0.0000 -0.9822 0.1881 +vn 0.8527 -0.4969 -0.1612 +vn -0.7258 -0.3487 -0.5930 +usemtl Material +s off +f 35/1/1 3/2/1 34/3/1 +f 8/4/2 11/5/2 7/6/2 +f 37/7/3 6/8/3 39/9/3 +f 36/10/4 8/11/4 33/12/4 +f 34/13/5 4/14/5 36/15/5 +f 5/16/6 2/17/6 6/18/6 +f 11/19/1 13/20/1 9/21/1 +f 8/11/7 10/22/7 12/23/7 +f 3/2/8 11/19/8 9/21/8 +f 3/24/9 10/25/9 4/14/9 +f 14/26/10 20/27/10 16/28/10 +f 12/29/11 15/30/11 11/5/11 +f 10/22/4 16/31/4 12/23/4 +f 9/32/5 14/33/5 10/25/5 +f 19/34/1 21/35/1 17/36/1 +f 13/37/12 18/38/12 14/33/12 +f 15/39/13 17/36/13 13/20/13 +f 15/30/14 20/40/14 19/41/14 +f 21/42/15 24/43/15 22/44/15 +f 20/40/11 23/45/11 19/41/11 +f 18/46/4 24/47/4 20/48/4 +f 17/49/5 22/50/5 18/38/5 +f 40/51/5 28/52/5 38/53/5 +f 39/54/16 49/55/16 25/56/16 +f 31/57/11 25/58/11 29/59/11 +f 37/60/1 26/61/1 40/62/1 +f 35/63/11 29/59/11 33/64/11 +f 26/65/5 32/66/5 28/52/5 +f 28/67/4 29/68/4 25/69/4 +f 27/70/1 30/71/1 26/61/1 +f 7/6/11 33/64/11 8/4/11 +f 30/72/5 36/15/5 32/66/5 +f 36/73/17 42/74/17 32/75/17 +f 31/76/1 34/3/1 30/71/1 +f 5/77/18 40/62/18 1/78/18 +f 2/79/19 39/80/19 6/81/19 +f 1/82/20 38/53/20 2/83/20 +f 27/84/11 39/9/11 25/58/11 +f 43/85/21 45/86/21 44/87/21 +f 33/88/15 44/87/15 36/89/15 +f 29/90/22 43/91/22 33/92/22 +f 32/93/6 41/94/6 29/95/6 +f 46/96/23 48/97/23 47/98/23 +f 42/99/6 47/100/6 41/94/6 +f 41/101/11 48/102/11 43/103/11 +f 42/104/5 45/105/5 46/106/5 +f 50/107/24 55/108/24 51/109/24 +f 38/110/6 52/111/6 39/112/6 +f 25/113/15 50/114/15 28/115/15 +f 28/116/25 51/117/25 38/118/25 +f 55/119/6 60/120/6 56/121/6 +f 49/122/26 56/123/26 53/124/26 +f 51/125/27 56/126/27 52/127/27 +f 49/128/15 54/129/15 50/114/15 +f 59/130/28 62/131/28 63/132/28 +f 53/133/29 58/134/29 54/129/29 +f 55/108/5 58/135/5 59/130/5 +f 56/123/11 57/136/11 53/124/11 +f 63/132/30 66/137/30 67/138/30 +f 60/139/31 61/140/31 57/136/31 +f 59/141/32 64/142/32 60/120/32 +f 57/143/33 62/144/33 58/134/33 +f 67/145/34 65/146/34 68/147/34 +f 64/148/35 65/149/35 61/140/35 +f 63/150/36 68/147/36 64/142/36 +f 61/151/37 66/152/37 62/153/37 +f 35/1/1 7/154/1 3/2/1 +f 8/4/2 12/29/2 11/5/2 +f 37/7/3 5/155/3 6/8/3 +f 36/10/4 4/156/4 8/11/4 +f 34/13/5 3/24/5 4/14/5 +f 5/16/6 1/157/6 2/17/6 +f 11/19/1 15/39/1 13/20/1 +f 8/11/7 4/156/7 10/22/7 +f 3/2/8 7/154/8 11/19/8 +f 3/24/9 9/32/9 10/25/9 +f 14/26/10 18/158/10 20/27/10 +f 12/29/11 16/159/11 15/30/11 +f 10/22/4 14/160/4 16/31/4 +f 9/32/5 13/37/5 14/33/5 +f 19/34/1 23/161/1 21/35/1 +f 13/37/12 17/49/12 18/38/12 +f 15/39/13 19/34/13 17/36/13 +f 15/30/14 16/159/14 20/40/14 +f 21/42/15 23/162/15 24/43/15 +f 20/40/11 24/163/11 23/45/11 +f 18/46/4 22/164/4 24/47/4 +f 17/49/5 21/165/5 22/50/5 +f 40/51/5 26/65/5 28/52/5 +f 39/54/16 52/166/16 49/55/16 +f 31/57/11 27/84/11 25/58/11 +f 37/60/1 27/70/1 26/61/1 +f 35/63/11 31/57/11 29/59/11 +f 26/65/5 30/72/5 32/66/5 +f 28/67/4 32/167/4 29/68/4 +f 27/70/1 31/76/1 30/71/1 +f 7/6/11 35/63/11 33/64/11 +f 30/72/5 34/13/5 36/15/5 +f 36/73/17 44/168/17 42/74/17 +f 31/76/1 35/1/1 34/3/1 +f 5/77/18 37/60/18 40/62/18 +f 2/79/19 38/169/19 39/80/19 +f 1/82/20 40/51/20 38/53/20 +f 27/84/11 37/7/11 39/9/11 +f 43/85/21 48/170/21 45/86/21 +f 33/88/15 43/85/15 44/87/15 +f 29/90/22 41/171/22 43/91/22 +f 32/93/6 42/99/6 41/94/6 +f 46/96/23 45/172/23 48/97/23 +f 42/99/6 46/173/6 47/100/6 +f 41/101/11 47/174/11 48/102/11 +f 42/104/5 44/175/5 45/105/5 +f 50/107/24 54/176/24 55/108/24 +f 38/110/6 51/177/6 52/111/6 +f 25/113/15 49/128/15 50/114/15 +f 28/116/25 50/178/25 51/117/25 +f 55/119/6 59/141/6 60/120/6 +f 49/122/26 52/179/26 56/123/26 +f 51/125/27 55/180/27 56/126/27 +f 49/128/15 53/133/15 54/129/15 +f 59/130/28 58/135/28 62/131/28 +f 53/133/29 57/143/29 58/134/29 +f 55/108/5 54/176/5 58/135/5 +f 56/123/11 60/139/11 57/136/11 +f 63/132/38 62/131/38 66/137/38 +f 60/139/31 64/148/31 61/140/31 +f 59/141/32 63/150/32 64/142/32 +f 57/143/33 61/181/33 62/144/33 +f 67/145/34 66/182/34 65/146/34 +f 64/148/39 68/183/39 65/149/39 +f 63/150/36 67/145/36 68/147/36 +f 61/151/37 65/184/37 66/152/37 diff --git a/client/src/main/resources/model/smg.png b/client/src/main/resources/model/smg.png new file mode 100644 index 0000000..4d7f32a Binary files /dev/null and b/client/src/main/resources/model/smg.png differ diff --git a/client/src/main/resources/shader/model/vertex.glsl b/client/src/main/resources/shader/model/vertex.glsl index 75e6cbd..382ae61 100644 --- a/client/src/main/resources/shader/model/vertex.glsl +++ b/client/src/main/resources/shader/model/vertex.glsl @@ -21,7 +21,7 @@ void main() { vec3 lightDirection = normalize(vec3(0.5, -1.0, -0.5));// TODO: Add this via a uniform. vec3 lightColor = vec3(1.0, 1.0, 0.9); // TODO: Add this via a uniform. - float ambientComponent = 0.1; + float ambientComponent = 0.25; float diffuseComponent = max(dot(-vertexNormal, lightDirection), 0.0); vertexColor = (ambientComponent + diffuseComponent) * lightColor; } \ No newline at end of file diff --git a/server/src/main/java/nl/andrewl/aos2_server/ClientCommunicationHandler.java b/server/src/main/java/nl/andrewl/aos2_server/ClientCommunicationHandler.java index d5ed537..567c886 100644 --- a/server/src/main/java/nl/andrewl/aos2_server/ClientCommunicationHandler.java +++ b/server/src/main/java/nl/andrewl/aos2_server/ClientCommunicationHandler.java @@ -151,8 +151,12 @@ public class ClientCommunicationHandler { } public void sendDatagramPacket(byte[] data) { - DatagramPacket packet = new DatagramPacket(data, data.length, clientAddress, clientUdpPort); - sendDatagramPacket(packet); + if (clientUdpPort != -1) { + DatagramPacket packet = new DatagramPacket(data, data.length, clientAddress, clientUdpPort); + sendDatagramPacket(packet); + } else { + log.warn("Can't send datagram packet because we don't know the client's UDP port yet."); + } } public void sendDatagramPacket(DatagramPacket packet) { diff --git a/server/src/main/java/nl/andrewl/aos2_server/PlayerManager.java b/server/src/main/java/nl/andrewl/aos2_server/PlayerManager.java index 2180d8e..87301ae 100644 --- a/server/src/main/java/nl/andrewl/aos2_server/PlayerManager.java +++ b/server/src/main/java/nl/andrewl/aos2_server/PlayerManager.java @@ -154,8 +154,15 @@ public class PlayerManager { Vector3f deathPosition = new Vector3f(player.getPosition()); player.setPosition(getBestSpawnPoint(player)); player.setVelocity(new Vector3f(0)); - player.setHealth(1); + resupply(player); + broadcastUdpMessage(player.getUpdateMessage(System.currentTimeMillis())); + broadcastUdpMessage(new SoundMessage("death", 1, deathPosition)); + // TODO: Team points or something. + } + + public void resupply(ServerPlayer player) { var handler = getHandler(player.getId()); + player.setHealth(1); for (int i = 0; i < player.getInventory().getItemStacks().size(); i++) { ItemStack stack = player.getInventory().getItemStacks().get(i); if (stack instanceof GunItemStack g) { @@ -168,9 +175,6 @@ public class PlayerManager { handler.sendTcpMessage(new ItemStackMessage(i, stack)); } handler.sendDatagramPacket(new ClientHealthMessage(player.getHealth())); - broadcastUdpMessage(player.getUpdateMessage(System.currentTimeMillis())); - broadcastUdpMessage(new SoundMessage("death", 1, deathPosition)); - // TODO: Team points or something. } public void handleUdpInit(DatagramInit init, DatagramPacket packet) { diff --git a/server/src/main/java/nl/andrewl/aos2_server/Server.java b/server/src/main/java/nl/andrewl/aos2_server/Server.java index caee45e..69b75b7 100644 --- a/server/src/main/java/nl/andrewl/aos2_server/Server.java +++ b/server/src/main/java/nl/andrewl/aos2_server/Server.java @@ -45,7 +45,7 @@ public class Server implements Runnable { this.teamManager = new TeamManager(this); this.projectileManager = new ProjectileManager(this); this.worldUpdater = new WorldUpdater(this, config.ticksPerSecond); - this.world = Worlds.flatWorld(); + this.world = Worlds.testingWorld(); // TODO: Add some way to configure teams with config files or commands. teamManager.addTeam("Red", new Vector3f(0.8f, 0, 0), "A"); diff --git a/server/src/main/java/nl/andrewl/aos2_server/config/ServerConfig.java b/server/src/main/java/nl/andrewl/aos2_server/config/ServerConfig.java index 3808993..9d873f1 100644 --- a/server/src/main/java/nl/andrewl/aos2_server/config/ServerConfig.java +++ b/server/src/main/java/nl/andrewl/aos2_server/config/ServerConfig.java @@ -20,5 +20,7 @@ public class ServerConfig { public static class ActionsConfig { public float blockRemoveCooldown = 0.25f; public float blockPlaceCooldown = 0.1f; + public float resupplyCooldown = 30; + public float resupplyRadius = 3; } } diff --git a/server/src/main/java/nl/andrewl/aos2_server/logic/PlayerActionManager.java b/server/src/main/java/nl/andrewl/aos2_server/logic/PlayerActionManager.java index 824c456..a166509 100644 --- a/server/src/main/java/nl/andrewl/aos2_server/logic/PlayerActionManager.java +++ b/server/src/main/java/nl/andrewl/aos2_server/logic/PlayerActionManager.java @@ -35,6 +35,8 @@ public class PlayerActionManager { private long lastBlockRemovedAt = 0; private long lastBlockPlacedAt = 0; + private long lastResupplyAt = System.currentTimeMillis(); + private long gunLastShotAt = 0; private boolean gunNeedsReCock = false; private boolean gunReloading = false; @@ -80,11 +82,16 @@ public class PlayerActionManager { if (selectedStack instanceof BlockItemStack b) { tickBlockAction(now, server, world, b); } else if (selectedStack instanceof GunItemStack g) { - try { - tickGunAction(now, server, world, g); - } catch (Exception e) { - System.out.println("bleh"); - } + tickGunAction(now, server, world, g); + } + + if ( + now - lastResupplyAt > server.getConfig().actions.resupplyCooldown * 1000 && + player.getTeam() != null && + player.getPosition().distance(player.getTeam().getSpawnPoint()) < server.getConfig().actions.resupplyRadius + ) { + server.getPlayerManager().resupply(player); + lastResupplyAt = now; } if (player.isCrouching() != lastInputState.crouching()) { @@ -161,6 +168,7 @@ public class PlayerActionManager { stack.incrementAmount(); server.getPlayerManager().getHandler(player.getId()).sendDatagramPacket(new ItemStackMessage(player.getInventory())); server.getPlayerManager().broadcastUdpMessage(ChunkUpdateMessage.fromWorld(hit.pos(), world)); + server.getPlayerManager().broadcastUdpMessage(new SoundMessage("block_break_1", 1, player.getPosition())); } } // Check for placing blocks. @@ -179,6 +187,7 @@ public class PlayerActionManager { stack.decrementAmount(); server.getPlayerManager().getHandler(player.getId()).sendDatagramPacket(new ItemStackMessage(player.getInventory())); server.getPlayerManager().broadcastUdpMessage(ChunkUpdateMessage.fromWorld(placePos, world)); + server.getPlayerManager().broadcastUdpMessage(new SoundMessage("block_place_1", 1, player.getPosition())); } } }