更新火炮

This commit is contained in:
Atsuihsio 2024-07-17 00:39:57 +08:00
parent b6fa4ef60e
commit 8bb6f0602a
11 changed files with 51 additions and 36 deletions

View file

@ -207,43 +207,25 @@ public class Mk42Entity extends PathfinderMob implements GeoEntity {
@Override
public void baseTick() {
super.baseTick();
double[] Timer = {0};
double totalTime = 10;
int sleepTime = 2;
double Duration = totalTime / sleepTime;
Runnable Runnable = () -> {
while (Timer[0] < Duration) {
if (this.getFirstPassenger() == null) return;
if (this.getFirstPassenger() == null) return;
Entity gunner = this.getFirstPassenger();
Entity gunner = this.getFirstPassenger();
float adjust_rateX = (float) Mth.clamp(Math.pow(gunner.getXRot() - this.getXRot(), 2),0,5f);
float adjust_rateY = (float) Mth.clamp(Math.pow(gunner.getYRot() - this.getYRot(), 2),0,3f);
float adjust_rateX = (float) Mth.clamp(Math.pow(gunner.getXRot() - this.getXRot(), 2),0,5f);
float adjust_rateY = (float) Mth.clamp(Math.pow(gunner.getYRot() - this.getYRot(), 2),0,3f);
if (RotY < gunner.getYRot()) {
RotY = (float) Mth.clamp(this.yHeadRot + adjust_rateY,Double.NEGATIVE_INFINITY, gunner.getYRot());
} else {
RotY = (float) Mth.clamp(this.yHeadRot- adjust_rateY,gunner.getYRot(),Double.POSITIVE_INFINITY);
}
if (RotY < gunner.getYRot()) {
RotY = (float) Mth.clamp(this.yHeadRot + adjust_rateY,Double.NEGATIVE_INFINITY, gunner.getYRot());
} else {
RotY = (float) Mth.clamp(this.yHeadRot- adjust_rateY,gunner.getYRot(),Double.POSITIVE_INFINITY);
}
if (RotX < gunner.getXRot()) {
RotX = Mth.clamp((Mth.clamp(this.getXRot() + adjust_rateX,-85 ,15)),-85, gunner.getXRot());
} else {
RotX = Mth.clamp((Mth.clamp(this.getXRot() - adjust_rateX,-85 ,15)),gunner.getXRot(),15);
}
Timer[0]++;
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
Thread Thread = new Thread(Runnable);
Thread.start();
if (RotX < gunner.getXRot()) {
RotX = Mth.clamp((Mth.clamp(this.getXRot() + adjust_rateX,-85 ,15)),-85, gunner.getXRot());
} else {
RotX = Mth.clamp((Mth.clamp(this.getXRot() - adjust_rateX,-85 ,15)),gunner.getXRot(),15);
}
this.refreshDimensions();
}

View file

@ -27,10 +27,8 @@ public class Mk42Model extends GeoModel<Mk42Entity> {
@Override
public void setCustomAnimations(Mk42Entity animatable, long instanceId, AnimationState animationState) {
CoreGeoBone barrle = getAnimationProcessor().getBone("maingun");
EntityModelData entityData = (EntityModelData) animationState.getData(DataTickets.ENTITY_MODEL_DATA);
barrle.setRotX((entityData.headPitch()) * Mth.DEG_TO_RAD);
}
}

View file

@ -58,7 +58,7 @@ public class He5Inches extends Item {
if (level instanceof ServerLevel server) {
MortarShellEntity entityToSpawn = new MortarShellEntity(TargetModEntities.MORTAR_SHELL.get(), player, level);
entityToSpawn.setPos(cannon.getX(), cannon.getEyeY(), cannon.getZ());
entityToSpawn.shoot(cannon.getLookAngle().x, cannon.getLookAngle().y, cannon.getLookAngle().z, 20, 0.1f);
entityToSpawn.shoot(cannon.getLookAngle().x, cannon.getLookAngle().y, cannon.getLookAngle().z, 10, 0.1f);
level.addFreshEntity(entityToSpawn);
if (player instanceof ServerPlayer serverPlayer) {
@ -68,6 +68,29 @@ public class He5Inches extends Item {
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), TargetModSounds.MK_42_VERYFAR.get(), SoundSource.PLAYERS, 32, 1);
}
server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE,
cannon.getX() + 5 * cannon.getLookAngle().x,
cannon.getY(),
cannon.getZ() + 5 * cannon.getLookAngle().z,
200, 5, 0.02, 5, 0.005);
server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE,
cannon.getX() + 10 * cannon.getLookAngle().x,
cannon.getEyeY() + 10 * cannon.getLookAngle().y,
cannon.getZ() + 10 * cannon.getLookAngle().z,
100, 0.5, 0.5, 0.5, 0.05);
// for (int index0 = 0; index0 < 40; index0++) {
// level.addParticle(ParticleTypes.CAMPFIRE_COSY_SMOKE,
// cannon.getX() + 8 * cannon.getLookAngle().x,
// cannon.getEyeY() + 8 * cannon.getLookAngle().y,
// cannon.getZ() + 8 * cannon.getLookAngle().z,
// (2 + 0.5 * (Math.random() - 0.5)) * cannon.getLookAngle().x,
// (2 + 0.5 * (Math.random() - 0.5)) * cannon.getLookAngle().y,
// (2 + 0.5 * (Math.random() - 0.5)) * cannon.getLookAngle().z);
// }
// server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, (player.getX() + 3 * player.getLookAngle().x), (player.getY() + 0.1 + 3 * player.getLookAngle().y), (player.getZ() + 3 * player.getLookAngle().z), 40, 0.4, 0.4, 0.4,
// 0.01);
// server.sendParticles(ParticleTypes.CAMPFIRE_COSY_SMOKE, player.getX(), player.getY(), player.getZ(), 100, 2.5, 0.04, 2.5, 0.005);

View file

@ -1194,7 +1194,19 @@
"mk_42_fire_1p": {
"sounds": [
{
"name": "target:mk_42/mk_42_fire_1p",
"name": "target:mk_42/mk_42_fire_1p_1",
"stream": false
},
{
"name": "target:mk_42/mk_42_fire_1p_2",
"stream": false
},
{
"name": "target:mk_42/mk_42_fire_1p_3",
"stream": false
},
{
"name": "target:mk_42/mk_42_fire_1p_4",
"stream": false
}
]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 436 B