Added Shotgun.

This commit is contained in:
Andrew Lalis 2022-07-27 00:50:56 +02:00
parent 4a2a715f32
commit cf67e4588e
17 changed files with 924 additions and 35 deletions

View File

@ -50,6 +50,7 @@ public class GameRenderer {
private Model blockModel;
private Model bulletModel;
private Model smgModel;
private Model shotgunModel;
private Model flagModel;
// Standard GUI textures.
@ -149,6 +150,7 @@ public class GameRenderer {
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");
shotgunModel = new Model("model/shotgun.obj", "model/shotgun.png");
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -231,6 +233,17 @@ public class GameRenderer {
}
}
smgModel.unbind();
shotgunModel.bind();
if (myPlayer.getInventory().getSelectedItemStack().getType().getId() == ItemTypes.WINCHESTER.getId()) {
modelRenderer.render(shotgunModel, myPlayer.getHeldItemTransformData(), myPlayer.getHeldItemNormalTransformData());
}
for (var player : client.getPlayers().values()) {
if (player.getHeldItemId() == ItemTypes.WINCHESTER.getId()) {
modelRenderer.render(shotgunModel, player.getHeldItemTransformData(), player.getHeldItemNormalTransformData());
}
}
shotgunModel.unbind();
blockModel.bind();
if (myPlayer.getInventory().getSelectedItemStack().getType().getId() == ItemTypes.BLOCK.getId()) {
BlockItemStack stack = (BlockItemStack) myPlayer.getInventory().getSelectedItemStack();

View File

@ -0,0 +1,13 @@
# Blender MTL File: 'shotgun.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 shotgun.png

View File

@ -0,0 +1,745 @@
# Blender v2.82 (sub 7) OBJ File: 'shotgun.blend'
# www.blender.org
mtllib shotgun.mtl
o Cube
v 0.047990 0.047990 0.025924
v 0.031359 -0.047990 0.025924
v -0.047990 0.047990 0.025924
v -0.031359 -0.047990 0.025924
v -0.031359 -0.047990 0.103381
v -0.047990 0.047990 0.103381
v 0.031359 -0.047990 0.103381
v 0.047990 0.047990 0.103381
v 0.047990 0.010865 0.125727
v 0.047990 0.047990 0.125727
v -0.047990 0.010865 0.125727
v 0.047990 0.043324 0.169151
v -0.047990 0.047990 0.125727
v 0.047990 0.015531 0.169151
v -0.047990 0.015531 0.169151
v -0.047990 0.043324 0.169151
v 0.000000 0.035078 0.169151
v 0.000000 0.023776 0.169151
v -0.023995 0.047990 0.169151
v 0.023995 0.047990 0.169151
v -0.023995 0.010865 0.169151
v 0.023995 0.010865 0.169151
v -0.011997 0.037556 0.169151
v 0.011997 0.021299 0.169151
v 0.011997 0.037556 0.169151
v -0.011997 0.021299 0.169151
v 0.035992 0.049212 0.169151
v -0.051755 0.029427 0.169151
v -0.035992 0.009643 0.169151
v 0.051755 0.029427 0.169151
v -0.035992 0.049212 0.169151
v 0.035992 0.009643 0.169151
v 0.000000 0.047990 0.125727
v 0.000000 0.010865 0.125727
v 0.047990 0.043324 0.683394
v 0.047990 0.015531 0.683394
v -0.047990 0.015531 0.683394
v -0.047990 0.043324 0.683394
v 0.000000 0.035078 0.683394
v 0.000000 0.023776 0.683394
v -0.023995 0.047990 0.683394
v 0.023995 0.047990 0.683394
v -0.023995 0.010865 0.683394
v 0.023995 0.010865 0.683394
v -0.011997 0.037556 0.683394
v 0.011997 0.021299 0.683394
v 0.011997 0.037556 0.683394
v -0.011997 0.021299 0.683394
v 0.035992 0.049212 0.683394
v -0.051755 0.029427 0.683394
v -0.035992 0.009643 0.683394
v 0.051755 0.029427 0.683394
v -0.035992 0.049212 0.683394
v 0.035992 0.009643 0.683394
v 0.044983 0.039600 0.683394
v 0.044983 0.019254 0.683394
v -0.044983 0.019254 0.683394
v -0.044983 0.039600 0.683394
v 0.000000 0.033564 0.683394
v 0.000000 0.025290 0.683394
v -0.022491 0.043016 0.683394
v 0.022491 0.043016 0.683394
v -0.022491 0.015838 0.683394
v 0.022491 0.015838 0.683394
v -0.014163 0.035378 0.683394
v 0.014163 0.023477 0.683394
v 0.014163 0.035378 0.683394
v -0.014163 0.023477 0.683394
v 0.033737 0.043911 0.683394
v -0.048512 0.029427 0.683394
v -0.033737 0.014944 0.683394
v 0.048512 0.029427 0.683394
v -0.033737 0.043911 0.683394
v 0.033737 0.014944 0.683394
v 0.039222 0.037714 0.661614
v 0.039222 0.021140 0.661614
v -0.039222 0.021140 0.661614
v -0.039222 0.037714 0.661614
v -0.026699 0.040496 0.661614
v 0.026699 0.040496 0.661614
v -0.026699 0.018358 0.661614
v 0.026699 0.018358 0.661614
v -0.020637 0.034274 0.661614
v 0.020637 0.024580 0.661614
v 0.020637 0.034274 0.661614
v -0.020637 0.024580 0.661614
v 0.033634 0.041225 0.661614
v -0.042299 0.029427 0.661614
v -0.033634 0.017630 0.661614
v 0.042299 0.029427 0.661614
v -0.033634 0.041225 0.661614
v 0.033634 0.017630 0.661614
v 0.047990 0.047990 -0.095389
v 0.031359 -0.047990 -0.095389
v -0.047990 0.047990 -0.095389
v -0.031359 -0.047990 -0.095389
v 0.031473 0.047990 -0.199306
v 0.020566 -0.047990 -0.199306
v -0.031473 0.047990 -0.199306
v -0.020566 -0.047990 -0.199306
v 0.027149 0.020337 -0.310971
v 0.017741 -0.075642 -0.281880
v -0.027149 0.020337 -0.310971
v -0.017741 -0.075642 -0.281880
v 0.009415 -0.056704 0.052989
v -0.009415 -0.056704 0.052989
v -0.009415 -0.056704 0.076317
v 0.009415 -0.056704 0.076317
v 0.009415 -0.073796 0.052989
v -0.009415 -0.073796 0.052989
v -0.009415 -0.080898 0.076317
v 0.009415 -0.080898 0.076317
v 0.009415 -0.085659 0.049377
v -0.009415 -0.085659 0.049377
v -0.009415 -0.096685 0.061547
v 0.009415 -0.096685 0.061547
v 0.009415 -0.093383 0.040493
v -0.009415 -0.093383 0.040493
v -0.009415 -0.104409 0.045490
v 0.009415 -0.104409 0.045490
vt 0.018674 0.758089
vt 0.181623 0.653031
vt 0.032429 0.646382
vt 0.190406 0.581707
vt 0.876032 0.080583
vt 0.727560 0.151954
vt 0.876032 0.151954
vt 0.239818 0.424942
vt 0.380229 0.346969
vt 0.231035 0.353618
vt 0.921024 0.324824
vt 0.984097 0.299695
vt 0.887079 0.299695
vt 0.801796 0.059993
vt 0.727560 0.059993
vt 0.727560 0.080583
vt 0.299550 0.443027
vt 0.389012 0.418293
vt 0.100945 0.556973
vt 0.041212 0.575058
vt 0.725050 0.532305
vt 0.725050 0.576616
vt 0.817741 0.561260
vt 0.312772 0.958716
vt 0.275576 0.484305
vt 0.254464 0.485191
vt 0.714198 0.537771
vt 0.695639 0.497833
vt 0.714198 0.497482
vt 0.297285 0.483326
vt 0.076971 0.515695
vt 0.055858 0.514809
vt 0.043746 0.554481
vt 0.584285 0.497833
vt 0.565726 0.537771
vt 0.565726 0.497482
vt 0.156988 0.043150
vt 0.098680 0.516674
vt 0.459569 0.497966
vt 0.478128 0.023177
vt 0.478128 0.497926
vt 0.602844 0.497760
vt 0.403892 0.538227
vt 0.403892 0.498061
vt 0.422451 0.498158
vt 0.552364 0.498061
vt 0.552364 0.538227
vt 0.533805 0.498158
vt 0.441010 0.498138
vt 0.515246 0.498138
vt 0.478128 0.538227
vt 0.764678 0.019982
vt 0.496687 0.497966
vt 0.677080 0.497760
vt 0.916390 0.510438
vt 0.981364 0.531871
vt 0.981364 0.486067
vt 0.639962 0.537771
vt 0.621403 0.497138
vt 0.658521 0.497138
vt 0.639962 0.496990
vt 0.496687 0.023218
vt 0.639962 0.023158
vt 0.422451 0.023410
vt 0.714198 0.023649
vt 0.658521 0.023305
vt 0.552364 0.023313
vt 0.441010 0.023390
vt 0.584285 0.024001
vt 0.333884 0.957829
vt 0.515246 0.023390
vt 0.677080 0.023928
vt 0.533805 0.023410
vt 0.602844 0.023928
vt 0.135279 0.042171
vt 0.459569 0.023218
vt 0.695639 0.024001
vt 0.621403 0.023305
vt 0.944755 0.413332
vt 0.938449 0.404336
vt 0.946644 0.402254
vt 0.944755 0.457643
vt 0.938449 0.466638
vt 0.937065 0.456254
vt 0.931784 0.393953
vt 0.937541 0.391176
vt 0.554028 0.584753
vt 0.543552 0.575372
vt 0.549377 0.588187
vt 0.903488 0.424409
vt 0.895045 0.414720
vt 0.906855 0.422410
vt 0.554028 0.565991
vt 0.549377 0.562558
vt 0.885466 0.402254
vt 0.900326 0.393953
vt 0.893662 0.404336
vt 0.928623 0.446565
vt 0.925256 0.448565
vt 0.909659 0.435487
vt 0.907318 0.435487
vt 0.946644 0.468720
vt 0.931784 0.477022
vt 0.885466 0.468720
vt 0.900326 0.477022
vt 0.894570 0.479798
vt 0.714751 0.584278
vt 0.704274 0.574897
vt 0.710099 0.587712
vt 0.903488 0.446565
vt 0.906855 0.448565
vt 0.922451 0.435487
vt 0.924792 0.435487
vt 0.928623 0.424409
vt 0.925256 0.422410
vt 0.887356 0.413332
vt 0.887356 0.457643
vt 0.893662 0.466638
vt 0.895045 0.456254
vt 0.714751 0.565516
vt 0.710099 0.562082
vt 0.937065 0.414720
vt 0.541666 0.582393
vt 0.525717 0.562308
vt 0.526234 0.582362
vt 0.510234 0.582393
vt 0.965242 0.578802
vt 0.978791 0.598924
vt 0.968691 0.598956
vt 0.598273 0.580288
vt 0.632612 0.585107
vt 0.598912 0.590667
vt 0.473475 0.572722
vt 0.507298 0.566303
vt 0.507235 0.572707
vt 0.436608 0.572723
vt 0.470431 0.579141
vt 0.436701 0.583106
vt 0.507298 0.577866
vt 0.473525 0.583106
vt 0.996700 0.554921
vt 0.981217 0.534836
vt 0.980699 0.554890
vt 0.560596 0.582973
vt 0.595053 0.584931
vt 0.561205 0.590668
vt 0.996098 0.578794
vt 0.977712 0.578754
vt 0.965268 0.554921
vt 0.560714 0.572589
vt 0.595053 0.567770
vt 0.594599 0.572926
vt 0.996098 0.556782
vt 0.982549 0.576904
vt 0.983627 0.556734
vt 0.470431 0.567578
vt 0.470368 0.572738
vt 0.967573 0.576936
vt 0.965242 0.556774
vt 0.594544 0.579330
vt 0.632103 0.573547
vt 0.632158 0.579951
vt 0.598155 0.569904
vt 0.632612 0.567946
vt 0.398775 0.572253
vt 0.404307 0.579708
vt 0.423063 0.562540
vt 0.673012 0.579237
vt 0.667477 0.571778
vt 0.691776 0.562072
vt 0.008199 0.853983
vt 0.167868 0.764738
vt 0.984097 0.187699
vt 0.727560 0.263734
vt 0.366474 0.235262
vt 0.038486 0.958716
vt 0.156940 0.860561
vt 0.967402 0.091762
vt 0.887079 0.187699
vt 0.753110 0.359485
vt 0.876032 0.263734
vt 0.206805 0.146017
vt 0.217280 0.241911
vt 0.909687 0.488031
vt 0.840246 0.577470
vt 0.895132 0.577470
vt 0.963031 0.015985
vt 0.903774 0.091762
vt 0.759799 0.464024
vt 0.850483 0.359485
vt 0.355546 0.139439
vt 0.237091 0.041284
vt 0.979837 0.459515
vt 0.950708 0.481825
vt 0.979837 0.481825
vt 0.921024 0.346361
vt 0.887079 0.371203
vt 0.950152 0.346361
vt 0.984097 0.371203
vt 0.950152 0.324824
vt 0.635474 0.588741
vt 0.664602 0.577901
vt 0.635474 0.577901
vt 0.664602 0.562127
vt 0.635474 0.562127
vt 0.963546 0.389475
vt 0.989178 0.411336
vt 0.997704 0.396419
vt 0.953247 0.565166
vt 0.927615 0.587027
vt 0.961773 0.580082
vt 0.984886 0.440283
vt 0.988548 0.422763
vt 0.965229 0.428763
vt 0.951478 0.410588
vt 0.929298 0.547739
vt 0.915547 0.565913
vt 0.979837 0.444260
vt 0.950708 0.459515
vt 0.981926 0.443352
vt 0.999222 0.460739
vt 0.999222 0.443352
vt 0.952617 0.553738
vt 0.948955 0.536218
vt 0.746608 0.598773
vt 0.721987 0.581386
vt 0.721987 0.598773
vt 0.981799 0.462303
vt 0.996286 0.479690
vt 0.996286 0.462303
vt 0.876032 0.059993
vt 0.242351 0.445519
vt 0.817741 0.503350
vt 0.725050 0.487994
vt 0.403892 0.023313
vt 0.565726 0.023649
vt 0.355594 0.956850
vt 0.114166 0.041284
vt 0.548568 0.575372
vt 0.894570 0.391176
vt 0.937541 0.479798
vt 0.709290 0.574897
vt 0.538271 0.562336
vt 0.512668 0.562336
vt 0.473568 0.562339
vt 0.994266 0.534863
vt 0.993767 0.598956
vt 0.968663 0.534863
vt 0.561353 0.562210
vt 0.992648 0.576936
vt 0.436658 0.562339
vt 0.598764 0.562210
vt 0.416654 0.583193
vt 0.433522 0.568939
vt 0.426629 0.581908
vt 0.433522 0.576955
vt 0.409639 0.562342
vt 0.401173 0.566333
vt 0.669877 0.565856
vt 0.678346 0.561868
vt 0.702238 0.568479
vt 0.702238 0.576497
vt 0.685364 0.582730
vt 0.695342 0.581449
vt 0.190406 0.938488
vt 0.825692 0.488031
vt 0.908145 0.015985
vt 0.843794 0.464024
vt 0.389012 0.061512
vt 0.664602 0.588741
vt 0.997704 0.432149
vt 0.950708 0.444260
vt 0.981926 0.460739
vt 0.961773 0.544353
vt 0.746608 0.581386
vt 0.981799 0.479690
vn -0.9853 -0.1707 0.0000
vn 0.0000 1.0000 0.0000
vn 0.9853 -0.1707 0.0000
vn 0.0000 -0.9519 -0.3065
vn 0.9479 -0.1643 -0.2729
vn -0.9479 -0.1643 -0.2729
vn 0.0000 -0.3550 0.9349
vn 0.9652 0.2615 0.0000
vn -0.4385 -0.8936 0.0960
vn 0.9648 -0.2614 0.0281
vn -0.9648 0.2614 0.0281
vn 0.4385 -0.8936 0.0960
vn -0.9652 -0.2615 0.0000
vn 0.2022 0.9793 0.0000
vn -0.1012 -0.9933 -0.0559
vn -0.4385 0.8936 0.0960
vn 0.4385 0.8936 0.0960
vn 0.1012 0.9933 -0.0559
vn -0.1012 0.9933 -0.0559
vn 0.6169 0.7094 0.3409
vn -0.6169 0.7094 0.3409
vn -0.1942 0.9403 0.2796
vn 0.1942 0.9403 0.2796
vn 0.1012 -0.9933 -0.0559
vn 0.0000 -1.0000 0.0000
vn -0.6169 -0.7094 0.3409
vn 0.6169 -0.7094 0.3409
vn 0.1942 -0.9403 0.2796
vn -0.1942 -0.9403 0.2796
vn -0.2022 0.9793 0.0000
vn -0.2022 -0.9793 0.0000
vn -0.4406 0.8977 0.0000
vn -0.4406 -0.8977 0.0000
vn 0.2022 -0.9793 0.0000
vn 0.4406 0.8977 0.0000
vn 0.1013 0.9949 0.0000
vn 0.4406 -0.8977 0.0000
vn 0.9652 -0.2615 0.0000
vn -0.6562 0.7546 0.0000
vn 0.6562 -0.7546 0.0000
vn -0.1013 0.9949 0.0000
vn -0.1013 -0.9949 0.0000
vn -0.9652 0.2615 0.0000
vn 0.6562 0.7546 0.0000
vn 0.1013 -0.9949 0.0000
vn -0.6562 -0.7546 0.0000
vn 0.0000 0.0000 1.0000
vn 0.9122 0.3165 0.2602
vn 0.9122 -0.3165 0.2602
vn -0.6996 0.6817 0.2140
vn -0.3525 -0.9197 0.1729
vn -0.1037 0.9872 0.1213
vn 0.0786 0.9884 0.1296
vn 0.3525 0.9197 0.1729
vn -0.9122 -0.3165 0.2602
vn -0.6575 -0.7169 0.2318
vn -0.9586 0.0000 0.2849
vn -0.9122 0.3165 0.2602
vn 0.5290 -0.8419 0.1063
vn 0.6575 0.7169 0.2318
vn -0.5290 0.8419 0.1063
vn 0.9586 0.0000 0.2849
vn -0.0786 -0.9884 0.1296
vn 0.1037 -0.9872 0.1213
vn 0.6996 -0.6817 0.2140
vn -0.9735 -0.1687 -0.1547
vn -0.9935 -0.1129 -0.0105
vn 0.9735 -0.1687 -0.1547
vn 0.0000 -0.2901 -0.9570
vn 0.0000 -0.9482 0.3176
vn 0.0000 0.9707 -0.2404
vn 0.9935 -0.1129 -0.0105
vn 0.3691 -0.9294 0.0000
vn 0.0000 -0.9519 0.3065
vn -0.3691 -0.9294 0.0000
vn 0.0000 0.2912 -0.9567
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.6832 0.7302
vn 0.0000 -0.4128 -0.9108
vn 0.0000 -0.9012 0.4335
vn 0.0000 0.7547 -0.6561
vn 0.9963 0.0000 -0.0864
vn 0.9648 0.2614 0.0281
vn -0.9963 0.0000 -0.0864
vn -0.9648 -0.2614 0.0281
vn 0.9032 0.3354 0.2679
vn 0.9032 -0.3354 0.2679
vn -0.6575 0.7169 0.2318
vn -0.5290 -0.8419 0.1063
vn -0.0786 0.9884 0.1296
vn 0.1037 0.9872 0.1213
vn 0.5290 0.8419 0.1063
vn -0.9032 -0.3354 0.2679
vn -0.6996 -0.6817 0.2140
vn -0.9032 0.3354 0.2679
vn 0.3525 -0.9197 0.1729
vn 0.6996 0.6817 0.2140
vn -0.3525 0.9197 0.1729
vn -0.1037 -0.9872 0.1213
vn 0.0786 -0.9884 0.1296
vn 0.6575 -0.7169 0.2318
vn -0.9884 -0.1123 -0.1026
vn -0.9952 -0.0979 -0.0013
vn 0.9884 -0.1123 -0.1026
vn 0.9952 -0.0979 -0.0013
usemtl Material
s off
f 95/1/1 4/2/1 3/3/1
f 5/4/1 3/3/1 4/2/1
f 6/5/2 1/6/2 3/7/2
f 8/8/3 2/9/3 1/10/3
f 105/11/4 4/12/4 2/13/4
f 33/14/2 10/15/2 8/16/2
f 8/8/5 9/17/5 7/18/5
f 11/19/6 6/20/6 5/4/6
f 34/21/7 11/22/7 5/23/7
f 35/24/8 30/25/8 12/26/8
f 11/27/9 29/28/9 15/29/9
f 30/25/10 14/30/10 9/17/10
f 28/31/11 16/32/11 13/33/11
f 32/34/12 9/35/12 14/36/12
f 37/37/13 28/31/13 15/38/13
f 23/39/14 39/40/14 17/41/14
f 32/34/15 22/42/15 9/35/15
f 13/43/16 16/44/16 31/45/16
f 12/46/17 10/47/17 27/48/17
f 31/45/18 19/49/18 13/43/18
f 27/48/19 10/47/19 20/50/19
f 13/43/2 19/49/2 33/51/2
f 23/39/20 33/51/20 19/49/20
f 10/15/2 33/14/2 20/52/2
f 20/50/21 33/51/21 25/53/21
f 25/53/22 33/51/22 17/41/22
f 17/41/23 33/51/23 23/39/23
f 29/28/24 11/27/24 21/54/24
f 11/55/25 34/56/25 21/57/25
f 9/35/25 22/42/25 34/58/25
f 22/42/26 24/59/26 34/58/26
f 21/54/27 34/58/27 26/60/27
f 26/60/28 34/58/28 18/61/28
f 18/61/29 34/58/29 24/59/29
f 17/41/30 47/62/30 25/53/30
f 24/59/31 40/63/31 18/61/31
f 16/44/32 53/64/32 31/45/32
f 29/28/33 37/65/33 15/29/33
f 18/61/34 48/66/34 26/60/34
f 27/48/35 35/67/35 12/46/35
f 31/45/36 41/68/36 19/49/36
f 14/36/37 54/69/37 32/34/37
f 52/70/38 14/30/38 30/25/38
f 25/53/39 42/71/39 20/50/39
f 26/60/40 43/72/40 21/54/40
f 20/50/41 49/73/41 27/48/41
f 32/34/42 44/74/42 22/42/42
f 50/75/43 16/32/43 28/31/43
f 19/49/44 45/76/44 23/39/44
f 21/54/45 51/77/45 29/28/45
f 22/42/46 46/78/46 24/59/46
f 43/79/47 71/80/47 51/81/47
f 44/82/47 74/83/47 64/84/47
f 51/81/47 57/85/47 37/86/47
f 55/87/47 52/88/47 35/89/47
f 45/90/47 61/91/47 65/92/47
f 52/88/47 56/93/47 36/94/47
f 53/95/47 58/96/47 73/97/47
f 46/98/47 64/84/47 66/99/47
f 45/90/47 59/100/47 39/101/47
f 54/102/47 56/103/47 74/83/47
f 49/104/47 55/105/47 35/106/47
f 57/107/47 50/108/47 37/109/47
f 47/110/47 59/100/47 67/111/47
f 46/98/47 60/112/47 40/113/47
f 48/114/47 60/112/47 68/115/47
f 41/116/47 73/97/47 61/91/47
f 42/117/47 69/118/47 49/104/47
f 47/110/47 62/119/47 42/117/47
f 50/108/47 58/120/47 38/121/47
f 48/114/47 63/122/47 43/79/47
f 68/115/47 59/100/47 65/92/47
f 67/111/47 60/112/47 66/99/47
f 57/123/48 88/124/48 70/125/48
f 88/124/49 58/126/49 70/125/49
f 63/127/50 86/128/50 81/129/50
f 69/130/51 75/131/51 55/132/51
f 71/133/52 81/134/52 89/135/52
f 74/136/53 82/137/53 64/138/53
f 71/133/54 77/139/54 57/140/54
f 55/141/55 90/142/55 72/143/55
f 61/144/56 83/145/56 65/146/56
f 65/147/57 86/128/57 68/148/57
f 90/142/58 56/149/58 72/143/58
f 73/150/59 78/151/59 91/152/59
f 64/153/60 84/154/60 66/155/60
f 74/136/61 76/156/61 92/157/61
f 66/155/62 85/158/62 67/159/62
f 73/150/63 79/160/63 61/144/63
f 69/130/64 80/161/64 87/162/64
f 62/163/65 85/164/65 80/161/65
f 78/165/47 88/166/47 83/167/47
f 90/168/47 75/169/47 85/170/47
f 99/171/66 96/172/66 95/1/66
f 96/173/25 2/13/25 4/12/25
f 93/174/2 3/7/2 1/6/2
f 94/175/3 1/10/3 2/9/3
f 103/176/67 100/177/67 99/171/67
f 100/178/25 94/179/25 96/173/25
f 97/180/2 95/181/2 93/174/2
f 94/175/68 97/182/68 93/183/68
f 103/184/69 102/185/69 104/186/69
f 104/187/70 98/188/70 100/178/70
f 101/189/71 99/190/71 97/180/71
f 98/191/72 101/192/72 97/182/72
f 111/193/47 108/194/47 107/195/47
f 108/196/73 2/13/73 7/197/73
f 107/198/74 7/197/74 5/199/74
f 106/200/75 5/199/75 4/12/75
f 113/201/76 110/202/76 109/203/76
f 109/203/77 106/204/77 105/205/77
f 108/206/78 109/207/78 105/208/78
f 110/209/79 107/210/79 106/211/79
f 120/212/78 113/213/78 116/214/78
f 116/214/78 109/207/78 112/215/78
f 110/209/79 115/216/79 111/217/79
f 115/218/80 112/219/80 111/193/80
f 120/220/81 118/221/81 117/222/81
f 114/223/79 119/224/79 115/216/79
f 119/225/82 116/226/82 115/227/82
f 117/228/83 114/229/83 113/230/83
f 95/1/1 96/172/1 4/2/1
f 5/4/1 6/20/1 3/3/1
f 6/5/2 8/16/2 1/6/2
f 8/8/3 7/18/3 2/9/3
f 105/11/4 106/200/4 4/12/4
f 8/16/2 6/5/2 33/14/2
f 6/5/2 13/231/2 33/14/2
f 8/8/78 10/232/78 9/17/78
f 11/19/79 13/33/79 6/20/79
f 5/23/7 7/233/7 34/21/7
f 7/233/7 9/234/7 34/21/7
f 35/24/8 52/70/8 30/25/8
f 9/17/84 10/232/84 30/25/84
f 10/232/85 12/26/85 30/25/85
f 13/33/86 11/19/86 28/31/86
f 11/19/87 15/38/87 28/31/87
f 37/37/13 50/75/13 28/31/13
f 23/39/14 45/76/14 39/40/14
f 17/41/30 39/40/30 47/62/30
f 24/59/31 46/78/31 40/63/31
f 16/44/32 38/235/32 53/64/32
f 29/28/33 51/77/33 37/65/33
f 18/61/34 40/63/34 48/66/34
f 27/48/35 49/73/35 35/67/35
f 31/45/36 53/64/36 41/68/36
f 14/36/37 36/236/37 54/69/37
f 52/70/38 36/237/38 14/30/38
f 25/53/39 47/62/39 42/71/39
f 26/60/40 48/66/40 43/72/40
f 20/50/41 42/71/41 49/73/41
f 32/34/42 54/69/42 44/74/42
f 50/75/43 38/238/43 16/32/43
f 19/49/44 41/68/44 45/76/44
f 21/54/45 43/72/45 51/77/45
f 22/42/46 44/74/46 46/78/46
f 43/79/47 63/122/47 71/80/47
f 44/82/47 54/102/47 74/83/47
f 51/81/47 71/80/47 57/85/47
f 55/87/47 72/239/47 52/88/47
f 45/90/47 41/116/47 61/91/47
f 52/88/47 72/239/47 56/93/47
f 53/95/47 38/240/47 58/96/47
f 46/98/47 44/82/47 64/84/47
f 45/90/47 65/92/47 59/100/47
f 54/102/47 36/241/47 56/103/47
f 49/104/47 69/118/47 55/105/47
f 57/107/47 70/242/47 50/108/47
f 47/110/47 39/101/47 59/100/47
f 46/98/47 66/99/47 60/112/47
f 48/114/47 40/113/47 60/112/47
f 41/116/47 53/95/47 73/97/47
f 42/117/47 62/119/47 69/118/47
f 47/110/47 67/111/47 62/119/47
f 50/108/47 70/242/47 58/120/47
f 48/114/47 68/115/47 63/122/47
f 68/115/47 60/112/47 59/100/47
f 67/111/47 59/100/47 60/112/47
f 57/123/88 77/243/88 88/124/88
f 88/124/89 78/244/89 58/126/89
f 63/127/90 68/148/90 86/128/90
f 69/130/91 87/162/91 75/131/91
f 71/133/92 63/245/92 81/134/92
f 74/136/93 92/157/93 82/137/93
f 71/133/94 89/135/94 77/139/94
f 55/141/95 75/246/95 90/142/95
f 61/144/96 79/160/96 83/145/96
f 65/147/57 83/247/57 86/128/57
f 90/142/97 76/248/97 56/149/97
f 73/150/98 58/249/98 78/151/98
f 64/153/99 82/250/99 84/154/99
f 74/136/100 56/251/100 76/156/100
f 66/155/62 84/154/62 85/158/62
f 73/150/101 91/152/101 79/160/101
f 69/130/102 62/163/102 80/161/102
f 62/163/103 67/252/103 85/164/103
f 88/166/47 77/253/47 86/254/47
f 77/253/47 89/255/47 81/256/47
f 86/254/47 77/253/47 81/256/47
f 86/254/47 83/167/47 88/166/47
f 83/167/47 79/257/47 78/165/47
f 79/257/47 91/258/47 78/165/47
f 75/169/47 87/259/47 80/260/47
f 80/260/47 85/170/47 75/169/47
f 85/170/47 84/261/47 90/168/47
f 84/261/47 82/262/47 76/263/47
f 82/262/47 92/264/47 76/263/47
f 76/263/47 90/168/47 84/261/47
f 99/171/104 100/177/104 96/172/104
f 96/173/25 94/179/25 2/13/25
f 93/174/2 95/181/2 3/7/2
f 94/175/3 93/183/3 1/10/3
f 103/176/105 104/265/105 100/177/105
f 100/178/25 98/188/25 94/179/25
f 97/180/2 99/190/2 95/181/2
f 94/175/106 98/191/106 97/182/106
f 103/184/69 101/266/69 102/185/69
f 104/187/70 102/267/70 98/188/70
f 101/189/71 103/268/71 99/190/71
f 98/191/107 102/269/107 101/192/107
f 111/193/47 112/219/47 108/194/47
f 108/196/73 105/11/73 2/13/73
f 107/198/74 108/196/74 7/197/74
f 106/200/75 107/198/75 5/199/75
f 113/201/76 114/270/76 110/202/76
f 109/203/77 110/202/77 106/204/77
f 108/206/78 112/215/78 109/207/78
f 110/209/79 111/217/79 107/210/79
f 120/212/78 117/271/78 113/213/78
f 116/214/78 113/213/78 109/207/78
f 110/209/79 114/223/79 115/216/79
f 115/218/80 116/272/80 112/219/80
f 120/220/81 119/273/81 118/221/81
f 114/223/79 118/274/79 119/224/79
f 119/225/82 120/275/82 116/226/82
f 117/228/83 118/276/83 114/229/83

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -13,7 +13,7 @@ public class Ak47 extends Gun {
0.95f,
0.1f,
1.2f,
40f,
0.4f,
30f,
true
);

View File

@ -13,7 +13,7 @@ public class Rifle extends Gun {
0.97f,
0.8f,
2.5f,
80f,
0.8f,
50f,
false
);

View File

@ -118,6 +118,30 @@ public class World {
return Collections.unmodifiableMap(spawnPoints);
}
public int getMinX() {
return chunkMap.values().stream().mapToInt(c -> c.getPosition().x * Chunk.SIZE).min().orElse(0);
}
public int getMinY() {
return chunkMap.values().stream().mapToInt(c -> c.getPosition().y * Chunk.SIZE).min().orElse(0);
}
public int getMinZ() {
return chunkMap.values().stream().mapToInt(c -> c.getPosition().z * Chunk.SIZE).min().orElse(0);
}
public int getMaxX() {
return chunkMap.values().stream().mapToInt(c -> c.getPosition().x * Chunk.SIZE + Chunk.SIZE - 1).max().orElse(0);
}
public int getMaxY() {
return chunkMap.values().stream().mapToInt(c -> c.getPosition().y * Chunk.SIZE + Chunk.SIZE - 1).max().orElse(0);
}
public int getMaxZ() {
return chunkMap.values().stream().mapToInt(c -> c.getPosition().z * Chunk.SIZE + Chunk.SIZE - 1).max().orElse(0);
}
/**
* Clears all data from the world.
*/

BIN
design/models/shotgun.blend Normal file

Binary file not shown.

Binary file not shown.

View File

@ -154,8 +154,9 @@ public class PlayerManager {
* determined to be killed somehow. We will reset their inventory, health,
* and respawn them.
* @param player The player that died.
* @param killedBy The player that killed them. Can be null.
*/
public void playerKilled(ServerPlayer player) {
public void playerKilled(ServerPlayer player, ServerPlayer killedBy) {
Vector3f deathPosition = new Vector3f(player.getPosition());
player.setPosition(getBestSpawnPoint(player));
player.setVelocity(new Vector3f(0));

View File

@ -1,5 +1,6 @@
package nl.andrewl.aos2_server;
import nl.andrewl.aos2_server.model.BlockHitTracker;
import nl.andrewl.aos2_server.model.ServerPlayer;
import nl.andrewl.aos2_server.model.ServerProjectile;
import nl.andrewl.aos_core.Directions;
@ -12,6 +13,7 @@ import nl.andrewl.aos_core.net.client.SoundMessage;
import nl.andrewl.aos_core.net.world.ChunkUpdateMessage;
import org.joml.Matrix4f;
import org.joml.Vector3f;
import org.joml.Vector3i;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
@ -27,11 +29,13 @@ public class ProjectileManager {
private int nextProjectileId = 1;
private final Map<Integer, ServerProjectile> projectiles;
private final Queue<ServerProjectile> removalQueue;
private final Map<Vector3i, BlockHitTracker> blockHitTrackers;
public ProjectileManager(Server server) {
this.server = server;
this.projectiles = new HashMap<>();
this.removalQueue = new LinkedList<>();
this.blockHitTrackers = new HashMap<>();
}
/**
@ -68,23 +72,25 @@ public class ProjectileManager {
.mul(200 * MOVEMENT_FACTOR)
.add(player.getVelocity());
ServerProjectile bullet = new ServerProjectile(id, new Vector3f(pos), vel, Projectile.Type.BULLET, player);
ServerProjectile bullet = new ServerProjectile(id, new Vector3f(pos), vel, Projectile.Type.BULLET, player, gun);
projectiles.put(bullet.getId(), bullet);
server.getPlayerManager().broadcastUdpMessage(bullet.toMessage(false));
}
}
public void tick(float dt) {
public void tick(long now, float dt) {
for (var projectile : projectiles.values()) {
tickProjectile(projectile, dt);
tickProjectile(projectile, now, dt);
}
while (!removalQueue.isEmpty()) {
ServerProjectile projectile = removalQueue.remove();
projectiles.remove(projectile.getId());
}
// Remove any block hit trackers for blocks whose cooldown period has passed.
blockHitTrackers.entrySet().removeIf(entry -> now - entry.getValue().getLastHitAt() > server.getConfig().actions.blockBulletDamageCooldown * 1000);
}
private void tickProjectile(ServerProjectile projectile, float dt) {
private void tickProjectile(ServerProjectile projectile, long now, float dt) {
projectile.getVelocity().y -= server.getConfig().physics.gravity * dt * MOVEMENT_FACTOR;
// Check for if the bullet will move close enough to a player to hit them.
@ -139,7 +145,7 @@ public class ProjectileManager {
// If we hit the world before the player,
if (hit != null && (playerHit == null || worldHitDist < playerHitDist)) {
// Bullet struck the world first.
handleProjectileBlockHit(hit, projectile);
handleProjectileBlockHit(hit, projectile, now);
} else if (playerHit != null && (hit == null || playerHitDist < worldHitDist)) {
// Bullet struck the player first.
handleProjectilePlayerHit(playerHitType, hitPlayer, projectile);
@ -154,25 +160,38 @@ public class ProjectileManager {
}
}
private void handleProjectileBlockHit(Hit hit, ServerProjectile projectile) {
private void handleProjectileBlockHit(Hit hit, ServerProjectile projectile, long now) {
if (!server.getTeamManager().isProtected(hit.pos())) {
Gun gun = (Gun) projectile.getSourceItem();
float damage = gun.getBaseDamage();
BlockHitTracker blockHitTracker = blockHitTrackers.computeIfAbsent(hit.pos(), p -> new BlockHitTracker(now, damage));
if (blockHitTracker.getDamageAccumulated() >= server.getConfig().actions.blockBulletDamageResistance) {
server.getWorld().setBlockAt(hit.pos().x, hit.pos().y, hit.pos().z, (byte) 0);
server.getPlayerManager().broadcastUdpMessage(ChunkUpdateMessage.fromWorld(hit.pos(), server.getWorld()));
blockHitTrackers.remove(hit.pos());
} else {
blockHitTracker.doHit(now, damage);
}
int soundVariant = ThreadLocalRandom.current().nextInt(1, 6);
server.getPlayerManager().broadcastUdpMessage(new SoundMessage("bullet_impact_" + soundVariant, 1, hit.rawPos()));
}
deleteProjectile(projectile);
}
private void handleProjectilePlayerHit(int playerHitType, ServerPlayer hitPlayer, ServerProjectile projectile) {
float damage = 0.4f;
if (!server.getTeamManager().isProtected(hitPlayer)) {
Gun gun = (Gun) projectile.getSourceItem();
float damage = gun.getBaseDamage();
if (playerHitType == 1) damage *= 2;
hitPlayer.setHealth(hitPlayer.getHealth() - damage);
int soundVariant = ThreadLocalRandom.current().nextInt(1, 4);
server.getPlayerManager().broadcastUdpMessage(new SoundMessage("hurt_" + soundVariant, 1, hitPlayer.getPosition(), hitPlayer.getVelocity()));
if (hitPlayer.getHealth() == 0) {
server.getPlayerManager().playerKilled(hitPlayer);
server.getPlayerManager().playerKilled(hitPlayer, projectile.getPlayer());
} else {
server.getPlayerManager().getHandler(hitPlayer).sendDatagramPacket(new ClientHealthMessage(hitPlayer.getHealth()));
}
}
deleteProjectile(projectile);
}

View File

@ -3,6 +3,7 @@ package nl.andrewl.aos2_server;
import nl.andrewl.aos2_server.model.ServerPlayer;
import nl.andrewl.aos_core.model.Team;
import org.joml.Vector3f;
import org.joml.Vector3i;
import java.util.Collection;
import java.util.Collections;
@ -46,4 +47,16 @@ public class TeamManager {
if (team == null) return Collections.emptyList();
return getPlayers(team);
}
public boolean isProtected(Vector3i pos) {
float prot = server.getConfig().actions.teamSpawnProtection;
return prot > 0 &&
getTeams().stream().anyMatch(t -> t.getSpawnPoint().distance(pos.x + 0.5f, pos.y + 0.5f, pos.z + 0.5f) <= prot);
}
public boolean isProtected(ServerPlayer player) {
float prot = server.getConfig().actions.teamSpawnProtection;
return prot > 0 &&
getTeams().stream().anyMatch(t -> t.equals(player.getTeam()) && player.getPosition().distance(t.getSpawnPoint()) <= prot);
}
}

View File

@ -22,8 +22,11 @@ public class ServerConfig {
public float blockPlaceCooldown = 0.1f;
public float blockBreakReach = 5;
public float blockPlaceReach = 5;
public float blockBulletDamageResistance = 3;
public float blockBulletDamageCooldown = 10;
public float resupplyCooldown = 30;
public float resupplyRadius = 3;
public float teamSpawnProtection = 10;
public float movementAccuracyDecreaseFactor = 0.01f;
public boolean friendlyFire = false;
}

View File

@ -11,10 +11,7 @@ import nl.andrewl.aos_core.model.item.gun.Ak47;
import nl.andrewl.aos_core.model.item.gun.Rifle;
import nl.andrewl.aos_core.model.item.gun.Winchester;
import nl.andrewl.aos_core.model.world.World;
import nl.andrewl.aos_core.net.client.ClientInputState;
import nl.andrewl.aos_core.net.client.InventorySelectedStackMessage;
import nl.andrewl.aos_core.net.client.ItemStackMessage;
import nl.andrewl.aos_core.net.client.SoundMessage;
import nl.andrewl.aos_core.net.client.*;
import nl.andrewl.aos_core.net.world.ChunkUpdateMessage;
import org.joml.Math;
import org.joml.Vector2i;
@ -23,6 +20,7 @@ import org.joml.Vector3i;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
import static nl.andrewl.aos2_server.model.ServerPlayer.RADIUS;
@ -100,7 +98,7 @@ public class PlayerActionManager {
updated = true;
}
tickMovement(dt, world, server.getConfig().physics);
tickMovement(dt, server, world, server.getConfig().physics);
}
private void tickGunAction(long now, Server server, World world, GunItemStack g) {
@ -110,7 +108,8 @@ public class PlayerActionManager {
g.getBulletCount() > 0 &&
!gunReloading &&
now - gunLastShotAt > gun.getShotCooldownTime() * 1000 &&
(gun.isAutomatic() || !gunNeedsReCock)
(gun.isAutomatic() || !gunNeedsReCock) &&
!server.getTeamManager().isProtected(player) // Don't allow players to shoot from within their own team's protected zones.
) {
server.getProjectileManager().spawnBullets(player, gun);
g.setBulletCount(g.getBulletCount() - 1);
@ -165,7 +164,7 @@ public class PlayerActionManager {
now - lastBlockRemovedAt > server.getConfig().actions.blockBreakCooldown * 1000
) {
var hit = world.getLookingAtPos(player.getEyePosition(), player.getViewVector(), server.getConfig().actions.blockBreakReach);
if (hit != null) {
if (hit != null && !server.getTeamManager().isProtected(hit.pos())) {
world.setBlockAt(hit.pos().x, hit.pos().y, hit.pos().z, (byte) 0);
lastBlockRemovedAt = now;
stack.incrementAmount();
@ -181,7 +180,7 @@ public class PlayerActionManager {
now - lastBlockPlacedAt > server.getConfig().actions.blockPlaceCooldown * 1000
) {
var hit = world.getLookingAtPos(player.getEyePosition(), player.getViewVector(), server.getConfig().actions.blockPlaceReach);
if (hit != null) {
if (hit != null && !server.getTeamManager().isProtected(hit.pos())) {
Vector3i placePos = new Vector3i(hit.pos());
placePos.add(hit.norm());
if (!isSpaceOccupied(placePos)) { // Ensure that we can't place blocks in space we're occupying.
@ -196,7 +195,7 @@ public class PlayerActionManager {
}
}
private void tickMovement(float dt, World world, ServerConfig.PhysicsConfig config) {
private void tickMovement(float dt, Server server, World world, ServerConfig.PhysicsConfig config) {
var velocity = player.getVelocity();
var position = player.getPosition();
boolean grounded = isGrounded(world);
@ -216,10 +215,19 @@ public class PlayerActionManager {
if (velocity.lengthSquared() > 0) {
Vector3f movement = new Vector3f(velocity).mul(dt);
// Check for collisions if we try to move according to what the player wants.
checkBlockCollisions(movement, world);
checkBlockCollisions(movement, server, world);
position.add(movement);
updated = true;
}
// Finally, check to see if the player is outside the world, and kill them if so.
if (
player.getPosition().x < world.getMinX() - 5 || player.getPosition().x > world.getMaxX() + 6 ||
player.getPosition().z < world.getMinZ() - 5 || player.getPosition().z > world.getMaxZ() + 6 ||
player.getPosition().y < world.getMinY() - 50 || player.getPosition().y > world.getMaxY() + 500
) {
server.getPlayerManager().playerKilled(player, null);
}
}
private void tickHorizontalVelocity(ServerConfig.PhysicsConfig config, boolean doDeceleration) {
@ -319,7 +327,7 @@ public class PlayerActionManager {
return pos.x >= minX && pos.x <= maxX && pos.y >= minY && pos.y <= maxY && pos.z >= minZ && pos.z <= maxZ;
}
private void checkBlockCollisions(Vector3f movement, World world) {
private void checkBlockCollisions(Vector3f movement, Server server, World world) {
var position = player.getPosition();
var velocity = player.getVelocity();
final Vector3f nextTickPosition = new Vector3f(position).add(movement);
@ -430,6 +438,19 @@ public class PlayerActionManager {
*/
boolean collidingWithFloor = playerBodyPrevMinY >= blockMaxY && playerBodyMinY < blockMaxY && world.getBlockAt(x, y + 1, z) <= 0;
if (collidingWithFloor) {
// This is a special case! We need to check for fall damage.
if (velocity.y < -20) {
float damage = velocity.y / 200f;
player.setHealth(player.getHealth() + damage);
if (player.getHealth() <= 0) {
server.getPlayerManager().playerKilled(player, player);
} else {
var handler = server.getPlayerManager().getHandler(player.getId());
handler.sendDatagramPacket(new ClientHealthMessage(player.getHealth()));
int soundVariant = ThreadLocalRandom.current().nextInt(1, 4);
handler.sendDatagramPacket(new SoundMessage("hurt_" + soundVariant, 1, player.getPosition()));
}
}
position.y = blockMaxY;
velocity.y = 0;
movement.y = 0;

View File

@ -60,6 +60,6 @@ public class WorldUpdater implements Runnable {
*/
private void tick(long currentTimeMillis) {
server.getPlayerManager().tick(currentTimeMillis, secondsPerTick);
server.getProjectileManager().tick(secondsPerTick);
server.getProjectileManager().tick(currentTimeMillis, secondsPerTick);
}
}

View File

@ -0,0 +1,29 @@
package nl.andrewl.aos2_server.model;
/**
* A simple component that's used to track an individual block's accumulated
* damage from consecutive bullet strikes. This is used to allow for blocks to
* take multiple hits before being destroyed.
*/
public class BlockHitTracker {
private long lastHitAt;
private float damageAccumulated;
public BlockHitTracker(long now, float initialDamage) {
this.lastHitAt = now;
damageAccumulated = initialDamage;
}
public void doHit(long now, float damage) {
lastHitAt = now;
damageAccumulated += damage;
}
public long getLastHitAt() {
return lastHitAt;
}
public float getDamageAccumulated() {
return damageAccumulated;
}
}

View File

@ -1,6 +1,8 @@
package nl.andrewl.aos2_server.model;
import nl.andrewl.aos_core.model.Projectile;
import nl.andrewl.aos_core.model.item.Gun;
import nl.andrewl.aos_core.model.item.Item;
import nl.andrewl.aos_core.net.client.ProjectileMessage;
import org.joml.Vector3f;
@ -11,12 +13,14 @@ import org.joml.Vector3f;
*/
public class ServerProjectile extends Projectile {
private final ServerPlayer player;
private final Item sourceItem;
private final Vector3f origin;
public ServerProjectile(int id, Vector3f position, Vector3f velocity, Type type, ServerPlayer player) {
public ServerProjectile(int id, Vector3f position, Vector3f velocity, Type type, ServerPlayer player, Item sourceItem) {
super(id, position, velocity, type);
this.player = player;
this.origin = new Vector3f(position);
this.sourceItem = sourceItem;
}
public ServerPlayer getPlayer() {
@ -39,4 +43,8 @@ public class ServerProjectile extends Projectile {
destroyed
);
}
public Item getSourceItem() {
return sourceItem;
}
}