优化数组

This commit is contained in:
Atsuihsio 2024-10-11 19:07:20 +08:00
parent 0b0d53ae42
commit 97a6bbc7e0
5 changed files with 271 additions and 77 deletions

View file

@ -104,5 +104,13 @@ public class M4ItemModel extends GeoModel<M4Item> {
camera.setRotZ(numR * camera.getRotZ());
}
ClientEventHandler.shake(Mth.RAD_TO_DEG * camera.getRotX(),Mth.RAD_TO_DEG * camera.getRotY(), Mth.RAD_TO_DEG * camera.getRotZ());
CoreGeoBone shell1 = getAnimationProcessor().getBone("shell1");
CoreGeoBone shell2 = getAnimationProcessor().getBone("shell2");
CoreGeoBone shell3 = getAnimationProcessor().getBone("shell3");
CoreGeoBone shell4 = getAnimationProcessor().getBone("shell4");
CoreGeoBone shell5 = getAnimationProcessor().getBone("shell5");
ClientEventHandler.handleShell(shell1, shell2, shell3, shell4, shell5);
}
}

View file

@ -109,15 +109,9 @@ public class ClientEventHandler {
public static int shellIndex = 0;
public static double shellIndexTime1 = 0;
public static double shellIndexTime2 = 0;
public static double shellIndexTime3 = 0;
public static double shellIndexTime4 = 0;
public static double shellIndexTime5 = 0;
public static double[] shellIndexTime = {0, 0, 0, 0, 0};
public static double randomShell1 = 0;
public static double randomShell2 = 0;
public static double randomShell3 = 0;
public static double[] randomShell = {0, 0, 0};
public static MillisTimer clientTimer = new MillisTimer();
@SubscribeEvent
@ -514,24 +508,11 @@ public class ClientEventHandler {
fireRecoilTime = time;
shellIndex++;
switch (shellIndex) {
case 0 ->
shellIndexTime1 = 0;
case 1 ->
shellIndexTime2 = 0;
case 2 ->
shellIndexTime3 = 0;
case 3 ->
shellIndexTime4 = 0;
case 4 ->
shellIndexTime5 = 0;
}
shellIndexTime[shellIndex] = 0;
randomShell1 = (1 + 2 * Math.random());
randomShell2 = (1 + 2 * Math.random());
randomShell3 = (1 + 2 * Math.random());
randomShell[0] = (1 + 2 * Math.random());
randomShell[1] = (1 + 2 * Math.random());
randomShell[2] = (1 + 2 * Math.random());
}
}
@ -598,18 +579,18 @@ public class ClientEventHandler {
if (shellIndex >= 5) {
shellIndex = 0;
shellIndexTime1 = 0;
shellIndexTime[0] = 0;
}
shellIndexTime1 = Math.min(shellIndexTime1 + 6 * times * ((50 - shellIndexTime1) / 50), 50);
shellIndexTime[0] = Math.min(shellIndexTime[0] + 6 * times * ((50 - shellIndexTime[0]) / 50), 50);
shellIndexTime2 = Math.min(shellIndexTime2 + 6 * times * ((50 - shellIndexTime2) / 50), 50);
shellIndexTime[1] = Math.min(shellIndexTime[1] + 6 * times * ((50 - shellIndexTime[1]) / 50), 50);
shellIndexTime3 = Math.min(shellIndexTime3 + 6 * times * ((50 - shellIndexTime3) / 50), 50);
shellIndexTime[2] = Math.min(shellIndexTime[2] + 6 * times * ((50 - shellIndexTime[2]) / 50), 50);
shellIndexTime4 = Math.min(shellIndexTime4 + 6 * times * ((50 - shellIndexTime4) / 50), 50);
shellIndexTime[3] = Math.min(shellIndexTime[3] + 6 * times * ((50 - shellIndexTime[3]) / 50), 50);
shellIndexTime5 = Math.min(shellIndexTime5 + 6 * times * ((50 - shellIndexTime5) / 50), 50);
shellIndexTime[4] = Math.min(shellIndexTime[4] + 6 * times * ((50 - shellIndexTime[4]) / 50), 50);
// player.displayClientMessage(Component.literal(new java.text.DecimalFormat("##.##").format(shellIndex) + " "
// + new java.text.DecimalFormat("##").format(shellIndexTime1) + " "
@ -899,30 +880,30 @@ public class ClientEventHandler {
public static void handleShell(CoreGeoBone shell1, CoreGeoBone shell2, CoreGeoBone shell3, CoreGeoBone shell4, CoreGeoBone shell5) {
shell1.setPosX((float) -shellIndexTime1);
shell1.setPosY((float) (randomShell1 * Math.sin(0.15 * shellIndexTime1)));
shell1.setRotX((float) (randomShell1 * shellIndexTime1));
shell1.setRotY((float) (randomShell3 * shellIndexTime1));
shell1.setPosX((float) -shellIndexTime[0]);
shell1.setPosY((float) (randomShell[0] * Math.sin(0.15 * shellIndexTime[0])));
shell1.setRotX((float) (randomShell[1] * shellIndexTime[0]));
shell1.setRotY((float) (randomShell[2] * shellIndexTime[0]));
shell2.setPosX((float) -shellIndexTime2);
shell2.setPosY((float) (randomShell1 * Math.sin(0.15 * shellIndexTime2)));
shell2.setRotX((float) (randomShell1 * shellIndexTime2));
shell2.setRotY((float) (randomShell3 * shellIndexTime2));
shell2.setPosX((float) -shellIndexTime[1]);
shell2.setPosY((float) (randomShell[0] * Math.sin(0.15 * shellIndexTime[1])));
shell2.setRotX((float) (randomShell[1] * shellIndexTime[1]));
shell2.setRotY((float) (randomShell[2] * shellIndexTime[1]));
shell3.setPosX((float) -shellIndexTime3);
shell3.setPosY((float) (randomShell1* Math.sin(0.15 * shellIndexTime3)));
shell2.setRotX((float) (randomShell1* shellIndexTime2));
shell3.setRotY((float) (randomShell3* shellIndexTime3));
shell3.setPosX((float) -shellIndexTime[2]);
shell3.setPosY((float) (randomShell[0]* Math.sin(0.15 * shellIndexTime[2])));
shell2.setRotX((float) (randomShell[1]* shellIndexTime[2]));
shell3.setRotY((float) (randomShell[2]* shellIndexTime[2]));
shell4.setPosX((float) -shellIndexTime4);
shell4.setPosY((float) (randomShell1* Math.sin(0.15 * shellIndexTime4)));
shell2.setRotX((float) (randomShell1* shellIndexTime2));
shell4.setRotY((float) (randomShell3* shellIndexTime4));
shell4.setPosX((float) -shellIndexTime[3]);
shell4.setPosY((float) (randomShell[0]* Math.sin(0.15 * shellIndexTime[3])));
shell2.setRotX((float) (randomShell[1]* shellIndexTime[3]));
shell4.setRotY((float) (randomShell[2]* shellIndexTime[3]));
shell5.setPosX((float) -shellIndexTime5);
shell5.setPosY((float) (randomShell1* Math.sin(0.15 * shellIndexTime5)));
shell2.setRotX((float) (randomShell1* shellIndexTime2));
shell5.setRotY((float) (randomShell3* shellIndexTime5));
shell5.setPosX((float) -shellIndexTime[4]);
shell5.setPosY((float) (randomShell[0]* Math.sin(0.15 * shellIndexTime[4])));
shell2.setRotX((float) (randomShell[1]* shellIndexTime[4]));
shell5.setRotY((float) (randomShell[2]* shellIndexTime[4]));
}

View file

@ -19,14 +19,9 @@
"name": "root",
"pivot": [0, 0, 0]
},
{
"name": "move",
"parent": "root",
"pivot": [0, 0, 0]
},
{
"name": "bone",
"parent": "move",
"parent": "root",
"pivot": [0, 0, 0]
},
{
@ -83,8 +78,8 @@
"pivot": [0.60283, 2.61538, -3.10152],
"cubes": [
{
"origin": [0.4238, 2.43635, -3.68242],
"size": [0.35805, 0.35805, 0.9922],
"origin": [0.4238, 2.43635, -3.93242],
"size": [0.35805, 0.35805, 1.2422],
"uv": {
"north": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"east": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
@ -126,8 +121,8 @@
"pivot": [0.60283, 2.61538, -3.10152],
"cubes": [
{
"origin": [0.4238, 2.43635, -3.68242],
"size": [0.35805, 0.35805, 0.9922],
"origin": [0.4238, 2.43635, -3.93242],
"size": [0.35805, 0.35805, 1.2422],
"uv": {
"north": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"east": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
@ -169,8 +164,8 @@
"pivot": [0.60283, 2.61538, -3.10152],
"cubes": [
{
"origin": [0.4238, 2.43635, -3.68242],
"size": [0.35805, 0.35805, 0.9922],
"origin": [0.4238, 2.43635, -3.93242],
"size": [0.35805, 0.35805, 1.2422],
"uv": {
"north": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"east": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
@ -212,8 +207,8 @@
"pivot": [0.60283, 2.61538, -3.10152],
"cubes": [
{
"origin": [0.4238, 2.43635, -3.68242],
"size": [0.35805, 0.35805, 0.9922],
"origin": [0.4238, 2.43635, -3.93242],
"size": [0.35805, 0.35805, 1.2422],
"uv": {
"north": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"east": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
@ -255,8 +250,8 @@
"pivot": [0.60283, 2.61538, -3.10152],
"cubes": [
{
"origin": [0.4238, 2.43635, -3.68242],
"size": [0.35805, 0.35805, 0.9922],
"origin": [0.4238, 2.43635, -3.93242],
"size": [0.35805, 0.35805, 1.2422],
"uv": {
"north": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"east": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},

View file

@ -15,14 +15,9 @@
"name": "root",
"pivot": [0, -2, -1]
},
{
"name": "move",
"parent": "root",
"pivot": [0, 0, 0]
},
{
"name": "bone",
"parent": "move",
"parent": "root",
"pivot": [0, 0, 0]
},
{
@ -1857,7 +1852,7 @@
},
{
"origin": [0.02825, 1.47981, -17.16889],
"size": [0.00099, 0.17445, 6.67574],
"size": [0.00099, 0.17445, 12.6523],
"pivot": [1.00468, -0.07992, -10.14281],
"rotation": [0, 0, 45],
"uv": {
@ -1867,7 +1862,7 @@
},
{
"origin": [2.07682, 1.50532, -17.16889],
"size": [0.00099, 0.17445, 6.67574],
"size": [0.00099, 0.17445, 12.6523],
"pivot": [1.12788, -0.07993, -10.14281],
"rotation": [0, 0, -45],
"uv": {
@ -2105,7 +2100,7 @@
},
{
"origin": [-0.02923, 1.47981, -17.16889],
"size": [0.00099, 0.17445, 6.67574],
"size": [0.00099, 0.17445, 12.6523],
"pivot": [-1.00468, -0.07992, -10.14281],
"rotation": [0, 0, -45],
"uv": {
@ -2115,7 +2110,7 @@
},
{
"origin": [-2.0778, 1.50532, -17.16889],
"size": [0.00099, 0.17445, 6.67574],
"size": [0.00099, 0.17445, 12.6523],
"pivot": [-1.12788, -0.07993, -10.14281],
"rotation": [0, 0, 45],
"uv": {
@ -6681,6 +6676,221 @@
}
]
},
{
"name": "shell1",
"parent": "gun",
"pivot": [0.00001, 2.01538, -2.10152],
"cubes": [
{
"origin": [-0.17902, 1.83635, -3.18242],
"size": [0.35805, 0.35805, 1.4922],
"uv": {
"north": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"east": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"south": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"west": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"up": {"uv": [0.75, 78.375], "uv_size": [0.75, 3.25]},
"down": {"uv": [0.75, 78.375], "uv_size": [0.75, 3.25]}
}
},
{
"origin": [-0.13282, 1.88255, -2.5949],
"size": [0.26565, 0.26565, 1.04328],
"uv": {
"north": {"uv": [2.75, 81.625], "uv_size": [-0.75, -3.25]},
"east": {"uv": [2.75, 81.625], "uv_size": [-0.75, -3.25]},
"south": {"uv": [2.75, 81.625], "uv_size": [-0.75, -3.25]},
"west": {"uv": [2.75, 81.625], "uv_size": [-0.75, -3.25]},
"up": {"uv": [2, 78.375], "uv_size": [0.75, 3.25]},
"down": {"uv": [2, 78.375], "uv_size": [0.75, 3.25]}
}
},
{
"origin": [-0.17902, 1.83635, -1.59782],
"size": [0.35805, 0.35805, 0.0924],
"uv": {
"north": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"east": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"south": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"west": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"up": {"uv": [0.75, 78.375], "uv_size": [0.75, 3.25]},
"down": {"uv": [0.75, 78.375], "uv_size": [0.75, 3.25]}
}
}
]
},
{
"name": "shell2",
"parent": "gun",
"pivot": [0.00001, 2.01538, -2.10152],
"cubes": [
{
"origin": [-0.17902, 1.83635, -3.18242],
"size": [0.35805, 0.35805, 1.4922],
"uv": {
"north": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"east": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"south": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"west": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"up": {"uv": [0.75, 78.375], "uv_size": [0.75, 3.25]},
"down": {"uv": [0.75, 78.375], "uv_size": [0.75, 3.25]}
}
},
{
"origin": [-0.13282, 1.88255, -2.5949],
"size": [0.26565, 0.26565, 1.04328],
"uv": {
"north": {"uv": [2.75, 81.625], "uv_size": [-0.75, -3.25]},
"east": {"uv": [2.75, 81.625], "uv_size": [-0.75, -3.25]},
"south": {"uv": [2.75, 81.625], "uv_size": [-0.75, -3.25]},
"west": {"uv": [2.75, 81.625], "uv_size": [-0.75, -3.25]},
"up": {"uv": [2, 78.375], "uv_size": [0.75, 3.25]},
"down": {"uv": [2, 78.375], "uv_size": [0.75, 3.25]}
}
},
{
"origin": [-0.17902, 1.83635, -1.59782],
"size": [0.35805, 0.35805, 0.0924],
"uv": {
"north": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"east": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"south": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"west": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"up": {"uv": [0.75, 78.375], "uv_size": [0.75, 3.25]},
"down": {"uv": [0.75, 78.375], "uv_size": [0.75, 3.25]}
}
}
]
},
{
"name": "shell3",
"parent": "gun",
"pivot": [0.00001, 2.01538, -2.10152],
"cubes": [
{
"origin": [-0.17902, 1.83635, -3.18242],
"size": [0.35805, 0.35805, 1.4922],
"uv": {
"north": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"east": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"south": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"west": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"up": {"uv": [0.75, 78.375], "uv_size": [0.75, 3.25]},
"down": {"uv": [0.75, 78.375], "uv_size": [0.75, 3.25]}
}
},
{
"origin": [-0.13282, 1.88255, -2.5949],
"size": [0.26565, 0.26565, 1.04328],
"uv": {
"north": {"uv": [2.75, 81.625], "uv_size": [-0.75, -3.25]},
"east": {"uv": [2.75, 81.625], "uv_size": [-0.75, -3.25]},
"south": {"uv": [2.75, 81.625], "uv_size": [-0.75, -3.25]},
"west": {"uv": [2.75, 81.625], "uv_size": [-0.75, -3.25]},
"up": {"uv": [2, 78.375], "uv_size": [0.75, 3.25]},
"down": {"uv": [2, 78.375], "uv_size": [0.75, 3.25]}
}
},
{
"origin": [-0.17902, 1.83635, -1.59782],
"size": [0.35805, 0.35805, 0.0924],
"uv": {
"north": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"east": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"south": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"west": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"up": {"uv": [0.75, 78.375], "uv_size": [0.75, 3.25]},
"down": {"uv": [0.75, 78.375], "uv_size": [0.75, 3.25]}
}
}
]
},
{
"name": "shell4",
"parent": "gun",
"pivot": [0.00001, 2.01538, -2.10152],
"cubes": [
{
"origin": [-0.17902, 1.83635, -3.18242],
"size": [0.35805, 0.35805, 1.4922],
"uv": {
"north": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"east": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"south": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"west": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"up": {"uv": [0.75, 78.375], "uv_size": [0.75, 3.25]},
"down": {"uv": [0.75, 78.375], "uv_size": [0.75, 3.25]}
}
},
{
"origin": [-0.13282, 1.88255, -2.5949],
"size": [0.26565, 0.26565, 1.04328],
"uv": {
"north": {"uv": [2.75, 81.625], "uv_size": [-0.75, -3.25]},
"east": {"uv": [2.75, 81.625], "uv_size": [-0.75, -3.25]},
"south": {"uv": [2.75, 81.625], "uv_size": [-0.75, -3.25]},
"west": {"uv": [2.75, 81.625], "uv_size": [-0.75, -3.25]},
"up": {"uv": [2, 78.375], "uv_size": [0.75, 3.25]},
"down": {"uv": [2, 78.375], "uv_size": [0.75, 3.25]}
}
},
{
"origin": [-0.17902, 1.83635, -1.59782],
"size": [0.35805, 0.35805, 0.0924],
"uv": {
"north": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"east": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"south": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"west": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"up": {"uv": [0.75, 78.375], "uv_size": [0.75, 3.25]},
"down": {"uv": [0.75, 78.375], "uv_size": [0.75, 3.25]}
}
}
]
},
{
"name": "shell5",
"parent": "gun",
"pivot": [0.00001, 2.01538, -2.10152],
"cubes": [
{
"origin": [-0.17902, 1.83635, -3.18242],
"size": [0.35805, 0.35805, 1.4922],
"uv": {
"north": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"east": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"south": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"west": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"up": {"uv": [0.75, 78.375], "uv_size": [0.75, 3.25]},
"down": {"uv": [0.75, 78.375], "uv_size": [0.75, 3.25]}
}
},
{
"origin": [-0.13282, 1.88255, -2.5949],
"size": [0.26565, 0.26565, 1.04328],
"uv": {
"north": {"uv": [2.75, 81.625], "uv_size": [-0.75, -3.25]},
"east": {"uv": [2.75, 81.625], "uv_size": [-0.75, -3.25]},
"south": {"uv": [2.75, 81.625], "uv_size": [-0.75, -3.25]},
"west": {"uv": [2.75, 81.625], "uv_size": [-0.75, -3.25]},
"up": {"uv": [2, 78.375], "uv_size": [0.75, 3.25]},
"down": {"uv": [2, 78.375], "uv_size": [0.75, 3.25]}
}
},
{
"origin": [-0.17902, 1.83635, -1.59782],
"size": [0.35805, 0.35805, 0.0924],
"uv": {
"north": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"east": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"south": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"west": {"uv": [1.5, 81.625], "uv_size": [-0.75, -3.25]},
"up": {"uv": [0.75, 78.375], "uv_size": [0.75, 3.25]},
"down": {"uv": [0.75, 78.375], "uv_size": [0.75, 3.25]}
}
}
]
},
{
"name": "magazine",
"parent": "0",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB