重制专注动画,优化后坐力表现,添加子弹重力

This commit is contained in:
Atsuihsio 2024-05-28 15:06:52 +08:00
parent 30e4d6c231
commit 6062f66624
11 changed files with 856 additions and 511 deletions

View file

@ -4,6 +4,7 @@ import net.mcreator.target.item.gun.Devotion;
import net.mcreator.target.network.TargetModVariables;
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.core.animatable.model.CoreGeoBone;
@ -672,5 +673,13 @@ public class DevotionItemModel extends GeoModel<Devotion> {
l.setRotX(1.5f);
r.setRotX(1.5f);
}
CoreGeoBone camera = getAnimationProcessor().getBone("camera");
player.getPersistentData().putDouble("camera_rot_x", Mth.RAD_TO_DEG * camera.getRotX());
player.getPersistentData().putDouble("camera_rot_y", Mth.RAD_TO_DEG * camera.getRotY());
player.getPersistentData().putDouble("camera_rot_z", Mth.RAD_TO_DEG * camera.getRotZ());
}
}

View file

@ -243,6 +243,8 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
this.setPosRaw(this.getX() + vec.x, this.getY() + vec.y, this.getZ() + vec.z);
}
this.setDeltaMovement(new Vec3((this.getDeltaMovement().x()), (this.getDeltaMovement().y() - 0.1), (this.getDeltaMovement().z())));
this.tickCount++;
if (this.tickCount > 30) {
this.discard();

View file

@ -356,7 +356,22 @@ public class GunEventHandler {
public static void gunShoot(Player player) {
ItemStack heldItem = player.getMainHandItem();
player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.recoilHorizon = Math.random() < 0.5 ? -1 : 1;
if (Math.random() < 0.2) {
capability.recoilHorizon = -1;
}
if (Math.random() >= 0.2 && Math.random() < 0.4) {
capability.recoilHorizon = -0.5;
}
if (Math.random() >= 0.4 && Math.random() < 0.6) {
capability.recoilHorizon = 0;
}
if (Math.random() >= 0.6 && Math.random() < 0.8) {
capability.recoilHorizon = 0.5;
}
if (Math.random() > 0.8) {
capability.recoilHorizon = 1;
}
capability.recoil = 0.1;
capability.firing = 1;
capability.syncPlayerVariables(player);

View file

@ -327,13 +327,20 @@ public class PlayerEventHandler {
if (recoil > 0) {
recoil += 0.01;
double sinRes = Math.sin(2 * Math.PI * (1.03f * recoil - 0.032047110911)) + 0.2;
double sinRes = 0;
if (0 < recoil && recoil < 0.2) {
sinRes = (-18.34) * Math.pow(recoil, 2) + 8.58 * recoil;
}
if (0.2 <= recoil && recoil < 1) {
sinRes = 2.6 * Math.pow(recoil, 2) - 5.5 * recoil + 2.167;
}
float newPitch = ((float) (player.getXRot() - 7.5f * recoilY * ry * sinRes));
player.setXRot(newPitch);
player.xRotO = player.getXRot();
float newYaw = ((float) (player.getYRot() - 5f * recoilYaw * recoilX * rx * sinRes));
float newYaw = ((float) (player.getYRot() - 7.5f * recoilYaw * recoilX * rx * sinRes));
player.setYRot(newYaw);
player.yRotO = player.getYRot();
}

View file

@ -87,11 +87,11 @@ public class Devotion extends GunItem implements GeoItem, AnimatedItem {
}
if (stack.getOrCreateTag().getBoolean("reloading") && stack.getOrCreateTag().getBoolean("empty_reload")) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.devotion.reload"));
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.devotion.reload_empty"));
}
if (stack.getOrCreateTag().getBoolean("reloading") && !stack.getOrCreateTag().getBoolean("empty_reload")) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.devotion.reload2"));
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.devotion.reload_normal"));
}
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
@ -171,7 +171,7 @@ public class Devotion extends GunItem implements GeoItem, AnimatedItem {
itemTag.putDouble("reload_time", 0);
}
if (itemTag.getBoolean("reloading") && itemTag.getInt("ammo") == 0) {
if (itemTag.getDouble("reload_time") == 71) {
if (itemTag.getDouble("reload_time") == 92) {
entity.getPersistentData().putDouble("id", id);
if (entity instanceof ServerPlayer player) {
SoundTool.playLocalSound(player, TargetModSounds.DEVOTION_RELOAD_EMPTY.get(), 100, 1);
@ -191,7 +191,7 @@ public class Devotion extends GunItem implements GeoItem, AnimatedItem {
GunReload.reload(entity, GunInfo.Type.RIFLE);
}
} else if (itemTag.getBoolean("reloading") && itemTag.getInt("ammo") > 0) {
if (itemTag.getDouble("reload_time") == 51) {
if (itemTag.getDouble("reload_time") == 70) {
entity.getPersistentData().putDouble("id", id);
if (entity instanceof ServerPlayer player) {
SoundTool.playLocalSound(player, TargetModSounds.DEVOTION_RELOAD_NORMAL.get(), 100, 1);

View file

@ -230,12 +230,12 @@ public class PlayerReloadProcedure {
tag.putBoolean("reloading", true);
tag.putBoolean("empty_reload", false);
tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
tag.putDouble("reload_time", 51);
tag.putDouble("reload_time", 70);
} else if (tag.getInt("ammo") == 0) {
tag.putBoolean("reloading", true);
tag.putDouble("empty_reload", 1);
tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
tag.putDouble("reload_time", 71);
tag.putDouble("reload_time", 92);
}
}
if (player.getMainHandItem().getItem() == TargetModItems.RPK.get()

View file

@ -11,6 +11,10 @@
"visible_bounds_offset": [0, 2, 0]
},
"bones": [
{
"name": "camera",
"pivot": [2.57141, 4.16276, 7.17702]
},
{
"name": "root",
"pivot": [0, 0, 0]
@ -14206,11 +14210,11 @@
{
"name": "holo",
"parent": "0",
"pivot": [0, 3.85547, -80.5],
"pivot": [0, 3.67891, -4.5],
"cubes": [
{
"origin": [-1.1934, 1.56032, -80.5],
"size": [2.3868, 2.3868, 0],
"origin": [-0.19125, 3.48766, -4.5],
"size": [0.3825, 0.3825, 0],
"uv": {
"north": {"uv": [59.53906, 60.625], "uv_size": [3.125, 2.625]},
"east": {"uv": [3.16406, 110.30469], "uv_size": [8, 8]},