使用Molang渲染阴险动画

This commit is contained in:
Light_Quanta 2025-05-18 03:42:15 +08:00
parent 1f0ba590ab
commit 2772dccd9e
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
4 changed files with 112 additions and 82 deletions

View file

@ -2,6 +2,7 @@ package com.atsuishio.superbwarfare;
import com.atsuishio.superbwarfare.api.event.RegisterContainersEvent; import com.atsuishio.superbwarfare.api.event.RegisterContainersEvent;
import com.atsuishio.superbwarfare.client.MouseMovementHandler; import com.atsuishio.superbwarfare.client.MouseMovementHandler;
import com.atsuishio.superbwarfare.client.renderer.molang.MolangVariable;
import com.atsuishio.superbwarfare.compat.CompatHolder; import com.atsuishio.superbwarfare.compat.CompatHolder;
import com.atsuishio.superbwarfare.compat.clothconfig.ClothConfigHelper; import com.atsuishio.superbwarfare.compat.clothconfig.ClothConfigHelper;
import com.atsuishio.superbwarfare.component.ModDataComponents; import com.atsuishio.superbwarfare.component.ModDataComponents;
@ -66,6 +67,7 @@ public class Mod {
bus.addListener(this::onClientSetup); bus.addListener(this::onClientSetup);
bus.addListener(FMLCommonSetupEvent.class, event -> onCommonSetup(bus)); bus.addListener(FMLCommonSetupEvent.class, event -> onCommonSetup(bus));
bus.addListener(FMLCommonSetupEvent.class, event -> MolangVariable.register());
bus.addListener(ModItems::registerDispenserBehavior); bus.addListener(ModItems::registerDispenserBehavior);
bus.addListener(NetworkRegistry::register); bus.addListener(NetworkRegistry::register);

View file

@ -77,14 +77,6 @@ public class InsidiousItemRenderer extends GeoItemRenderer<InsidiousItem> {
AnimationHelper.handleShootFlare(name, stack, itemStack, bone, buffer, packedLightIn, 0, 0, 1, 0.38); AnimationHelper.handleShootFlare(name, stack, itemStack, bone, buffer, packedLightIn, 0, 0, 1, 0.38);
if (name.equals("rot1")) {
bone.setRotZ((System.currentTimeMillis() % 36000000) / 400f);
}
if (name.equals("rot2")) {
bone.setRotZ(-(System.currentTimeMillis() % 36000000) / 400f);
}
AnimationHelper.handleZoomCrossHair(currentBuffer, renderType, name, stack, bone, buffer, 0, 0.359325, 40, 0.33f, 255, 0, 0, 255, "insidious", false); AnimationHelper.handleZoomCrossHair(currentBuffer, renderType, name, stack, bone, buffer, 0, 0.359325, 40, 0.33f, 255, 0, 0, 255, "insidious", false);
if (renderingArms) { if (renderingArms) {

View file

@ -0,0 +1,10 @@
package com.atsuishio.superbwarfare.client.renderer.molang;
import software.bernie.geckolib.loading.math.MathParser;
import software.bernie.geckolib.loading.math.value.Variable;
public class MolangVariable {
public static void register() {
MathParser.registerVariable(new Variable("sbw.system_time", System::currentTimeMillis));
}
}

View file

@ -2,7 +2,15 @@
"format_version": "1.8.0", "format_version": "1.8.0",
"animations": { "animations": {
"animation.insidious.idle": { "animation.insidious.idle": {
"animation_length": 1 "animation_length": 1,
"bones": {
"rot1": {
"rotation": [0, 0, "(sbw.system_time % 36000000) / 400 / 2 / math.pi * 360"]
},
"rot2": {
"rotation": [0, 0, "-(sbw.system_time % 36000000) / 400 / 2 / math.pi * 360"]
}
}
}, },
"animation.insidious.reload": { "animation.insidious.reload": {
"animation_length": 3, "animation_length": 3,
@ -300,34 +308,34 @@
"Lefthand": { "Lefthand": {
"rotation": { "rotation": {
"0.0": [0, 0, 0], "0.0": [0, 0, 0],
"0.0667": [-3.1936, 24.51049, 7.5871], "0.0833": [-3.1936, 24.51049, 7.5871],
"0.2": [-3.14008, 19.39916, 11.32393], "0.2083": [-3.14008, 19.39916, 11.32393],
"0.2917": [-4.46292, 0.94838, 16.96183], "0.2917": [-4.46292, 0.94838, 16.96183],
"0.4583": [-4.46292, 0.94838, 16.96183], "0.4583": [-4.46292, 0.94838, 16.96183],
"0.7083": [-4.46292, 0.94838, 16.96183], "0.7083": [-4.46292, 0.94838, 16.96183],
"0.8167": [-28.33435, -12.61568, 45.95484], "0.8333": [-28.33435, -12.61568, 45.95484],
"1.5417": [-28.33435, -12.61568, 45.95484], "1.5417": [-28.33435, -12.61568, 45.95484],
"1.75": [-15.82573, 15.60063, 31.96328], "1.75": [-15.82573, 15.60063, 31.96328],
"1.8": [-19.88703, 0.29301, 34.55901], "1.7917": [-19.88703, 0.29301, 34.55901],
"1.9333": [-18.4573, 3.88617, 32.29314], "1.9167": [-18.4573, 3.88617, 32.29314],
"2.0417": [0, 0, 7], "2.0417": [0, 0, 7],
"2.1083": [0, 0, 0] "2.125": [0, 0, 0]
}, },
"position": { "position": {
"0.0": [0, 0, 0], "0.0": [0, 0, 0],
"0.0667": [0, -0.8, 0], "0.0833": [0, -0.8, 0],
"0.2": [-0.09, -3.36, 9.03], "0.2083": [-0.09, -3.36, 9.03],
"0.2917": [-0.15, -2.75, 16], "0.2917": [-0.15, -2.75, 16],
"0.4583": [-0.15, -2.75, 16], "0.4583": [-0.15, -2.75, 16],
"0.7083": [-0.15, -2.75, 16], "0.7083": [-0.15, -2.75, 16],
"0.8167": [-0.55, -2.75, 17.65], "0.8333": [-0.55, -2.75, 17.65],
"1.5417": [-0.55, -2.75, 17.65], "1.5417": [-0.55, -2.75, 17.65],
"1.6417": [-1, -3.59, 15.87], "1.625": [-1, -3.59, 15.87],
"1.75": [-0.55, -7.7, 14.1], "1.75": [-0.55, -7.7, 14.1],
"1.8": [-0.55, -3.35, 16.25], "1.7917": [-0.55, -3.35, 16.25],
"1.9333": [-0.55, -5.5, 14.15], "1.9167": [-0.55, -5.5, 14.15],
"2.0417": [0, -1, 2], "2.0417": [0, -1, 2],
"2.1083": [0, 0, 0] "2.125": [0, 0, 0]
} }
}, },
"camera": { "camera": {
@ -477,67 +485,12 @@
"lerp_mode": "catmullrom" "lerp_mode": "catmullrom"
} }
} }
}
}
},
"animation.insidious.run": {
"loop": true,
"animation_length": 0.8,
"bones": {
"0": {
"rotation": {
"0.0": {
"post": [-19.82442, -57.81517, 38.62375],
"lerp_mode": "catmullrom"
},
"0.2": {
"post": [-23.65942, -57.81517, 38.62375],
"lerp_mode": "catmullrom"
},
"0.4": {
"post": [-19.82442, -57.81517, 38.62375],
"lerp_mode": "catmullrom"
},
"0.6": {
"post": [-15.98942, -57.81517, 38.62375],
"lerp_mode": "catmullrom"
},
"0.8": {
"post": [-19.82442, -57.81517, 38.62375],
"lerp_mode": "catmullrom"
}
},
"position": {
"0.0": {
"post": [6.85, -3.45, 0],
"lerp_mode": "catmullrom"
},
"0.2": {
"post": [4.8, -2.45, 0],
"lerp_mode": "catmullrom"
},
"0.4": {
"post": [3.1, -3.45, 0],
"lerp_mode": "catmullrom"
},
"0.6": {
"post": [4.35, -2.45, 0],
"lerp_mode": "catmullrom"
},
"0.8": {
"post": [6.85, -3.45, 0],
"lerp_mode": "catmullrom"
}
}
}, },
"camera": { "rot1": {
"rotation": { "rotation": [0, 0, "(sbw.system_time % 36000000) / 400 / 2 / math.pi * 360"]
"0.0": [-0.3, -0.3, 0.3], },
"0.2": [0.3, 0, -0.3], "rot2": {
"0.4": [-0.3, 0.3, 0.3], "rotation": [0, 0, "-(sbw.system_time % 36000000) / 400 / 2 / math.pi * 360"]
"0.6": [0.3, 0, -0.3],
"0.8": [-0.3, -0.3, 0.3]
}
} }
} }
}, },
@ -604,6 +557,79 @@
"0.525": [0.3, 0, -0.3], "0.525": [0.3, 0, -0.3],
"0.7": [-0.3, -0.3, 0.3] "0.7": [-0.3, -0.3, 0.3]
} }
},
"rot1": {
"rotation": [0, 0, "(sbw.system_time % 36000000) / 400 / 2 / math.pi * 360"]
},
"rot2": {
"rotation": [0, 0, "-(sbw.system_time % 36000000) / 400 / 2 / math.pi * 360"]
}
}
},
"animation.insidious.run": {
"loop": true,
"animation_length": 1,
"bones": {
"0": {
"rotation": {
"0.0": {
"post": [-19.82442, -57.81517, 38.62375],
"lerp_mode": "catmullrom"
},
"0.2": {
"post": [-23.65942, -57.81517, 38.62375],
"lerp_mode": "catmullrom"
},
"0.4": {
"post": [-19.82442, -57.81517, 38.62375],
"lerp_mode": "catmullrom"
},
"0.6": {
"post": [-15.98942, -57.81517, 38.62375],
"lerp_mode": "catmullrom"
},
"0.8": {
"post": [-19.82442, -57.81517, 38.62375],
"lerp_mode": "catmullrom"
}
},
"position": {
"0.0": {
"post": [6.85, -3.45, 0],
"lerp_mode": "catmullrom"
},
"0.2": {
"post": [4.8, -2.45, 0],
"lerp_mode": "catmullrom"
},
"0.4": {
"post": [3.1, -3.45, 0],
"lerp_mode": "catmullrom"
},
"0.6": {
"post": [4.35, -2.45, 0],
"lerp_mode": "catmullrom"
},
"0.8": {
"post": [6.85, -3.45, 0],
"lerp_mode": "catmullrom"
}
}
},
"camera": {
"rotation": {
"0.0": [-0.3, -0.3, 0.3],
"0.2": [0.3, 0, -0.3],
"0.4": [-0.3, 0.3, 0.3],
"0.6": [0.3, 0, -0.3],
"0.8": [-0.3, -0.3, 0.3]
}
},
"rot1": {
"rotation": [0, 0, "(sbw.system_time % 36000000) / 400 / 2 / math.pi * 360"]
},
"rot2": {
"rotation": [0, 0, "-(sbw.system_time % 36000000) / 400 / 2 / math.pi * 360"]
} }
} }
} }