Compare commits
226 commits
4c4b5d4a64
...
5465ec47c2
Author | SHA1 | Date | |
---|---|---|---|
5465ec47c2 | |||
64bcfd82f3 | |||
37b263ed35 | |||
|
0f32897ecc | ||
|
5f22d530e7 | ||
|
b4ea5bb23a | ||
|
d57bd9016a | ||
|
9edf8784df | ||
|
c39cb62469 | ||
|
8bbeff2e7a | ||
|
10f6d62642 | ||
|
49c99568c7 | ||
|
7cd07e224c | ||
|
e8aa39c70c | ||
|
8bf18bbfaf | ||
|
f75350fd2d | ||
|
6616a7286f | ||
|
747bf6a8c9 | ||
|
61f0d091a2 | ||
|
61aa246768 | ||
|
c4a77c088c | ||
|
f7f0992946 | ||
|
af9ef7182b | ||
|
9ad273d750 | ||
|
101ae62310 | ||
|
a3feab62a6 | ||
|
8749c82572 | ||
|
83b81b1b46 | ||
|
1a1847512b | ||
|
8c00ec72f4 | ||
|
20ba4312d8 | ||
|
f8d5549bbf | ||
|
136ea48433 | ||
|
12c2cc356d | ||
|
97957e5b59 | ||
|
302bb8f0ba | ||
|
726bb6f42e | ||
|
5a593b0634 | ||
|
8efe96de2c | ||
|
733d540645 | ||
|
b27b4d6da7 | ||
|
a34fe36a2b | ||
|
f797dcdbae | ||
|
c4eda2a41c | ||
|
45a81337ed | ||
|
c040b9c698 | ||
|
df6aedd336 | ||
|
b0c767dd47 | ||
|
dc7d7501c0 | ||
|
3eeb8795d3 | ||
|
cdc7971afd | ||
|
919fd1aa1c | ||
|
0b2823abe9 | ||
|
9d7353dd85 | ||
|
3411cb80be | ||
|
8e1cc4a8c9 | ||
|
bb94bd42bd | ||
|
72ca920a0c | ||
|
a94a8ffde8 | ||
|
2585b0aedf | ||
|
cb16663ea8 | ||
|
913899dd8d | ||
|
85ea6f3077 | ||
|
f163ce1e5a | ||
|
1e56aad393 | ||
|
d42138bb9d | ||
|
67a7acb39d | ||
|
b21a595095 | ||
|
0d175a9dbc | ||
|
4f3c41def4 | ||
|
63817a8aff | ||
|
4cc1131e52 | ||
|
a987aad5d7 | ||
|
8b635587a4 | ||
|
8029532678 | ||
|
a4a8c57b62 | ||
|
2edc769362 | ||
|
514c6ed288 | ||
|
ead5464212 | ||
|
aea798837b | ||
|
94a0e76973 | ||
|
889d0d67e7 | ||
|
4bc0dcc469 | ||
|
f1993adedf | ||
|
c536212aaf | ||
|
b12b263361 | ||
|
bb59072a6a | ||
|
7d3b7e6572 | ||
|
24b04c1176 | ||
|
8aa9a0d528 | ||
|
a26434880d | ||
|
ca2bdc884e | ||
|
6ff0e587d1 | ||
|
64f0c88898 | ||
|
949fe96bec | ||
|
d12ab212a6 | ||
|
c47a62591a | ||
|
902580798a | ||
|
e5eff31afc | ||
|
e4057e0bd7 | ||
|
a71a03d1f7 | ||
|
3ab3a583d1 | ||
|
2fc4a4a9ce | ||
|
29f810eb04 | ||
|
aa0e839c7c | ||
|
d9ed8195b1 | ||
|
ddf9bc1e2c | ||
|
343663db00 | ||
|
7effc4f889 | ||
|
9a66a45981 | ||
|
e115a06969 | ||
|
168178e96d | ||
|
c1794973c0 | ||
|
7add137f27 | ||
|
34c63b8c38 | ||
|
73333a079f | ||
|
987cf8779f | ||
|
23ce0d352d | ||
|
8d9bb92241 | ||
|
4ca89c305f | ||
|
970aa5ac86 | ||
|
e06d4abb3b | ||
|
04b3c4896b | ||
|
9568c9b1a6 | ||
|
fc1973f596 | ||
|
8aa49a988e | ||
|
73fbb55a68 | ||
|
6079faa766 | ||
|
97a03c50ee | ||
|
644056e2e9 | ||
|
cfed9e6511 | ||
|
41354c428a | ||
|
d3949f23ce | ||
|
7b8ee5f1cd | ||
|
9de5cb6676 | ||
|
f6f2de4f22 | ||
|
f5093b7af0 | ||
|
3866ee858d | ||
|
bfaad88cd0 | ||
|
95c78585a8 | ||
|
337db22580 | ||
|
9c5d9cdd6c | ||
|
1056bfc97b | ||
|
07950ecf6f | ||
|
15b20eb86f | ||
|
1742e1b706 | ||
|
c86dc2341a | ||
|
e757a298f6 | ||
|
2f0866e00b | ||
|
8c7169a01a | ||
|
f876137e17 | ||
|
926b43f32a | ||
|
da9d55a249 | ||
|
b936f29e97 | ||
|
44bb4340ba | ||
|
8b8bbc7f0d | ||
|
84857daf3a | ||
|
87064d0a71 | ||
|
bd14b981b1 | ||
|
e53137b47a | ||
|
f8b463848c | ||
|
86246f2cd9 | ||
|
5354d8e7de | ||
|
2e4fd79576 | ||
|
cba9ad73f8 | ||
|
b8bcac246d | ||
|
380dbf79b7 | ||
|
f2fc7943e1 | ||
|
cb43fade3e | ||
|
d6fcd7a101 | ||
|
813bd7eeb8 | ||
|
e825990c63 | ||
|
152e3777b1 | ||
|
ade2ce3628 | ||
|
80e600775b | ||
|
620e92e0a4 | ||
|
790c0a93bc | ||
|
e1fa30aee6 | ||
|
b805c4add5 | ||
|
8328816ae2 | ||
|
6258da944c | ||
|
f0642bb279 | ||
|
b8db249e5d | ||
|
8849199f6e | ||
|
6700db1869 | ||
|
d9df495dbd | ||
|
a1f4d689ec | ||
|
cc1f635ad1 | ||
|
c69536f32c | ||
|
bd1abe8fc6 | ||
|
2643a97445 | ||
|
2b466a0036 | ||
|
9c83e6d2a8 | ||
|
22fca7a1be | ||
|
ccb8dc7417 | ||
|
1f565e145a | ||
|
dc9f63bfbf | ||
|
7e0a8aab38 | ||
|
6c50715d9a | ||
|
b49f4c27d9 | ||
|
0c24e5f668 | ||
|
636e21a56b | ||
|
e8db3c22cd | ||
|
7460d3cad0 | ||
|
7b1a78560d | ||
|
f510ca7d5d | ||
|
07a11ba96f | ||
|
53f998d5ae | ||
|
bf5900d1e0 | ||
|
5fc159ee3f | ||
|
24fb5c99aa | ||
|
31fa3ff792 | ||
|
779b4a0db1 | ||
|
c03e27d317 | ||
|
67878578f7 | ||
|
014708a31e | ||
|
f60d19e112 | ||
|
58a88578ad | ||
|
81a91f0a84 | ||
|
dc59ff7af5 | ||
|
f2224c1d80 | ||
|
bb797c018a | ||
|
7697968b29 | ||
|
98d9c9e078 | ||
|
6475034b52 | ||
|
f852530a40 |
455 changed files with 103956 additions and 8351 deletions
|
@ -162,6 +162,13 @@ dependencies {
|
|||
runtimeOnly "mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}"
|
||||
implementation "curse.maven:jade-324717:6291517"
|
||||
|
||||
// FTB Chunks integration
|
||||
runtimeOnly("curse.maven:ftb-chunks-forge-314906:${ftbchunks_version}")
|
||||
runtimeOnly("curse.maven:architectury-api-419699:5786327")
|
||||
runtimeOnly("curse.maven:ftb-library-forge-404465:6711324")
|
||||
runtimeOnly("curse.maven:ftb-ranks-forge-314905:6431744")
|
||||
runtimeOnly("curse.maven:ftb-teams-forge-404468:6119437")
|
||||
|
||||
// 帕秋莉手册
|
||||
compileOnly "curse.maven:patchouli-306770:6164617"
|
||||
runtimeOnly "curse.maven:patchouli-306770:6164617"
|
||||
|
|
|
@ -16,9 +16,10 @@ mod_id=superbwarfare
|
|||
mod_name=Superb Warfare
|
||||
mod_license=GNU General Public License v3.0
|
||||
mod_description=A Warfare Mod
|
||||
mod_version=0.8.4
|
||||
mod_version=0.8.5
|
||||
mod_authors=Atsuishio, Roki27, Light_Quanta
|
||||
# dependencies
|
||||
jei_version=19.21.0.247
|
||||
cloth_config_version=11.1.106
|
||||
jade_version=4681833
|
||||
jade_version=4681833
|
||||
ftbchunks_version=5448646
|
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"variants": {
|
||||
"facing=east,opened=false": {
|
||||
"model": "superbwarfare:block/container",
|
||||
"y": 90
|
||||
},
|
||||
"facing=east,opened=true": {
|
||||
"model": "superbwarfare:block/container",
|
||||
"y": 90
|
||||
},
|
||||
"facing=north,opened=false": {
|
||||
"model": "superbwarfare:block/container"
|
||||
},
|
||||
"facing=north,opened=true": {
|
||||
"model": "superbwarfare:block/container"
|
||||
},
|
||||
"facing=south,opened=false": {
|
||||
"model": "superbwarfare:block/container",
|
||||
"y": 180
|
||||
},
|
||||
"facing=south,opened=true": {
|
||||
"model": "superbwarfare:block/container",
|
||||
"y": 180
|
||||
},
|
||||
"facing=west,opened=false": {
|
||||
"model": "superbwarfare:block/container",
|
||||
"y": 270
|
||||
},
|
||||
"facing=west,opened=true": {
|
||||
"model": "superbwarfare:block/container",
|
||||
"y": 270
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "superbwarfare:item/rocket_70"
|
||||
"layer0": "superbwarfare:item/cm_head"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "superbwarfare:item/medium_rocket_ap"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "superbwarfare:item/medium_rocket_cm"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "superbwarfare:item/medium_rocket_he"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"base": {
|
||||
"parent": "superbwarfare:item/qbz_191_base"
|
||||
},
|
||||
"gui_light": "front",
|
||||
"loader": "neoforge:separate_transforms",
|
||||
"perspectives": {
|
||||
"gui": {
|
||||
"parent": "superbwarfare:item/qbz_191_icon"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "superbwarfare:displaysettings/qbz_191.item",
|
||||
"textures": {
|
||||
"layer0": "superbwarfare:item/qbz_191"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "superbwarfare:item/gun_blueprint"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "superbwarfare:item/qbz_191_icon"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "superbwarfare:item/small_rocket"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"values": [
|
||||
"superbwarfare:crowbar"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"type": "superbwarfare:smoke_dye",
|
||||
"category": "misc"
|
||||
}
|
|
@ -20,6 +20,7 @@
|
|||
"superbwarfare:small_container",
|
||||
"superbwarfare:vehicle_deployer",
|
||||
"superbwarfare:aircraft_catapult",
|
||||
"superbwarfare:superb_item_interface"
|
||||
"superbwarfare:superb_item_interface",
|
||||
"superbwarfare:lucky_container"
|
||||
]
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
"parent": "minecraft:recipes/root",
|
||||
"criteria": {
|
||||
"has_annihilator_blueprint": {
|
||||
"has_qbz_191_blueprint": {
|
||||
"conditions": {
|
||||
"items": [
|
||||
{
|
||||
"items": "superbwarfare:annihilator_blueprint"
|
||||
"items": "superbwarfare:qbz_191_blueprint"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -13,7 +13,7 @@
|
|||
},
|
||||
"has_the_recipe": {
|
||||
"conditions": {
|
||||
"recipe": "superbwarfare:annihilator_blueprint"
|
||||
"recipe": "superbwarfare:qbz_191_smithing"
|
||||
},
|
||||
"trigger": "minecraft:recipe_unlocked"
|
||||
}
|
||||
|
@ -21,12 +21,12 @@
|
|||
"requirements": [
|
||||
[
|
||||
"has_the_recipe",
|
||||
"has_annihilator_blueprint"
|
||||
"has_qbz_191_blueprint"
|
||||
]
|
||||
],
|
||||
"rewards": {
|
||||
"recipes": [
|
||||
"superbwarfare:annihilator_blueprint"
|
||||
"superbwarfare:qbz_191_smithing"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"parent": "minecraft:recipes/root",
|
||||
"criteria": {
|
||||
"has_fusee": {
|
||||
"conditions": {
|
||||
"items": [
|
||||
{
|
||||
"items": "superbwarfare:fusee"
|
||||
}
|
||||
]
|
||||
},
|
||||
"trigger": "minecraft:inventory_changed"
|
||||
},
|
||||
"has_the_recipe": {
|
||||
"conditions": {
|
||||
"recipe": "superbwarfare:rocket"
|
||||
},
|
||||
"trigger": "minecraft:recipe_unlocked"
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[
|
||||
"has_the_recipe",
|
||||
"has_fusee"
|
||||
]
|
||||
],
|
||||
"rewards": {
|
||||
"recipes": [
|
||||
"superbwarfare:rocket"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"parent": "minecraft:recipes/root",
|
||||
"criteria": {
|
||||
"has_fusee": {
|
||||
"conditions": {
|
||||
"items": [
|
||||
{
|
||||
"items": "superbwarfare:fusee"
|
||||
}
|
||||
]
|
||||
},
|
||||
"trigger": "minecraft:inventory_changed"
|
||||
},
|
||||
"has_the_recipe": {
|
||||
"conditions": {
|
||||
"recipe": "superbwarfare:small_rocket"
|
||||
},
|
||||
"trigger": "minecraft:recipe_unlocked"
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[
|
||||
"has_the_recipe",
|
||||
"has_fusee"
|
||||
]
|
||||
],
|
||||
"rewards": {
|
||||
"recipes": [
|
||||
"superbwarfare:small_rocket"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"parent": "minecraft:recipes/root",
|
||||
"criteria": {
|
||||
"has_spyglass": {
|
||||
"conditions": {
|
||||
"items": [
|
||||
{
|
||||
"items": "minecraft:spyglass"
|
||||
}
|
||||
]
|
||||
},
|
||||
"trigger": "minecraft:inventory_changed"
|
||||
},
|
||||
"has_the_recipe": {
|
||||
"conditions": {
|
||||
"recipe": "superbwarfare:artillery_indicator"
|
||||
},
|
||||
"trigger": "minecraft:recipe_unlocked"
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[
|
||||
"has_the_recipe",
|
||||
"has_spyglass"
|
||||
]
|
||||
],
|
||||
"rewards": {
|
||||
"recipes": [
|
||||
"superbwarfare:artillery_indicator"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"parent": "minecraft:recipes/root",
|
||||
"criteria": {
|
||||
"has_artillery_indicator": {
|
||||
"conditions": {
|
||||
"items": [
|
||||
{
|
||||
"items": "superbwarfare:artillery_indicator"
|
||||
}
|
||||
]
|
||||
},
|
||||
"trigger": "minecraft:inventory_changed"
|
||||
},
|
||||
"has_the_recipe": {
|
||||
"conditions": {
|
||||
"recipe": "superbwarfare:artillery_indicator_clear"
|
||||
},
|
||||
"trigger": "minecraft:recipe_unlocked"
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[
|
||||
"has_the_recipe",
|
||||
"has_artillery_indicator"
|
||||
]
|
||||
],
|
||||
"rewards": {
|
||||
"recipes": [
|
||||
"superbwarfare:artillery_indicator_clear"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"parent": "minecraft:recipes/root",
|
||||
"criteria": {
|
||||
"has_qbz_191_blueprint": {
|
||||
"conditions": {
|
||||
"items": [
|
||||
{
|
||||
"items": "superbwarfare:qbz_191_blueprint"
|
||||
}
|
||||
]
|
||||
},
|
||||
"trigger": "minecraft:inventory_changed"
|
||||
},
|
||||
"has_the_recipe": {
|
||||
"conditions": {
|
||||
"recipe": "superbwarfare:qbz_191_blueprint"
|
||||
},
|
||||
"trigger": "minecraft:recipe_unlocked"
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[
|
||||
"has_the_recipe",
|
||||
"has_qbz_191_blueprint"
|
||||
]
|
||||
],
|
||||
"rewards": {
|
||||
"recipes": [
|
||||
"superbwarfare:qbz_191_blueprint"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"bonus_rolls": 0.0,
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:survives_explosion"
|
||||
}
|
||||
],
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "superbwarfare:lucky_container"
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:copy_components",
|
||||
"include": [
|
||||
"minecraft:block_entity_data"
|
||||
],
|
||||
"source": "block_entity"
|
||||
}
|
||||
],
|
||||
"rolls": 1.0
|
||||
}
|
||||
],
|
||||
"random_sequence": "superbwarfare:blocks/lucky_container"
|
||||
}
|
|
@ -147,6 +147,10 @@
|
|||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "superbwarfare:insidious_blueprint"
|
||||
},
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "superbwarfare:qbz_191_blueprint"
|
||||
}
|
||||
],
|
||||
"rolls": 1.0
|
||||
|
|
|
@ -59,6 +59,11 @@
|
|||
"name": "superbwarfare:insidious_blueprint",
|
||||
"weight": 10
|
||||
},
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "superbwarfare:qbz_191_blueprint",
|
||||
"weight": 10
|
||||
},
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "superbwarfare:aa_12_blueprint",
|
||||
|
@ -103,11 +108,6 @@
|
|||
"type": "minecraft:item",
|
||||
"name": "superbwarfare:hpj_11_blueprint",
|
||||
"weight": 5
|
||||
},
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "superbwarfare:annihilator_blueprint",
|
||||
"weight": 5
|
||||
}
|
||||
],
|
||||
"rolls": 1.0
|
||||
|
|
|
@ -154,6 +154,11 @@
|
|||
"name": "superbwarfare:insidious_blueprint",
|
||||
"weight": 10
|
||||
},
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "superbwarfare:qbz_191_blueprint",
|
||||
"weight": 10
|
||||
},
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "superbwarfare:aa_12_blueprint",
|
||||
|
@ -198,10 +203,6 @@
|
|||
"type": "minecraft:item",
|
||||
"name": "superbwarfare:hpj_11_blueprint",
|
||||
"weight": 2
|
||||
},
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "superbwarfare:annihilator_blueprint"
|
||||
}
|
||||
],
|
||||
"rolls": 1.0
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"category": "misc",
|
||||
"key": {
|
||||
"a": {
|
||||
"item": "minecraft:spyglass"
|
||||
},
|
||||
"b": {
|
||||
"item": "superbwarfare:monitor"
|
||||
},
|
||||
"c": {
|
||||
"item": "superbwarfare:firing_parameters"
|
||||
}
|
||||
},
|
||||
"pattern": [
|
||||
" b ",
|
||||
"aca"
|
||||
],
|
||||
"result": {
|
||||
"count": 1,
|
||||
"id": "superbwarfare:artillery_indicator"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"category": "misc",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "superbwarfare:artillery_indicator"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"count": 1,
|
||||
"id": "superbwarfare:artillery_indicator"
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@
|
|||
"item": "minecraft:lapis_lazuli"
|
||||
},
|
||||
"S": {
|
||||
"item": "superbwarfare:annihilator_blueprint"
|
||||
"item": "superbwarfare:qbz_191_blueprint"
|
||||
}
|
||||
},
|
||||
"pattern": [
|
||||
|
@ -19,6 +19,6 @@
|
|||
],
|
||||
"result": {
|
||||
"count": 2,
|
||||
"id": "superbwarfare:annihilator_blueprint"
|
||||
"id": "superbwarfare:qbz_191_blueprint"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"type": "minecraft:smithing_transform",
|
||||
"addition": {
|
||||
"tag": "superbwarfare:ingots/cemented_carbide"
|
||||
},
|
||||
"base": {
|
||||
"item": "superbwarfare:epic_material_pack"
|
||||
},
|
||||
"result": {
|
||||
"count": 1,
|
||||
"id": "superbwarfare:qbz_191"
|
||||
},
|
||||
"template": {
|
||||
"item": "superbwarfare:qbz_191_blueprint"
|
||||
}
|
||||
}
|
|
@ -1,11 +1,6 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"category": "equipment",
|
||||
"pattern": [
|
||||
" a ",
|
||||
"bcb",
|
||||
" d "
|
||||
],
|
||||
"key": {
|
||||
"a": {
|
||||
"item": "superbwarfare:fusee"
|
||||
|
@ -20,8 +15,13 @@
|
|||
"item": "superbwarfare:grain"
|
||||
}
|
||||
},
|
||||
"pattern": [
|
||||
" a ",
|
||||
"bcb",
|
||||
" d "
|
||||
],
|
||||
"result": {
|
||||
"id": "superbwarfare:rocket",
|
||||
"count": 2
|
||||
"count": 2,
|
||||
"id": "superbwarfare:rocket"
|
||||
}
|
||||
}
|
|
@ -1,11 +1,6 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"category": "equipment",
|
||||
"pattern": [
|
||||
" a ",
|
||||
"bcb",
|
||||
" d "
|
||||
],
|
||||
"key": {
|
||||
"a": {
|
||||
"item": "superbwarfare:fusee"
|
||||
|
@ -20,8 +15,13 @@
|
|||
"item": "superbwarfare:grain"
|
||||
}
|
||||
},
|
||||
"pattern": [
|
||||
" a ",
|
||||
"bcb",
|
||||
" d "
|
||||
],
|
||||
"result": {
|
||||
"id": "superbwarfare:rocket_70",
|
||||
"count": 4
|
||||
"count": 4,
|
||||
"id": "superbwarfare:small_rocket"
|
||||
}
|
||||
}
|
|
@ -15,6 +15,7 @@
|
|||
"superbwarfare:m_4",
|
||||
"superbwarfare:hk_416",
|
||||
"superbwarfare:qbz_95",
|
||||
"superbwarfare:qbz_191",
|
||||
"superbwarfare:insidious",
|
||||
"superbwarfare:mk_14",
|
||||
"superbwarfare:marlin",
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
"superbwarfare:taser",
|
||||
"superbwarfare:minigun",
|
||||
"superbwarfare:mp_5",
|
||||
"superbwarfare:m_2_hb"
|
||||
"superbwarfare:m_2_hb",
|
||||
"superbwarfare:qbz_191"
|
||||
]
|
||||
}
|
|
@ -62,7 +62,7 @@ public class Mod {
|
|||
ModEntities.REGISTRY.register(bus);
|
||||
ModMobEffects.REGISTRY.register(bus);
|
||||
ModParticleTypes.REGISTRY.register(bus);
|
||||
ModPotion.POTIONS.register(bus);
|
||||
ModPotions.POTIONS.register(bus);
|
||||
ModMenuTypes.REGISTRY.register(bus);
|
||||
ModVillagers.register(bus);
|
||||
ModRecipes.RECIPE_SERIALIZERS.register(bus);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.atsuishio.superbwarfare.api.event;
|
||||
|
||||
import com.atsuishio.superbwarfare.item.ContainerBlockItem;
|
||||
import com.atsuishio.superbwarfare.item.common.container.ContainerBlockItem;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
|
|
@ -2,8 +2,8 @@ package com.atsuishio.superbwarfare.block;
|
|||
|
||||
import com.atsuishio.superbwarfare.block.entity.ContainerBlockEntity;
|
||||
import com.atsuishio.superbwarfare.init.ModBlockEntities;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -64,7 +64,7 @@ public class ContainerBlock extends BaseEntityBlock {
|
|||
|| !(level.getBlockEntity(pos) instanceof ContainerBlockEntity containerBlockEntity)
|
||||
) return ItemInteractionResult.FAIL;
|
||||
|
||||
if (!stack.is(ModItems.CROWBAR.get())) {
|
||||
if (!stack.is(ModTags.Items.CROWBAR)) {
|
||||
player.displayClientMessage(Component.translatable("des.superbwarfare.container.fail.crowbar"), true);
|
||||
return ItemInteractionResult.FAIL;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,143 @@
|
|||
package com.atsuishio.superbwarfare.block;
|
||||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.block.entity.LuckyContainerBlockEntity;
|
||||
import com.atsuishio.superbwarfare.init.ModBlockEntities;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.ItemInteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class LuckyContainerBlock extends BaseEntityBlock {
|
||||
|
||||
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
|
||||
public static final BooleanProperty OPENED = BooleanProperty.create("opened");
|
||||
|
||||
public LuckyContainerBlock() {
|
||||
this(BlockBehaviour.Properties.of().sound(SoundType.METAL).strength(3.0f).noOcclusion().requiresCorrectToolForDrops());
|
||||
}
|
||||
|
||||
public LuckyContainerBlock(BlockBehaviour.Properties properties) {
|
||||
super(properties);
|
||||
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(OPENED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
protected @NotNull ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) {
|
||||
if (level.isClientSide
|
||||
|| state.getValue(OPENED)
|
||||
|| !(level.getBlockEntity(pos) instanceof LuckyContainerBlockEntity)
|
||||
) return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||
|
||||
if (!stack.is(ModTags.Items.CROWBAR)) {
|
||||
player.displayClientMessage(Component.translatable("des.superbwarfare.container.fail.crowbar"), true);
|
||||
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||
}
|
||||
|
||||
level.setBlockAndUpdate(pos, state.setValue(OPENED, true));
|
||||
level.playSound(null, BlockPos.containing(pos.getX(), pos.getY(), pos.getZ()), ModSounds.OPEN.get(), SoundSource.BLOCKS, 1, 1);
|
||||
|
||||
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level pLevel, @NotNull BlockState pState, @NotNull BlockEntityType<T> pBlockEntityType) {
|
||||
if (!pLevel.isClientSide) {
|
||||
return createTickerHelper(pBlockEntityType, ModBlockEntities.LUCKY_CONTAINER.get(), LuckyContainerBlockEntity::serverTick);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
public void appendHoverText(ItemStack stack, Item.TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
|
||||
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);
|
||||
var component = stack.get(DataComponents.BLOCK_ENTITY_DATA);
|
||||
CompoundTag tag = component == null ? new CompoundTag() : component.copyTag();
|
||||
|
||||
String location = tag.getString("Location");
|
||||
if (location.startsWith(Mod.MODID)) {
|
||||
var split = location.split(Mod.MODID + ":");
|
||||
if (split.length == 2) {
|
||||
location = "location." + split[1];
|
||||
}
|
||||
tooltipComponents.add(Component.translatable("des.superbwarfare.lucky_container." + location).withStyle(ChatFormatting.GRAY));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
public @NotNull VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
|
||||
return state.getValue(OPENED) ? box(1, 0, 1, 15, 14, 15) : box(0, 0, 0, 16, 15, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NotNull MapCodec<? extends BaseEntityBlock> codec() {
|
||||
return simpleCodec(LuckyContainerBlock::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull RenderShape getRenderShape(@NotNull BlockState state) {
|
||||
return RenderShape.ENTITYBLOCK_ANIMATED;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(@NotNull BlockPos blockPos, @NotNull BlockState blockState) {
|
||||
return new LuckyContainerBlockEntity(blockPos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
builder.add(FACING).add(OPENED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite()).setValue(OPENED, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
public @NotNull ItemStack getCloneItemStack(LevelReader level, BlockPos pos, BlockState state) {
|
||||
ItemStack itemstack = super.getCloneItemStack(level, pos, state);
|
||||
level.getBlockEntity(pos, ModBlockEntities.LUCKY_CONTAINER.get()).ifPresent((blockEntity) -> blockEntity.saveToItem(itemstack, level.registryAccess()));
|
||||
return itemstack;
|
||||
}
|
||||
}
|
|
@ -3,8 +3,8 @@ package com.atsuishio.superbwarfare.block;
|
|||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.block.entity.SmallContainerBlockEntity;
|
||||
import com.atsuishio.superbwarfare.init.ModBlockEntities;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -62,7 +62,7 @@ public class SmallContainerBlock extends BaseEntityBlock {
|
|||
}
|
||||
|
||||
ItemStack stack = player.getItemInHand(player.getUsedItemHand());
|
||||
if (!stack.is(ModItems.CROWBAR.get())) {
|
||||
if (!stack.is(ModTags.Items.CROWBAR)) {
|
||||
player.displayClientMessage(Component.translatable("des.superbwarfare.container.fail.crowbar"), true);
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
|
|
@ -2,13 +2,16 @@ package com.atsuishio.superbwarfare.block;
|
|||
|
||||
import com.atsuishio.superbwarfare.block.entity.SuperbItemInterfaceBlockEntity;
|
||||
import com.atsuishio.superbwarfare.init.ModBlockEntities;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.Containers;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.ItemInteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
@ -75,6 +78,20 @@ public class SuperbItemInterfaceBlock extends BaseEntityBlock {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
protected @NotNull ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) {
|
||||
if (stack.is(ModTags.Items.CROWBAR) || stack.is(ModTags.Items.WRENCHES) || stack.is(ModTags.Items.WRENCH)) {
|
||||
var facing = hitResult.getDirection();
|
||||
if (state.getValue(FACING) == facing) {
|
||||
facing = facing.getOpposite();
|
||||
}
|
||||
level.setBlockAndUpdate(pos, state.setValue(FACING, facing));
|
||||
return ItemInteractionResult.SUCCESS;
|
||||
}
|
||||
return super.useItemOn(stack, state, level, pos, player, hand, hitResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
protected @NotNull InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) {
|
||||
|
|
|
@ -0,0 +1,167 @@
|
|||
package com.atsuishio.superbwarfare.block.entity;
|
||||
|
||||
import com.atsuishio.superbwarfare.block.LuckyContainerBlock;
|
||||
import com.atsuishio.superbwarfare.data.container.ContainerDataManager;
|
||||
import com.atsuishio.superbwarfare.init.ModBlockEntities;
|
||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||
import it.unimi.dsi.fastutil.Pair;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joml.Math;
|
||||
import software.bernie.geckolib.animatable.GeoBlockEntity;
|
||||
import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
|
||||
import software.bernie.geckolib.animation.*;
|
||||
import software.bernie.geckolib.util.GeckoLibUtil;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
public class LuckyContainerBlockEntity extends BlockEntity implements GeoBlockEntity {
|
||||
|
||||
@Nullable
|
||||
public ResourceLocation location;
|
||||
@Nullable
|
||||
public ResourceLocation icon;
|
||||
public int tick = 0;
|
||||
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
|
||||
public LuckyContainerBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(ModBlockEntities.LUCKY_CONTAINER.get(), pos, state);
|
||||
}
|
||||
|
||||
public static void serverTick(Level pLevel, BlockPos pPos, BlockState pState, LuckyContainerBlockEntity blockEntity) {
|
||||
if (!pState.getValue(LuckyContainerBlock.OPENED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (blockEntity.tick < 20) {
|
||||
blockEntity.tick++;
|
||||
blockEntity.setChanged();
|
||||
|
||||
if (blockEntity.tick == 18) {
|
||||
ParticleTool.sendParticle((ServerLevel) pLevel, ParticleTypes.EXPLOSION, pPos.getX(), pPos.getY() + 1, pPos.getZ(), 40, 1.5, 1.5, 1.5, 1, false);
|
||||
pLevel.playSound(null, pPos, SoundEvents.GENERIC_EXPLODE.value(), SoundSource.BLOCKS, 4.0F, (1.0F + (pLevel.random.nextFloat() - pLevel.random.nextFloat()) * 0.2F) * 0.7F);
|
||||
}
|
||||
} else {
|
||||
var direction = pState.getValue(LuckyContainerBlock.FACING);
|
||||
var type = blockEntity.unpackEntities();
|
||||
|
||||
if (type != null) {
|
||||
var entity = type.create(pLevel);
|
||||
if (entity != null) {
|
||||
entity.setPos(pPos.getX() + 0.5 + (2 * Math.random() - 1) * 0.1f, pPos.getY() + 0.5 + (2 * Math.random() - 1) * 0.1f, pPos.getZ() + 0.5 + (2 * Math.random() - 1) * 0.1f);
|
||||
entity.setYRot(direction.toYRot());
|
||||
pLevel.addFreshEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
pLevel.setBlockAndUpdate(pPos, Blocks.AIR.defaultBlockState());
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EntityType<?> unpackEntities() {
|
||||
if (this.location != null && this.level != null && this.level.getServer() != null) {
|
||||
ContainerDataManager dataManager = ContainerDataManager.INSTANCE;
|
||||
var list = dataManager.getEntityTypes(this.location);
|
||||
if (list.isPresent()) {
|
||||
var pool = list.get();
|
||||
int sum = pool.stream().mapToInt(Pair::second).sum();
|
||||
if (sum <= 0) return null;
|
||||
|
||||
int rand = this.level.random.nextInt(sum);
|
||||
|
||||
int cumulativeWeight = 0;
|
||||
for (var entry : pool) {
|
||||
cumulativeWeight += entry.second();
|
||||
if (rand < cumulativeWeight) {
|
||||
return EntityType.byString(entry.first()).orElse(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private PlayState predicate(AnimationState<LuckyContainerBlockEntity> event) {
|
||||
if (this.getBlockState().getValue(LuckyContainerBlock.OPENED)) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.container.open"));
|
||||
}
|
||||
return PlayState.STOP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
|
||||
data.add(new AnimationController<>(this, "controller", 0, this::predicate));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnimatableInstanceCache getAnimatableInstanceCache() {
|
||||
return this.cache;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||
super.loadAdditional(tag, registries);
|
||||
if (tag.contains("Location", 8)) {
|
||||
this.location = ResourceLocation.parse(tag.getString("Location"));
|
||||
}
|
||||
if (tag.contains("Icon", 8)) {
|
||||
this.icon = ResourceLocation.parse(tag.getString("Icon"));
|
||||
}
|
||||
this.tick = tag.getInt("Tick");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||
super.saveAdditional(tag, registries);
|
||||
if (this.location != null) {
|
||||
tag.putString("Location", this.location.toString());
|
||||
}
|
||||
if (this.icon != null) {
|
||||
tag.putString("Icon", this.icon.toString());
|
||||
}
|
||||
tag.putInt("Tick", this.tick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientboundBlockEntityDataPacket getUpdatePacket() {
|
||||
return ClientboundBlockEntityDataPacket.create(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull CompoundTag getUpdateTag(HolderLookup.@NotNull Provider registries) {
|
||||
return this.saveWithFullMetadata(registries);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
public void saveToItem(ItemStack stack, HolderLookup.Provider registries) {
|
||||
CompoundTag tag = new CompoundTag();
|
||||
if (this.location != null) {
|
||||
tag.putString("Location", this.location.toString());
|
||||
}
|
||||
if (this.icon != null) {
|
||||
tag.putString("Icon", this.icon.toString());
|
||||
}
|
||||
BlockItem.setBlockEntityData(stack, this.getType(), tag);
|
||||
}
|
||||
}
|
|
@ -77,7 +77,18 @@ public class SuperbItemInterfaceBlockEntity extends BaseContainerBlockEntity {
|
|||
for (int i = 0; i < itemHandler.getSlots(); i++) {
|
||||
if (stack.isEmpty()) break;
|
||||
|
||||
stack = itemHandler.insertItem(i, stack, false);
|
||||
int inserted;
|
||||
for (inserted = stack.getCount(); inserted > 0; inserted--) {
|
||||
var insertedStack = itemHandler.insertItem(i, stack.copyWithCount(inserted), true);
|
||||
if (insertedStack.getCount() != inserted || !ItemStack.isSameItemSameComponents(insertedStack, stack)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (inserted > 0) {
|
||||
itemHandler.insertItem(i, stack.copyWithCount(inserted), false);
|
||||
stack.shrink(inserted);
|
||||
}
|
||||
}
|
||||
|
||||
blockEntity.items.set(index, stack);
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.atsuishio.superbwarfare.compat.clothconfig.ClothConfigHelper;
|
|||
import com.atsuishio.superbwarfare.config.client.ReloadConfig;
|
||||
import com.atsuishio.superbwarfare.data.gun.FireMode;
|
||||
import com.atsuishio.superbwarfare.data.gun.GunData;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.DroneEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.MortarEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.ArmedVehicleEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.CannonEntity;
|
||||
|
@ -13,24 +14,30 @@ import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity;
|
|||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.event.ClientMouseHandler;
|
||||
import com.atsuishio.superbwarfare.init.*;
|
||||
import com.atsuishio.superbwarfare.item.ItemScreenProvider;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.network.message.send.*;
|
||||
import com.atsuishio.superbwarfare.tools.EntityFindUtil;
|
||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
||||
import com.atsuishio.superbwarfare.tools.SeekTool;
|
||||
import com.atsuishio.superbwarfare.tools.TraceTool;
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.ClipContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
|
@ -82,12 +89,23 @@ public class ClickHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean cancelFireKey(Player player, ItemStack stack) {
|
||||
return stack.getItem() instanceof GunItem || stack.is(ModItems.MONITOR.get()) || stack.is(ModItems.LUNGE_MINE.get()) || stack.is(ModItems.ARTILLERY_INDICATOR.get()) || player.hasEffect(ModMobEffects.SHOCK)
|
||||
|| (player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player));
|
||||
}
|
||||
|
||||
private static boolean cancelZoomKey(Player player, ItemStack stack) {
|
||||
return stack.getItem() instanceof GunItem
|
||||
|| (player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.isDriver(player) && stack.get(DataComponents.FOOD) != null);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onButtonPressed(InputEvent.MouseButton.Pre event) {
|
||||
if (notInGame()) return;
|
||||
if (event.getAction() != InputConstants.PRESS) return;
|
||||
|
||||
Player player = Minecraft.getInstance().player;
|
||||
var mc = Minecraft.getInstance();
|
||||
Player player = mc.player;
|
||||
if (player == null) return;
|
||||
if (player.isSpectator()) return;
|
||||
|
||||
|
@ -95,25 +113,36 @@ public class ClickHandler {
|
|||
|
||||
int button = event.getButton();
|
||||
|
||||
if (stack.getItem() instanceof GunItem || stack.is(ModItems.MONITOR.get()) || stack.is(ModItems.LUNGE_MINE.get()) || player.hasEffect(ModMobEffects.SHOCK)
|
||||
|| (player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player))) {
|
||||
if (button == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
var fireKey = ModKeyMappings.FIRE.getKey();
|
||||
if (fireKey.getType() == InputConstants.Type.MOUSE
|
||||
&& fireKey.getValue() == button
|
||||
&& cancelFireKey(player, stack)
|
||||
) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
if (player.hasEffect(ModMobEffects.SHOCK)) return;
|
||||
|
||||
if (button == GLFW.GLFW_MOUSE_BUTTON_RIGHT) {
|
||||
if (stack.getItem() instanceof GunItem
|
||||
|| (player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.isDriver(player) && stack.get(DataComponents.FOOD) != null)) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
var zoomKey = ModKeyMappings.HOLD_ZOOM.getKey();
|
||||
if (zoomKey.getType() == InputConstants.Type.MOUSE
|
||||
&& zoomKey.getValue() == button
|
||||
&& cancelZoomKey(player, stack)
|
||||
) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
if (button == GLFW.GLFW_MOUSE_BUTTON_MIDDLE) {
|
||||
if (player.hasEffect(ModMobEffects.SHOCK)) {
|
||||
event.setCanceled(true);
|
||||
return;
|
||||
}
|
||||
if (stack.is(ModItems.ARTILLERY_INDICATOR.get())) {
|
||||
PacketDistributor.sendToServer(SetFiringParametersMessage.INSTANCE);
|
||||
event.setCanceled(true);
|
||||
}
|
||||
if (stack.is(ModItems.MONITOR.get()) && player.getOffhandItem().is(ModItems.ARTILLERY_INDICATOR.get())) {
|
||||
droneLeftClick(stack, player);
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +150,9 @@ public class ClickHandler {
|
|||
|| stack.is(ModItems.MONITOR.get())
|
||||
|| stack.is(ModItems.LUNGE_MINE.get())
|
||||
|| (player.getVehicle() instanceof ArmedVehicleEntity)
|
||||
|| (stack.is(Items.SPYGLASS) && player.isScoping() && player.getOffhandItem().is(ModItems.FIRING_PARAMETERS.get()))) {
|
||||
|| (stack.is(Items.SPYGLASS) && player.isScoping() && player.getOffhandItem().is(ModItems.FIRING_PARAMETERS.get()))
|
||||
|| (stack.is(ModItems.ARTILLERY_INDICATOR.get()))
|
||||
) {
|
||||
if (button == ModKeyMappings.FIRE.getKey().getValue()) {
|
||||
handleWeaponFirePress(player, stack);
|
||||
}
|
||||
|
@ -139,6 +170,15 @@ public class ClickHandler {
|
|||
}
|
||||
}
|
||||
|
||||
// 枪械交互时禁止挥舞手臂
|
||||
@SubscribeEvent
|
||||
public static void stopSwing(InputEvent.InteractionKeyMappingTriggered event) {
|
||||
var player = Minecraft.getInstance().player;
|
||||
if (player != null && player.getItemInHand(event.getHand()).getItem() instanceof GunItem) {
|
||||
event.setSwingHand(false);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onMouseScrolling(InputEvent.MouseScrollingEvent event) {
|
||||
Player player = Minecraft.getInstance().player;
|
||||
|
@ -188,8 +228,12 @@ public class ClickHandler {
|
|||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
if (player.isUsingItem() && player.getUseItem().is(ModItems.ARTILLERY_INDICATOR.get())) {
|
||||
artilleryIndicatorCustomZoom = Mth.clamp(artilleryIndicatorCustomZoom + 0.4 * scroll, -2, 6);
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
Entity looking = TraceTool.findLookingEntity(player, 6);
|
||||
if (looking == null) return;
|
||||
if (looking instanceof MortarEntity && player.isShiftKeyDown()) {
|
||||
PacketDistributor.sendToServer(new AdjustMortarAngleMessage(scroll));
|
||||
event.setCanceled(true);
|
||||
|
@ -221,25 +265,46 @@ public class ClickHandler {
|
|||
if (key == ModKeyMappings.RELOAD.getKey().getValue()) {
|
||||
ClientEventHandler.burstFireAmount = 0;
|
||||
ClickHandler.isEditing = false;
|
||||
PacketDistributor.sendToServer(new ReloadMessage(0));
|
||||
PacketDistributor.sendToServer(ReloadMessage.INSTANCE);
|
||||
}
|
||||
if (key == ModKeyMappings.FIRE_MODE.getKey().getValue()) {
|
||||
PacketDistributor.sendToServer(new FireModeMessage(0));
|
||||
PacketDistributor.sendToServer(FireModeMessage.INSTANCE);
|
||||
}
|
||||
if (key == ModKeyMappings.INTERACT.getKey().getValue()) {
|
||||
PacketDistributor.sendToServer(new InteractMessage(0));
|
||||
var mc = Minecraft.getInstance();
|
||||
if (mc.player.getMainHandItem().getItem() instanceof GunItem) {
|
||||
KeyMapping.click(mc.options.keyUse.getKey());
|
||||
} else if (mc.player.getMainHandItem().is(ModItems.MONITOR.get())) {
|
||||
PacketDistributor.sendToServer(InteractMessage.INSTANCE);
|
||||
}
|
||||
}
|
||||
if (key == ModKeyMappings.DISMOUNT.getKey().getValue()) {
|
||||
handleDismountPress(player);
|
||||
}
|
||||
if (key == ModKeyMappings.EDIT_MODE.getKey().getValue() && ClientEventHandler.burstFireAmount == 0
|
||||
&& stack.getItem() instanceof GunItem gunItem && gunItem.isCustomizable(stack)) {
|
||||
ClientEventHandler.holdFire = false;
|
||||
if (key == ModKeyMappings.EDIT_MODE.getKey().getValue()) {
|
||||
if (ClientEventHandler.burstFireAmount == 0 && stack.getItem() instanceof GunItem gunItem && gunItem.isCustomizable(stack)) {
|
||||
ClientEventHandler.holdFire = false;
|
||||
|
||||
if (!isEditing) {
|
||||
player.playSound(ModSounds.EDIT_MODE.get(), 1, 1);
|
||||
if (!isEditing) {
|
||||
player.playSound(ModSounds.EDIT_MODE.get(), 1, 1);
|
||||
}
|
||||
isEditing = !isEditing;
|
||||
}
|
||||
if (stack.getItem() instanceof ItemScreenProvider provider) {
|
||||
var screen = provider.getItemScreen(stack, player, InteractionHand.MAIN_HAND);
|
||||
if (screen != null) {
|
||||
Minecraft.getInstance().setScreen(screen);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ItemStack offHand = player.getOffhandItem();
|
||||
if (offHand.getItem() instanceof ItemScreenProvider provider) {
|
||||
var screen = provider.getItemScreen(offHand, player, InteractionHand.OFF_HAND);
|
||||
if (screen != null) {
|
||||
Minecraft.getInstance().setScreen(screen);
|
||||
return;
|
||||
}
|
||||
}
|
||||
isEditing = !isEditing;
|
||||
}
|
||||
|
||||
if (key == ModKeyMappings.BREATH.getKey().getValue() && !exhaustion && zoom) {
|
||||
|
@ -279,7 +344,9 @@ public class ClickHandler {
|
|||
if (stack.getItem() instanceof GunItem
|
||||
|| stack.is(ModItems.MONITOR.get())
|
||||
|| (player.getVehicle() instanceof ArmedVehicleEntity iVehicle && iVehicle.isDriver(player))
|
||||
|| (stack.is(Items.SPYGLASS) && player.isScoping() && player.getOffhandItem().is(ModItems.FIRING_PARAMETERS.get()))) {
|
||||
|| (stack.is(Items.SPYGLASS) && player.isScoping() && player.getOffhandItem().is(ModItems.FIRING_PARAMETERS.get()))
|
||||
|| (stack.is(ModItems.ARTILLERY_INDICATOR.get()))
|
||||
) {
|
||||
if (key == ModKeyMappings.FIRE.getKey().getValue()) {
|
||||
handleWeaponFirePress(player, stack);
|
||||
}
|
||||
|
@ -301,7 +368,6 @@ public class ClickHandler {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (player.hasEffect(ModMobEffects.SHOCK)) return;
|
||||
|
||||
|
@ -323,15 +389,6 @@ public class ClickHandler {
|
|||
isEditing = false;
|
||||
if (player.hasEffect(ModMobEffects.SHOCK)) return;
|
||||
|
||||
if (stack.is(Items.SPYGLASS) && player.isScoping() && player.getOffhandItem().is(ModItems.FIRING_PARAMETERS.get())) {
|
||||
PacketDistributor.sendToServer(new SetFiringParametersMessage(0));
|
||||
}
|
||||
|
||||
if (stack.is(ModItems.MONITOR.get())) {
|
||||
PacketDistributor.sendToServer(new DroneFireMessage(0));
|
||||
}
|
||||
|
||||
|
||||
if (player.getVehicle() instanceof WeaponVehicleEntity iVehicle && iVehicle.banHand(player)) {
|
||||
if (player.getVehicle() instanceof VehicleEntity pVehicle && iVehicle.hasWeapon(pVehicle.getSeatIndex(player))) {
|
||||
ClientEventHandler.holdFireVehicle = true;
|
||||
|
@ -339,6 +396,22 @@ public class ClickHandler {
|
|||
return;
|
||||
}
|
||||
|
||||
if (stack.is(ModItems.ARTILLERY_INDICATOR.get())) {
|
||||
ClientEventHandler.holdFire = true;
|
||||
}
|
||||
|
||||
if (stack.is(Items.SPYGLASS) && player.isScoping() && player.getOffhandItem().is(ModItems.FIRING_PARAMETERS.get())) {
|
||||
PacketDistributor.sendToServer(SetFiringParametersMessage.INSTANCE);
|
||||
}
|
||||
|
||||
if (stack.is(ModItems.MONITOR.get())) {
|
||||
if (player.getOffhandItem().is(ModItems.ARTILLERY_INDICATOR.get())) {
|
||||
ClientEventHandler.holdFire = true;
|
||||
} else {
|
||||
droneLeftClick(stack, player);
|
||||
}
|
||||
}
|
||||
|
||||
if (stack.is(ModItems.LUNGE_MINE.get())) {
|
||||
ClientEventHandler.holdFire = true;
|
||||
}
|
||||
|
@ -362,7 +435,7 @@ public class ClickHandler {
|
|||
|
||||
if (!data.useBackpackAmmo() && data.ammo.get() <= 0 && data.reload.time() == 0) {
|
||||
if (ReloadConfig.LEFT_CLICK_RELOAD.get()) {
|
||||
PacketDistributor.sendToServer(new ReloadMessage(0));
|
||||
PacketDistributor.sendToServer(ReloadMessage.INSTANCE);
|
||||
ClientEventHandler.burstFireAmount = 0;
|
||||
}
|
||||
} else {
|
||||
|
@ -401,7 +474,7 @@ public class ClickHandler {
|
|||
ItemStack stack = player.getMainHandItem();
|
||||
|
||||
if (stack.is(ModItems.BOCEK.get())) {
|
||||
PacketDistributor.sendToServer(new ReloadMessage(0));
|
||||
PacketDistributor.sendToServer(ReloadMessage.INSTANCE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -453,7 +526,7 @@ public class ClickHandler {
|
|||
if (canDoubleJump) {
|
||||
player.setDeltaMovement(new Vec3(player.getLookAngle().x, 0.8, player.getLookAngle().z));
|
||||
level.playLocalSound(x, y, z, ModSounds.DOUBLE_JUMP.get(), SoundSource.BLOCKS, 1, 1, false);
|
||||
PacketDistributor.sendToServer(new DoubleJumpMessage(0));
|
||||
PacketDistributor.sendToServer(DoubleJumpMessage.INSTANCE);
|
||||
canDoubleJump = false;
|
||||
}
|
||||
}
|
||||
|
@ -475,6 +548,32 @@ public class ClickHandler {
|
|||
ClientEventHandler.dismountCountdown = 20;
|
||||
return;
|
||||
}
|
||||
PacketDistributor.sendToServer(new PlayerStopRidingMessage(0));
|
||||
PacketDistributor.sendToServer(PlayerStopRidingMessage.INSTANCE);
|
||||
}
|
||||
|
||||
public static void droneLeftClick(ItemStack stack, Player player) {
|
||||
var tag = NBTTool.getTag(stack);
|
||||
if (stack.is(ModItems.MONITOR.get()) && tag.getBoolean("Using") && tag.getBoolean("Linked")) {
|
||||
DroneEntity drone = EntityFindUtil.findDrone(player.level(), tag.getString("LinkedDrone"));
|
||||
if (drone != null) {
|
||||
boolean lookAtEntity = false;
|
||||
|
||||
Entity lookingEntity = SeekTool.seekLivingEntity(drone, drone.level(), 512, 2 / droneFovLerp);
|
||||
|
||||
BlockHitResult result = player.level().clip(new ClipContext(drone.getEyePosition(), drone.getEyePosition().add(drone.getLookAngle().scale(512)),
|
||||
ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, drone));
|
||||
Vec3 pos = result.getLocation();
|
||||
|
||||
if (lookingEntity != null) {
|
||||
lookAtEntity = true;
|
||||
}
|
||||
|
||||
if (lookAtEntity) {
|
||||
pos = lookingEntity.position();
|
||||
}
|
||||
|
||||
PacketDistributor.sendToServer(new DroneFireMessage(pos.toVector3f()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,9 @@
|
|||
package com.atsuishio.superbwarfare.client;
|
||||
|
||||
import com.atsuishio.superbwarfare.client.decorator.ContainerItemDecorator;
|
||||
import com.atsuishio.superbwarfare.client.decorator.LuckyContainerItemDecorator;
|
||||
import com.atsuishio.superbwarfare.client.overlay.*;
|
||||
import com.atsuishio.superbwarfare.client.renderer.block.ChargingStationBlockEntityRenderer;
|
||||
import com.atsuishio.superbwarfare.client.renderer.block.ContainerBlockEntityRenderer;
|
||||
import com.atsuishio.superbwarfare.client.renderer.block.FuMO25BlockEntityRenderer;
|
||||
import com.atsuishio.superbwarfare.client.renderer.block.SmallContainerBlockEntityRenderer;
|
||||
import com.atsuishio.superbwarfare.client.renderer.block.*;
|
||||
import com.atsuishio.superbwarfare.client.tooltip.*;
|
||||
import com.atsuishio.superbwarfare.client.tooltip.component.*;
|
||||
import com.atsuishio.superbwarfare.init.ModBlockEntities;
|
||||
|
@ -39,23 +38,25 @@ public class ClientRenderHandler {
|
|||
event.registerBlockEntityRenderer(ModBlockEntities.FUMO_25.get(), context -> new FuMO25BlockEntityRenderer());
|
||||
event.registerBlockEntityRenderer(ModBlockEntities.CHARGING_STATION.get(), context -> new ChargingStationBlockEntityRenderer());
|
||||
event.registerBlockEntityRenderer(ModBlockEntities.SMALL_CONTAINER.get(), context -> new SmallContainerBlockEntityRenderer());
|
||||
event.registerBlockEntityRenderer(ModBlockEntities.LUCKY_CONTAINER.get(), context -> new LuckyContainerBlockEntityRenderer());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerOverlays(RegisterGuiLayersEvent event) {
|
||||
event.registerBelowAll(KillMessageOverlay.ID, new KillMessageOverlay());
|
||||
event.registerBelow(KillMessageOverlay.ID, JavelinHudOverlay.ID, new JavelinHudOverlay());
|
||||
event.registerBelow(KillMessageOverlay.ID, VehicleTeamOverlay.ID, new VehicleTeamOverlay());
|
||||
event.registerBelow(VehicleTeamOverlay.ID, JavelinHudOverlay.ID, new JavelinHudOverlay());
|
||||
event.registerBelow(JavelinHudOverlay.ID, ArmorPlateOverlay.ID, new ArmorPlateOverlay());
|
||||
event.registerBelow(ArmorPlateOverlay.ID, VehicleHudOverlay.ID, new VehicleHudOverlay());
|
||||
event.registerBelow(VehicleHudOverlay.ID, VehicleMgHudOverlay.ID, new VehicleMgHudOverlay());
|
||||
event.registerBelowAll(StaminaOverlay.ID, new StaminaOverlay());
|
||||
event.registerBelowAll(VehicleTeamOverlay.ID, new VehicleTeamOverlay());
|
||||
event.registerBelowAll(Yx100SwarmDroneHudOverlay.ID, new Yx100SwarmDroneHudOverlay());
|
||||
event.registerBelowAll(AmmoBarOverlay.ID, new AmmoBarOverlay());
|
||||
event.registerBelowAll(AmmoCountOverlay.ID, new AmmoCountOverlay());
|
||||
event.registerBelowAll(ItemRendererFixOverlay.ID, new ItemRendererFixOverlay());
|
||||
event.registerBelowAll(CannonHudOverlay.ID, new CannonHudOverlay());
|
||||
event.registerBelowAll(CrossHairOverlay.ID, new CrossHairOverlay());
|
||||
event.registerBelowAll(HeatBarOverlay.ID, new HeatBarOverlay());
|
||||
event.registerBelowAll(DroneHudOverlay.ID, new DroneHudOverlay());
|
||||
event.registerBelowAll(GrenadeLauncherOverlay.ID, new GrenadeLauncherOverlay());
|
||||
event.registerBelowAll(RedTriangleOverlay.ID, new RedTriangleOverlay());
|
||||
|
@ -64,10 +65,12 @@ public class ClientRenderHandler {
|
|||
event.registerBelowAll(HelicopterHudOverlay.ID, new HelicopterHudOverlay());
|
||||
event.registerBelowAll(AircraftOverlay.ID, new AircraftOverlay());
|
||||
event.registerBelowAll(MortarInfoOverlay.ID, new MortarInfoOverlay());
|
||||
event.registerBelowAll(Type63InfoOverlay.ID, new Type63InfoOverlay());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItemDecorations(RegisterItemDecorationsEvent event) {
|
||||
event.register(ModItems.CONTAINER.get(), new ContainerItemDecorator());
|
||||
event.register(ModItems.LUCKY_CONTAINER.get(), new LuckyContainerItemDecorator());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package com.atsuishio.superbwarfare.client;
|
||||
|
||||
import com.atsuishio.superbwarfare.client.renderer.CustomGunRenderer;
|
||||
import com.atsuishio.superbwarfare.client.renderer.SimpleGunRenderer;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import software.bernie.geckolib.animatable.GeoAnimatable;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class GunRendererBuilder {
|
||||
|
||||
public static <T extends GunItem & GeoAnimatable> Supplier<CustomGunRenderer<T>> simple(
|
||||
Supplier<GeoModel<T>> model,
|
||||
double x,
|
||||
double y,
|
||||
double z,
|
||||
double size
|
||||
) {
|
||||
return simple(model, x, y, z, size, false);
|
||||
}
|
||||
|
||||
public static <T extends GunItem & GeoAnimatable> Supplier<CustomGunRenderer<T>> simple(
|
||||
Supplier<GeoModel<T>> model,
|
||||
double x,
|
||||
double y,
|
||||
double z,
|
||||
double size,
|
||||
boolean useOldHandRender
|
||||
) {
|
||||
return () -> new SimpleGunRenderer<>(model.get(), x, y, z, size, useOldHandRender);
|
||||
}
|
||||
}
|
|
@ -2,17 +2,11 @@ package com.atsuishio.superbwarfare.client;
|
|||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.*;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class RenderHelper {
|
||||
// code from GuiGraphics
|
||||
|
@ -244,25 +238,6 @@ public class RenderHelper {
|
|||
RenderSystem.disableBlend();
|
||||
}
|
||||
|
||||
/**
|
||||
* Codes based on @Xjqsh
|
||||
*/
|
||||
@Nullable
|
||||
public static Vec3 worldToScreen(Vec3 pos, Vec3 cameraPos) {
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
Frustum frustum = minecraft.levelRenderer.getFrustum();
|
||||
|
||||
Vector3f relativePos = pos.subtract(cameraPos).toVector3f();
|
||||
Vector3f transformedPos = frustum.matrix.transformProject(relativePos.x, relativePos.y, relativePos.z, new Vector3f());
|
||||
|
||||
double scaleFactor = minecraft.getWindow().getGuiScale();
|
||||
float guiScaleMul = (float) (0.5f / scaleFactor);
|
||||
|
||||
Vector3f screenPos = transformedPos.mul(1.0f, -1.0f, 1.0f).add(1.0f, 1.0f, 0.0f)
|
||||
.mul(guiScaleMul * minecraft.getWindow().getWidth(), guiScaleMul * minecraft.getWindow().getHeight(), 1.0f);
|
||||
|
||||
return transformedPos.z < 1.0f ? new Vec3(screenPos.x, screenPos.y, transformedPos.z) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills a rectangle with the specified color and z-level using the given render type and coordinates as the boundaries.
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.atsuishio.superbwarfare.client;
|
||||
|
||||
import com.atsuishio.superbwarfare.init.ModKeyMappings;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -17,4 +18,9 @@ public class TooltipTool {
|
|||
public static void addDevelopingText(List<Component> tooltip) {
|
||||
tooltip.add(Component.translatable("des.superbwarfare.developing").withStyle(ChatFormatting.LIGHT_PURPLE).withStyle(ChatFormatting.BOLD));
|
||||
}
|
||||
|
||||
public static void addScreenProviderText(List<Component> tooltip) {
|
||||
tooltip.add(Component.translatable("des.superbwarfare.item_screen_provider",
|
||||
"[" + ModKeyMappings.EDIT_MODE.getKey().getDisplayName().getString() + "]").withStyle(ChatFormatting.AQUA));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package com.atsuishio.superbwarfare.client;
|
||||
package com.atsuishio.superbwarfare.client.decorator;
|
||||
|
||||
import com.atsuishio.superbwarfare.client.RenderHelper;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
||||
import com.atsuishio.superbwarfare.item.ContainerBlockItem;
|
||||
import com.atsuishio.superbwarfare.item.common.container.ContainerBlockItem;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
|
@ -0,0 +1,39 @@
|
|||
package com.atsuishio.superbwarfare.client.decorator;
|
||||
|
||||
import com.atsuishio.superbwarfare.client.RenderHelper;
|
||||
import com.atsuishio.superbwarfare.item.common.container.LuckyContainerBlockItem;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import net.neoforged.neoforge.client.IItemDecorator;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class LuckyContainerItemDecorator implements IItemDecorator {
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
public boolean render(GuiGraphics guiGraphics, Font font, ItemStack stack, int xOffset, int yOffset) {
|
||||
if (!(stack.getItem() instanceof LuckyContainerBlockItem)) return false;
|
||||
var data = stack.get(DataComponents.BLOCK_ENTITY_DATA);
|
||||
if (data == null) return false;
|
||||
|
||||
var tag = data.copyTag();
|
||||
if (!tag.contains("Icon")) return false;
|
||||
var iconTag = tag.getString("Icon");
|
||||
ResourceLocation icon = ResourceLocation.tryParse(iconTag);
|
||||
if (icon == null) return false;
|
||||
|
||||
var pose = guiGraphics.pose();
|
||||
pose.pushPose();
|
||||
RenderHelper.preciseBlit(guiGraphics, icon, xOffset, yOffset, 200, 0, 0, 8, 8, 8, 8);
|
||||
pose.popPose();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.atsuishio.superbwarfare.client.layer.projectile;
|
||||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.entity.projectile.MediumRocketEntity;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import software.bernie.geckolib.cache.object.BakedGeoModel;
|
||||
import software.bernie.geckolib.renderer.GeoRenderer;
|
||||
import software.bernie.geckolib.renderer.layer.GeoRenderLayer;
|
||||
|
||||
public class MediumRocketLayer extends GeoRenderLayer<MediumRocketEntity> {
|
||||
private static final ResourceLocation LAYER = Mod.loc("textures/entity/rpg_rocket_e.png");
|
||||
|
||||
public MediumRocketLayer(GeoRenderer<MediumRocketEntity> entityRenderer) {
|
||||
super(entityRenderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack poseStack, MediumRocketEntity animatable, BakedGeoModel bakedModel, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) {
|
||||
RenderType glowRenderType = RenderType.eyes(LAYER);
|
||||
getRenderer().reRender(getDefaultBakedModel(animatable), poseStack, bufferSource, animatable, glowRenderType, bufferSource.getBuffer(glowRenderType), partialTick, packedLight, OverlayTexture.NO_OVERLAY, 0xFFFFFFFF);
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package com.atsuishio.superbwarfare.client.layer.projectile;
|
||||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.entity.projectile.HeliRocketEntity;
|
||||
import com.atsuishio.superbwarfare.entity.projectile.SmallRocketEntity;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
|
@ -12,15 +12,16 @@ import software.bernie.geckolib.cache.object.BakedGeoModel;
|
|||
import software.bernie.geckolib.renderer.GeoRenderer;
|
||||
import software.bernie.geckolib.renderer.layer.GeoRenderLayer;
|
||||
|
||||
public class HeliRocketLayer extends GeoRenderLayer<HeliRocketEntity> {
|
||||
public class SmallRocketLayer extends GeoRenderLayer<SmallRocketEntity> {
|
||||
|
||||
private static final ResourceLocation LAYER = Mod.loc("textures/entity/rpg_rocket_e.png");
|
||||
|
||||
public HeliRocketLayer(GeoRenderer<HeliRocketEntity> entityRenderer) {
|
||||
public SmallRocketLayer(GeoRenderer<SmallRocketEntity> entityRenderer) {
|
||||
super(entityRenderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack poseStack, HeliRocketEntity animatable, BakedGeoModel bakedModel, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) {
|
||||
public void render(PoseStack poseStack, SmallRocketEntity animatable, BakedGeoModel bakedModel, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) {
|
||||
RenderType glowRenderType = RenderType.eyes(LAYER);
|
||||
getRenderer().reRender(getDefaultBakedModel(animatable), poseStack, bufferSource, animatable, glowRenderType, bufferSource.getBuffer(glowRenderType), partialTick, packedLight, OverlayTexture.NO_OVERLAY, 0xFFFFFFFF);
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.atsuishio.superbwarfare.client.model.block;
|
||||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.block.entity.LuckyContainerBlockEntity;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
public class LuckyContainerBlockModel extends GeoModel<LuckyContainerBlockEntity> {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getAnimationResource(LuckyContainerBlockEntity animatable) {
|
||||
return Mod.loc("animations/container.animation.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getModelResource(LuckyContainerBlockEntity animatable) {
|
||||
return Mod.loc("geo/container.geo.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTextureResource(LuckyContainerBlockEntity animatable) {
|
||||
return Mod.loc("textures/block/lucky_container.png");
|
||||
}
|
||||
}
|
|
@ -28,11 +28,11 @@ public class Ah6Model extends GeoModel<Ah6Entity> {
|
|||
if (distance < 32) {
|
||||
return Mod.loc("geo/ah_6.geo.json");
|
||||
} else if (distance < 64) {
|
||||
return Mod.loc("geo/ah_6.lod1.geo.json");
|
||||
return Mod.loc("geo/vehicle_lod/ah_6.lod1.geo.json");
|
||||
} else if (distance < 96) {
|
||||
return Mod.loc("geo/ah_6.lod2.geo.json");
|
||||
return Mod.loc("geo/vehicle_lod/ah_6.lod2.geo.json");
|
||||
} else {
|
||||
return Mod.loc("geo/ah_6.lod3.geo.json");
|
||||
return Mod.loc("geo/vehicle_lod/ah_6.lod3.geo.json");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public class AnnihilatorModel extends GeoModel<AnnihilatorEntity> {
|
|||
if (distance < 64) {
|
||||
return Mod.loc("geo/annihilator.geo.json");
|
||||
} else {
|
||||
return Mod.loc("geo/annihilator.lod1.geo.json");
|
||||
return Mod.loc("geo/vehicle_lod/annihilator.lod1.geo.json");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@ package com.atsuishio.superbwarfare.client.model.entity;
|
|||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.Bmp2Entity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
public class Bmp2Model extends GeoModel<Bmp2Entity> {
|
||||
|
@ -14,20 +16,21 @@ public class Bmp2Model extends GeoModel<Bmp2Entity> {
|
|||
|
||||
@Override
|
||||
public ResourceLocation getModelResource(Bmp2Entity entity) {
|
||||
return Mod.loc("geo/bmp2.geo.json");
|
||||
// Player player = Minecraft.getInstance().player;
|
||||
//
|
||||
// int distance = 0;
|
||||
//
|
||||
// if (player != null) {
|
||||
// distance = (int) player.position().distanceTo(entity.position());
|
||||
// }
|
||||
//
|
||||
// if (distance < 32) {
|
||||
// return ModUtils.loc("geo/Bmp2.geo.json");
|
||||
// } else {
|
||||
// return ModUtils.loc("geo/speedboat.lod1.geo.json");
|
||||
// }
|
||||
Player player = Minecraft.getInstance().player;
|
||||
|
||||
int distance = 0;
|
||||
|
||||
if (player != null) {
|
||||
distance = (int) player.position().distanceTo(entity.position());
|
||||
}
|
||||
|
||||
if (distance < 48 || player.isScoping()) {
|
||||
return Mod.loc("geo/bmp2.geo.json");
|
||||
} else if (distance < 96) {
|
||||
return Mod.loc("geo/vehicle_lod/bmp2.lod1.geo.json");
|
||||
} else {
|
||||
return Mod.loc("geo/vehicle_lod/bmp2.lod2.geo.json");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
package com.atsuishio.superbwarfare.client.model.entity;
|
||||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.entity.projectile.HeliRocketEntity;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
public class HeliRocketModel extends GeoModel<HeliRocketEntity> {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getAnimationResource(HeliRocketEntity entity) {
|
||||
return Mod.loc("animations/rpg_rocket.animation.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getModelResource(HeliRocketEntity entity) {
|
||||
return Mod.loc("geo/heli_rocket.geo.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTextureResource(HeliRocketEntity entity) {
|
||||
return Mod.loc("textures/entity/heli_rocket.png");
|
||||
}
|
||||
}
|
|
@ -31,9 +31,9 @@ public class LaserTowerModel extends GeoModel<LaserTowerEntity> {
|
|||
if (distance < 24 || player.isScoping()) {
|
||||
return Mod.loc("geo/laser_tower.geo.json");
|
||||
} else if (distance < 48) {
|
||||
return Mod.loc("geo/laser_tower.lod1.geo.json");
|
||||
return Mod.loc("geo/vehicle_lod/laser_tower.lod1.geo.json");
|
||||
} else {
|
||||
return Mod.loc("geo/laser_tower.lod2.geo.json");
|
||||
return Mod.loc("geo/vehicle_lod/laser_tower.lod2.geo.json");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@ package com.atsuishio.superbwarfare.client.model.entity;
|
|||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.Lav150Entity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
public class Lav150Model extends GeoModel<Lav150Entity> {
|
||||
|
@ -14,24 +16,39 @@ public class Lav150Model extends GeoModel<Lav150Entity> {
|
|||
|
||||
@Override
|
||||
public ResourceLocation getModelResource(Lav150Entity entity) {
|
||||
return Mod.loc("geo/lav150.geo.json");
|
||||
// Player player = Minecraft.getInstance().player;
|
||||
//
|
||||
// int distance = 0;
|
||||
//
|
||||
// if (player != null) {
|
||||
// distance = (int) player.position().distanceTo(entity.position());
|
||||
// }
|
||||
//
|
||||
// if (distance < 32) {
|
||||
// return ModUtils.loc("geo/lav150.geo.json");
|
||||
// } else {
|
||||
// return ModUtils.loc("geo/speedboat.lod1.geo.json");
|
||||
// }
|
||||
Player player = Minecraft.getInstance().player;
|
||||
|
||||
int distance = 0;
|
||||
|
||||
if (player != null) {
|
||||
distance = (int) player.position().distanceTo(entity.position());
|
||||
}
|
||||
|
||||
if (distance < 32 || player.isScoping()) {
|
||||
return Mod.loc("geo/lav150.geo.json");
|
||||
} else if (distance < 96) {
|
||||
return Mod.loc("geo/vehicle_lod/lav150.lod1.geo.json");
|
||||
} else {
|
||||
return Mod.loc("geo/vehicle_lod/lav150.lod2.geo.json");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTextureResource(Lav150Entity entity) {
|
||||
return Mod.loc("textures/entity/lav150.png");
|
||||
Player player = Minecraft.getInstance().player;
|
||||
|
||||
int distance = 0;
|
||||
|
||||
if (player != null) {
|
||||
distance = (int) player.position().distanceTo(entity.position());
|
||||
}
|
||||
|
||||
if (distance < 32 || player.isScoping()) {
|
||||
return Mod.loc("textures/entity/lav150.png");
|
||||
} else if (distance < 96) {
|
||||
return Mod.loc("textures/entity/lav150_lod1.png");
|
||||
} else {
|
||||
return Mod.loc("textures/entity/lav150_lod2.png");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package com.atsuishio.superbwarfare.client.model.entity;
|
||||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.entity.projectile.M18SmokeGrenadeEntity;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
public class M18SmokeGrenadeEntityModel extends GeoModel<M18SmokeGrenadeEntity> {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getAnimationResource(M18SmokeGrenadeEntity entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getModelResource(M18SmokeGrenadeEntity entity) {
|
||||
return Mod.loc("geo/m18_smoke_grenade.geo.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTextureResource(M18SmokeGrenadeEntity entity) {
|
||||
return Mod.loc("textures/item/m_18.png");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.atsuishio.superbwarfare.client.model.entity;
|
||||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.entity.projectile.MediumRocketEntity;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
public class MediumRocketModel extends GeoModel<MediumRocketEntity> {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getAnimationResource(MediumRocketEntity entity) {
|
||||
return Mod.loc("animations/rpg_rocket.animation.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getModelResource(MediumRocketEntity entity) {
|
||||
return Mod.loc("geo/medium_rocket.geo.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTextureResource(MediumRocketEntity entity) {
|
||||
return Mod.loc("textures/entity/type_63.png");
|
||||
}
|
||||
}
|
|
@ -32,9 +32,9 @@ public class Mk42Model extends GeoModel<Mk42Entity> {
|
|||
if (distance < 32) {
|
||||
return Mod.loc("geo/sherman.geo.json");
|
||||
} else if (distance < 64) {
|
||||
return Mod.loc("geo/sherman_lod1.geo.json");
|
||||
return Mod.loc("geo/vehicle_lod/sherman_lod1.geo.json");
|
||||
} else {
|
||||
return Mod.loc("geo/sherman_lod2.geo.json");
|
||||
return Mod.loc("geo/vehicle_lod/sherman_lod2.geo.json");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public class Mle1934Model extends GeoModel<Mle1934Entity> {
|
|||
if (distance < 32) {
|
||||
return Mod.loc("geo/mle1934.geo.json");
|
||||
} else {
|
||||
return Mod.loc("geo/mle1934_lod1.geo.json");
|
||||
return Mod.loc("geo/vehicle_lod/mle1934_lod1.geo.json");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,10 @@ package com.atsuishio.superbwarfare.client.model.entity;
|
|||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.MortarEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import software.bernie.geckolib.animation.AnimationState;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
import software.bernie.geckolib.constant.DataTickets;
|
||||
|
@ -19,7 +21,19 @@ public class MortarModel extends GeoModel<MortarEntity> {
|
|||
|
||||
@Override
|
||||
public ResourceLocation getModelResource(MortarEntity entity) {
|
||||
return Mod.loc("geo/mortar.geo.json");
|
||||
Player player = Minecraft.getInstance().player;
|
||||
|
||||
int distance = 0;
|
||||
|
||||
if (player != null) {
|
||||
distance = (int) player.position().distanceTo(entity.position());
|
||||
}
|
||||
|
||||
if (distance < 48 || player.isScoping()) {
|
||||
return Mod.loc("geo/mortar.geo.json");
|
||||
} else {
|
||||
return Mod.loc("geo/vehicle_lod/mortar.lod1.geo.json");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package com.atsuishio.superbwarfare.client.model.entity;
|
||||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.entity.projectile.SmallRocketEntity;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
public class SmallRocketModel extends GeoModel<SmallRocketEntity> {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getAnimationResource(SmallRocketEntity entity) {
|
||||
return Mod.loc("animations/rpg_rocket.animation.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getModelResource(SmallRocketEntity entity) {
|
||||
return Mod.loc("geo/small_rocket.geo.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTextureResource(SmallRocketEntity entity) {
|
||||
return Mod.loc("textures/entity/small_rocket.png");
|
||||
}
|
||||
}
|
|
@ -27,7 +27,7 @@ public class SpeedboatModel extends GeoModel<SpeedboatEntity> {
|
|||
if (distance < 32) {
|
||||
return Mod.loc("geo/speedboat.geo.json");
|
||||
} else {
|
||||
return Mod.loc("geo/speedboat.lod1.geo.json");
|
||||
return Mod.loc("geo/vehicle_lod/speedboat.lod1.geo.json");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package com.atsuishio.superbwarfare.client.model.entity;
|
||||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.Type63Entity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
public class Type63Model extends GeoModel<Type63Entity> {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getAnimationResource(Type63Entity entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getModelResource(Type63Entity entity) {
|
||||
Player player = Minecraft.getInstance().player;
|
||||
|
||||
int distance = 0;
|
||||
|
||||
if (player != null) {
|
||||
distance = (int) player.position().distanceTo(entity.position());
|
||||
}
|
||||
|
||||
if (distance < 32 || player.isScoping()) {
|
||||
return Mod.loc("geo/type_63.geo.json");
|
||||
} else if (distance < 96) {
|
||||
return Mod.loc("geo/vehicle_lod/type_63.lod1.geo.json");
|
||||
} else {
|
||||
return Mod.loc("geo/vehicle_lod/type_63.lod2.geo.json");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTextureResource(Type63Entity entity) {
|
||||
return Mod.loc("textures/entity/type_63.png");
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package com.atsuishio.superbwarfare.client.model.item;
|
||||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.item.ContainerBlockItem;
|
||||
import com.atsuishio.superbwarfare.item.common.container.ContainerBlockItem;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package com.atsuishio.superbwarfare.client.model.item;
|
||||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.item.common.container.LuckyContainerBlockItem;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
public class LuckyContainerItemModel extends GeoModel<LuckyContainerBlockItem> {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getAnimationResource(LuckyContainerBlockItem animatable) {
|
||||
return Mod.loc("animations/container.animation.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getModelResource(LuckyContainerBlockItem animatable) {
|
||||
return Mod.loc("geo/container.geo.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTextureResource(LuckyContainerBlockItem animatable) {
|
||||
return Mod.loc("textures/block/lucky_container.png");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,155 @@
|
|||
package com.atsuishio.superbwarfare.client.model.item;
|
||||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.AnimationHelper;
|
||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||
import com.atsuishio.superbwarfare.data.gun.GunData;
|
||||
import com.atsuishio.superbwarfare.data.gun.value.AttachmentType;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.item.gun.rifle.Qbz191Item;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import software.bernie.geckolib.animation.AnimationState;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
|
||||
public class Qbz191ItemModel extends CustomGunModel<Qbz191Item> {
|
||||
|
||||
public static float rotXSight = 0f;
|
||||
public static float rotXBipod = 0f;
|
||||
public static float fireRotY = 0f;
|
||||
public static float fireRotZ = 0f;
|
||||
|
||||
@Override
|
||||
public ResourceLocation getAnimationResource(Qbz191Item animatable) {
|
||||
return Mod.loc("animations/qbz_191.animation.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getModelResource(Qbz191Item animatable) {
|
||||
return Mod.loc("geo/qbz_191.geo.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTextureResource(Qbz191Item animatable) {
|
||||
return Mod.loc("textures/item/qbz_191.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getLODModelResource(Qbz191Item animatable) {
|
||||
return Mod.loc("geo/lod/qbz_191.geo.json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getLODTextureResource(Qbz191Item animatable) {
|
||||
return Mod.loc("textures/item/lod/qbz_191.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomAnimations(Qbz191Item animatable, long instanceId, AnimationState<Qbz191Item> animationState) {
|
||||
Player player = Minecraft.getInstance().player;
|
||||
if (player == null) return;
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (shouldCancelRender(stack, animationState)) return;
|
||||
|
||||
GeoBone gun = getAnimationProcessor().getBone("bone");
|
||||
GeoBone scope = getAnimationProcessor().getBone("Scope1");
|
||||
GeoBone scope2 = getAnimationProcessor().getBone("Scope2");
|
||||
GeoBone scope3 = getAnimationProcessor().getBone("Scope3");
|
||||
GeoBone sight1fold = getAnimationProcessor().getBone("sight1fold");
|
||||
GeoBone sight2fold = getAnimationProcessor().getBone("sight2fold");
|
||||
|
||||
float times = 0.6f * (float) Math.min(Minecraft.getInstance().getTimer().getRealtimeDeltaTicks(), 0.8);
|
||||
double zt = ClientEventHandler.zoomTime;
|
||||
double zp = ClientEventHandler.zoomPos;
|
||||
double zpz = ClientEventHandler.zoomPosZ;
|
||||
double fpz = ClientEventHandler.firePosZ * 17 * times;
|
||||
double fp = ClientEventHandler.firePos;
|
||||
double fr = ClientEventHandler.fireRot;
|
||||
|
||||
int type = GunData.from(stack).attachment.get(AttachmentType.SCOPE);
|
||||
rotXSight = Mth.lerp(1.5f * times, rotXSight, type == 0 ? 0 : 90);
|
||||
|
||||
float posY = switch (type) {
|
||||
case 0 -> 0.52f;
|
||||
case 1 -> 0.63f;
|
||||
case 2 -> 0.43f;
|
||||
case 3 -> 0.27f;
|
||||
default -> 0f;
|
||||
};
|
||||
float scaleZ = switch (type) {
|
||||
case 0, 1 -> 0.5f;
|
||||
case 2 -> 0.85f;
|
||||
case 3 -> 0.94f;
|
||||
default -> 0f;
|
||||
};
|
||||
float posZ = switch (type) {
|
||||
case 0 -> 3.4f;
|
||||
case 1 -> 3.5f;
|
||||
case 2 -> 6.6f;
|
||||
case 3 -> 6.4f;
|
||||
default -> 0f;
|
||||
};
|
||||
|
||||
sight1fold.setRotX(rotXSight * Mth.DEG_TO_RAD);
|
||||
sight2fold.setRotX(rotXSight * Mth.DEG_TO_RAD);
|
||||
|
||||
gun.setPosX(3.21f * (float) zp);
|
||||
gun.setPosY(posY * (float) zp - (float) (0.2f * zpz));
|
||||
gun.setPosZ(posZ * (float) zp + (float) (0.2f * zpz));
|
||||
gun.setScaleZ(1f - (scaleZ * (float) zp));
|
||||
gun.setRotZ((float) (0.05f * zpz));
|
||||
scope.setScaleZ(1f - (0.4f * (float) zp));
|
||||
scope2.setScaleZ(1f - (0.27f * (float) zp));
|
||||
scope3.setScaleZ(1f + (0.2f * (float) zp));
|
||||
|
||||
GeoBone shen;
|
||||
if (zt < 0.5) {
|
||||
shen = getAnimationProcessor().getBone("fireRootNormal");
|
||||
} else {
|
||||
shen = switch (type) {
|
||||
case 0 -> getAnimationProcessor().getBone("fireRoot0");
|
||||
case 1 -> getAnimationProcessor().getBone("fireRoot1");
|
||||
case 2 -> getAnimationProcessor().getBone("fireRoot2");
|
||||
case 3 -> getAnimationProcessor().getBone("fireRoot3");
|
||||
default -> getAnimationProcessor().getBone("fireRootNormal");
|
||||
};
|
||||
}
|
||||
|
||||
fireRotY = (float) Mth.lerp(0.5f * times, fireRotY, 0.2f * ClientEventHandler.recoilHorizon * fpz);
|
||||
fireRotZ = (float) Mth.lerp(2f * times, fireRotZ, (0.2f + 0.3 * fpz) * ClientEventHandler.recoilHorizon);
|
||||
|
||||
shen.setPosX(-0.4f * (float) (ClientEventHandler.recoilHorizon * (0.5 + 0.4 * ClientEventHandler.fireSpread)));
|
||||
shen.setPosY((float) (0.15f * fp + 0.18f * fr));
|
||||
shen.setPosZ((float) (0.375 * fp + 0.44f * fr + 0.75 * fpz));
|
||||
shen.setRotX((float) (0.01f * fp + 0.05f * fr + 0.01f * fpz));
|
||||
shen.setRotY(fireRotY);
|
||||
shen.setRotZ(fireRotZ);
|
||||
|
||||
shen.setPosX((float) (shen.getPosX() * (1 - 0.1 * zt)));
|
||||
shen.setPosY((float) (shen.getPosY() * (-1 + 0.8 * zt)));
|
||||
shen.setPosZ((float) (shen.getPosZ() * (1 - 0.6 * zt)));
|
||||
shen.setRotX((float) (shen.getRotX() * (1 - (type == 3 ? 0.98 : type == 2 ? 0.97 : 0.92) * zt)));
|
||||
shen.setRotY((float) (shen.getRotY() * (1 - (type == 3 ? 0.95 : 0.9) * zt)));
|
||||
shen.setRotZ((float) (shen.getRotZ() * (1 - 0.4 * zt)));
|
||||
|
||||
CrossHairOverlay.gunRot = shen.getRotZ();
|
||||
|
||||
GeoBone bolt = getAnimationProcessor().getBone("bolt");
|
||||
bolt.setPosZ(3f * (float) ClientEventHandler.firePos);
|
||||
|
||||
ClientEventHandler.gunRootMove(getAnimationProcessor());
|
||||
|
||||
GeoBone camera = getAnimationProcessor().getBone("camera");
|
||||
GeoBone main = getAnimationProcessor().getBone("0");
|
||||
|
||||
float numR = (float) (1 - 0.985 * zt);
|
||||
float numP = (float) (1 - 0.92 * zt);
|
||||
|
||||
AnimationHelper.handleReloadShakeAnimation(stack, main, camera, numR, numP);
|
||||
ClientEventHandler.handleReloadShake(Mth.RAD_TO_DEG * camera.getRotX(), Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
|
||||
AnimationHelper.handleShellsAnimation(getAnimationProcessor(), 1f, 0.55f);
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package com.atsuishio.superbwarfare.client.model.item;
|
||||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.item.SmallContainerBlockItem;
|
||||
import com.atsuishio.superbwarfare.item.common.container.SmallContainerBlockItem;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
|
|
|
@ -8,10 +8,7 @@ import com.atsuishio.superbwarfare.entity.vehicle.base.AircraftEntity;
|
|||
import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity;
|
||||
import com.atsuishio.superbwarfare.event.ClientMouseHandler;
|
||||
import com.atsuishio.superbwarfare.tools.EntityFindUtil;
|
||||
import com.atsuishio.superbwarfare.tools.FormatTool;
|
||||
import com.atsuishio.superbwarfare.tools.InventoryTool;
|
||||
import com.atsuishio.superbwarfare.tools.SeekTool;
|
||||
import com.atsuishio.superbwarfare.tools.*;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
@ -48,7 +45,6 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
|||
private static float lerpVy = 1;
|
||||
private static float lerpLock = 1;
|
||||
private static float lerpG = 1;
|
||||
|
||||
private static final ResourceLocation FRAME = Mod.loc("textures/screens/aircraft/frame.png");
|
||||
private static final ResourceLocation FRAME_TARGET = Mod.loc("textures/screens/aircraft/frame_target.png");
|
||||
private static final ResourceLocation FRAME_LOCK = Mod.loc("textures/screens/aircraft/frame_lock.png");
|
||||
|
@ -64,7 +60,8 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
|||
Camera camera = mc.gameRenderer.getMainCamera();
|
||||
Vec3 cameraPos = camera.getPosition();
|
||||
PoseStack poseStack = guiGraphics.pose();
|
||||
Vec3 lookVec = new Vec3(camera.getLookVector());
|
||||
var screenWidth = guiGraphics.guiWidth();
|
||||
var screenHeight = guiGraphics.guiHeight();
|
||||
|
||||
var partialTick = deltaTracker.getGameTimeDeltaPartialTick(true);
|
||||
|
||||
|
@ -87,22 +84,49 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
|||
float diffY = (float) ClientMouseHandler.lerpSpeedX;
|
||||
float diffX = (float) ClientMouseHandler.lerpSpeedY;
|
||||
|
||||
float fovAdjust2 = (float) (Minecraft.getInstance().options.fov().get() / 30) - 1;
|
||||
double zoom = 3 + 0.06 * fovAdjust2;
|
||||
|
||||
Vec3 pos = cameraPos.add(mobileVehicle.getViewVector(partialTick).scale(192));
|
||||
Vec3 lookAngle = lookVec.normalize().scale(pos.distanceTo(cameraPos) * (1 - 1.0 / zoom));
|
||||
|
||||
Vec3 posCross = aircraftEntity.shootPos(partialTick).add(aircraftEntity.shootVec(partialTick).scale(192));
|
||||
Vec3 lookAngle2 = lookVec.normalize().scale(posCross.distanceTo(cameraPos) * (1 - 1.0 / zoom));
|
||||
|
||||
var cPos = cameraPos.add(lookAngle);
|
||||
var cPos2 = cameraPos.add(lookAngle2);
|
||||
Vec3 p = VectorUtil.worldToScreen(pos);
|
||||
Vec3 pCross = VectorUtil.worldToScreen(posCross);
|
||||
|
||||
Vec3 p = RenderHelper.worldToScreen(pos, zoomVehicle ? cPos : cameraPos);
|
||||
Vec3 pCross = RenderHelper.worldToScreen(posCross, zoomVehicle ? cPos2 : cameraPos);
|
||||
// 投弹准星
|
||||
if (mobileVehicle instanceof A10Entity a10Entity && weaponVehicle.getWeaponIndex(0) == 2 && (zoomVehicle || mc.options.getCameraType() != CameraType.FIRST_PERSON)) {
|
||||
Vec3 p0 = a10Entity.bombLandingPosO;
|
||||
Vec3 p1 = a10Entity.bombLandingPos;
|
||||
if (p0 != null && p1 != null) {
|
||||
Vec3 bombCross = p0.lerp(p1, partialTick);
|
||||
pCross = VectorUtil.worldToScreen(bombCross);
|
||||
|
||||
if (p != null) {
|
||||
if (zoomVehicle) {
|
||||
float f = (float) Math.min(screenWidth, screenHeight);
|
||||
float f1 = Math.min((float) screenWidth / f, (float) screenHeight / f);
|
||||
int i = Mth.floor(f * f1);
|
||||
int j = Mth.floor(f * f1);
|
||||
|
||||
float x = (float) pCross.x;
|
||||
float y = (float) pCross.y;
|
||||
poseStack.pushPose();
|
||||
poseStack.rotateAround(Axis.ZP.rotationDegrees(aircraftEntity.getRotZ(partialTick)), x, y, 0);
|
||||
poseStack.pushPose();
|
||||
|
||||
poseStack.pushPose();
|
||||
poseStack.translate(x, y, 0);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("MK82 BOMB " + aircraftEntity.getAmmoCount(player)), 25, -11, 1, false);
|
||||
poseStack.popPose();
|
||||
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/aircraft/bomb_scope.png"), x - 1.5f * i, y - 1.5f * j, 0, 0, 3 * i, 3 * j, 3 * i, 3 * j);
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/aircraft/bomb_scope_pitch.png"), x - 1.5f * i, y - 1.5f * j - 4 * a10Entity.getPitch(partialTick), 0, 0, 3 * i, 3 * j, 3 * i, 3 * j);
|
||||
renderKillIndicator(guiGraphics, x - 7.5f + (float) (2 * (Math.random() - 0.5f)), y - 7.5f + (float) (2 * (Math.random() - 0.5f)));
|
||||
poseStack.popPose();
|
||||
poseStack.popPose();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
poseStack.pushPose();
|
||||
float x = (float) p.x;
|
||||
float y = (float) p.y;
|
||||
|
@ -208,21 +232,23 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
|||
poseStack.popPose();
|
||||
|
||||
// 能量警告
|
||||
if (mobileVehicle.getEnergy() < 0.02 * mobileVehicle.getMaxEnergy()) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("NO POWER!"),
|
||||
(int) x - 144, (int) y + 14, -65536, false);
|
||||
} else if (mobileVehicle.getEnergy() < 0.2 * mobileVehicle.getMaxEnergy()) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("LOW POWER"),
|
||||
(int) x - 144, (int) y + 14, 0xFF6B00, false);
|
||||
if (mobileVehicle.hasEnergyStorage()) {
|
||||
if (mobileVehicle.getEnergy() < 0.02 * mobileVehicle.getMaxEnergy()) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("NO POWER!"),
|
||||
(int) x - 144, (int) y + 14, -65536, false);
|
||||
} else if (mobileVehicle.getEnergy() < 0.2 * mobileVehicle.getMaxEnergy()) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("LOW POWER"),
|
||||
(int) x - 144, (int) y + 14, 0xFF6B00, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 准星
|
||||
if (pCross != null) {
|
||||
{
|
||||
poseStack.pushPose();
|
||||
float x = (float) pCross.x;
|
||||
float y = (float) pCross.y + (zoomVehicle ? 15 * (float) (Minecraft.getInstance().options.fov().get() / 70) : 5);
|
||||
float y = (float) pCross.y;
|
||||
|
||||
if (mc.options.getCameraType() == CameraType.FIRST_PERSON && !(mobileVehicle instanceof A10Entity a10Entity && a10Entity.getWeaponIndex(0) == 3)) {
|
||||
RenderSystem.disableDepthTest();
|
||||
|
@ -239,14 +265,13 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
|||
} else if (mc.options.getCameraType() == CameraType.THIRD_PERSON_BACK) {
|
||||
poseStack.pushPose();
|
||||
poseStack.rotateAround(Axis.ZP.rotationDegrees(aircraftEntity.getRotZ(partialTick)), x, y, 0);
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/drone.png"), x - 8, y - 8, 0, 0, 16, 16, 16, 16);
|
||||
renderKillIndicator(guiGraphics, x - 7.5f + (float) (2 * (Math.random() - 0.5f)), y - 7.5f + (float) (2 * (Math.random() - 0.5f)));
|
||||
|
||||
poseStack.pushPose();
|
||||
|
||||
poseStack.translate(x, y, 0);
|
||||
poseStack.scale(0.75f, 0.75f, 1);
|
||||
|
||||
ResourceLocation cross = Mod.loc("textures/screens/drone.png");
|
||||
float size = 16;
|
||||
|
||||
if (mobileVehicle instanceof A10Entity a10Entity) {
|
||||
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
||||
double heat = a10Entity.getEntityData().get(HEAT) / 100.0F;
|
||||
|
@ -254,6 +279,8 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
|||
} else if (weaponVehicle.getWeaponIndex(0) == 1) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("70MM ROCKET " + aircraftEntity.getAmmoCount(player)), 25, -9, -1, false);
|
||||
} else if (weaponVehicle.getWeaponIndex(0) == 2) {
|
||||
cross = Mod.loc("textures/screens/shotgun_hud.png");
|
||||
size = 24;
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("MK82 BOMB " + aircraftEntity.getAmmoCount(player)), 25, -9, -1, false);
|
||||
} else if (weaponVehicle.getWeaponIndex(0) == 3) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("AGM-65 " + aircraftEntity.getAmmoCount(player)), 25, -9, -1, false);
|
||||
|
@ -262,6 +289,8 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
|||
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("IR FLARES " + aircraftEntity.getDecoy()), 25, 1, -1, false);
|
||||
poseStack.popPose();
|
||||
preciseBlit(guiGraphics, cross, x - 0.5f * size, y - 0.5f * size, 0, 0, size, size, size, size);
|
||||
renderKillIndicator(guiGraphics, x - 7.5f + (float) (2 * (Math.random() - 0.5f)), y - 7.5f + (float) (2 * (Math.random() - 0.5f)));
|
||||
poseStack.popPose();
|
||||
}
|
||||
poseStack.popPose();
|
||||
|
@ -274,32 +303,28 @@ public class AircraftOverlay implements LayeredDraw.Layer {
|
|||
|
||||
for (var e : entities) {
|
||||
Vec3 pos3 = new Vec3(Mth.lerp(partialTick, e.xo, e.getX()), Mth.lerp(partialTick, e.yo + e.getEyeHeight(), e.getEyeY()), Mth.lerp(partialTick, e.zo, e.getZ()));
|
||||
Vec3 lookAngle3 = lookVec.normalize().scale(pos3.distanceTo(cameraPos) * (1 - 1.0 / zoom));
|
||||
var cPos3 = cameraPos.add(lookAngle3);
|
||||
Vec3 point = RenderHelper.worldToScreen(pos3, zoomVehicle ? cPos3 : cameraPos);
|
||||
if (point != null) {
|
||||
boolean nearest = e == targetEntity;
|
||||
boolean lockOn = a10Entity.locked && nearest;
|
||||
Vec3 point = VectorUtil.worldToScreen(pos3);
|
||||
boolean nearest = e == targetEntity;
|
||||
boolean lockOn = a10Entity.locked && nearest;
|
||||
|
||||
poseStack.pushPose();
|
||||
float x = (float) point.x;
|
||||
float y = (float) point.y;
|
||||
poseStack.pushPose();
|
||||
float x = (float) point.x;
|
||||
float y = (float) point.y;
|
||||
|
||||
if (lockOn) {
|
||||
RenderHelper.preciseBlit(guiGraphics, FRAME_LOCK, x - 12, y - 12, 24, 24, 0, 0, 24, 24, 24, 24);
|
||||
} else if (nearest) {
|
||||
lerpLock = Mth.lerp(partialTick, lerpLock, 2 * a10Entity.lockTime);
|
||||
float lockTime = Mth.clamp(20 - lerpLock, 0, 20);
|
||||
RenderHelper.preciseBlit(guiGraphics, IND_1, x - 12, y - 12 - lockTime, 24, 24, 0, 0, 24, 24, 24, 24);
|
||||
RenderHelper.preciseBlit(guiGraphics, IND_2, x - 12, y - 12 + lockTime, 24, 24, 0, 0, 24, 24, 24, 24);
|
||||
RenderHelper.preciseBlit(guiGraphics, IND_3, x - 12 - lockTime, y - 12, 24, 24, 0, 0, 24, 24, 24, 24);
|
||||
RenderHelper.preciseBlit(guiGraphics, IND_4, x - 12 + lockTime, y - 12, 24, 24, 0, 0, 24, 24, 24, 24);
|
||||
RenderHelper.preciseBlit(guiGraphics, FRAME_TARGET, x - 12, y - 12, 24, 24, 0, 0, 24, 24, 24, 24);
|
||||
} else {
|
||||
RenderHelper.preciseBlit(guiGraphics, FRAME, x - 12, y - 12, 24, 24, 0, 0, 24, 24, 24, 24);
|
||||
}
|
||||
poseStack.popPose();
|
||||
if (lockOn) {
|
||||
RenderHelper.preciseBlit(guiGraphics, FRAME_LOCK, x - 12, y - 12, 24, 24, 0, 0, 24, 24, 24, 24);
|
||||
} else if (nearest) {
|
||||
lerpLock = Mth.lerp(partialTick, lerpLock, 2 * a10Entity.lockTime);
|
||||
float lockTime = Mth.clamp(20 - lerpLock, 0, 20);
|
||||
RenderHelper.preciseBlit(guiGraphics, IND_1, x - 12, y - 12 - lockTime, 24, 24, 0, 0, 24, 24, 24, 24);
|
||||
RenderHelper.preciseBlit(guiGraphics, IND_2, x - 12, y - 12 + lockTime, 24, 24, 0, 0, 24, 24, 24, 24);
|
||||
RenderHelper.preciseBlit(guiGraphics, IND_3, x - 12 - lockTime, y - 12, 24, 24, 0, 0, 24, 24, 24, 24);
|
||||
RenderHelper.preciseBlit(guiGraphics, IND_4, x - 12 + lockTime, y - 12, 24, 24, 0, 0, 24, 24, 24, 24);
|
||||
RenderHelper.preciseBlit(guiGraphics, FRAME_TARGET, x - 12, y - 12, 24, 24, 0, 0, 24, 24, 24, 24);
|
||||
} else {
|
||||
RenderHelper.preciseBlit(guiGraphics, FRAME, x - 12, y - 12, 24, 24, 0, 0, 24, 24, 24, 24);
|
||||
}
|
||||
poseStack.popPose();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.atsuishio.superbwarfare.client.overlay;
|
||||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.RenderHelper;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.AnnihilatorEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.Hpj11Entity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.Mk42Entity;
|
||||
|
@ -12,6 +11,7 @@ import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
|||
import com.atsuishio.superbwarfare.tools.FormatTool;
|
||||
import com.atsuishio.superbwarfare.tools.InventoryTool;
|
||||
import com.atsuishio.superbwarfare.tools.TraceTool;
|
||||
import com.atsuishio.superbwarfare.tools.VectorUtil;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
@ -56,6 +56,7 @@ public class CannonHudOverlay implements LayeredDraw.Layer {
|
|||
PoseStack poseStack = guiGraphics.pose();
|
||||
Camera camera = mc.gameRenderer.getMainCamera();
|
||||
Vec3 cameraPos = camera.getPosition();
|
||||
Vec3 viewVec = new Vec3(camera.getLookVector());
|
||||
|
||||
if (!shouldRenderCrossHair(player)) return;
|
||||
|
||||
|
@ -105,7 +106,7 @@ public class CannonHudOverlay implements LayeredDraw.Layer {
|
|||
shootPos = cannon.driverZoomPos(deltaTracker.getRealtimeDeltaTicks());
|
||||
}
|
||||
|
||||
Entity lookingEntity = TraceTool.camerafFindLookingEntity(player, cameraPos, 512, deltaTracker.getRealtimeDeltaTicks());
|
||||
Entity lookingEntity = TraceTool.camerafFindLookingEntity(player, cameraPos, viewVec, 512);
|
||||
boolean lookAtEntity = false;
|
||||
|
||||
BlockHitResult result = player.level().clip(new ClipContext(shootPos, shootPos.add(player.getViewVector(1).scale(512)),
|
||||
|
@ -121,9 +122,7 @@ public class CannonHudOverlay implements LayeredDraw.Layer {
|
|||
}
|
||||
if (lookAtEntity) {
|
||||
var component = Component.translatable("tips.superbwarfare.drone.range").append(Component.literal(FormatTool.format1D(entityRange, "m ")));
|
||||
if (lookingEntity.getDisplayName() != null) {
|
||||
component.append(lookingEntity.getDisplayName());
|
||||
}
|
||||
component.append(lookingEntity.getDisplayName());
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, component, w / 2 + 14, h / 2 - 20, -1, false);
|
||||
} else {
|
||||
if (blockRange > 511) {
|
||||
|
@ -142,7 +141,8 @@ public class CannonHudOverlay implements LayeredDraw.Layer {
|
|||
} else {
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/cannon/cannon_crosshair.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
}
|
||||
float diffY = -Mth.wrapDegrees(Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), player.yHeadRotO, player.getYHeadRot()) - Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), cannon.yRotO, cannon.getYRot()));
|
||||
float diffY = -Mth.wrapDegrees(Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), player.yHeadRotO, player.getYHeadRot())
|
||||
- Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), cannon.yRotO, cannon.getYRot()));
|
||||
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/cannon/indicator.png"), (float) w / 2 - 4.3f + 0.45f * diffY, (float) h / 2 - 10, 0, 0.0F, 8, 8, 8, 8);
|
||||
} else {
|
||||
|
@ -168,46 +168,44 @@ public class CannonHudOverlay implements LayeredDraw.Layer {
|
|||
|
||||
renderKillIndicator(guiGraphics, w, h);
|
||||
} else if (Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK && !ClientEventHandler.zoomVehicle) {
|
||||
Vec3 p = RenderHelper.worldToScreen(new Vec3(Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), player.xo, player.getX()), Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), player.yo, player.getY()),
|
||||
Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), player.zo, player.getZ())).add(cannon.getViewVector(deltaTracker.getGameTimeDeltaPartialTick(true)).scale(128)), cameraPos);
|
||||
Vec3 p = VectorUtil.worldToScreen(new Vec3(Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), player.xo, player.getX()), Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), player.yo, player.getY()),
|
||||
Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), player.zo, player.getZ())).add(cannon.getViewVector(deltaTracker.getGameTimeDeltaPartialTick(true)).scale(128)));
|
||||
|
||||
// 第三人称准星
|
||||
if (p != null) {
|
||||
poseStack.pushPose();
|
||||
float x = (float) p.x;
|
||||
float y = (float) p.y;
|
||||
poseStack.pushPose();
|
||||
float x = (float) p.x;
|
||||
float y = (float) p.y;
|
||||
|
||||
poseStack.pushPose();
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/drone.png"), x - 12, y - 12, 0, 0, 24, 24, 24, 24);
|
||||
renderKillIndicator3P(guiGraphics, x - 7.5f + (float) (2 * (Math.random() - 0.5f)), y - 7.5f + (float) (2 * (Math.random() - 0.5f)));
|
||||
poseStack.pushPose();
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/drone.png"), x - 12, y - 12, 0, 0, 24, 24, 24, 24);
|
||||
renderKillIndicator3P(guiGraphics, x - 7.5f + (float) (2 * (Math.random() - 0.5f)), y - 7.5f + (float) (2 * (Math.random() - 0.5f)));
|
||||
|
||||
poseStack.pushPose();
|
||||
poseStack.pushPose();
|
||||
|
||||
poseStack.translate(x, y, 0);
|
||||
poseStack.scale(0.75f, 0.75f, 1);
|
||||
poseStack.translate(x, y, 0);
|
||||
poseStack.scale(0.75f, 0.75f, 1);
|
||||
|
||||
if (player.getVehicle() instanceof Mk42Entity || player.getVehicle() instanceof Mle1934Entity) {
|
||||
if (cannonEntity.getWeaponIndex(0) == 0) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("AP SHELL " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : cannonEntity.getAmmoCount(player))), 30, -9, -1, false);
|
||||
} else {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("HE SHELL " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : cannonEntity.getAmmoCount(player))), 30, -9, -1, false);
|
||||
}
|
||||
if (player.getVehicle() instanceof Mk42Entity || player.getVehicle() instanceof Mle1934Entity) {
|
||||
if (cannonEntity.getWeaponIndex(0) == 0) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("AP SHELL " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : cannonEntity.getAmmoCount(player))), 30, -9, -1, false);
|
||||
} else {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("HE SHELL " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : cannonEntity.getAmmoCount(player))), 30, -9, -1, false);
|
||||
}
|
||||
|
||||
// 歼灭者
|
||||
if (player.getVehicle() instanceof AnnihilatorEntity annihilatorEntity) {
|
||||
guiGraphics.drawString(mc.font, Component.literal("LASER " + (FormatTool.format0D((double) (100 * annihilatorEntity.getEnergy()) / annihilatorEntity.getMaxEnergy()) + "%")), 30, -9, -1, false);
|
||||
}
|
||||
|
||||
double heal = 1 - cannon.getHealth() / cannon.getMaxHealth();
|
||||
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("HP " +
|
||||
FormatTool.format0D(100 * cannon.getHealth() / cannon.getMaxHealth())), 30, 1, Mth.hsvToRgb(0F, (float) heal, 1.0F), false);
|
||||
|
||||
poseStack.popPose();
|
||||
poseStack.popPose();
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
||||
// 歼灭者
|
||||
if (player.getVehicle() instanceof AnnihilatorEntity annihilatorEntity) {
|
||||
guiGraphics.drawString(mc.font, Component.literal("LASER " + (FormatTool.format0D((double) (100 * annihilatorEntity.getEnergy()) / annihilatorEntity.getMaxEnergy()) + "%")), 30, -9, -1, false);
|
||||
}
|
||||
|
||||
double heal = 1 - cannon.getHealth() / cannon.getMaxHealth();
|
||||
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("HP " +
|
||||
FormatTool.format0D(100 * cannon.getHealth() / cannon.getMaxHealth())), 30, 1, Mth.hsvToRgb(0F, (float) heal, 1.0F), false);
|
||||
|
||||
poseStack.popPose();
|
||||
poseStack.popPose();
|
||||
poseStack.popPose();
|
||||
}
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.atsuishio.superbwarfare.entity.vehicle.base.ArmedVehicleEntity;
|
|||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.perk.AmmoPerk;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
@ -64,7 +65,7 @@ public class CrossHairOverlay implements LayeredDraw.Layer {
|
|||
|
||||
if (ClickHandler.isEditing)
|
||||
return;
|
||||
if (!player.getMainHandItem().is(ModTags.Items.GUN) || (player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player)))
|
||||
if (!(player.getMainHandItem().getItem() instanceof GunItem) || (player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player)))
|
||||
return;
|
||||
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.atsuishio.superbwarfare.client.overlay;
|
|||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.RenderHelper;
|
||||
import com.atsuishio.superbwarfare.component.ModDataComponents;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.DroneEntity;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
|
@ -15,6 +16,9 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.LayeredDraw;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
|
@ -31,15 +35,21 @@ import javax.annotation.ParametersAreNonnullByDefault;
|
|||
import java.util.List;
|
||||
|
||||
import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit;
|
||||
import static com.atsuishio.superbwarfare.entity.vehicle.DroneEntity.AMMO;
|
||||
import static com.atsuishio.superbwarfare.entity.vehicle.DroneEntity.KAMIKAZE_MODE;
|
||||
import static com.atsuishio.superbwarfare.client.overlay.SpyglassRangeOverlay.FRIENDLY_INDICATOR;
|
||||
import static com.atsuishio.superbwarfare.client.overlay.SpyglassRangeOverlay.INDICATOR;
|
||||
import static com.atsuishio.superbwarfare.entity.vehicle.DroneEntity.*;
|
||||
import static com.atsuishio.superbwarfare.item.ArtilleryIndicator.TAG_CANNON;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class DroneHudOverlay implements LayeredDraw.Layer {
|
||||
|
||||
public static final ResourceLocation ID = Mod.loc("drone_hud");
|
||||
|
||||
public static int MAX_DISTANCE = 256;
|
||||
public static int getMaxDistance() {
|
||||
var connection = Minecraft.getInstance().getConnection();
|
||||
return (connection == null ? 16 : connection.serverSimulationDistance) * 16;
|
||||
}
|
||||
|
||||
private static final ResourceLocation FRAME = Mod.loc("textures/screens/frame/frame.png");
|
||||
private static final ResourceLocation TV_FRAME = Mod.loc("textures/screens/land/tv_frame.png");
|
||||
|
||||
|
@ -77,7 +87,7 @@ public class DroneHudOverlay implements LayeredDraw.Layer {
|
|||
int addH = (w / h) * 27;
|
||||
preciseBlit(guiGraphics, TV_FRAME, (float) -addW / 2, (float) -addH / 2, 10, 0, 0.0F, w + addW, h + addH, w + addW, h + addH);
|
||||
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/drone_fov_move.png"), (float) w / 2 + 100, (float) (h / 2 - 64 - ((ClientEventHandler.droneFovLerp - 1) * 23.8)), 0, 0, 64, 129, 64, 129);
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/drone_fov_move.png"), (float) w / 2 + 100, (float) (h / 2f - 64 - ((ClientEventHandler.droneFovLerp - 1) * 23.8)), 0, 0, 64, 129, 64, 129);
|
||||
guiGraphics.drawString(mc.font, Component.literal(FormatTool.format1D(ClientEventHandler.droneFovLerp, "x")),
|
||||
w / 2 + 144, h / 2 + 56 - (int) ((ClientEventHandler.droneFovLerp - 1) * 23.8), -1, false);
|
||||
|
||||
|
@ -104,7 +114,7 @@ public class DroneHudOverlay implements LayeredDraw.Layer {
|
|||
int color = -1;
|
||||
|
||||
// 超出距离警告
|
||||
if (distance > MAX_DISTANCE - 48) {
|
||||
if (distance > getMaxDistance() - 48) {
|
||||
guiGraphics.drawString(mc.font, Component.translatable("tips.superbwarfare.drone.warning"),
|
||||
w / 2 - 18, h / 2 - 47, -65536, false);
|
||||
color = -65536;
|
||||
|
@ -119,10 +129,10 @@ public class DroneHudOverlay implements LayeredDraw.Layer {
|
|||
guiGraphics.drawString(mc.font, Component.translatable("tips.superbwarfare.drone.health")
|
||||
.append(Component.literal(FormatTool.format1D(entity.getHealth()) + " / " + FormatTool.format1D(entity.getMaxHealth()))),
|
||||
w / 2 - 77, h / 2 + 33, -1, false);
|
||||
if (entity.getEntityData().get(KAMIKAZE_MODE) == 0) {
|
||||
if (!entity.getEntityData().get(IS_KAMIKAZE)) {
|
||||
// 弹药
|
||||
guiGraphics.drawString(mc.font, Component.translatable("tips.superbwarfare.drone.ammo")
|
||||
.append(Component.literal(FormatTool.format1D(entity.getEntityData().get(AMMO), " / 6"))),
|
||||
.append(Component.literal(entity.getEntityData().get(AMMO) + " / " + entity.getEntityData().get(MAX_AMMO))),
|
||||
w / 2 + 12, h / 2 - 37, -1, false);
|
||||
} else {
|
||||
// 神风
|
||||
|
@ -133,7 +143,6 @@ public class DroneHudOverlay implements LayeredDraw.Layer {
|
|||
if (lookAtEntity) {
|
||||
// 实体距离
|
||||
var displayName = lookingEntity.getDisplayName();
|
||||
if (displayName == null) displayName = Component.empty();
|
||||
|
||||
guiGraphics.drawString(mc.font, Component.translatable("tips.superbwarfare.drone.range")
|
||||
.append(Component.literal(FormatTool.format1D(entityRange, "m ") + displayName.getString())),
|
||||
|
@ -152,24 +161,63 @@ public class DroneHudOverlay implements LayeredDraw.Layer {
|
|||
|
||||
|
||||
List<Entity> entities = SeekTool.seekLivingEntities(entity, entity.level(), 256, 30);
|
||||
float fovAdjust2 = (float) (mc.options.fov().get() / 30) - 1;
|
||||
double zoom = 0.975 * ClientEventHandler.droneFovLerp + 0.06 * fovAdjust2;
|
||||
|
||||
for (var e : entities) {
|
||||
Vec3 droneVec = new Vec3(Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), entity.xo, entity.getX()), Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), entity.yo + entity.getEyeHeight(), entity.getEyeY()), Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), entity.zo, entity.getZ()));
|
||||
Vec3 pos = new Vec3(Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), e.xo, e.getX()), Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), e.yo + e.getEyeHeight(), e.getEyeY()), Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), e.zo, e.getZ()));
|
||||
Vec3 point = VectorUtil.worldToScreen(pos);
|
||||
poseStack.pushPose();
|
||||
float x = (float) point.x;
|
||||
float y = (float) point.y;
|
||||
|
||||
Vec3 lookAngle = entity.getLookAngle().normalize().scale(pos.distanceTo(droneVec) * (1 - 1.0 / zoom));
|
||||
RenderHelper.preciseBlit(guiGraphics, FRAME, x - 12, y - 12, 24, 24, 0, 0, 24, 24, 24, 24);
|
||||
poseStack.popPose();
|
||||
}
|
||||
}
|
||||
|
||||
var cPos = droneVec.add(lookAngle);
|
||||
Vec3 point = RenderHelper.worldToScreen(pos, cPos);
|
||||
if (point != null) {
|
||||
poseStack.pushPose();
|
||||
float x = (float) point.x;
|
||||
float y = (float) point.y;
|
||||
// 射击诸元标记
|
||||
|
||||
RenderHelper.preciseBlit(guiGraphics, FRAME, x - 12, y - 12, 24, 24, 0, 0, 24, 24, 24, 24);
|
||||
poseStack.popPose();
|
||||
ItemStack offStack = player.getOffhandItem();
|
||||
if (offStack.is(ModItems.FIRING_PARAMETERS.get()) || offStack.is(ModItems.ARTILLERY_INDICATOR.get())) {
|
||||
var parameters = offStack.get(ModDataComponents.FIRING_PARAMETERS);
|
||||
BlockPos blockPos;
|
||||
if (parameters != null) {
|
||||
blockPos = parameters.pos();
|
||||
} else {
|
||||
blockPos = new BlockPos(0, 0, 0);
|
||||
}
|
||||
|
||||
double targetX = blockPos.getX();
|
||||
double targetY = blockPos.getY();
|
||||
double targetZ = blockPos.getZ();
|
||||
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.depthMask(false);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
|
||||
// 标记位置
|
||||
Vec3 pos = new Vec3(targetX, targetY, targetZ);
|
||||
Vec3 point = VectorUtil.worldToScreen(pos);
|
||||
float x = (float) point.x;
|
||||
float y = (float) point.y;
|
||||
preciseBlit(guiGraphics, INDICATOR, Mth.clamp(x - 6, 0, w - 12), Mth.clamp(y - 6, 0, h - 12), 0, 0, 12, 12, 12, 12);
|
||||
|
||||
// 火炮位置
|
||||
|
||||
if (offStack.is(ModItems.ARTILLERY_INDICATOR.get())) {
|
||||
ListTag tags = NBTTool.getTag(offStack).getList(TAG_CANNON, Tag.TAG_COMPOUND);
|
||||
for (int m = 0; m < tags.size(); m++) {
|
||||
var t = tags.getCompound(m);
|
||||
Entity e = EntityFindUtil.findEntity(player.level(), t.getString("UUID"));
|
||||
if (e != null) {
|
||||
Vec3 posF = e.getBoundingBox().getCenter();
|
||||
Vec3 pointF = VectorUtil.worldToScreen(posF);
|
||||
float xf = (float) pointF.x;
|
||||
float yf = (float) pointF.y;
|
||||
|
||||
preciseBlit(guiGraphics, FRIENDLY_INDICATOR, Mth.clamp(xf - 6, 0, w - 12), Mth.clamp(yf - 6, 0, h - 12), 0, 0, 12, 12, 12, 12);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,11 @@ import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
|||
import com.atsuishio.superbwarfare.init.ModPerks;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.tools.SeekTool;
|
||||
import com.atsuishio.superbwarfare.tools.VectorUtil;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
|
@ -44,6 +46,7 @@ public class HandsomeFrameOverlay implements LayeredDraw.Layer {
|
|||
public void render(GuiGraphics guiGraphics, DeltaTracker deltaTracker) {
|
||||
Player player = Minecraft.getInstance().player;
|
||||
PoseStack poseStack = guiGraphics.pose();
|
||||
Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera();
|
||||
|
||||
if (player == null) return;
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
|
@ -72,22 +75,9 @@ public class HandsomeFrameOverlay implements LayeredDraw.Layer {
|
|||
Entity targetEntity = ClientEventHandler.entity;
|
||||
|
||||
|
||||
float fovAdjust2 = (float) (Minecraft.getInstance().options.fov().get() / 30) - 1;
|
||||
|
||||
double zoom = 1;
|
||||
|
||||
if (ClientEventHandler.zoom) {
|
||||
zoom = Minecraft.getInstance().options.fov().get() / ClientEventHandler.fov + 0.05 * fovAdjust2;
|
||||
}
|
||||
|
||||
for (var e : allEntities) {
|
||||
Vec3 playerVec = new Vec3(Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), player.xo, player.getX()), Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), player.yo + player.getEyeHeight(), player.getEyeY()), Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), player.zo, player.getZ()));
|
||||
Vec3 pos = new Vec3(Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), e.xo, e.getX()), Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), e.yo + e.getEyeHeight(), e.getEyeY()), Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), e.zo, e.getZ()));
|
||||
Vec3 lookAngle = player.getLookAngle().normalize().scale(pos.distanceTo(playerVec) * (1 - 1.0 / zoom));
|
||||
|
||||
var cPos = playerVec.add(lookAngle);
|
||||
Vec3 point = RenderHelper.worldToScreen(pos, cPos);
|
||||
if (point == null) return;
|
||||
Vec3 point = VectorUtil.worldToScreen(pos);
|
||||
|
||||
boolean lockOn = e == targetEntity;
|
||||
boolean isNearestEntity = e == naerestEntity;
|
||||
|
|
|
@ -0,0 +1,126 @@
|
|||
package com.atsuishio.superbwarfare.client.overlay;
|
||||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.ClickHandler;
|
||||
import com.atsuishio.superbwarfare.client.RenderHelper;
|
||||
import com.atsuishio.superbwarfare.config.client.DisplayConfig;
|
||||
import com.atsuishio.superbwarfare.data.gun.GunData;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.ArmedVehicleEntity;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.tools.animation.AnimationCurves;
|
||||
import com.atsuishio.superbwarfare.tools.animation.AnimationTimer;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.LayeredDraw;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.FastColor;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class HeatBarOverlay implements LayeredDraw.Layer {
|
||||
|
||||
public static final ResourceLocation ID = Mod.loc("heat_bar");
|
||||
|
||||
private static final ResourceLocation TEXTURE = Mod.loc("textures/screens/heat_bar.png");
|
||||
|
||||
private static final AnimationTimer timer = new AnimationTimer(200)
|
||||
.animation(AnimationCurves.EASE_IN_QUART);
|
||||
|
||||
@Override
|
||||
public void render(@NotNull GuiGraphics guiGraphics, @NotNull DeltaTracker deltaTracker) {
|
||||
if (!DisplayConfig.ENABLE_HEAT_BAR_HUD.get()) return;
|
||||
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
Player player = mc.player;
|
||||
if (player == null) return;
|
||||
|
||||
var screenWidth = guiGraphics.guiWidth();
|
||||
var screenHeight = guiGraphics.guiHeight();
|
||||
|
||||
double heat;
|
||||
if (ClickHandler.isEditing
|
||||
|| !(player.getMainHandItem().getItem() instanceof GunItem)
|
||||
|| (player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player))
|
||||
) {
|
||||
heat = 0;
|
||||
} else {
|
||||
heat = GunData.from(player.getMainHandItem()).heat.get();
|
||||
}
|
||||
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if (heat <= 0) {
|
||||
timer.forward(currentTime);
|
||||
} else {
|
||||
timer.beginForward(currentTime);
|
||||
}
|
||||
if (timer.finished(currentTime)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var poseStack = guiGraphics.pose();
|
||||
poseStack.pushPose();
|
||||
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.depthMask(false);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
|
||||
int width = 16;
|
||||
int height = 64;
|
||||
|
||||
int i = (screenWidth - width) / 2;
|
||||
int j = (screenHeight - height) / 2;
|
||||
|
||||
float posX = i + 64 + DisplayConfig.HEAT_BAR_HUD_X_OFFSET.get() + timer.lerp(0, 5, currentTime);
|
||||
float posY = j + 6 + DisplayConfig.HEAT_BAR_HUD_Y_OFFSET.get();
|
||||
|
||||
float alpha = timer.lerp(1, 0, currentTime);
|
||||
RenderSystem.setShaderColor(1, 1, 1, alpha);
|
||||
|
||||
RenderHelper.preciseBlit(guiGraphics, TEXTURE, posX, posY, 0, 0, 37 / 4f, 233 / 4f, width, height);
|
||||
|
||||
float rate = (float) (heat / 100.0);
|
||||
float barHeight = 56 * rate;
|
||||
|
||||
poseStack.pushPose();
|
||||
|
||||
var color = rate >= 0.795f ? calculateGradientColor(rate) : 0xFFFFFF;
|
||||
var red = FastColor.ARGB32.red(color) / 255f;
|
||||
var green = FastColor.ARGB32.green(color) / 255f;
|
||||
var blue = FastColor.ARGB32.blue(color) / 255f;
|
||||
|
||||
RenderSystem.setShaderColor(red, green, blue, alpha);
|
||||
RenderHelper.preciseBlit(guiGraphics, TEXTURE, posX + 2.5f, posY + 1.5f + 56 - barHeight,
|
||||
10.5f, 0, 2.25f, barHeight, width, height);
|
||||
|
||||
poseStack.popPose();
|
||||
|
||||
RenderSystem.depthMask(true);
|
||||
RenderSystem.defaultBlendFunc();
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
||||
public static int calculateGradientColor(float rate) {
|
||||
float clampedRate = Mth.clamp(rate, 0.795f, 1.0f);
|
||||
float normalized = (clampedRate - 0.795f) / (1.0f - 0.795f);
|
||||
|
||||
int red = 255;
|
||||
int green = (int) (255 * (1 - normalized));
|
||||
int blue = (int) (255 * (1 - normalized));
|
||||
|
||||
return (red << 16) | (green << 8) | blue;
|
||||
}
|
||||
}
|
|
@ -2,7 +2,6 @@ package com.atsuishio.superbwarfare.client.overlay;
|
|||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.ClickHandler;
|
||||
import com.atsuishio.superbwarfare.client.RenderHelper;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.Ah6Entity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.HelicopterEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity;
|
||||
|
@ -10,11 +9,11 @@ import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity;
|
|||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.tools.FormatTool;
|
||||
import com.atsuishio.superbwarfare.tools.InventoryTool;
|
||||
import com.atsuishio.superbwarfare.tools.VectorUtil;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.CameraType;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -54,8 +53,6 @@ public class HelicopterHudOverlay implements LayeredDraw.Layer {
|
|||
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
Player player = mc.player;
|
||||
Camera camera = mc.gameRenderer.getMainCamera();
|
||||
Vec3 cameraPos = camera.getPosition();
|
||||
PoseStack poseStack = guiGraphics.pose();
|
||||
|
||||
if (player == null) return;
|
||||
|
@ -113,7 +110,7 @@ public class HelicopterHudOverlay implements LayeredDraw.Layer {
|
|||
lerpVy = (float) Mth.lerp(0.021f * partialTick, lerpVy, mobileVehicle.getDeltaMovement().y());
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/helicopter/heli_vy_move.png"), (float) w / 2 + 138, ((float) h / 2 - 3 - Math.max(lerpVy * 20, -24) * 2.5f), 0, 0, 8, 8, 8, 8);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal(FormatTool.format0D(lerpVy * 20, "m/s")),
|
||||
w / 2 + 146, (int) (h / 2 - 3 - Math.max(lerpVy * 20, -24) * 2.5), (lerpVy * 20 < -24 || ((lerpVy * 20 < -10 || (lerpVy * 20 < -1 && length(mobileVehicle.getDeltaMovement().x, mobileVehicle.getDeltaMovement().y, mobileVehicle.getDeltaMovement().z) * 72 > 100)) && height < 36) || (length(mobileVehicle.getDeltaMovement().x, mobileVehicle.getDeltaMovement().y, mobileVehicle.getDeltaMovement().z) * 72 > 40 && blockInWay < 72) ? -65536 : 0x66FF00), false);
|
||||
w / 2 + 146, (int) (h / 2F - 3 - Math.max(lerpVy * 20, -24) * 2.5), (lerpVy * 20 < -24 || ((lerpVy * 20 < -10 || (lerpVy * 20 < -1 && length(mobileVehicle.getDeltaMovement().x, mobileVehicle.getDeltaMovement().y, mobileVehicle.getDeltaMovement().z) * 72 > 100)) && height < 36) || (length(mobileVehicle.getDeltaMovement().x, mobileVehicle.getDeltaMovement().y, mobileVehicle.getDeltaMovement().z) * 72 > 40 && blockInWay < 72) ? -65536 : 0x66FF00), false);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal(FormatTool.format0D(mobileVehicle.getY())),
|
||||
w / 2 + 104, h / 2, 0x66FF00, false);
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/helicopter/speed_frame.png"), (float) w / 2 - 144, (float) h / 2 - 6, 0, 0, 50, 18, 50, 18);
|
||||
|
@ -141,64 +138,55 @@ public class HelicopterHudOverlay implements LayeredDraw.Layer {
|
|||
w / 2 - 42, h / 2 + 24, -65536, false);
|
||||
}
|
||||
|
||||
if (mobileVehicle.getEnergy() < 0.02 * mobileVehicle.getMaxEnergy()) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("NO POWER!"),
|
||||
w / 2 - 144, h / 2 + 14, -65536, false);
|
||||
} else if (mobileVehicle.getEnergy() < 0.2 * mobileVehicle.getMaxEnergy()) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("LOW POWER"),
|
||||
w / 2 - 144, h / 2 + 14, 0xFF6B00, false);
|
||||
if (mobileVehicle.hasEnergyStorage()) {
|
||||
if (mobileVehicle.getEnergy() < 0.02 * mobileVehicle.getMaxEnergy()) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("NO POWER!"),
|
||||
w / 2 - 144, h / 2 + 14, -65536, false);
|
||||
} else if (mobileVehicle.getEnergy() < 0.2 * mobileVehicle.getMaxEnergy()) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("LOW POWER"),
|
||||
w / 2 - 144, h / 2 + 14, 0xFF6B00, false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
float fovAdjust2 = (float) (Minecraft.getInstance().options.fov().get() / 30) - 1;
|
||||
double zoom = 0.96 * 3 + 0.06 * fovAdjust2;
|
||||
|
||||
Vec3 lookVec = new Vec3(camera.getLookVector());
|
||||
Vec3 pos = iHelicopterEntity.shootPos(partialTick).add(iHelicopterEntity.shootVec(partialTick).scale(192));
|
||||
Vec3 lookAngle = lookVec.normalize().scale(pos.distanceTo(cameraPos) * (1 - 1.0 / zoom));
|
||||
Vec3 p = VectorUtil.worldToScreen(pos);
|
||||
|
||||
var cPos = cameraPos.add(lookAngle);
|
||||
poseStack.pushPose();
|
||||
float x = (float) p.x;
|
||||
float y = (float) p.y;
|
||||
|
||||
Vec3 p = RenderHelper.worldToScreen(iHelicopterEntity.shootPos(partialTick).add(mobileVehicle.getViewVector(partialTick).scale(192)), ClientEventHandler.zoomVehicle ? cPos : cameraPos);
|
||||
|
||||
if (p != null) {
|
||||
if (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON) {
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/helicopter/crosshair_ind.png"), x - 8, y - 8, 0, 0, 16, 16, 16, 16);
|
||||
renderKillIndicator(guiGraphics, x - 7.5f + (float) (2 * (Math.random() - 0.5f)), y - 7.5f + (float) (2 * (Math.random() - 0.5f)));
|
||||
} else if (mc.options.getCameraType() != CameraType.FIRST_PERSON) {
|
||||
poseStack.pushPose();
|
||||
float x = (float) p.x;
|
||||
float y = (float) p.y;
|
||||
poseStack.rotateAround(Axis.ZP.rotationDegrees(iHelicopterEntity.getRotZ(partialTick)), x, y, 0);
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/drone.png"), x - 8, y - 8, 0, 0, 16, 16, 16, 16);
|
||||
renderKillIndicator(guiGraphics, x - 7.5f + (float) (2 * (Math.random() - 0.5f)), y - 7.5f + (float) (2 * (Math.random() - 0.5f)));
|
||||
|
||||
poseStack.pushPose();
|
||||
|
||||
if (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON) {
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/helicopter/crosshair_ind.png"), x - 8, y - 8, 0, 0, 16, 16, 16, 16);
|
||||
renderKillIndicator(guiGraphics, x - 7.5f + (float) (2 * (Math.random() - 0.5f)), y - 7.5f + (float) (2 * (Math.random() - 0.5f)));
|
||||
} else if (mc.options.getCameraType() != CameraType.FIRST_PERSON) {
|
||||
poseStack.pushPose();
|
||||
poseStack.rotateAround(Axis.ZP.rotationDegrees(iHelicopterEntity.getRotZ(partialTick)), x, y, 0);
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/drone.png"), x - 8, y - 8, 0, 0, 16, 16, 16, 16);
|
||||
renderKillIndicator(guiGraphics, x - 7.5f + (float) (2 * (Math.random() - 0.5f)), y - 7.5f + (float) (2 * (Math.random() - 0.5f)));
|
||||
poseStack.translate(x, y, 0);
|
||||
poseStack.scale(0.75f, 0.75f, 1);
|
||||
|
||||
poseStack.pushPose();
|
||||
|
||||
poseStack.translate(x, y, 0);
|
||||
poseStack.scale(0.75f, 0.75f, 1);
|
||||
|
||||
if (mobileVehicle instanceof Ah6Entity ah6Entity) {
|
||||
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
||||
double heat = ah6Entity.getEntityData().get(HEAT) / 100.0F;
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("20MM CANNON " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : iHelicopterEntity.getAmmoCount(player))), 25, -9, Mth.hsvToRgb(0F, (float) heat, 1.0F), false);
|
||||
} else {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("70MM ROCKET " + iHelicopterEntity.getAmmoCount(player)), 25, -9, -1, false);
|
||||
}
|
||||
if (mobileVehicle instanceof Ah6Entity ah6Entity) {
|
||||
if (weaponVehicle.getWeaponIndex(0) == 0) {
|
||||
double heat = ah6Entity.getEntityData().get(HEAT) / 100.0F;
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("20MM CANNON " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : iHelicopterEntity.getAmmoCount(player))), 25, -9, Mth.hsvToRgb(0F, (float) heat, 1.0F), false);
|
||||
} else {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("70MM ROCKET " + iHelicopterEntity.getAmmoCount(player)), 25, -9, -1, false);
|
||||
}
|
||||
|
||||
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("FLARE " + iHelicopterEntity.getDecoy()), 25, 1, -1, false);
|
||||
poseStack.popPose();
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
||||
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("FLARE " + iHelicopterEntity.getDecoy()), 25, 1, -1, false);
|
||||
poseStack.popPose();
|
||||
poseStack.popPose();
|
||||
}
|
||||
poseStack.popPose();
|
||||
|
||||
poseStack.popPose();
|
||||
} else {
|
||||
|
|
|
@ -9,9 +9,11 @@ import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
|||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.tools.EntityFindUtil;
|
||||
import com.atsuishio.superbwarfare.tools.SeekTool;
|
||||
import com.atsuishio.superbwarfare.tools.VectorUtil;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
|
@ -49,104 +51,91 @@ public class JavelinHudOverlay implements LayeredDraw.Layer {
|
|||
int h = guiGraphics.guiHeight();
|
||||
Player player = Minecraft.getInstance().player;
|
||||
PoseStack poseStack = guiGraphics.pose();
|
||||
Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera();
|
||||
|
||||
if (player != null) {
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (player == null) return;
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
|
||||
if (ClickHandler.isEditing)
|
||||
return;
|
||||
if (player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player))
|
||||
return;
|
||||
if (ClickHandler.isEditing)
|
||||
return;
|
||||
if (player.getVehicle() instanceof ArmedVehicleEntity iArmedVehicle && iArmedVehicle.banHand(player))
|
||||
return;
|
||||
|
||||
if ((stack.getItem() == ModItems.JAVELIN.get() && ClientEventHandler.zoomPos > 0.8) && Minecraft.getInstance().options.getCameraType().isFirstPerson() && ClientEventHandler.zoom) {
|
||||
var data = GunData.from(stack);
|
||||
var tag = data.tag();
|
||||
if ((stack.getItem() == ModItems.JAVELIN.get() && ClientEventHandler.zoomPos > 0.8) && Minecraft.getInstance().options.getCameraType().isFirstPerson() && ClientEventHandler.zoom) {
|
||||
var data = GunData.from(stack);
|
||||
var tag = data.tag();
|
||||
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.depthMask(false);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
float deltaFrame = Minecraft.getInstance().getTimer().getRealtimeDeltaTicks();
|
||||
float moveX = (float) (-32 * ClientEventHandler.turnRot[1] - (player.isSprinting() ? 100 : 67) * ClientEventHandler.movePosX + 3 * ClientEventHandler.cameraRot[2]);
|
||||
float moveY = (float) (-32 * ClientEventHandler.turnRot[0] + 100 * (float) ClientEventHandler.velocityY - (player.isSprinting() ? 100 : 67) * ClientEventHandler.movePosY - 12 * ClientEventHandler.firePos + 3 * ClientEventHandler.cameraRot[1]);
|
||||
scopeScale = (float) Mth.lerp(0.5F * deltaFrame, scopeScale, 1.35F + (0.2f * ClientEventHandler.firePos));
|
||||
float f = (float) Math.min(w, h);
|
||||
float f1 = Math.min((float) w / f, (float) h / f) * scopeScale;
|
||||
float i = Mth.floor(f * f1);
|
||||
float j = Mth.floor(f * f1);
|
||||
float k = ((w - i) / 2) + moveX;
|
||||
float l = ((h - j) / 2) + moveY;
|
||||
float i1 = k + i;
|
||||
float j1 = l + j;
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/javelin/javelin_hud.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
preciseBlit(guiGraphics, Mod.loc(tag.getBoolean("TopMode") ? "textures/screens/javelin/top.png" : "textures/screens/javelin/dir.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
preciseBlit(guiGraphics, Mod.loc(data.hasEnoughAmmoToShoot(player) ? "textures/screens/javelin/missile_green.png" : "textures/screens/javelin/missile_red.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
if (tag.getInt("SeekTime") > 1 && tag.getInt("SeekTime") < 20) {
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/javelin/seek.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
}
|
||||
poseStack.pushPose();
|
||||
|
||||
guiGraphics.fill(RenderType.guiOverlay(), 0, (int) l, (int) k + 3, (int) j1, -90, -16777216);
|
||||
guiGraphics.fill(RenderType.guiOverlay(), (int) i1, (int) l, w, (int) j1, -90, -16777216);
|
||||
RenderSystem.depthMask(true);
|
||||
RenderSystem.defaultBlendFunc();
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.depthMask(false);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
|
||||
float fovAdjust = (float) Minecraft.getInstance().options.fov().get() / 80;
|
||||
float deltaFrame = Minecraft.getInstance().getTimer().getRealtimeDeltaTicks();
|
||||
float moveX = (float) (-32 * ClientEventHandler.turnRot[1] - (player.isSprinting() ? 100 : 67) * ClientEventHandler.movePosX + 3 * ClientEventHandler.cameraRot[2]);
|
||||
float moveY = (float) (-32 * ClientEventHandler.turnRot[0] + 100 * (float) ClientEventHandler.velocityY - (player.isSprinting() ? 100 : 67) * ClientEventHandler.movePosY - 12 * ClientEventHandler.firePos + 3 * ClientEventHandler.cameraRot[1]);
|
||||
scopeScale = (float) Mth.lerp(0.5F * deltaFrame, scopeScale, 1.35F + (0.2f * ClientEventHandler.firePos));
|
||||
float f = (float) Math.min(w, h);
|
||||
float f1 = Math.min((float) w / f, (float) h / f) * scopeScale;
|
||||
float i = Mth.floor(f * f1);
|
||||
float j = Mth.floor(f * f1);
|
||||
float k = ((w - i) / 2) + moveX;
|
||||
float l = ((h - j) / 2) + moveY;
|
||||
float i1 = k + i;
|
||||
float j1 = l + j;
|
||||
|
||||
Entity targetEntity = EntityFindUtil.findEntity(player.level(), tag.getString("TargetEntity"));
|
||||
List<Entity> entities = SeekTool.seekLivingEntities(player, player.level(), 512, 8 * fovAdjust);
|
||||
Entity naerestEntity = SeekTool.seekLivingEntity(player, player.level(), 512, 6);
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/javelin/javelin_hud.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
preciseBlit(guiGraphics, Mod.loc(tag.getBoolean("TopMode") ? "textures/screens/javelin/top.png" : "textures/screens/javelin/dir.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
preciseBlit(guiGraphics, Mod.loc(data.hasEnoughAmmoToShoot(player) ? "textures/screens/javelin/missile_green.png" : "textures/screens/javelin/missile_red.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
if (tag.getInt("SeekTime") > 1 && tag.getInt("SeekTime") < 20) {
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/javelin/seek.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
}
|
||||
|
||||
float fovAdjust2 = (float) (Minecraft.getInstance().options.fov().get() / 30) - 1;
|
||||
guiGraphics.fill(RenderType.guiOverlay(), 0, (int) l, (int) k + 3, (int) j1, -90, -16777216);
|
||||
guiGraphics.fill(RenderType.guiOverlay(), (int) i1, (int) l, w, (int) j1, -90, -16777216);
|
||||
RenderSystem.depthMask(true);
|
||||
RenderSystem.defaultBlendFunc();
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
|
||||
double zoom = Minecraft.getInstance().options.fov().get() / ClientEventHandler.fov + 0.5 * fovAdjust2;
|
||||
poseStack.popPose();
|
||||
|
||||
Vec3 playerVec = new Vec3(Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), player.xo, player.getX()), Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), player.yo + player.getEyeHeight(), player.getEyeY()), Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), player.zo, player.getZ()));
|
||||
float fovAdjust = (float) Minecraft.getInstance().options.fov().get() / 80;
|
||||
|
||||
if (tag.getInt("GuideType") == 0) {
|
||||
for (var e : entities) {
|
||||
Vec3 pos = new Vec3(Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), e.xo, e.getX()), Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), e.yo + e.getEyeHeight(), e.getEyeY()), Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), e.zo, e.getZ()));
|
||||
Vec3 lookAngle = player.getLookAngle().normalize().scale(pos.distanceTo(playerVec) * (1 - 1.0 / zoom));
|
||||
Entity targetEntity = EntityFindUtil.findEntity(player.level(), tag.getString("TargetEntity"));
|
||||
List<Entity> entities = SeekTool.seekLivingEntities(player, player.level(), 512, 8 * fovAdjust);
|
||||
Entity naerestEntity = SeekTool.seekLivingEntity(player, player.level(), 512, 6);
|
||||
|
||||
var cPos = playerVec.add(lookAngle);
|
||||
Vec3 point = RenderHelper.worldToScreen(pos, cPos);
|
||||
if (point == null) return;
|
||||
poseStack.pushPose();
|
||||
if (tag.getInt("GuideType") == 0) {
|
||||
for (var e : entities) {
|
||||
Vec3 pos = e.getBoundingBox().getCenter();
|
||||
Vec3 point = VectorUtil.worldToScreen(pos);
|
||||
boolean lockOn = tag.getInt("SeekTime") > 20 && e == targetEntity;
|
||||
boolean nearest = e == naerestEntity;
|
||||
|
||||
boolean lockOn = tag.getInt("SeekTime") > 20 && e == targetEntity;
|
||||
boolean nearest = e == naerestEntity;
|
||||
|
||||
poseStack.pushPose();
|
||||
float x = (float) point.x;
|
||||
float y = (float) point.y;
|
||||
|
||||
RenderHelper.preciseBlit(guiGraphics, lockOn ? FRAME_LOCK : nearest ? FRAME_TARGET : FRAME, x - 12, y - 12, 24, 24, 0, 0, 24, 24, 24, 24);
|
||||
poseStack.popPose();
|
||||
}
|
||||
} else {
|
||||
Vec3 pos = new Vec3(tag.getDouble("TargetPosX"), tag.getDouble("TargetPosY"), tag.getDouble("TargetPosZ"));
|
||||
Vec3 lookAngle = player.getLookAngle().normalize().scale(pos.distanceTo(playerVec) * (1 - 1.0 / zoom));
|
||||
|
||||
boolean lockOn = tag.getInt("SeekTime") > 20;
|
||||
|
||||
var cPos = playerVec.add(lookAngle);
|
||||
Vec3 point = RenderHelper.worldToScreen(pos, cPos);
|
||||
if (point == null) return;
|
||||
|
||||
poseStack.pushPose();
|
||||
float x = (float) point.x;
|
||||
float y = (float) point.y;
|
||||
|
||||
RenderHelper.preciseBlit(guiGraphics, lockOn ? FRAME_LOCK : FRAME_TARGET, x - 12, y - 12, 24, 24, 0, 0, 24, 24, 24, 24);
|
||||
poseStack.popPose();
|
||||
RenderHelper.preciseBlit(guiGraphics, lockOn ? FRAME_LOCK : nearest ? FRAME_TARGET : FRAME, x - 12, y - 12, 24, 24, 0, 0, 24, 24, 24, 24);
|
||||
}
|
||||
|
||||
} else {
|
||||
scopeScale = 1;
|
||||
Vec3 pos = new Vec3(tag.getDouble("TargetPosX"), tag.getDouble("TargetPosY"), tag.getDouble("TargetPosZ"));
|
||||
boolean lockOn = tag.getInt("SeekTime") > 20;
|
||||
|
||||
Vec3 point = VectorUtil.worldToScreen(pos);
|
||||
float x = (float) point.x;
|
||||
float y = (float) point.y;
|
||||
|
||||
RenderHelper.preciseBlit(guiGraphics, lockOn ? FRAME_LOCK : FRAME_TARGET, x - 12, y - 12, 24, 24, 0, 0, 24, 24, 24, 24);
|
||||
}
|
||||
poseStack.popPose();
|
||||
} else {
|
||||
scopeScale = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -41,7 +41,7 @@ public class MortarInfoOverlay implements LayeredDraw.Layer {
|
|||
.append(Component.literal(FormatTool.format1D(mortar.getYRot(), "°"))),
|
||||
w / 2 - 90, h / 2 - 16, -1, false);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable("tips.superbwarfare.mortar.range")
|
||||
.append(Component.literal(FormatTool.format1D((int) RangeTool.getRange(-mortar.getXRot(), 11.4, 0.146), "m"))),
|
||||
.append(Component.literal(FormatTool.format1D((int) RangeTool.getRange(-mortar.getXRot(), mortar.shootVelocity(), mortar.projectileGravity()), "m"))),
|
||||
w / 2 - 90, h / 2 - 6, -1, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,10 @@ import com.atsuishio.superbwarfare.client.RenderHelper;
|
|||
import com.atsuishio.superbwarfare.entity.vehicle.base.ArmedVehicleEntity;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.tools.SeekTool;
|
||||
import com.atsuishio.superbwarfare.tools.VectorUtil;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
|
@ -34,6 +36,8 @@ public class RedTriangleOverlay implements LayeredDraw.Layer {
|
|||
public void render(GuiGraphics guiGraphics, DeltaTracker deltaTracker) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
PoseStack poseStack = guiGraphics.pose();
|
||||
Camera camera = mc.gameRenderer.getMainCamera();
|
||||
Vec3 cameraPos = camera.getPosition();
|
||||
|
||||
Player player = mc.player;
|
||||
if (player == null) return;
|
||||
|
@ -45,11 +49,9 @@ public class RedTriangleOverlay implements LayeredDraw.Layer {
|
|||
|
||||
Entity idf = SeekTool.seekLivingEntity(player, player.level(), 128, 6);
|
||||
if (idf == null) return;
|
||||
Vec3 playerVec = new Vec3(Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), player.xo, player.getX()), Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), player.yo + player.getEyeHeight(), player.getEyeY()), Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), player.zo, player.getZ()));
|
||||
double distance = idf.position().distanceTo(playerVec);
|
||||
double distance = idf.position().distanceTo(cameraPos);
|
||||
Vec3 pos = new Vec3(Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), idf.xo, idf.getX()), Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), idf.yo + idf.getEyeHeight() + 0.5 + 0.07 * distance, idf.getEyeY() + 0.5 + 0.07 * distance), Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), idf.zo, idf.getZ()));
|
||||
Vec3 point = RenderHelper.worldToScreen(pos, playerVec);
|
||||
if (point == null) return;
|
||||
Vec3 point = VectorUtil.worldToScreen(pos);
|
||||
|
||||
poseStack.pushPose();
|
||||
float x = (float) point.x;
|
||||
|
|
|
@ -1,18 +1,31 @@
|
|||
package com.atsuishio.superbwarfare.client.overlay;
|
||||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.RenderHelper;
|
||||
import com.atsuishio.superbwarfare.component.ModDataComponents;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
||||
import com.atsuishio.superbwarfare.tools.FormatTool;
|
||||
import com.atsuishio.superbwarfare.tools.TraceTool;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.tools.*;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.CameraType;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.LayeredDraw;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ClipContext;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
@ -21,18 +34,96 @@ import net.neoforged.api.distmarker.OnlyIn;
|
|||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit;
|
||||
import static com.atsuishio.superbwarfare.item.ArtilleryIndicator.TAG_CANNON;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class SpyglassRangeOverlay implements LayeredDraw.Layer {
|
||||
|
||||
public static final ResourceLocation ID = Mod.loc("spyglass_range");
|
||||
public static final ResourceLocation INDICATOR = Mod.loc("textures/screens/indicator.png");
|
||||
public static final ResourceLocation FRIENDLY_INDICATOR = Mod.loc("textures/screens/friendly_indicator.png");
|
||||
private static float scopeScale = 1;
|
||||
|
||||
private static float lerpHoldArtilleryIndicator;
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
public void render(GuiGraphics guiGraphics, DeltaTracker deltaTracker) {
|
||||
int w = guiGraphics.guiWidth();
|
||||
int h = guiGraphics.guiHeight();
|
||||
Player player = Minecraft.getInstance().player;
|
||||
if (player != null && (player.getMainHandItem().getItem() == Items.SPYGLASS || player.getOffhandItem().getItem() == Items.SPYGLASS) && player.isUsingItem()) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
PoseStack poseStack = guiGraphics.pose();
|
||||
Player player = mc.player;
|
||||
Camera camera = mc.gameRenderer.getMainCamera();
|
||||
var screenWidth = guiGraphics.guiWidth();
|
||||
var screenHeight = guiGraphics.guiHeight();
|
||||
|
||||
if (player == null) return;
|
||||
|
||||
lerpHoldArtilleryIndicator = Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), lerpHoldArtilleryIndicator, ClientEventHandler.holdArtilleryIndicator);
|
||||
|
||||
if (ClientEventHandler.holdArtilleryIndicator > 0) {
|
||||
RenderHelper.fill(guiGraphics, RenderType.guiOverlay(), (float) screenWidth / 2 - 40, (float) (screenHeight / 2 + 64), (float) screenWidth / 2 + 40, (float) screenHeight / 2 + 68, -90, -16777216);
|
||||
RenderHelper.fill(guiGraphics, RenderType.guiOverlay(), (float) screenWidth / 2 - 40, (float) (screenHeight / 2 + 64), (float) screenWidth / 2 - 40 + 8 * lerpHoldArtilleryIndicator, (float) screenHeight / 2 + 68, -90, -1);
|
||||
}
|
||||
|
||||
if (((player.isUsingItem() && player.getUseItem().is(ModItems.ARTILLERY_INDICATOR.get())) || player.isScoping()) && mc.options.getCameraType() == CameraType.FIRST_PERSON) {
|
||||
if (player.getUseItem().is(ModItems.ARTILLERY_INDICATOR.get())) {
|
||||
ItemStack stack = player.getUseItem();
|
||||
poseStack.pushPose();
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.depthMask(false);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexShader);
|
||||
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
|
||||
float deltaFrame = Minecraft.getInstance().getTimer().getRealtimeDeltaTicks();
|
||||
scopeScale = (float) Mth.lerp(0.5F * deltaFrame, scopeScale, 1.35F + (0.2f * ClientEventHandler.firePos));
|
||||
float f = (float) Math.min(screenWidth, screenHeight);
|
||||
float f1 = Math.min((float) screenWidth / f, (float) screenHeight / f) * scopeScale;
|
||||
float i = Mth.floor(f * f1);
|
||||
float j = Mth.floor(f * f1);
|
||||
float k = ((screenWidth - i) / 2);
|
||||
float l = ((screenHeight - j) / 2);
|
||||
float w = i * 21 / 9;
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/spyglass.png"), k - (2 * w / 7), l, 0, 0.0F, w, j, w, j);
|
||||
|
||||
// 标记位置
|
||||
Vec3 pos;
|
||||
var parameters = stack.get(ModDataComponents.FIRING_PARAMETERS);
|
||||
if (parameters != null) {
|
||||
var blockPos = parameters.pos();
|
||||
pos = new Vec3(blockPos.getX() - 0.5, blockPos.getY() + 0.5, blockPos.getZ() + 0.5);
|
||||
} else {
|
||||
pos = Vec3.ZERO;
|
||||
}
|
||||
Vec3 point = VectorUtil.worldToScreen(pos);
|
||||
if (VectorUtil.canSee(pos)) {
|
||||
float x = (float) point.x;
|
||||
float y = (float) point.y;
|
||||
preciseBlit(guiGraphics, INDICATOR, Mth.clamp(x - 6, 0, screenWidth - 12), Mth.clamp(y - 6, 0, screenHeight - 12), 0, 0, 12, 12, 12, 12);
|
||||
}
|
||||
|
||||
// 火炮位置
|
||||
|
||||
ListTag tags = NBTTool.getTag(stack).getList(TAG_CANNON, Tag.TAG_COMPOUND);
|
||||
for (int m = 0; m < tags.size(); m++) {
|
||||
var tag = tags.getCompound(m);
|
||||
Entity entity = EntityFindUtil.findEntity(player.level(), tag.getString("UUID"));
|
||||
if (entity != null) {
|
||||
Vec3 posF = entity.getBoundingBox().getCenter();
|
||||
Vec3 pointF = VectorUtil.worldToScreen(posF);
|
||||
if (VectorUtil.canSee(posF)) {
|
||||
float xf = (float) pointF.x;
|
||||
float yf = (float) pointF.y;
|
||||
preciseBlit(guiGraphics, FRIENDLY_INDICATOR, Mth.clamp(xf - 6, 0, screenWidth - 12), Mth.clamp(yf - 6, 0, screenHeight - 12), 0, 0, 12, 12, 12, 12);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
||||
boolean lookAtEntity = false;
|
||||
|
||||
BlockHitResult result = player.level().clip(new ClipContext(player.getEyePosition(), player.getEyePosition().add(player.getViewVector(1).scale(512)),
|
||||
|
@ -54,17 +145,19 @@ public class SpyglassRangeOverlay implements LayeredDraw.Layer {
|
|||
if (lookAtEntity) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable("tips.superbwarfare.drone.range")
|
||||
.append(Component.literal(FormatTool.format1D(entityRange, "M ") + lookingEntity.getDisplayName().getString())),
|
||||
w / 2 + 12, h / 2 - 28, -1, false);
|
||||
screenWidth / 2 + 12, screenHeight / 2 - 28, -1, false);
|
||||
} else {
|
||||
if (blockRange > 500) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable("tips.superbwarfare.drone.range")
|
||||
.append(Component.literal("---M")), w / 2 + 12, h / 2 - 28, -1, false);
|
||||
.append(Component.literal("---M")), screenWidth / 2 + 12, screenHeight / 2 - 28, -1, false);
|
||||
} else {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable("tips.superbwarfare.drone.range")
|
||||
.append(Component.literal(FormatTool.format1D(blockRange, "M"))),
|
||||
w / 2 + 12, h / 2 - 28, -1, false);
|
||||
screenWidth / 2 + 12, screenHeight / 2 - 28, -1, false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
scopeScale = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,163 @@
|
|||
package com.atsuishio.superbwarfare.client.overlay;
|
||||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.component.ModDataComponents;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.Type63Entity;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.item.FiringParameters;
|
||||
import com.atsuishio.superbwarfare.tools.*;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.LayeredDraw;
|
||||
import net.minecraft.commands.arguments.EntityAnchorArgument;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static com.atsuishio.superbwarfare.entity.vehicle.Type63Entity.SHOOT_PITCH;
|
||||
import static com.atsuishio.superbwarfare.entity.vehicle.Type63Entity.SHOOT_YAW;
|
||||
import static com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity.getXRotFromVector;
|
||||
import static com.atsuishio.superbwarfare.tools.RangeTool.calculateLaunchVector;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class Type63InfoOverlay implements LayeredDraw.Layer {
|
||||
|
||||
public static final ResourceLocation ID = Mod.loc("type_63_info");
|
||||
|
||||
private static final ItemStack AP = new ItemStack(ModItems.MEDIUM_ROCKET_AP.get());
|
||||
private static final ItemStack HE = new ItemStack(ModItems.MEDIUM_ROCKET_HE.get());
|
||||
private static final ItemStack CM = new ItemStack(ModItems.MEDIUM_ROCKET_CM.get());
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics guiGraphics, @NotNull DeltaTracker deltaTracker) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
Player player = mc.player;
|
||||
PoseStack poseStack = guiGraphics.pose();
|
||||
|
||||
if (player == null) return;
|
||||
|
||||
var screenWidth = guiGraphics.guiWidth();
|
||||
var screenHeight = guiGraphics.guiHeight();
|
||||
var partialTick = deltaTracker.getGameTimeDeltaPartialTick(true);
|
||||
|
||||
Entity lookingEntity = TraceTool.findLookingEntity(player, player.entityInteractionRange());
|
||||
|
||||
if (!(lookingEntity instanceof Type63Entity type63Entity)) return;
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable("tips.superbwarfare.mortar.pitch")
|
||||
.append(Component.literal(FormatTool.format2D(type63Entity.getEntityData().get(SHOOT_PITCH), "°"))),
|
||||
screenWidth / 2 - 130, screenHeight / 2 - 26, -1, false);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable("tips.superbwarfare.mortar.yaw")
|
||||
.append(Component.literal(FormatTool.format2D(type63Entity.getEntityData().get(SHOOT_YAW), "°"))),
|
||||
screenWidth / 2 - 130, screenHeight / 2 - 16, -1, false);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable("tips.superbwarfare.mortar.range")
|
||||
.append(Component.literal(FormatTool.format1D(Math.max((int) RangeTool.getRange(type63Entity.getEntityData().get(SHOOT_PITCH), 10, 0.05), 0) , "m"))),
|
||||
screenWidth / 2 - 130, screenHeight / 2 - 6, -1, false);
|
||||
|
||||
var items = type63Entity.getEntityData().get(Type63Entity.LOADED_AMMO);
|
||||
for (int i = 0; i < type63Entity.barrel.length; i++) {
|
||||
if (OBB.getLookingObb(player, player.entityInteractionRange()) == type63Entity.barrel[i]) {
|
||||
int type = items.get(i);
|
||||
|
||||
ItemStack stack = switch (type) {
|
||||
case 0 -> AP;
|
||||
case 1 -> HE;
|
||||
case 2 -> CM;
|
||||
default -> ItemStack.EMPTY;
|
||||
};
|
||||
|
||||
Vec3 pos = new Vec3(type63Entity.barrel[i].center());
|
||||
Vec3 point = VectorUtil.worldToScreen(pos);
|
||||
|
||||
poseStack.pushPose();
|
||||
float x = (float) point.x;
|
||||
float y = (float) point.y;
|
||||
|
||||
var component = stack.getHoverName();
|
||||
|
||||
if (stack.isEmpty()) {
|
||||
component = Component.translatable("tips.superbwarfare.barrel_empty");
|
||||
int width = Minecraft.getInstance().font.width(component);
|
||||
|
||||
poseStack.translate(x - width / 2F, y, 0);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, component, 0, 0, -1, false);
|
||||
} else {
|
||||
int width = Minecraft.getInstance().font.width(component) + 20;
|
||||
|
||||
poseStack.pushPose();
|
||||
poseStack.translate(x - width / 2F, y, 0);
|
||||
guiGraphics.renderFakeItem(stack, 0, 0);
|
||||
|
||||
poseStack.translate(20, 4, 0);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, component, 0, 0, -1, false);
|
||||
}
|
||||
|
||||
poseStack.popPose();
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack stack = player.getOffhandItem();
|
||||
|
||||
if (player.getMainHandItem().getItem() instanceof FiringParameters) {
|
||||
stack = player.getMainHandItem();
|
||||
}
|
||||
|
||||
if (stack.getItem() instanceof FiringParameters) {
|
||||
var parameters = stack.get(ModDataComponents.FIRING_PARAMETERS);
|
||||
if (parameters == null) {
|
||||
parameters = new FiringParameters.Parameters(new BlockPos(0, 0, 0));
|
||||
}
|
||||
double targetX = parameters.pos().getX();
|
||||
double targetY = parameters.pos().getY() - 1;
|
||||
double targetZ = parameters.pos().getZ();
|
||||
boolean isDepressed = parameters.isDepressed();
|
||||
|
||||
Vec3 targetPos = new Vec3(targetX, targetY, targetZ);
|
||||
Vec3 launchVector = calculateLaunchVector(type63Entity.getShootPos(partialTick), targetPos, 10, 0.05, isDepressed);
|
||||
|
||||
Vec3 vec3 = EntityAnchorArgument.Anchor.EYES.apply(lookingEntity);
|
||||
double d0 = (targetPos.x - vec3.x) * 0.2;
|
||||
double d2 = (targetPos.z - vec3.z) * 0.2;
|
||||
double targetYaw = Mth.wrapDegrees((float) (Mth.atan2(d2, d0) * 57.2957763671875) - 90.0F);
|
||||
|
||||
float angle = 0;
|
||||
|
||||
if (launchVector != null) {
|
||||
angle = (float) getXRotFromVector(launchVector);
|
||||
} else {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable("tips.superbwarfare.mortar.out_of_range").withStyle(ChatFormatting.RED),
|
||||
screenWidth / 2 + 90, screenHeight / 2 - 26, -1, false);
|
||||
return;
|
||||
}
|
||||
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable("tips.superbwarfare.target.pitch")
|
||||
.append(Component.literal(FormatTool.format2D(angle, "°"))),
|
||||
screenWidth / 2 + 90, screenHeight / 2 - 26, -1, false);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable("tips.superbwarfare.target.yaw")
|
||||
.append(Component.literal(FormatTool.format2D(targetYaw, "°"))),
|
||||
screenWidth / 2 + 90, screenHeight / 2 - 16, -1, false);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable("tips.superbwarfare.mortar.target_pos")
|
||||
.append(Component.literal(FormatTool.format0D(targetX) + " " + FormatTool.format0D(targetY) + " " + FormatTool.format0D(targetZ))),
|
||||
screenWidth / 2 + 90, screenHeight / 2 - 6, -1, false);
|
||||
|
||||
if (angle < -5 || angle > 60) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable("tips.superbwarfare.mortar.warn", lookingEntity.getDisplayName()).withStyle(ChatFormatting.RED),
|
||||
screenWidth / 2 + 90, screenHeight / 2 + 4, -1, false);
|
||||
if (angle > 60 && !isDepressed) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.translatable("tips.superbwarfare.ballistics.warn").withStyle(ChatFormatting.RED),
|
||||
screenWidth / 2 + 90, screenHeight / 2 + 14, -1, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,19 +1,15 @@
|
|||
package com.atsuishio.superbwarfare.client.overlay;
|
||||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.RenderHelper;
|
||||
import com.atsuishio.superbwarfare.config.client.DisplayConfig;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.SpeedboatEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.*;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.weapon.HeliRocketWeapon;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.weapon.LaserWeapon;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.weapon.SmallRocketWeapon;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.weapon.SwarmDroneWeapon;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.tools.FormatTool;
|
||||
import com.atsuishio.superbwarfare.tools.InventoryTool;
|
||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
||||
import com.atsuishio.superbwarfare.tools.TraceTool;
|
||||
import com.atsuishio.superbwarfare.tools.*;
|
||||
import com.atsuishio.superbwarfare.tools.animation.AnimationCurves;
|
||||
import com.atsuishio.superbwarfare.tools.animation.AnimationTimer;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
@ -103,9 +99,9 @@ public class VehicleHudOverlay implements LayeredDraw.Layer {
|
|||
|
||||
int compatHeight = getArmorPlateCompatHeight(player);
|
||||
|
||||
if (vehicle instanceof EnergyVehicleEntity energyVehicleEntity) {
|
||||
float energy = energyVehicleEntity.getEnergy();
|
||||
float maxEnergy = energyVehicleEntity.getMaxEnergy();
|
||||
if (vehicle instanceof VehicleEntity vehicleEntity && vehicleEntity.hasEnergyStorage()) {
|
||||
float energy = vehicleEntity.getEnergy();
|
||||
float maxEnergy = vehicleEntity.getMaxEnergy();
|
||||
preciseBlit(guiGraphics, ENERGY, 10, h - 22 - compatHeight, 100, 0, 0, 8, 8, 8, 8);
|
||||
preciseBlit(guiGraphics, HEALTH_FRAME, 20, h - 21 - compatHeight, 100, 0, 0, 60, 6, 60, 6);
|
||||
preciseBlit(guiGraphics, HEALTH, 20, h - 21 - compatHeight, 100, 0, 0, (int) (60 * energy / maxEnergy), 6, 60, 6);
|
||||
|
@ -159,6 +155,7 @@ public class VehicleHudOverlay implements LayeredDraw.Layer {
|
|||
PoseStack poseStack = guiGraphics.pose();
|
||||
Camera camera = mc.gameRenderer.getMainCamera();
|
||||
Vec3 cameraPos = camera.getPosition();
|
||||
Vec3 viewVec = new Vec3(camera.getLookVector());
|
||||
|
||||
assert player != null;
|
||||
|
||||
|
@ -254,12 +251,14 @@ public class VehicleHudOverlay implements LayeredDraw.Layer {
|
|||
w / 2 + 160, h / 2 - 48, 0x66FF00, false);
|
||||
|
||||
// 低电量警告
|
||||
if (mobileVehicle.getEnergy() < 0.02 * mobileVehicle.getMaxEnergy()) {
|
||||
guiGraphics.drawString(mc.font, Component.literal("NO POWER!"),
|
||||
w / 2 - 144, h / 2 + 14, -65536, false);
|
||||
} else if (mobileVehicle.getEnergy() < 0.2 * mobileVehicle.getMaxEnergy()) {
|
||||
guiGraphics.drawString(mc.font, Component.literal("LOW POWER"),
|
||||
w / 2 - 144, h / 2 + 14, 0xFF6B00, false);
|
||||
if (mobileVehicle.hasEnergyStorage()) {
|
||||
if (mobileVehicle.getEnergy() < 0.02 * mobileVehicle.getMaxEnergy()) {
|
||||
guiGraphics.drawString(mc.font, Component.literal("NO POWER!"),
|
||||
w / 2 - 144, h / 2 + 14, -65536, false);
|
||||
} else if (mobileVehicle.getEnergy() < 0.2 * mobileVehicle.getMaxEnergy()) {
|
||||
guiGraphics.drawString(mc.font, Component.literal("LOW POWER"),
|
||||
w / 2 - 144, h / 2 + 14, 0xFF6B00, false);
|
||||
}
|
||||
}
|
||||
|
||||
// 测距
|
||||
|
@ -273,7 +272,7 @@ public class VehicleHudOverlay implements LayeredDraw.Layer {
|
|||
|
||||
double entityRange = 0;
|
||||
|
||||
Entity lookingEntity = TraceTool.camerafFindLookingEntity(player, cameraPos, 512, deltaTracker.getRealtimeDeltaTicks());
|
||||
Entity lookingEntity = TraceTool.camerafFindLookingEntity(player, cameraPos, viewVec, 512);
|
||||
if (lookingEntity != null) {
|
||||
lookAtEntity = true;
|
||||
entityRange = player.distanceTo(lookingEntity);
|
||||
|
@ -304,36 +303,34 @@ public class VehicleHudOverlay implements LayeredDraw.Layer {
|
|||
|
||||
renderKillIndicator(guiGraphics, w, h);
|
||||
} else if (Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK && !ClientEventHandler.zoomVehicle) {
|
||||
Vec3 p = RenderHelper.worldToScreen(new Vec3(Mth.lerp(partialTick, player.xo, player.getX()), Mth.lerp(partialTick, player.yo + player.getEyeHeight(), player.getEyeY()), Mth.lerp(partialTick, player.zo, player.getZ())).add(iLand.getBarrelVec(partialTick).scale(192)), cameraPos);
|
||||
Vec3 p = VectorUtil.worldToScreen(new Vec3(Mth.lerp(partialTick, player.xo, player.getX()), Mth.lerp(partialTick, player.yo + player.getEyeHeight(), player.getEyeY()), Mth.lerp(partialTick, player.zo, player.getZ())).add(iLand.getBarrelVec(partialTick).scale(192)));
|
||||
// 第三人称准星
|
||||
if (p != null) {
|
||||
poseStack.pushPose();
|
||||
float x = (float) p.x;
|
||||
float y = (float) p.y;
|
||||
poseStack.pushPose();
|
||||
float x = (float) p.x;
|
||||
float y = (float) p.y;
|
||||
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/drone.png"), x - 12, y - 12, 0, 0, 24, 24, 24, 24);
|
||||
renderKillIndicator3P(guiGraphics, x - 7.5f + (float) (2 * (Math.random() - 0.5f)), y - 7.5f + (float) (2 * (Math.random() - 0.5f)));
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/drone.png"), x - 12, y - 12, 0, 0, 24, 24, 24, 24);
|
||||
renderKillIndicator3P(guiGraphics, x - 7.5f + (float) (2 * (Math.random() - 0.5f)), y - 7.5f + (float) (2 * (Math.random() - 0.5f)));
|
||||
|
||||
poseStack.pushPose();
|
||||
poseStack.pushPose();
|
||||
|
||||
poseStack.translate(x, y, 0);
|
||||
poseStack.scale(0.75f, 0.75f, 1);
|
||||
poseStack.translate(x, y, 0);
|
||||
poseStack.scale(0.75f, 0.75f, 1);
|
||||
|
||||
// 载具自定义第三人称准心
|
||||
mobileVehicle.renderThirdPersonOverlay(guiGraphics, mc.font, player, w, h, scale);
|
||||
// 载具自定义第三人称准心
|
||||
mobileVehicle.renderThirdPersonOverlay(guiGraphics, mc.font, player, w, h, scale);
|
||||
|
||||
double health = 1 - mobileVehicle.getHealth() / mobileVehicle.getMaxHealth();
|
||||
double health = 1 - mobileVehicle.getHealth() / mobileVehicle.getMaxHealth();
|
||||
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("HP " +
|
||||
FormatTool.format0D(100 * mobileVehicle.getHealth() / mobileVehicle.getMaxHealth())), 30, 1, Mth.hsvToRgb(0F, (float) health, 1.0F), false);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("HP " +
|
||||
FormatTool.format0D(100 * mobileVehicle.getHealth() / mobileVehicle.getMaxHealth())), 30, 1, Mth.hsvToRgb(0F, (float) health, 1.0F), false);
|
||||
|
||||
if (mobileVehicle.hasDecoy()) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("SMOKE " + mobileVehicle.getEntityData().get(DECOY_COUNT)), 30, 11, -1, false);
|
||||
}
|
||||
|
||||
poseStack.popPose();
|
||||
poseStack.popPose();
|
||||
if (mobileVehicle.hasDecoy()) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("SMOKE " + mobileVehicle.getEntityData().get(DECOY_COUNT)), 30, 11, -1, false);
|
||||
}
|
||||
|
||||
poseStack.popPose();
|
||||
poseStack.popPose();
|
||||
}
|
||||
poseStack.popPose();
|
||||
} else {
|
||||
|
@ -516,7 +513,7 @@ public class VehicleHudOverlay implements LayeredDraw.Layer {
|
|||
);
|
||||
|
||||
preciseBlit(guiGraphics, SELECTED, w - 95, startY, 100, 0, 0, 8, 8, 8, 8);
|
||||
if (InventoryTool.hasCreativeAmmoBox(player) && !(weapon instanceof LaserWeapon) && !(weapon instanceof HeliRocketWeapon) && !(weapon instanceof SwarmDroneWeapon)) {
|
||||
if (InventoryTool.hasCreativeAmmoBox(player) && !(weapon instanceof LaserWeapon) && !(weapon instanceof SmallRocketWeapon) && !(weapon instanceof SwarmDroneWeapon)) {
|
||||
preciseBlit(guiGraphics, NUMBER, w - 28 + xOffset, h - frameIndex * 18 - 15, 100, 58, 0, 10, 7.5f, 75, 7.5f);
|
||||
} else {
|
||||
renderNumber(guiGraphics, weaponVehicle.getAmmoCount(player), weapon instanceof LaserWeapon,
|
||||
|
|
|
@ -10,10 +10,10 @@ import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity;
|
|||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.tools.FormatTool;
|
||||
import com.atsuishio.superbwarfare.tools.InventoryTool;
|
||||
import com.atsuishio.superbwarfare.tools.VectorUtil;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.CameraType;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -51,8 +51,6 @@ public class VehicleMgHudOverlay implements LayeredDraw.Layer {
|
|||
Minecraft mc = Minecraft.getInstance();
|
||||
Player player = mc.player;
|
||||
PoseStack poseStack = guiGraphics.pose();
|
||||
Camera camera = mc.gameRenderer.getMainCamera();
|
||||
Vec3 cameraPos = camera.getPosition();
|
||||
|
||||
if (!shouldRenderCrossHair(player)) return;
|
||||
|
||||
|
@ -79,45 +77,43 @@ public class VehicleMgHudOverlay implements LayeredDraw.Layer {
|
|||
RenderHelper.preciseBlit(guiGraphics, Mod.loc("textures/screens/cannon/cannon_crosshair_notzoom.png"), k, l, 0, 0.0F, i, j, i, j);
|
||||
VehicleHudOverlay.renderKillIndicator(guiGraphics, w, h);
|
||||
} else if (Minecraft.getInstance().options.getCameraType() == CameraType.THIRD_PERSON_BACK && !ClientEventHandler.zoomVehicle) {
|
||||
Vec3 p = RenderHelper.worldToScreen(new Vec3(Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), player.xo, player.getX()), Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), player.yo + player.getEyeHeight(), player.getEyeY()),
|
||||
Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), player.zo, player.getZ())).add(iLand.getGunVec(deltaTracker.getGameTimeDeltaPartialTick(true)).scale(192)), cameraPos);
|
||||
Vec3 p = VectorUtil.worldToScreen(new Vec3(Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), player.xo, player.getX()), Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), player.yo + player.getEyeHeight(), player.getEyeY()),
|
||||
Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), player.zo, player.getZ())).add(iLand.getGunVec(deltaTracker.getGameTimeDeltaPartialTick(true)).scale(192)));
|
||||
|
||||
// 第三人称准星
|
||||
if (p != null) {
|
||||
poseStack.pushPose();
|
||||
float x = (float) p.x;
|
||||
float y = (float) p.y;
|
||||
poseStack.pushPose();
|
||||
float x = (float) p.x;
|
||||
float y = (float) p.y;
|
||||
|
||||
poseStack.pushPose();
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/drone.png"), x - 12, y - 12, 0, 0, 24, 24, 24, 24);
|
||||
renderKillIndicator3P(guiGraphics, x - 7.5f + (float) (2 * (Math.random() - 0.5f)), y - 7.5f + (float) (2 * (Math.random() - 0.5f)));
|
||||
poseStack.pushPose();
|
||||
preciseBlit(guiGraphics, Mod.loc("textures/screens/drone.png"), x - 12, y - 12, 0, 0, 24, 24, 24, 24);
|
||||
renderKillIndicator3P(guiGraphics, x - 7.5f + (float) (2 * (Math.random() - 0.5f)), y - 7.5f + (float) (2 * (Math.random() - 0.5f)));
|
||||
|
||||
poseStack.pushPose();
|
||||
poseStack.pushPose();
|
||||
|
||||
poseStack.translate(x, y, 0);
|
||||
poseStack.scale(0.75f, 0.75f, 1);
|
||||
poseStack.translate(x, y, 0);
|
||||
poseStack.scale(0.75f, 0.75f, 1);
|
||||
|
||||
// YX-100
|
||||
if (player.getVehicle() instanceof Yx100Entity yx100) {
|
||||
double heat = yx100.getEntityData().get(HEAT) / 100.0F;
|
||||
guiGraphics.drawString(mc.font, Component.literal(".50 HMG " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getEntityData().get(MG_AMMO))), 30, -9, Mth.hsvToRgb(0F, (float) heat, 1.0F), false);
|
||||
}
|
||||
|
||||
// 快艇
|
||||
if (player.getVehicle() instanceof SpeedboatEntity speedboat) {
|
||||
double heat = speedboat.getEntityData().get(HEAT) / 100.0F;
|
||||
guiGraphics.drawString(mc.font, Component.literal(".50 HMG " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : speedboat.getEntityData().get(AMMO))), 30, -9, Mth.hsvToRgb(0F, (float) heat, 1.0F), false);
|
||||
}
|
||||
|
||||
double heal = 1 - mobileVehicle.getHealth() / mobileVehicle.getMaxHealth();
|
||||
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("HP " +
|
||||
FormatTool.format0D(100 * mobileVehicle.getHealth() / mobileVehicle.getMaxHealth())), 30, 1, Mth.hsvToRgb(0F, (float) heal, 1.0F), false);
|
||||
|
||||
poseStack.popPose();
|
||||
poseStack.popPose();
|
||||
poseStack.popPose();
|
||||
// YX-100
|
||||
if (player.getVehicle() instanceof Yx100Entity yx100) {
|
||||
double heat = yx100.getEntityData().get(HEAT) / 100.0F;
|
||||
guiGraphics.drawString(mc.font, Component.literal(".50 HMG " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : yx100.getEntityData().get(MG_AMMO))), 30, -9, Mth.hsvToRgb(0F, (float) heat, 1.0F), false);
|
||||
}
|
||||
|
||||
// 快艇
|
||||
if (player.getVehicle() instanceof SpeedboatEntity speedboat) {
|
||||
double heat = speedboat.getEntityData().get(HEAT) / 100.0F;
|
||||
guiGraphics.drawString(mc.font, Component.literal(".50 HMG " + (InventoryTool.hasCreativeAmmoBox(player) ? "∞" : speedboat.getEntityData().get(AMMO))), 30, -9, Mth.hsvToRgb(0F, (float) heat, 1.0F), false);
|
||||
}
|
||||
|
||||
double heal = 1 - mobileVehicle.getHealth() / mobileVehicle.getMaxHealth();
|
||||
|
||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal("HP " +
|
||||
FormatTool.format0D(100 * mobileVehicle.getHealth() / mobileVehicle.getMaxHealth())), 30, 1, Mth.hsvToRgb(0F, (float) heal, 1.0F), false);
|
||||
|
||||
poseStack.popPose();
|
||||
poseStack.popPose();
|
||||
poseStack.popPose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
package com.atsuishio.superbwarfare.client.overlay;
|
||||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.RenderHelper;
|
||||
import com.atsuishio.superbwarfare.config.client.DisplayConfig;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.tools.FormatTool;
|
||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
||||
import com.atsuishio.superbwarfare.tools.TraceTool;
|
||||
import com.atsuishio.superbwarfare.tools.*;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.LayeredDraw;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -23,6 +24,10 @@ import net.neoforged.api.distmarker.Dist;
|
|||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.List;
|
||||
|
||||
import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit;
|
||||
import static com.atsuishio.superbwarfare.client.overlay.SpyglassRangeOverlay.FRIENDLY_INDICATOR;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class VehicleTeamOverlay implements LayeredDraw.Layer {
|
||||
|
@ -34,12 +39,11 @@ public class VehicleTeamOverlay implements LayeredDraw.Layer {
|
|||
public void render(GuiGraphics guiGraphics, DeltaTracker deltaTracker) {
|
||||
if (!DisplayConfig.VEHICLE_INFO.get()) return;
|
||||
|
||||
int w = guiGraphics.guiWidth();
|
||||
int h = guiGraphics.guiHeight();
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
Player player = mc.player;
|
||||
Camera camera = mc.gameRenderer.getMainCamera();
|
||||
Vec3 cameraPos = camera.getPosition();
|
||||
Vec3 viewVec = new Vec3(camera.getLookVector());
|
||||
PoseStack poseStack = guiGraphics.pose();
|
||||
if (player == null) return;
|
||||
|
||||
|
@ -50,29 +54,76 @@ public class VehicleTeamOverlay implements LayeredDraw.Layer {
|
|||
boolean lookAtEntity = false;
|
||||
|
||||
double entityRange = 0;
|
||||
Entity lookingEntity = TraceTool.camerafFindLookingEntity(player, cameraPos, 512, deltaTracker.getRealtimeDeltaTicks());
|
||||
Entity lookingEntity = TraceTool.camerafFindLookingEntity(player, cameraPos, viewVec, 512);
|
||||
|
||||
if (lookingEntity instanceof VehicleEntity) {
|
||||
if (lookingEntity != null) {
|
||||
lookAtEntity = true;
|
||||
entityRange = player.distanceTo(lookingEntity);
|
||||
}
|
||||
|
||||
if (lookAtEntity) {
|
||||
if (lookAtEntity && lookingEntity instanceof VehicleEntity vehicle) {
|
||||
Vec3 pos = lookingEntity.getBoundingBox().getCenter().add(new Vec3(0, lookingEntity.getBbHeight() / 2 + 1, 0));
|
||||
Vec3 point = VectorUtil.worldToScreen(pos);
|
||||
|
||||
float x = (float) point.x;
|
||||
float y = (float) point.y;
|
||||
|
||||
poseStack.pushPose();
|
||||
poseStack.scale(0.8f, 0.8f, 1);
|
||||
if (lookingEntity.getFirstPassenger() instanceof Player passenger) {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font,
|
||||
Component.literal(passenger.getDisplayName().getString() + (passenger.getTeam() == null ? "" : " <" + (passenger.getTeam().getName()) + ">")),
|
||||
w / 2 + 90, h / 2 - 4, passenger.getTeamColor(), false);
|
||||
guiGraphics.drawString(Minecraft.getInstance().font,
|
||||
Component.literal(lookingEntity.getDisplayName().getString() + " " + FormatTool.format1D(entityRange, "m")),
|
||||
w / 2 + 90, h / 2 + 5, passenger.getTeamColor(), false);
|
||||
poseStack.translate(x, y - 12, 0);
|
||||
|
||||
float size = (float) Mth.clamp((50 / VectorUtil.fov) * 0.9f * Math.max((512 - entityRange) / 512, 0.1), 0.4, 1);
|
||||
poseStack.scale(size, size, size);
|
||||
var font = Minecraft.getInstance().font;
|
||||
|
||||
int color = -1;
|
||||
|
||||
if (lookingEntity.getFirstPassenger() instanceof Player player1) {
|
||||
color = player1.getTeamColor();
|
||||
String info = player1.getDisplayName().getString() + (player1.getTeam() == null ? "" : " <" + (player1.getTeam().getName()) + ">");
|
||||
int width = Minecraft.getInstance().font.width(info);
|
||||
guiGraphics.drawString(font, Component.literal(info), -width / 2, -13, color, false);
|
||||
} else {
|
||||
guiGraphics.drawString(Minecraft.getInstance().font,
|
||||
Component.literal(lookingEntity.getDisplayName().getString() + " " + FormatTool.format1D(entityRange, "M")),
|
||||
w / 2 + 90, h / 2 + 5, -1, false);
|
||||
String info = lookingEntity.getDisplayName().getString();
|
||||
int width = Minecraft.getInstance().font.width(info);
|
||||
guiGraphics.drawString(font, Component.literal(info), -width / 2, -13, color, false);
|
||||
}
|
||||
|
||||
String range = FormatTool.format1D(entityRange, "M");
|
||||
int width2 = Minecraft.getInstance().font.width(range);
|
||||
guiGraphics.drawString(font, Component.literal(range), -width2 / 2, 7, color, false);
|
||||
|
||||
RenderHelper.fill(guiGraphics, RenderType.guiOverlay(), -40, -2, 40, 2, 0, -16777216);
|
||||
RenderHelper.fill(guiGraphics, RenderType.guiOverlay(), -40, -2, -40 + 80 * (vehicle.getHealth() / vehicle.getMaxHealth()), 2, 0, -1);
|
||||
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
||||
var partialTick = deltaTracker.getGameTimeDeltaPartialTick(true);
|
||||
var screenWidth = guiGraphics.guiWidth();
|
||||
var screenHeight = guiGraphics.guiHeight();
|
||||
|
||||
if (player.getVehicle() instanceof VehicleEntity) {
|
||||
List<Entity> entities = SeekTool.getPlayer(player, player.level());
|
||||
for (var e : entities) {
|
||||
if (e != null && e != player && VectorUtil.canSee(e.position())) {
|
||||
Entity team = e;
|
||||
if (e.getVehicle() != null) {
|
||||
team = e.getVehicle();
|
||||
}
|
||||
Vec3 pos = new Vec3(Mth.lerp(partialTick, team.xo, team.getX()), Mth.lerp(partialTick, team.yo + team.getBbHeight() / 2, team.getY() + team.getBbHeight() / 2), Mth.lerp(partialTick, team.zo, team.getZ()));
|
||||
Vec3 point = VectorUtil.worldToScreen(pos);
|
||||
float xf = (float) point.x;
|
||||
float yf = (float) point.y;
|
||||
|
||||
preciseBlit(guiGraphics, FRIENDLY_INDICATOR, Mth.clamp(xf - 6, 0, screenWidth - 12), Mth.clamp(yf - 6, 0, screenHeight - 12), 0, 0, 12, 12, 12, 12);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static double calculateAngle(Entity entityA, Camera camera) {
|
||||
Vec3 v1 = camera.getPosition().vectorTo(entityA.position());
|
||||
Vec3 v2 = new Vec3(camera.getLookVector());
|
||||
return VectorTool.calculateAngle(v1,v2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ package com.atsuishio.superbwarfare.client.overlay;
|
|||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.RenderHelper;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.Yx100Entity;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.tools.SeekTool;
|
||||
import com.atsuishio.superbwarfare.tools.VectorUtil;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
@ -67,22 +67,10 @@ public class Yx100SwarmDroneHudOverlay implements LayeredDraw.Layer {
|
|||
VehicleHudOverlay.renderKillIndicator(guiGraphics, w, h);
|
||||
Entity naerestEntity = SeekTool.seekLivingEntity(player, player.level(), 384, 6);
|
||||
|
||||
float fovAdjust2 = (float) (Minecraft.getInstance().options.fov().get() / 30) - 1;
|
||||
|
||||
double zoom = 1;
|
||||
|
||||
if (ClientEventHandler.zoomVehicle) {
|
||||
zoom = Minecraft.getInstance().options.fov().get() / ClientEventHandler.fov + 0.05 * fovAdjust2;
|
||||
}
|
||||
|
||||
if (naerestEntity != null) {
|
||||
Vec3 playerVec = new Vec3(Mth.lerp(deltaTracker.getRealtimeDeltaTicks(), player.xo, player.getX()), Mth.lerp(deltaTracker.getRealtimeDeltaTicks(), player.yo + player.getEyeHeight(), player.getEyeY()), Mth.lerp(deltaTracker.getRealtimeDeltaTicks(), player.zo, player.getZ()));
|
||||
Vec3 pos = new Vec3(Mth.lerp(deltaTracker.getRealtimeDeltaTicks(), naerestEntity.xo, naerestEntity.getX()), Mth.lerp(deltaTracker.getRealtimeDeltaTicks(), naerestEntity.yo + naerestEntity.getEyeHeight(), naerestEntity.getEyeY()), Mth.lerp(deltaTracker.getRealtimeDeltaTicks(), naerestEntity.zo, naerestEntity.getZ()));
|
||||
Vec3 lookAngle = player.getLookAngle().normalize().scale(pos.distanceTo(playerVec) * (1 - 1.0 / zoom));
|
||||
Vec3 pos = new Vec3(Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), naerestEntity.xo, naerestEntity.getX()), Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), naerestEntity.yo + naerestEntity.getEyeHeight(), naerestEntity.getEyeY()), Mth.lerp(deltaTracker.getGameTimeDeltaPartialTick(true), naerestEntity.zo, naerestEntity.getZ()));
|
||||
|
||||
var cPos = playerVec.add(lookAngle);
|
||||
Vec3 point = RenderHelper.worldToScreen(pos, cPos);
|
||||
if (point == null) return;
|
||||
Vec3 point = VectorUtil.worldToScreen(pos);
|
||||
|
||||
poseStack.pushPose();
|
||||
float x = (float) point.x;
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
package com.atsuishio.superbwarfare.client.particle;
|
||||
|
||||
import com.atsuishio.superbwarfare.init.ModParticleTypes;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.core.particles.ParticleType;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CustomSmokeOption implements ParticleOptions {
|
||||
|
||||
public static final MapCodec<CustomSmokeOption> CODEC = RecordCodecBuilder.mapCodec(builder ->
|
||||
builder.group(
|
||||
Codec.FLOAT.fieldOf("r").forGetter(option -> option.red),
|
||||
Codec.FLOAT.fieldOf("g").forGetter(option -> option.green),
|
||||
Codec.FLOAT.fieldOf("b").forGetter(option -> option.blue)
|
||||
).apply(builder, CustomSmokeOption::new));
|
||||
|
||||
public static final StreamCodec<ByteBuf, CustomSmokeOption> STREAM_CODEC = StreamCodec.composite(
|
||||
ByteBufCodecs.FLOAT,
|
||||
CustomSmokeOption::getRed,
|
||||
ByteBufCodecs.FLOAT,
|
||||
CustomSmokeOption::getGreen,
|
||||
ByteBufCodecs.FLOAT,
|
||||
CustomSmokeOption::getBlue,
|
||||
CustomSmokeOption::new
|
||||
);
|
||||
|
||||
private final float red;
|
||||
private final float green;
|
||||
private final float blue;
|
||||
|
||||
public CustomSmokeOption(float r, float g, float b) {
|
||||
this.red = r;
|
||||
this.green = g;
|
||||
this.blue = b;
|
||||
}
|
||||
|
||||
public float getRed() {
|
||||
return red;
|
||||
}
|
||||
|
||||
public float getGreen() {
|
||||
return green;
|
||||
}
|
||||
|
||||
public float getBlue() {
|
||||
return blue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ParticleType<?> getType() {
|
||||
return ModParticleTypes.CUSTOM_SMOKE.get();
|
||||
}
|
||||
}
|
|
@ -2,43 +2,43 @@ package com.atsuishio.superbwarfare.client.particle;
|
|||
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.particle.*;
|
||||
import net.minecraft.core.particles.SimpleParticleType;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class CustomSmokeParticle extends TextureSheetParticle {
|
||||
public static FireStarParticleProvider provider(SpriteSet spriteSet) {
|
||||
return new FireStarParticleProvider(spriteSet);
|
||||
}
|
||||
|
||||
public static class FireStarParticleProvider implements ParticleProvider<SimpleParticleType> {
|
||||
private final SpriteSet spriteSet;
|
||||
|
||||
public FireStarParticleProvider(SpriteSet spriteSet) {
|
||||
this.spriteSet = spriteSet;
|
||||
}
|
||||
|
||||
public Particle createParticle(@NotNull SimpleParticleType typeIn, @NotNull ClientLevel worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
|
||||
return new CustomSmokeParticle(worldIn, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet);
|
||||
}
|
||||
}
|
||||
|
||||
private final SpriteSet spriteSet;
|
||||
|
||||
protected CustomSmokeParticle(ClientLevel world, double x, double y, double z, double vx, double vy, double vz, SpriteSet spriteSet) {
|
||||
super(world, x, y, z);
|
||||
protected CustomSmokeParticle(ClientLevel level, double x, double y, double z, double vx, double vy, double vz, SpriteSet spriteSet, float rCol, float gCol, float bCol) {
|
||||
super(level, x, y, z);
|
||||
this.spriteSet = spriteSet;
|
||||
this.setSize(0.4f, 0.4f);
|
||||
this.quadSize *= 10f;
|
||||
this.lifetime = this.random.nextInt(200) + 600;
|
||||
this.gravity = 0.001f;
|
||||
this.hasPhysics = false;
|
||||
this.hasPhysics = true;
|
||||
this.xd = vx * 0.9;
|
||||
this.yd = vy * 0.9;
|
||||
this.zd = vz * 0.9;
|
||||
this.setSpriteFromAge(spriteSet);
|
||||
this.rCol = rCol;
|
||||
this.gCol = gCol;
|
||||
this.bCol = bCol;
|
||||
}
|
||||
|
||||
private final SpriteSet spriteSet;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static class Provider implements ParticleProvider<CustomSmokeOption> {
|
||||
private final SpriteSet spriteSet;
|
||||
|
||||
public Provider(SpriteSet spriteSet) {
|
||||
this.spriteSet = spriteSet;
|
||||
}
|
||||
|
||||
public Particle createParticle(CustomSmokeOption pType, @NotNull ClientLevel pLevel, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
|
||||
return new CustomSmokeParticle(pLevel, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet, pType.getRed(), pType.getGreen(), pType.getBlue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package com.atsuishio.superbwarfare.client.renderer.gun;
|
||||
package com.atsuishio.superbwarfare.client.renderer;
|
||||
|
||||
import com.atsuishio.superbwarfare.client.AnimationHelper;
|
||||
import com.atsuishio.superbwarfare.client.model.item.M2HBItemModel;
|
||||
import com.atsuishio.superbwarfare.client.renderer.CustomGunRenderer;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.machinegun.M2HBItem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -12,17 +9,31 @@ import net.minecraft.client.renderer.MultiBufferSource;
|
|||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import software.bernie.geckolib.animatable.GeoAnimatable;
|
||||
import software.bernie.geckolib.animatable.GeoItem;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
public class M2HBItemRenderer extends CustomGunRenderer<M2HBItem> {
|
||||
public class SimpleGunRenderer<T extends GunItem & GeoAnimatable> extends CustomGunRenderer<T> {
|
||||
|
||||
public M2HBItemRenderer() {
|
||||
super(new M2HBItemModel());
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
private final double size;
|
||||
private final boolean useOldHandRenderer;
|
||||
|
||||
public SimpleGunRenderer(GeoModel<T> model, double x, double y, double z, double size, boolean useOldHandRenderer) {
|
||||
super(model);
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.size = size;
|
||||
this.useOldHandRenderer = useOldHandRenderer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderRecursively(PoseStack stack, M2HBItem animatable, GeoBone bone, RenderType type, MultiBufferSource buffer, VertexConsumer bufferIn, boolean isReRender, float partialTick, int packedLightIn, int packedOverlayIn, int color) {
|
||||
public void renderRecursively(PoseStack poseStack, T animatable, GeoBone bone, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, int colour) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
String name = bone.getName();
|
||||
boolean renderingArms = false;
|
||||
|
@ -39,13 +50,14 @@ public class M2HBItemRenderer extends CustomGunRenderer<M2HBItem> {
|
|||
|
||||
if (itemStack.getItem() instanceof GunItem && GeoItem.getId(itemStack) == this.getInstanceId(animatable)) {
|
||||
if (this.renderPerspective == ItemDisplayContext.FIRST_PERSON_RIGHT_HAND || this.renderPerspective == ItemDisplayContext.THIRD_PERSON_RIGHT_HAND) {
|
||||
AnimationHelper.handleShootFlare(name, stack, itemStack, bone, buffer, packedLightIn, 0, 0.1, 2.95, 1.2);
|
||||
AnimationHelper.handleShootFlare(name, poseStack, itemStack, bone, bufferSource, packedLight, this.x, this.y, this.z, this.size);
|
||||
}
|
||||
}
|
||||
|
||||
if (renderingArms) {
|
||||
AnimationHelper.renderArms(player, this.renderPerspective, stack, name, bone, buffer, type, packedLightIn, false);
|
||||
AnimationHelper.renderArms(player, this.renderPerspective, poseStack, name, bone, bufferSource, renderType, packedLight, this.useOldHandRenderer);
|
||||
}
|
||||
super.renderRecursively(stack, animatable, bone, type, buffer, bufferIn, isReRender, partialTick, packedLightIn, packedOverlayIn, color);
|
||||
|
||||
super.renderRecursively(poseStack, animatable, bone, renderType, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, colour);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.atsuishio.superbwarfare.client.renderer.block;
|
||||
|
||||
import com.atsuishio.superbwarfare.block.entity.LuckyContainerBlockEntity;
|
||||
import com.atsuishio.superbwarfare.client.model.block.LuckyContainerBlockModel;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import software.bernie.geckolib.renderer.GeoBlockRenderer;
|
||||
|
||||
public class LuckyContainerBlockEntityRenderer extends GeoBlockRenderer<LuckyContainerBlockEntity> {
|
||||
|
||||
public LuckyContainerBlockEntityRenderer() {
|
||||
super(new LuckyContainerBlockModel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderType getRenderType(LuckyContainerBlockEntity animatable, ResourceLocation texture, MultiBufferSource bufferSource, float partialTick) {
|
||||
return RenderType.entityTranslucent(getTextureLocation(animatable));
|
||||
}
|
||||
}
|
|
@ -2,14 +2,17 @@ package com.atsuishio.superbwarfare.client.renderer.entity;
|
|||
|
||||
import com.atsuishio.superbwarfare.client.model.entity.A10Model;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.A10Entity;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import software.bernie.geckolib.cache.object.BakedGeoModel;
|
||||
|
@ -54,6 +57,10 @@ public class A10Renderer extends GeoEntityRenderer<A10Entity> {
|
|||
@Override
|
||||
public void renderRecursively(PoseStack poseStack, A10Entity animatable, GeoBone bone, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, int color) {
|
||||
String name = bone.getName();
|
||||
if (name.equals("root")) {
|
||||
Player player = Minecraft.getInstance().player;
|
||||
bone.setHidden(ClientEventHandler.zoomVehicle && animatable.getFirstPassenger() == player && animatable.getWeaponIndex(0) == 2);
|
||||
}
|
||||
if (name.equals("wingLR")) {
|
||||
bone.setRotX(1.5f * Mth.lerp(partialTick, animatable.flap1LRotO, animatable.getFlap1LRot()) * Mth.DEG_TO_RAD);
|
||||
}
|
||||
|
|
|
@ -2,10 +2,7 @@
|
|||
package com.atsuishio.superbwarfare.client.renderer.entity;
|
||||
|
||||
import com.atsuishio.superbwarfare.client.model.entity.DroneModel;
|
||||
import com.atsuishio.superbwarfare.entity.projectile.MortarShellEntity;
|
||||
import com.atsuishio.superbwarfare.entity.projectile.RgoGrenadeEntity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.DroneEntity;
|
||||
import com.atsuishio.superbwarfare.init.ModEntities;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.tools.EntityFindUtil;
|
||||
import com.atsuishio.superbwarfare.tools.NBTTool;
|
||||
|
@ -63,49 +60,6 @@ public class DroneRenderer extends GeoEntityRenderer<DroneEntity> {
|
|||
DroneEntity drone = EntityFindUtil.findDrone(player.level(), tag.getString("LinkedDrone"));
|
||||
|
||||
if (!(stack.is(ModItems.MONITOR.get()) && tag.getBoolean("Using") && tag.getBoolean("Linked") && drone != null && drone.getUUID() == entityIn.getUUID())) {
|
||||
if (entityIn.getEntityData().get(KAMIKAZE_MODE) == 1) {
|
||||
Entity entity = new MortarShellEntity(ModEntities.MORTAR_SHELL.get(), entityIn.level());
|
||||
entityRenderDispatcher.render(entity, 0, 0.03, 0.25, entityYaw, partialTicks, poseStack, bufferIn, packedLightIn);
|
||||
}
|
||||
|
||||
for (int i = 0; i < entityIn.getEntityData().get(AMMO); i++) {
|
||||
double yOffset = 0;
|
||||
double xOffset = 0;
|
||||
|
||||
if (i == 0) {
|
||||
yOffset = 0.2;
|
||||
xOffset = 0.1;
|
||||
}
|
||||
if (i == 1) {
|
||||
yOffset = 0.2;
|
||||
xOffset = -0.1;
|
||||
}
|
||||
if (i == 2) {
|
||||
yOffset = -0.05;
|
||||
xOffset = 0.1;
|
||||
}
|
||||
if (i == 3) {
|
||||
yOffset = -0.05;
|
||||
xOffset = -0.1;
|
||||
}
|
||||
if (i == 4) {
|
||||
yOffset = -0.3;
|
||||
xOffset = 0.1;
|
||||
}
|
||||
if (i == 5) {
|
||||
yOffset = -0.3;
|
||||
xOffset = -0.1;
|
||||
}
|
||||
|
||||
|
||||
poseStack.pushPose();
|
||||
poseStack.mulPose(Axis.XP.rotationDegrees(90));
|
||||
poseStack.scale(0.35f, 0.35f, 0.35f);
|
||||
Entity entity = new RgoGrenadeEntity(ModEntities.RGO_GRENADE.get(), entityIn.level());
|
||||
entityRenderDispatcher.render(entity, xOffset, yOffset, 0, entityYaw, partialTicks, poseStack, bufferIn, packedLightIn);
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
||||
renderAttachments(entityIn, entityYaw, partialTicks, poseStack, bufferIn, packedLightIn);
|
||||
}
|
||||
}
|
||||
|
@ -115,10 +69,12 @@ public class DroneRenderer extends GeoEntityRenderer<DroneEntity> {
|
|||
|
||||
private String entityNameCache = "";
|
||||
private Entity entityCache = null;
|
||||
private int attachedTick = Integer.MAX_VALUE;
|
||||
|
||||
// 统一渲染挂载实体
|
||||
private void renderAttachments(DroneEntity entity, float entityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource buffer, int packedLight) {
|
||||
var attached = entity.getEntityData().get(ATTACHED_ENTITY);
|
||||
var data = entity.getEntityData();
|
||||
var attached = data.get(DISPLAY_ENTITY);
|
||||
if (attached.isEmpty()) return;
|
||||
|
||||
Entity renderEntity;
|
||||
|
@ -131,26 +87,57 @@ public class DroneRenderer extends GeoEntityRenderer<DroneEntity> {
|
|||
.orElse(null);
|
||||
if (renderEntity == null) return;
|
||||
|
||||
// 填充tag
|
||||
var tag = data.get(DISPLAY_ENTITY_TAG);
|
||||
if (!tag.isEmpty()) {
|
||||
renderEntity.load(tag);
|
||||
}
|
||||
|
||||
entityNameCache = attached;
|
||||
entityCache = renderEntity;
|
||||
attachedTick = entity.tickCount;
|
||||
}
|
||||
var displayData = data.get(DISPLAY_DATA);
|
||||
|
||||
var displayData = entity.getEntityData().get(ATTACHMENT_DISPLAY);
|
||||
renderEntity.tickCount = displayData.get(11) >= 0 ? displayData.get(11).intValue() : entity.tickCount - attachedTick;
|
||||
|
||||
var scale = new float[]{displayData.get(0), displayData.get(1), displayData.get(2)};
|
||||
var offset = new float[]{displayData.get(3), displayData.get(4), displayData.get(5)};
|
||||
var rotation = new float[]{displayData.get(6), displayData.get(7), displayData.get(8)};
|
||||
var xLength = displayData.get(9);
|
||||
var yLength = displayData.get(10);
|
||||
|
||||
poseStack.pushPose();
|
||||
poseStack.translate(offset[0], offset[1], offset[2]);
|
||||
poseStack.scale(scale[0], scale[1], scale[2]);
|
||||
poseStack.mulPose(Axis.XP.rotationDegrees(rotation[0]));
|
||||
poseStack.mulPose(Axis.YP.rotationDegrees(rotation[2]));
|
||||
poseStack.mulPose(Axis.ZP.rotationDegrees(rotation[1]));
|
||||
for (int i = 0; i < data.get(AMMO); i++) {
|
||||
float x, z;
|
||||
if (data.get(MAX_AMMO) == 1) {
|
||||
// 神风或单个挂载
|
||||
x = 0;
|
||||
z = 0;
|
||||
} else {
|
||||
// 投弹
|
||||
x = xLength / 2 * (i % 2 == 0 ? 1 : -1);
|
||||
|
||||
entityRenderDispatcher.render(renderEntity, 0, 0, 0, entityYaw, partialTicks, poseStack, buffer, packedLight);
|
||||
var rows = data.get(MAX_AMMO) / 2;
|
||||
var row = i / 2;
|
||||
if (rows < 2) {
|
||||
z = 0;
|
||||
} else {
|
||||
var rowLength = yLength / rows;
|
||||
z = -yLength / 2 + rowLength * row;
|
||||
}
|
||||
}
|
||||
|
||||
poseStack.popPose();
|
||||
poseStack.pushPose();
|
||||
poseStack.translate(x + offset[0], offset[1], z + offset[2]);
|
||||
poseStack.scale(scale[0], scale[1], scale[2]);
|
||||
poseStack.mulPose(Axis.XP.rotationDegrees(rotation[0]));
|
||||
poseStack.mulPose(Axis.YP.rotationDegrees(rotation[2]));
|
||||
poseStack.mulPose(Axis.ZP.rotationDegrees(rotation[1]));
|
||||
|
||||
entityRenderDispatcher.render(renderEntity, 0, 0, 0, entityYaw, partialTicks, poseStack, buffer, packedLight);
|
||||
|
||||
poseStack.popPose();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package com.atsuishio.superbwarfare.client.renderer.entity;
|
||||
|
||||
import com.atsuishio.superbwarfare.client.layer.projectile.HeliRocketLayer;
|
||||
import com.atsuishio.superbwarfare.client.model.entity.HeliRocketModel;
|
||||
import com.atsuishio.superbwarfare.entity.projectile.HeliRocketEntity;
|
||||
import com.atsuishio.superbwarfare.client.model.entity.M18SmokeGrenadeEntityModel;
|
||||
import com.atsuishio.superbwarfare.entity.projectile.M18SmokeGrenadeEntity;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Axis;
|
||||
|
@ -11,22 +10,22 @@ import net.minecraft.client.renderer.RenderType;
|
|||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import software.bernie.geckolib.cache.object.BakedGeoModel;
|
||||
import software.bernie.geckolib.renderer.GeoEntityRenderer;
|
||||
|
||||
public class HeliRocketRenderer extends GeoEntityRenderer<HeliRocketEntity> {
|
||||
public HeliRocketRenderer(EntityRendererProvider.Context renderManager) {
|
||||
super(renderManager, new HeliRocketModel());
|
||||
this.addRenderLayer(new HeliRocketLayer(this));
|
||||
public class M18SmokeGrenadeRenderer extends GeoEntityRenderer<M18SmokeGrenadeEntity> {
|
||||
public M18SmokeGrenadeRenderer(EntityRendererProvider.Context renderManager) {
|
||||
super(renderManager, new M18SmokeGrenadeEntityModel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderType getRenderType(HeliRocketEntity animatable, ResourceLocation texture, MultiBufferSource bufferSource, float partialTick) {
|
||||
public RenderType getRenderType(M18SmokeGrenadeEntity animatable, ResourceLocation texture, MultiBufferSource bufferSource, float partialTick) {
|
||||
return RenderType.entityTranslucent(getTextureLocation(animatable));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preRender(PoseStack poseStack, HeliRocketEntity entity, BakedGeoModel model, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, int color) {
|
||||
public void preRender(PoseStack poseStack, M18SmokeGrenadeEntity entity, BakedGeoModel model, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, int color) {
|
||||
float scale = 1f;
|
||||
this.scaleHeight = scale;
|
||||
this.scaleWidth = scale;
|
||||
|
@ -34,7 +33,7 @@ public class HeliRocketRenderer extends GeoEntityRenderer<HeliRocketEntity> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(HeliRocketEntity entityIn, float entityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource bufferIn, int packedLightIn) {
|
||||
public void render(M18SmokeGrenadeEntity entityIn, float entityYaw, float partialTicks, PoseStack poseStack, @NotNull MultiBufferSource bufferIn, int packedLightIn) {
|
||||
poseStack.pushPose();
|
||||
poseStack.mulPose(Axis.YP.rotationDegrees(Mth.lerp(partialTicks, entityIn.yRotO, entityIn.getYRot()) - 90));
|
||||
poseStack.mulPose(Axis.ZP.rotationDegrees(90 + Mth.lerp(partialTicks, entityIn.xRotO, entityIn.getXRot())));
|
||||
|
@ -43,7 +42,7 @@ public class HeliRocketRenderer extends GeoEntityRenderer<HeliRocketEntity> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected float getDeathMaxRotation(HeliRocketEntity entityLivingBaseIn) {
|
||||
protected float getDeathMaxRotation(M18SmokeGrenadeEntity entityLivingBaseIn) {
|
||||
return 0.0F;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package com.atsuishio.superbwarfare.client.renderer.entity;
|
||||
|
||||
import com.atsuishio.superbwarfare.client.layer.projectile.MediumRocketLayer;
|
||||
import com.atsuishio.superbwarfare.client.model.entity.MediumRocketModel;
|
||||
import com.atsuishio.superbwarfare.entity.projectile.MediumRocketEntity;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import software.bernie.geckolib.cache.object.BakedGeoModel;
|
||||
import software.bernie.geckolib.renderer.GeoEntityRenderer;
|
||||
|
||||
public class MediumRocketRenderer extends GeoEntityRenderer<MediumRocketEntity> {
|
||||
public MediumRocketRenderer(EntityRendererProvider.Context renderManager) {
|
||||
super(renderManager, new MediumRocketModel());
|
||||
this.addRenderLayer(new MediumRocketLayer(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderType getRenderType(MediumRocketEntity animatable, ResourceLocation texture, MultiBufferSource bufferSource, float partialTick) {
|
||||
return RenderType.entityTranslucent(getTextureLocation(animatable));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preRender(PoseStack poseStack, MediumRocketEntity entity, BakedGeoModel model, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, int color) {
|
||||
float scale = 1f;
|
||||
this.scaleHeight = scale;
|
||||
this.scaleWidth = scale;
|
||||
super.preRender(poseStack, entity, model, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MediumRocketEntity entityIn, float entityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource bufferIn, int packedLightIn) {
|
||||
poseStack.pushPose();
|
||||
poseStack.mulPose(Axis.YP.rotationDegrees(Mth.lerp(partialTicks, entityIn.yRotO, entityIn.getYRot()) - 90));
|
||||
poseStack.mulPose(Axis.ZP.rotationDegrees(90 + Mth.lerp(partialTicks, entityIn.xRotO, entityIn.getXRot())));
|
||||
super.render(entityIn, entityYaw, partialTicks, poseStack, bufferIn, packedLightIn);
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getDeathMaxRotation(MediumRocketEntity entityLivingBaseIn) {
|
||||
return 0.0F;
|
||||
}
|
||||
}
|
|
@ -11,9 +11,13 @@ import net.minecraft.client.renderer.RenderType;
|
|||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import software.bernie.geckolib.cache.object.BakedGeoModel;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
import software.bernie.geckolib.renderer.GeoEntityRenderer;
|
||||
|
||||
import static com.atsuishio.superbwarfare.entity.vehicle.MortarEntity.INTELLIGENT;
|
||||
|
||||
public class MortarRenderer extends GeoEntityRenderer<MortarEntity> {
|
||||
|
||||
public MortarRenderer(EntityRendererProvider.Context renderManager) {
|
||||
|
@ -36,7 +40,7 @@ public class MortarRenderer extends GeoEntityRenderer<MortarEntity> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(MortarEntity entityIn, float entityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource bufferIn, int packedLightIn) {
|
||||
public void render(MortarEntity entityIn, float entityYaw, float partialTicks, PoseStack poseStack, @NotNull MultiBufferSource bufferIn, int packedLightIn) {
|
||||
poseStack.pushPose();
|
||||
poseStack.mulPose(Axis.YP.rotationDegrees(-Mth.lerp(partialTicks, entityIn.yRotO, entityIn.getYRot())));
|
||||
super.render(entityIn, entityYaw, partialTicks, poseStack, bufferIn, packedLightIn);
|
||||
|
@ -44,8 +48,13 @@ public class MortarRenderer extends GeoEntityRenderer<MortarEntity> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected float getDeathMaxRotation(MortarEntity entityLivingBaseIn) {
|
||||
return 0.0F;
|
||||
public void renderRecursively(PoseStack poseStack, MortarEntity animatable, GeoBone bone, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, int color) {
|
||||
String name = bone.getName();
|
||||
|
||||
if (name.equals("monitor")) {
|
||||
bone.setHidden(!animatable.getEntityData().get(INTELLIGENT));
|
||||
}
|
||||
super.renderRecursively(poseStack, animatable, bone, renderType, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
package com.atsuishio.superbwarfare.client.renderer.entity;
|
||||
|
||||
import com.atsuishio.superbwarfare.client.layer.projectile.SmallRocketLayer;
|
||||
import com.atsuishio.superbwarfare.client.model.entity.SmallRocketModel;
|
||||
import com.atsuishio.superbwarfare.entity.projectile.SmallRocketEntity;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import software.bernie.geckolib.cache.object.BakedGeoModel;
|
||||
import software.bernie.geckolib.renderer.GeoEntityRenderer;
|
||||
|
||||
public class SmallRocketRenderer extends GeoEntityRenderer<SmallRocketEntity> {
|
||||
public SmallRocketRenderer(EntityRendererProvider.Context renderManager) {
|
||||
super(renderManager, new SmallRocketModel());
|
||||
this.addRenderLayer(new SmallRocketLayer(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderType getRenderType(SmallRocketEntity animatable, ResourceLocation texture, MultiBufferSource bufferSource, float partialTick) {
|
||||
return RenderType.entityTranslucent(getTextureLocation(animatable));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preRender(PoseStack poseStack, SmallRocketEntity entity, BakedGeoModel model, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, int color) {
|
||||
float scale = 1f;
|
||||
this.scaleHeight = scale;
|
||||
this.scaleWidth = scale;
|
||||
super.preRender(poseStack, entity, model, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(SmallRocketEntity entityIn, float entityYaw, float partialTicks, PoseStack poseStack, @NotNull MultiBufferSource bufferIn, int packedLightIn) {
|
||||
poseStack.pushPose();
|
||||
poseStack.mulPose(Axis.YP.rotationDegrees(Mth.lerp(partialTicks, entityIn.yRotO, entityIn.getYRot()) - 90));
|
||||
poseStack.mulPose(Axis.ZP.rotationDegrees(90 + Mth.lerp(partialTicks, entityIn.xRotO, entityIn.getXRot())));
|
||||
super.render(entityIn, entityYaw, partialTicks, poseStack, bufferIn, packedLightIn);
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getDeathMaxRotation(SmallRocketEntity entityLivingBaseIn) {
|
||||
return 0.0F;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package com.atsuishio.superbwarfare.client.renderer.entity;
|
||||
|
||||
import com.atsuishio.superbwarfare.client.model.entity.Type63Model;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.Type63Entity;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import software.bernie.geckolib.cache.object.BakedGeoModel;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
import software.bernie.geckolib.renderer.GeoEntityRenderer;
|
||||
|
||||
import static com.atsuishio.superbwarfare.entity.vehicle.Type63Entity.LOADED_AMMO;
|
||||
|
||||
|
||||
public class Type63Renderer extends GeoEntityRenderer<Type63Entity> {
|
||||
|
||||
public Type63Renderer(EntityRendererProvider.Context renderManager) {
|
||||
super(renderManager, new Type63Model());
|
||||
this.shadowRadius = 0.8f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderType getRenderType(Type63Entity animatable, ResourceLocation texture, MultiBufferSource bufferSource, float partialTick) {
|
||||
return RenderType.entityTranslucent(getTextureLocation(animatable));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preRender(PoseStack poseStack, Type63Entity entity, BakedGeoModel model, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, int color) {
|
||||
float scale = 1f;
|
||||
this.scaleHeight = scale;
|
||||
this.scaleWidth = scale;
|
||||
super.preRender(poseStack, entity, model, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Type63Entity entityIn, float entityYaw, float partialTicks, PoseStack poseStack, @NotNull MultiBufferSource bufferIn, int packedLightIn) {
|
||||
poseStack.pushPose();
|
||||
poseStack.mulPose(Axis.YP.rotationDegrees(-Mth.lerp(partialTicks, entityIn.yRotO, entityIn.getYRot())));
|
||||
super.render(entityIn, entityYaw, partialTicks, poseStack, bufferIn, packedLightIn);
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderRecursively(PoseStack poseStack, Type63Entity animatable, GeoBone bone, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, int color) {
|
||||
String name = bone.getName();
|
||||
|
||||
if (name.equals("wheel1")) {
|
||||
bone.setRotX(Mth.lerp(partialTick, animatable.leftWheelRotO, animatable.getLeftWheelRot()));
|
||||
}
|
||||
if (name.equals("wheel2")) {
|
||||
bone.setRotX(Mth.lerp(partialTick, animatable.rightWheelRotO, animatable.getRightWheelRot()));
|
||||
}
|
||||
|
||||
if (name.equals("main")) {
|
||||
bone.setRotY(Mth.lerp(partialTick, animatable.turretYRotO, animatable.getTurretYRot()) * Mth.DEG_TO_RAD);
|
||||
}
|
||||
|
||||
if (name.equals("paotou")) {
|
||||
bone.setRotX(-Mth.lerp(partialTick, animatable.turretXRotO, animatable.getTurretXRot()) * Mth.DEG_TO_RAD);
|
||||
}
|
||||
|
||||
if (name.equals("shoulunx")) {
|
||||
bone.setRotX(-Mth.lerp(partialTick, animatable.turretXRotO, animatable.getTurretXRot()) * 3);
|
||||
}
|
||||
|
||||
if (name.equals("shouluny")) {
|
||||
bone.setRotZ(-Mth.lerp(partialTick, animatable.turretYRotO, animatable.getTurretYRot()) * 6);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 12; i++) {
|
||||
var items = animatable.getEntityData().get(LOADED_AMMO);
|
||||
if (name.equals("shell" + i)) {
|
||||
bone.setHidden(items.get(i) == -1);
|
||||
}
|
||||
}
|
||||
|
||||
super.renderRecursively(poseStack, animatable, bone, renderType, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, color);
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package com.atsuishio.superbwarfare.client.renderer.gun;
|
||||
|
||||
import com.atsuishio.superbwarfare.client.AnimationHelper;
|
||||
import com.atsuishio.superbwarfare.client.model.item.Aa12ItemModel;
|
||||
import com.atsuishio.superbwarfare.client.renderer.CustomGunRenderer;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.shotgun.Aa12Item;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import software.bernie.geckolib.animatable.GeoItem;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
|
||||
public class Aa12ItemRenderer extends CustomGunRenderer<Aa12Item> {
|
||||
|
||||
public Aa12ItemRenderer() {
|
||||
super(new Aa12ItemModel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderRecursively(PoseStack stack, Aa12Item animatable, GeoBone bone, RenderType type, MultiBufferSource buffer, VertexConsumer bufferIn, boolean isReRender, float partialTick, int packedLightIn, int packedOverlayIn, int color) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
String name = bone.getName();
|
||||
boolean renderingArms = false;
|
||||
if (name.equals("Lefthand") || name.equals("Righthand")) {
|
||||
bone.setHidden(true);
|
||||
renderingArms = true;
|
||||
} else {
|
||||
bone.setHidden(false);
|
||||
}
|
||||
|
||||
var player = mc.player;
|
||||
if (player == null) return;
|
||||
ItemStack itemStack = player.getMainHandItem();
|
||||
|
||||
if (itemStack.getItem() instanceof GunItem && GeoItem.getId(itemStack) == this.getInstanceId(animatable)) {
|
||||
AnimationHelper.handleShootFlare(name, stack, itemStack, bone, buffer, packedLightIn, 0, 0, 1.31465, 0.5);
|
||||
}
|
||||
|
||||
if (renderingArms) {
|
||||
AnimationHelper.renderArms(player, this.renderPerspective, stack, name, bone, buffer, type, packedLightIn, true);
|
||||
}
|
||||
super.renderRecursively(stack, animatable, bone, type, buffer, bufferIn, isReRender, partialTick, packedLightIn, packedOverlayIn, color);
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package com.atsuishio.superbwarfare.client.renderer.gun;
|
||||
|
||||
import com.atsuishio.superbwarfare.client.AnimationHelper;
|
||||
import com.atsuishio.superbwarfare.client.model.item.AureliaSceptreModel;
|
||||
import com.atsuishio.superbwarfare.client.renderer.CustomGunRenderer;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.handgun.AureliaSceptre;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import software.bernie.geckolib.animatable.GeoItem;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
|
||||
public class AureliaSceptreRenderer extends CustomGunRenderer<AureliaSceptre> {
|
||||
|
||||
public AureliaSceptreRenderer() {
|
||||
super(new AureliaSceptreModel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderRecursively(PoseStack stack, AureliaSceptre animatable, GeoBone bone, RenderType type, MultiBufferSource buffer, VertexConsumer bufferIn, boolean isReRender, float partialTick, int packedLightIn, int packedOverlayIn, int color) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
String name = bone.getName();
|
||||
boolean renderingArms = false;
|
||||
if (name.equals("Lefthand") || name.equals("Righthand")) {
|
||||
bone.setHidden(true);
|
||||
renderingArms = true;
|
||||
} else {
|
||||
bone.setHidden(false);
|
||||
}
|
||||
|
||||
var player = mc.player;
|
||||
if (player == null) return;
|
||||
ItemStack itemStack = player.getMainHandItem();
|
||||
if (itemStack.getItem() instanceof GunItem && GeoItem.getId(itemStack) == this.getInstanceId(animatable)) {
|
||||
AnimationHelper.handleShootFlare(name, stack, itemStack, bone, buffer, packedLightIn, 0, 0, 0.3022, 0.3);
|
||||
}
|
||||
|
||||
if (renderingArms) {
|
||||
AnimationHelper.renderArms(player, this.renderPerspective, stack, name, bone, this.currentBuffer, type, packedLightIn, false);
|
||||
}
|
||||
super.renderRecursively(stack, animatable, bone, type, buffer, bufferIn, isReRender, partialTick, packedLightIn, packedOverlayIn, color);
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package com.atsuishio.superbwarfare.client.renderer.gun;
|
||||
|
||||
import com.atsuishio.superbwarfare.client.AnimationHelper;
|
||||
import com.atsuishio.superbwarfare.client.model.item.Glock17ItemModel;
|
||||
import com.atsuishio.superbwarfare.client.renderer.CustomGunRenderer;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.handgun.Glock17Item;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import software.bernie.geckolib.animatable.GeoItem;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
|
||||
public class Glock17ItemRenderer extends CustomGunRenderer<Glock17Item> {
|
||||
|
||||
public Glock17ItemRenderer() {
|
||||
super(new Glock17ItemModel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderRecursively(PoseStack stack, Glock17Item animatable, GeoBone bone, RenderType type, MultiBufferSource buffer, VertexConsumer bufferIn, boolean isReRender, float partialTick, int packedLightIn, int packedOverlayIn, int color) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
String name = bone.getName();
|
||||
boolean renderingArms = false;
|
||||
if (name.equals("Lefthand") || name.equals("Righthand")) {
|
||||
bone.setHidden(true);
|
||||
renderingArms = true;
|
||||
} else {
|
||||
bone.setHidden(false);
|
||||
}
|
||||
|
||||
var player = mc.player;
|
||||
if (player == null) return;
|
||||
ItemStack itemStack = player.getMainHandItem();
|
||||
if (itemStack.getItem() instanceof GunItem && GeoItem.getId(itemStack) == this.getInstanceId(animatable)) {
|
||||
if (this.renderPerspective == ItemDisplayContext.FIRST_PERSON_RIGHT_HAND || this.renderPerspective == ItemDisplayContext.THIRD_PERSON_RIGHT_HAND) {
|
||||
AnimationHelper.handleShootFlare(name, stack, itemStack, bone, buffer, packedLightIn, 0, 0, 0.3022, 0.3);
|
||||
}
|
||||
}
|
||||
|
||||
if (renderingArms) {
|
||||
AnimationHelper.renderArms(player, this.renderPerspective, stack, name, bone, buffer, type, packedLightIn, false);
|
||||
}
|
||||
super.renderRecursively(stack, animatable, bone, type, buffer, bufferIn, isReRender, partialTick, packedLightIn, packedOverlayIn, color);
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package com.atsuishio.superbwarfare.client.renderer.gun;
|
||||
|
||||
import com.atsuishio.superbwarfare.client.AnimationHelper;
|
||||
import com.atsuishio.superbwarfare.client.model.item.Glock18ItemModel;
|
||||
import com.atsuishio.superbwarfare.client.renderer.CustomGunRenderer;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.handgun.Glock18Item;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import software.bernie.geckolib.animatable.GeoItem;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
|
||||
public class Glock18ItemRenderer extends CustomGunRenderer<Glock18Item> {
|
||||
|
||||
public Glock18ItemRenderer() {
|
||||
super(new Glock18ItemModel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderRecursively(PoseStack stack, Glock18Item animatable, GeoBone bone, RenderType type, MultiBufferSource buffer, VertexConsumer bufferIn, boolean isReRender, float partialTick, int packedLightIn, int packedOverlayIn, int color) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
String name = bone.getName();
|
||||
boolean renderingArms = false;
|
||||
if (name.equals("Lefthand") || name.equals("Righthand")) {
|
||||
bone.setHidden(true);
|
||||
renderingArms = true;
|
||||
} else {
|
||||
bone.setHidden(false);
|
||||
}
|
||||
|
||||
var player = mc.player;
|
||||
if (player == null) return;
|
||||
ItemStack itemStack = player.getMainHandItem();
|
||||
if (itemStack.getItem() instanceof GunItem && GeoItem.getId(itemStack) == this.getInstanceId(animatable)) {
|
||||
if (this.renderPerspective == ItemDisplayContext.FIRST_PERSON_RIGHT_HAND || this.renderPerspective == ItemDisplayContext.THIRD_PERSON_RIGHT_HAND) {
|
||||
AnimationHelper.handleShootFlare(name, stack, itemStack, bone, buffer, packedLightIn, 0, 0, 0.3022, 0.3);
|
||||
}
|
||||
}
|
||||
|
||||
if (renderingArms) {
|
||||
AnimationHelper.renderArms(player, this.renderPerspective, stack, name, bone, buffer, type, packedLightIn, false);
|
||||
}
|
||||
super.renderRecursively(stack, animatable, bone, type, buffer, bufferIn, isReRender, partialTick, packedLightIn, packedOverlayIn, color);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue