修改M870模型,优化波塞克动画

This commit is contained in:
Atsuihsio 2024-07-26 22:39:20 +08:00
parent 6c921a9c77
commit 6a9a63ca69
11 changed files with 7047 additions and 6946 deletions

View file

@ -5,6 +5,7 @@ import net.mcreator.target.item.gun.BocekItem;
import net.mcreator.target.network.TargetModVariables; import net.mcreator.target.network.TargetModVariables;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import software.bernie.geckolib.core.animatable.model.CoreGeoBone; import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
@ -35,6 +36,7 @@ public class BocekItemModel extends GeoModel<BocekItem> {
CoreGeoBone rh = getAnimationProcessor().getBone("ys"); CoreGeoBone rh = getAnimationProcessor().getBone("ys");
CoreGeoBone lun = getAnimationProcessor().getBone("hualun1"); CoreGeoBone lun = getAnimationProcessor().getBone("hualun1");
CoreGeoBone shen = getAnimationProcessor().getBone("shen"); CoreGeoBone shen = getAnimationProcessor().getBone("shen");
CoreGeoBone shen_pos = getAnimationProcessor().getBone("shen_pos");
CoreGeoBone xian = getAnimationProcessor().getBone("xian1"); CoreGeoBone xian = getAnimationProcessor().getBone("xian1");
CoreGeoBone xian2 = getAnimationProcessor().getBone("xian2"); CoreGeoBone xian2 = getAnimationProcessor().getBone("xian2");
CoreGeoBone fire = getAnimationProcessor().getBone("fire"); CoreGeoBone fire = getAnimationProcessor().getBone("fire");
@ -42,32 +44,19 @@ public class BocekItemModel extends GeoModel<BocekItem> {
CoreGeoBone deng2 = getAnimationProcessor().getBone("deng2"); CoreGeoBone deng2 = getAnimationProcessor().getBone("deng2");
CoreGeoBone deng3 = getAnimationProcessor().getBone("deng3"); CoreGeoBone deng3 = getAnimationProcessor().getBone("deng3");
CoreGeoBone holo = getAnimationProcessor().getBone("holo"); CoreGeoBone holo = getAnimationProcessor().getBone("holo");
CoreGeoBone r = getAnimationProcessor().getBone("r");
Player player = Minecraft.getInstance().player; Player player = Minecraft.getInstance().player;
if (player == null) return; if (player == null) return;
ItemStack stack = player.getMainHandItem(); ItemStack stack = player.getMainHandItem();
if (!stack.is(TargetModTags.Items.GUN)) return; if (!stack.is(TargetModTags.Items.GUN)) return;
if (stack.getOrCreateTag().getInt("arrow_empty") > 0) { arrow.setHidden(stack.getOrCreateTag().getInt("arrow_empty") > 0);
arrow.setScaleX(0); jian.setHidden(stack.getOrCreateTag().getInt("max_ammo") == 0);
arrow.setScaleY(0);
arrow.setScaleZ(0);
}
if (stack.getOrCreateTag().getInt("max_ammo") == 0) { double pp = player.getPersistentData().getDouble("pullpos");
jian.setScaleX(0); double bp = player.getPersistentData().getDouble("bowpos");
jian.setScaleY(0); double hp = player.getPersistentData().getDouble("handpos");
jian.setScaleZ(0);
}
double pp = 0;
pp = player.getPersistentData().getDouble("pullpos");
double bp = 0;
bp = player.getPersistentData().getDouble("bowpos");
double hp = 0;
hp = player.getPersistentData().getDouble("handpos");
arrow.setPosZ(9f * (float) bp); arrow.setPosZ(9f * (float) bp);
rh.setPosZ(9f * (float) hp); rh.setPosZ(9f * (float) hp);
@ -81,39 +70,28 @@ public class BocekItemModel extends GeoModel<BocekItem> {
xian2.setPosZ(9f * (float) bp); xian2.setPosZ(9f * (float) bp);
gun.setScaleZ(1f - (0.2f * (float) pp)); gun.setScaleZ(1f - (0.2f * (float) pp));
gun.setRotZ(0.48f * (float) pp); gun.setRotZ(0.2f * (float) pp);
gun.setRotX(0.01f * (float) pp); gun.setRotX(0.01f * (float) pp);
gun.setPosZ(-3f * (float) pp); gun.setPosZ(-3f * (float) pp);
gun.setPosY(0f * (float) pp); gun.setPosY(0.1f * (float) pp);
r.setScaleZ(1f - (0.2f * (float) pp));
deng2.setRotX(1.6f * (float) bp); deng2.setRotX(1.6f * (float) bp);
deng2.setPosZ(0.05f * (float) bp); deng2.setPosZ(0.05f * (float) bp);
deng3.setRotX(-1.6f * (float) bp); deng3.setRotX(-1.6f * (float) bp);
deng3.setPosZ(0.05f * (float) bp); deng3.setPosZ(0.05f * (float) bp);
if (arrow.getPosZ() > 8.5) { deng.setHidden(!(arrow.getPosZ() > 8.5));
deng.setScaleX(1);
deng.setScaleY(1);
} else {
deng.setScaleX(0);
deng.setScaleY(0);
}
double p = 0; double p = player.getPersistentData().getDouble("zoom_pos");
p = player.getPersistentData().getDouble("zoom_pos"); double zp = player.getPersistentData().getDouble("zoom_pos_z");
double zp = 0; shen_pos.setPosX(-3.4f * (float) p);
zp = player.getPersistentData().getDouble("zoom_pos_z"); shen_pos.setPosY(6.76f * (float) p - (float) (0.2f * zp));
shen_pos.setPosZ(6.4f * (float) p + (float) (0.3f * zp));
r.setScaleZ(1f - (0.31f * (float) p));
shen.setRotZ(60 * Mth.DEG_TO_RAD * (float) p + (float) (0.05f * zp) - 0.2f);
shen.setPosX(3.08f * (float) p); holo.setHidden(!(shen_pos.getPosX() < -0.7 && gun.getPosZ() < -2.5));
shen.setPosY(4.38f * (float) p - (float) (0.2f * zp));
shen.setPosZ(3f * (float) p + (float) (0.3f * zp));
shen.setRotZ(0.478f * (float) p + (float) (0.05f * zp));
double FirePosZ = 0;
double FireRotX = 0;
double fp = player.getPersistentData().getDouble("fire_pos"); double fp = player.getPersistentData().getDouble("fire_pos");
double fr = player.getPersistentData().getDouble("fire_rot"); double fr = player.getPersistentData().getDouble("fire_rot");
@ -134,11 +112,8 @@ public class BocekItemModel extends GeoModel<BocekItem> {
float PosX = (float)player.getPersistentData().getDouble("gun_move_posX"); float PosX = (float)player.getPersistentData().getDouble("gun_move_posX");
float PosY = (float)player.getPersistentData().getDouble("gun_move_posY"); float PosY = (float)player.getPersistentData().getDouble("gun_move_posY");
double y = player.getPersistentData().getDouble("y");
double y = 0; double x = player.getPersistentData().getDouble("x");
double x = 0;
y = player.getPersistentData().getDouble("y");
x = player.getPersistentData().getDouble("x");
root.setPosX(PosX); root.setPosX(PosX);
@ -154,17 +129,10 @@ public class BocekItemModel extends GeoModel<BocekItem> {
CoreGeoBone move = getAnimationProcessor().getBone("move"); CoreGeoBone move = getAnimationProcessor().getBone("move");
double m = 0; double m = player.getPersistentData().getDouble("move");
m = player.getPersistentData().getDouble("move"); double yaw = player.getPersistentData().getDouble("yaw");
double pit = player.getPersistentData().getDouble("gun_pitch");
double yaw = 0; double vy = player.getPersistentData().getDouble("vy");
yaw = player.getPersistentData().getDouble("yaw");
double pit = 0;
pit = player.getPersistentData().getDouble("gun_pitch");
double vy = 0;
vy = player.getPersistentData().getDouble("vy");
move.setPosY(-1 * (float) vy); move.setPosY(-1 * (float) vy);
@ -172,16 +140,16 @@ public class BocekItemModel extends GeoModel<BocekItem> {
move.setRotX(0.5f * (float) pit); move.setRotX(0.5f * (float) pit);
move.setRotZ(3.7f * (float) yaw + 2.7f * (float) m); move.setRotZ(0.7f * (float) yaw + 2.7f * (float) m);
move.setRotY(1.9f * (float) yaw - 1.7f * (float) m); move.setRotY(0.9f * (float) yaw - 1.7f * (float) m);
if (shen.getPosX() > 2.9 && gun.getRotZ() > 0.42) { CoreGeoBone camera = getAnimationProcessor().getBone("camera");
holo.setScaleX(1);
holo.setScaleY(1); player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
} else {
holo.setScaleX(0); player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
holo.setScaleY(0);
} player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
} }
} }

View file

@ -36,7 +36,7 @@ public class CrossHairOverlay {
if (player == null) { if (player == null) {
return; return;
} }
ItemStack stack = player.getMainHandItem();
double spread = player.getPersistentData().getDouble("crosshair"); double spread = player.getPersistentData().getDouble("crosshair");
RenderSystem.disableDepthTest(); RenderSystem.disableDepthTest();
@ -46,7 +46,7 @@ public class CrossHairOverlay {
RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
RenderSystem.setShaderColor(1, 1, 1, 1); RenderSystem.setShaderColor(1, 1, 1, 1);
if (shouldRenderCrossHair(player)) { if (shouldRenderCrossHair(player) || stack.is(TargetModItems.MINIGUN.get())) {
preciseBlit(event.getGuiGraphics(), new ResourceLocation("target:textures/screens/point.png"), w / 2f - 7.5f, h / 2f - 8, 0, 0, 16, 16, 16, 16); preciseBlit(event.getGuiGraphics(), new ResourceLocation("target:textures/screens/point.png"), w / 2f - 7.5f, h / 2f - 8, 0, 0, 16, 16, 16, 16);
preciseBlit(event.getGuiGraphics(), new ResourceLocation("target:textures/screens/rexheng.png"), w / 2f - 9.5f - 2.8f * (float) spread, h / 2f - 8, 0, 0, 16, 16, 16, 16); preciseBlit(event.getGuiGraphics(), new ResourceLocation("target:textures/screens/rexheng.png"), w / 2f - 9.5f - 2.8f * (float) spread, h / 2f - 8, 0, 0, 16, 16, 16, 16);
preciseBlit(event.getGuiGraphics(), new ResourceLocation("target:textures/screens/rexheng.png"), w / 2f - 6.5f + 2.8f * (float) spread, h / 2f - 8, 0, 0, 16, 16, 16, 16); preciseBlit(event.getGuiGraphics(), new ResourceLocation("target:textures/screens/rexheng.png"), w / 2f - 6.5f + 2.8f * (float) spread, h / 2f - 8, 0, 0, 16, 16, 16, 16);
@ -79,7 +79,6 @@ public class CrossHairOverlay {
RenderSystem.disableBlend(); RenderSystem.disableBlend();
RenderSystem.setShaderColor(1, 1, 1, 1); RenderSystem.setShaderColor(1, 1, 1, 1);
ItemStack stack = player.getMainHandItem();
if (!stack.is(TargetModTags.Items.GUN)) return; if (!stack.is(TargetModTags.Items.GUN)) return;
if (stack.getOrCreateTag().getBoolean("need_bolt_action")) { if (stack.getOrCreateTag().getBoolean("need_bolt_action")) {
@ -95,7 +94,7 @@ public class CrossHairOverlay {
if (player == null) return false; if (player == null) return false;
if (player.isSpectator()) return false; if (player.isSpectator()) return false;
if (!player.getMainHandItem().is(TargetModTags.Items.GUN) || (player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zoom) if (!player.getMainHandItem().is(TargetModTags.Items.GUN) || (player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zooming)
return false; return false;
return !(player.getMainHandItem().getItem() == TargetModItems.M_79.get()) return !(player.getMainHandItem().getItem() == TargetModItems.M_79.get())

View file

@ -394,9 +394,9 @@ public class ClientEventHandler {
CompoundTag persistentData = entity.getPersistentData(); CompoundTag persistentData = entity.getPersistentData();
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).bowPull) { if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).bowPull) {
persistentData.putDouble("pulltime", Math.min(persistentData.getDouble("pulltime") + 0.014 * times, 1)); persistentData.putDouble("pulltime", Math.min(persistentData.getDouble("pulltime") + 0.018 * times, 1));
persistentData.putDouble("bowtime", Math.min(persistentData.getDouble("bowtime") + 0.014 * times, 1)); persistentData.putDouble("bowtime", Math.min(persistentData.getDouble("bowtime") + 0.018 * times, 1));
persistentData.putDouble("handtime", Math.min(persistentData.getDouble("handtime") + 0.014 * times, 1)); persistentData.putDouble("handtime", Math.min(persistentData.getDouble("handtime") + 0.018 * times, 1));
persistentData.putDouble("handpos", (0.5 * Math.cos(Math.PI * Math.pow(Math.pow(persistentData.getDouble("handtime"), 2) - 1, 2)) + 0.5)); persistentData.putDouble("handpos", (0.5 * Math.cos(Math.PI * Math.pow(Math.pow(persistentData.getDouble("handtime"), 2) - 1, 2)) + 0.5));
} else { } else {
persistentData.putDouble("pulltime", Math.max(persistentData.getDouble("pulltime") - 0.009 * times, 0)); persistentData.putDouble("pulltime", Math.max(persistentData.getDouble("pulltime") - 0.009 * times, 0));

View file

@ -82,6 +82,10 @@ public class BocekItem extends GunItem implements GeoItem, AnimatedItem {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.bocek.draw")); return event.setAndContinue(RawAnimation.begin().thenLoop("animation.bocek.draw"));
} }
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.bocek.run"));
}
if (this.animationProcedure.equals("empty")) { if (this.animationProcedure.equals("empty")) {
event.getController().setAnimation(RawAnimation.begin().thenLoop("animation.bocek.idle")); event.getController().setAnimation(RawAnimation.begin().thenLoop("animation.bocek.idle"));
return PlayState.CONTINUE; return PlayState.CONTINUE;
@ -109,7 +113,7 @@ public class BocekItem extends GunItem implements GeoItem, AnimatedItem {
public void registerControllers(AnimatableManager.ControllerRegistrar data) { public void registerControllers(AnimatableManager.ControllerRegistrar data) {
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate); var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController); data.add(procedureController);
var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate); var idleController = new AnimationController<>(this, "idleController", 3, this::idlePredicate);
data.add(idleController); data.add(idleController);
} }

View file

@ -5,7 +5,7 @@
"loop": true, "loop": true,
"animation_length": 1, "animation_length": 1,
"bones": { "bones": {
"bow": { "r": {
"rotation": { "rotation": {
"vector": [0, 0, 0] "vector": [0, 0, 0]
} }
@ -15,14 +15,9 @@
"animation.bocek.draw": { "animation.bocek.draw": {
"animation_length": 1, "animation_length": 1,
"bones": { "bones": {
"bow": {
"rotation": {
"vector": [0, 0, 0]
}
},
"anim": { "anim": {
"rotation": { "rotation": {
"0.0": { "0.1667": {
"vector": [27.21312, -47.42646, -2.0218] "vector": [27.21312, -47.42646, -2.0218]
}, },
"0.2917": { "0.2917": {
@ -39,8 +34,8 @@
} }
}, },
"position": { "position": {
"0.0": { "0.1667": {
"vector": [3, -17.3, 0] "vector": [5, -27.3, 5]
}, },
"0.4167": { "0.4167": {
"vector": [0, 0, -1.65] "vector": [0, 0, -1.65]
@ -54,6 +49,70 @@
} }
} }
} }
},
"animation.bocek.run": {
"loop": true,
"animation_length": 0.8333,
"bones": {
"camera": {
"rotation": {
"0.0": {
"vector": [-0.3, -0.3, 0.3]
},
"0.2083": {
"vector": [0.3, 0, -0.3]
},
"0.4167": {
"vector": [-0.3, 0.3, 0.3]
},
"0.5833": {
"vector": [0.3, 0, -0.3]
},
"0.7917": {
"vector": [-0.3, -0.3, 0.3]
}
}
},
"anim": {
"rotation": {
"0.0": {
"vector": [10, -10, 5]
},
"0.2083": {
"vector": [5, -6, 1]
},
"0.4167": {
"vector": [10, -2, -7.5]
},
"0.625": {
"vector": [5, -4, -2]
},
"0.8333": {
"vector": [10, -10, 5]
}
},
"position": {
"0.0": {
"vector": [2.49619, -1.07196, 0.17365]
},
"0.2083": {
"vector": [-0.25, 0.5, 0],
"easing": "easeInSine"
},
"0.4167": {
"vector": [-2.4969, -1.11525, 0.13864],
"easing": "easeOutSine"
},
"0.625": {
"vector": [-0.25, 0.5, 0],
"easing": "easeInSine"
},
"0.8333": {
"vector": [2.49619, -1.07196, 0.17365]
}
}
}
}
} }
}, },
"geckolib_format_version": 2 "geckolib_format_version": 2

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -7,38 +7,40 @@
], ],
"display": { "display": {
"firstperson_righthand": { "firstperson_righthand": {
"rotation": [
0,
0,
-54
],
"translation": [ "translation": [
-14.5, -10.25,
-2, -2.5,
-1.5 -7.25
],
"scale": [
0.8,
0.8,
0.8
] ]
}, },
"firstperson_lefthand": { "firstperson_lefthand": {
"rotation": [
0,
0,
70
],
"translation": [ "translation": [
-0.5, -80,
-2, -80,
-3.25 -80
], ],
"scale": [ "scale": [
0, 0,
0, 0,
0 0
] ]
},
"gui": {
"rotation": [
165.69,
-39.63,
178.66
],
"translation": [
0.25,
-3.5,
0
],
"scale": [
0.45,
0.45,
0.45
]
} }
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB