重制M870的动画,优化马林的抛壳,修复靶子在无来源伤害情况下会被打死的bug

This commit is contained in:
Atsuihsio 2024-06-07 15:33:04 +08:00
parent 763d707482
commit 44c60a0a18
12 changed files with 2204 additions and 1902 deletions

View file

@ -52,9 +52,9 @@ public class M870ItemModel extends GeoModel<M870Item> {
double zp = 0;
zp = player.getPersistentData().getDouble("zoom_pos_z");
gun.setPosX(5.22f * (float) p);
gun.setPosX(1.7f * (float) p);
gun.setPosY(3.00f * (float) p - (float) (0.7f * zp));
gun.setPosY(1.12f * (float) p - (float) (0.2f * zp));
gun.setPosZ(1.5f * (float) p + (float) (0.9f * zp));
@ -66,8 +66,8 @@ public class M870ItemModel extends GeoModel<M870Item> {
double fr = player.getPersistentData().getDouble("fire_rot");
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).zooming) {
shen.setPosY(0.4f * (float) (fp + 2 * fr));
shen.setPosZ(5.6f * (float) (fp + 0.54f * fr));
shen.setPosY(0.2f * (float) (fp + 2 * fr));
shen.setPosZ(2.6f * (float) (fp + 0.54f * fr));
shen.setRotX(0.28f * (float) (fp + fr));
shen.setRotZ(0f);
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon > 0) {
@ -76,8 +76,8 @@ public class M870ItemModel extends GeoModel<M870Item> {
shen.setRotY(-0.025f * (float) fr);
}
} else {
shen.setPosY(0.7f * (float) (fp + 2 * fr));
shen.setPosZ(6.2f * (float) (fp + 0.54f * fr));
shen.setPosY(0.3f * (float) (fp + 2 * fr));
shen.setPosZ(3.2f * (float) (fp + 0.54f * fr));
shen.setRotX(0.3f * (float) (0.18f * fp + fr));
shen.setRotZ(-0.01f * (float) (fp + 1.3 * fr));
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon > 0) {
@ -111,7 +111,7 @@ public class M870ItemModel extends GeoModel<M870Item> {
root.setPosX(PosX);
root.setPosY((float) y + 2.5f * PosY);
root.setPosY((float) y + PosY);
root.setRotX((float) x);
@ -142,5 +142,13 @@ public class M870ItemModel extends GeoModel<M870Item> {
move.setRotY(Mth.DEG_TO_RAD * (float) yRot);
move.setRotZ(2.7f * (float) m + Mth.DEG_TO_RAD * (float) zRot);
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

@ -191,7 +191,7 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa
boolean legshot = false;
float eyeHeight = entity.getEyeHeight();
float BodyHeight = entity.getBbHeight();
if ((eyeHeight - 0.3) < hitBoxPos.y && hitBoxPos.y < (eyeHeight + 0.4)) {
if ((eyeHeight - 0.35) < hitBoxPos.y && hitBoxPos.y < (eyeHeight + 0.4)) {
headshot = true;
}
if (hitBoxPos.y < (0.33 * BodyHeight)) {

View file

@ -29,10 +29,12 @@ import net.minecraft.world.entity.ai.navigation.PathNavigation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.ThrownPotion;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
@ -105,38 +107,11 @@ public class Target1Entity extends PathfinderMob implements GeoEntity, AnimatedE
@Override
public boolean hurt(DamageSource source, float amount) {
if (this.getPersistentData().getDouble("target_down") > 0) {
return false;
}
if (!this.level().isClientSide()) {
this.level().playSound(null, BlockPos.containing(this.getX(), this.getY(), this.getZ()), TargetModSounds.HIT.get(), SoundSource.BLOCKS, 2, 1);
this.level().playSound(null, BlockPos.containing(this.getX(), this.getY(), this.getZ()), TargetModSounds.HIT.get(), SoundSource.BLOCKS, 8, 1);
} else {
this.level().playLocalSound(this.getX(), this.getY(), this.getZ(), TargetModSounds.HIT.get(), SoundSource.BLOCKS, 2, 1, false);
this.level().playLocalSound(this.getX(), this.getY(), this.getZ(), TargetModSounds.HIT.get(), SoundSource.BLOCKS, 8, 1, false);
}
if (source.is(DamageTypes.IN_FIRE))
return false;
if (source.getDirectEntity() instanceof ThrownPotion || source.getDirectEntity() instanceof AreaEffectCloud)
return false;
if (source.is(DamageTypes.FALL))
return false;
if (source.is(DamageTypes.CACTUS))
return false;
if (source.is(DamageTypes.DROWN))
return false;
if (source.is(DamageTypes.LIGHTNING_BOLT))
return false;
if (source.is(DamageTypes.FALLING_ANVIL))
return false;
if (source.is(DamageTypes.DRAGON_BREATH))
return false;
if (source.is(DamageTypes.WITHER))
return false;
if (source.is(DamageTypes.WITHER_SKULL))
return false;
return super.hurt(source, amount);
}
@ -164,18 +139,45 @@ public class Target1Entity extends PathfinderMob implements GeoEntity, AnimatedE
super.readAdditionalSaveData(compound);
}
public static void onEntityAttacked(LivingAttackEvent event, DamageSource source) {
var entity = event.getEntity();
if (entity == null) return;
if (entity instanceof Target1Entity target1) {
if (source.is(DamageTypes.IN_FIRE)
|| source.getDirectEntity() instanceof ThrownPotion
|| source.getDirectEntity() instanceof AreaEffectCloud
|| source.is(DamageTypes.FALL)
|| source.is(DamageTypes.CACTUS)
|| source.is(DamageTypes.DROWN)
|| source.is(DamageTypes.LIGHTNING_BOLT)
|| source.is(DamageTypes.FALLING_ANVIL)
|| source.is(DamageTypes.DRAGON_BREATH)
|| source.is(DamageTypes.WITHER)
|| source.is(DamageTypes.WITHER_SKULL)
|| source.is(DamageTypes.MAGIC)) {
event.setCanceled(true);
}
if (entity.getPersistentData().getDouble("target_down") > 0) {
event.setCanceled(true);
}
}
}
@SubscribeEvent
public static void onTarget1Down(LivingDeathEvent event) {
var entity = event.getEntity();
var sourceEntity = event.getSource().getEntity();
if (entity == null || sourceEntity == null) return;
if (entity == null) return;
if (entity instanceof Target1Entity target1) {
event.setCanceled(true);
event.setCanceled(true);
target1.setHealth(target1.getMaxHealth());
if (sourceEntity == null) return;
if (sourceEntity instanceof Player player) {
player.displayClientMessage(Component.literal(("Target Down " + new java.text.DecimalFormat("##.#").format((entity.position()).distanceTo((sourceEntity.position()))) + "M")), true);
SoundTool.playLocalSound(player, TargetModSounds.TARGET_DOWN.get(), 100, 1);
@ -309,6 +311,7 @@ public class Target1Entity extends PathfinderMob implements GeoEntity, AnimatedE
protected void tickDeath() {
++this.deathTime;
if (this.deathTime >= 100) {
this.spawnAtLocation(new ItemStack(TargetModItems.TARGET_DEPLOYER.get()));
this.remove(Target1Entity.RemovalReason.KILLED);
}
}

View file

@ -343,8 +343,8 @@ public class GunEventHandler {
projectile.beast();
}
projectile.setPos(player.getX() - 0.1 * player.getLookAngle().x, player.getEyeY() - 0.1 - 0.1 * player.getLookAngle().y, player.getZ() + -0.1 * player.getLookAngle().z);
projectile.shoot(player.getLookAngle().x, player.getLookAngle().y + 0.001f , player.getLookAngle().z, 1 * (float) heldItem.getOrCreateTag().getDouble("velocity"),
projectile.setPos(player.getX() - 0.1 * player.getLookAngle().x, player.getEyeY() - 0.02 - 0.1 * player.getLookAngle().y, player.getZ() + -0.1 * player.getLookAngle().z);
projectile.shoot(player.getLookAngle().x, player.getLookAngle().y + 0.0015f , player.getLookAngle().z, 1 * (float) heldItem.getOrCreateTag().getDouble("velocity"),
(float) player.getAttributeBaseValue(TargetModAttributes.SPREAD.get()));
player.level().addFreshEntity(projectile);
}

View file

@ -142,7 +142,7 @@ public class M870Item extends GunItem implements GeoItem, AnimatedItem {
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate);
var idleController = new AnimationController<>(this, "idleController", 3, this::idlePredicate);
data.add(idleController);
}

View file

@ -149,7 +149,7 @@ public class MarlinItem extends GunItem implements GeoItem, AnimatedItem {
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate);
var idleController = new AnimationController<>(this, "idleController", 3, this::idlePredicate);
data.add(idleController);
}

File diff suppressed because it is too large Load diff

View file

@ -3,7 +3,14 @@
"animations": {
"animation.marlin.idle": {
"loop": true,
"animation_length": 2
"animation_length": 2,
"bones": {
"bullet": {
"scale": {
"vector": [0, 0, 0]
}
}
}
},
"animation.marlin.draw": {
"animation_length": 1,
@ -125,6 +132,11 @@
"vector": [-0.3, -0.3, 0.3]
}
}
},
"bullet": {
"scale": {
"vector": [0, 0, 0]
}
}
}
},
@ -138,6 +150,11 @@
"position": {
"vector": [0, 0, 0]
}
},
"bullet": {
"scale": {
"vector": [0, 0, 0]
}
}
}
},
@ -151,6 +168,11 @@
"position": {
"vector": [0, 0, 0]
}
},
"bullet": {
"scale": {
"vector": [0, 0, 0]
}
}
}
},
@ -287,6 +309,86 @@
}
}
},
"bullet": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"0.0833": {
"vector": [0, 0, 0]
},
"0.1": {
"vector": [0, 0, 0]
},
"0.15": {
"vector": [0, 0, 0]
},
"0.3167": {
"vector": [0, 200, 0]
},
"0.35": {
"vector": [0, 0, 0]
}
},
"position": {
"0.0": {
"vector": [0, 0, 0]
},
"0.0833": {
"vector": [0, 0, 0]
},
"0.1": {
"vector": [0, 0, -0.2]
},
"0.15": {
"vector": [0, 0, 1.5]
},
"0.1833": {
"vector": [-2.32654, 0.7466, 1.92913]
},
"0.2": {
"vector": [-4.27048, 1.1725, 2.40688]
},
"0.2167": {
"vector": [-5.89, 1.36, 2.95]
},
"0.2333": {
"vector": [-7.50182, 1.3413, 3.68384]
},
"0.25": {
"vector": [-8.97823, 1.019, 4.34468]
},
"0.2667": {
"vector": [-10.23, 0.46, 5.08]
},
"0.2833": {
"vector": [-11.78333, -0.3, 5.70914]
},
"0.3": {
"vector": [-13.24357, -1.77189, 6.06307]
},
"0.3333": {
"vector": [-1508.57, 2.02, 2.78]
},
"0.35": {
"vector": [0, 0, 0]
}
},
"scale": {
"0.0": {
"vector": [0, 0, 0]
},
"0.1": {
"vector": [1, 1, 1]
},
"0.2833": {
"vector": [1, 1, 1]
},
"0.3": {
"vector": [0, 0, 0]
}
}
},
"camera": {
"rotation": {
"0.0": {
@ -463,6 +565,83 @@
"easing": "easeInElastic"
}
}
},
"bullet": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"0.05": {
"vector": [0, 0, 0]
},
"0.0667": {
"vector": [0, 0, 0]
},
"0.1167": {
"vector": [0, 0, 0]
},
"0.25": {
"vector": [0, 200, 0]
},
"0.2833": {
"vector": [0, 0, 0]
}
},
"position": {
"0.0": {
"vector": [0, 0, 0]
},
"0.05": {
"vector": [0, 0, 0]
},
"0.0667": {
"vector": [0, 0, -0.2]
},
"0.1167": {
"vector": [0, 0, 1.5]
},
"0.15": {
"vector": [-2.32654, 0.7466, 1.92913]
},
"0.1667": {
"vector": [-4.27048, 1.1725, 2.40688]
},
"0.1833": {
"vector": [-5.89, 1.36, 2.95]
},
"0.2": {
"vector": [-7.50182, 1.3413, 3.68384]
},
"0.2167": {
"vector": [-8.97823, 1.019, 4.34468]
},
"0.2333": {
"vector": [-10.23, 0.46, 5.08]
},
"0.25": {
"vector": [-1508.57, 2.02, 2.78]
},
"0.2667": {
"vector": [0, 0, 0]
}
},
"scale": {
"0.0": {
"vector": [0, 0, 0]
},
"0.0333": {
"vector": [1, 1, 1]
},
"0.25": {
"vector": [1, 1, 1]
},
"0.2667": {
"vector": [0, 0, 0]
},
"0.45": {
"vector": [0, 0, 0]
}
}
}
}
},
@ -543,6 +722,11 @@
"vector": [0, 0, 0]
}
}
},
"bullet": {
"scale": {
"vector": [0, 0, 0]
}
}
}
},

File diff suppressed because it is too large Load diff

View file

@ -9,9 +9,9 @@
"display": {
"firstperson_righthand": {
"translation": [
-3.75,
-22,
7.25
-7.25,
4.75,
5.5
]
},
"firstperson_lefthand": {
@ -22,10 +22,20 @@
]
},
"gui": {
"rotation": [
165.69,
-39.63,
178.66
],
"translation": [
0,
-14.5,
-1.9,
-3.25,
0
],
"scale": [
0.18,
0.18,
0.18
]
}
}