修改无人机带C4的模型,调整无人机飞控

This commit is contained in:
Atsuihsio 2025-01-23 01:12:21 +08:00
parent 4a549d40c9
commit 1ca260e231
6 changed files with 1651 additions and 1599 deletions

View file

@ -40,6 +40,7 @@ public class DroneModel extends GeoModel<DroneEntity> {
CoreGeoBone ammo5 = getAnimationProcessor().getBone("ammo5"); CoreGeoBone ammo5 = getAnimationProcessor().getBone("ammo5");
CoreGeoBone ammo6 = getAnimationProcessor().getBone("ammo6"); CoreGeoBone ammo6 = getAnimationProcessor().getBone("ammo6");
CoreGeoBone shell = getAnimationProcessor().getBone("shell"); CoreGeoBone shell = getAnimationProcessor().getBone("shell");
CoreGeoBone c4 = getAnimationProcessor().getBone("c4");
// TODO 适配C4模型 // TODO 适配C4模型
ammo6.setHidden(animatable.getEntityData().get(AMMO) <= 5); ammo6.setHidden(animatable.getEntityData().get(AMMO) <= 5);
@ -49,6 +50,7 @@ public class DroneModel extends GeoModel<DroneEntity> {
ammo2.setHidden(animatable.getEntityData().get(AMMO) <= 1); ammo2.setHidden(animatable.getEntityData().get(AMMO) <= 1);
ammo1.setHidden(animatable.getEntityData().get(AMMO) <= 0); ammo1.setHidden(animatable.getEntityData().get(AMMO) <= 0);
shell.setHidden(animatable.getEntityData().get(KAMIKAZE_MODE) != 1); shell.setHidden(animatable.getEntityData().get(KAMIKAZE_MODE) != 1);
c4.setHidden(animatable.getEntityData().get(KAMIKAZE_MODE) != 2);
CoreGeoBone weapon = getAnimationProcessor().getBone("Weapon"); CoreGeoBone weapon = getAnimationProcessor().getBone("Weapon");
String id = animatable.getEntityData().get(CONTROLLER); String id = animatable.getEntityData().get(CONTROLLER);

View file

@ -18,6 +18,7 @@ public class ExplosionConfig {
public static ForgeConfigSpec.IntValue DRONE_KAMIKAZE_HIT_DAMAGE; public static ForgeConfigSpec.IntValue DRONE_KAMIKAZE_HIT_DAMAGE;
public static ForgeConfigSpec.IntValue DRONE_KAMIKAZE_EXPLOSION_DAMAGE; public static ForgeConfigSpec.IntValue DRONE_KAMIKAZE_EXPLOSION_DAMAGE;
public static ForgeConfigSpec.IntValue DRONE_KAMIKAZE_EXPLOSION_RADIUS; public static ForgeConfigSpec.IntValue DRONE_KAMIKAZE_EXPLOSION_RADIUS;
public static ForgeConfigSpec.IntValue DRONE_KAMIKAZE_HIT_DAMAGE_C4;
public static ForgeConfigSpec.IntValue C4_EXPLOSION_COUNTDOWN; public static ForgeConfigSpec.IntValue C4_EXPLOSION_COUNTDOWN;
public static ForgeConfigSpec.IntValue C4_EXPLOSION_DAMAGE; public static ForgeConfigSpec.IntValue C4_EXPLOSION_DAMAGE;
@ -69,6 +70,9 @@ public class ExplosionConfig {
builder.comment("The hit damage of Drone Kamikaze"); builder.comment("The hit damage of Drone Kamikaze");
DRONE_KAMIKAZE_HIT_DAMAGE = builder.defineInRange("drone_kamikaze_hit_damage", 300, 1, 10000000); DRONE_KAMIKAZE_HIT_DAMAGE = builder.defineInRange("drone_kamikaze_hit_damage", 300, 1, 10000000);
builder.comment("The hit damage of Drone Kamikaze with C4");
DRONE_KAMIKAZE_HIT_DAMAGE_C4 = builder.defineInRange("drone_kamikaze_hit_damage_c4", 700, 1, 10000000);
builder.comment("The explosion damage of Drone Kamikaze"); builder.comment("The explosion damage of Drone Kamikaze");
DRONE_KAMIKAZE_EXPLOSION_DAMAGE = builder.defineInRange("drone_kamikaze_explosion_damage", 160, 1, 10000000); DRONE_KAMIKAZE_EXPLOSION_DAMAGE = builder.defineInRange("drone_kamikaze_explosion_damage", 160, 1, 10000000);
@ -80,13 +84,13 @@ public class ExplosionConfig {
builder.push("C4"); builder.push("C4");
builder.comment("The explosion damage of C4"); builder.comment("The explosion damage of C4");
C4_EXPLOSION_DAMAGE = builder.defineInRange("c4_explosion_damage", 700, 1, Integer.MAX_VALUE); C4_EXPLOSION_DAMAGE = builder.defineInRange("c4_explosion_damage", 500, 1, Integer.MAX_VALUE);
builder.comment("The explosion countdown of C4"); builder.comment("The explosion countdown of C4");
C4_EXPLOSION_COUNTDOWN = builder.defineInRange("c4_explosion_countdown", 514, 1, Integer.MAX_VALUE); C4_EXPLOSION_COUNTDOWN = builder.defineInRange("c4_explosion_countdown", 514, 1, Integer.MAX_VALUE);
builder.comment("The explosion radius of C4"); builder.comment("The explosion radius of C4");
C4_EXPLOSION_RADIUS = builder.defineInRange("c4_explosion_radius", 24, 1, Integer.MAX_VALUE); C4_EXPLOSION_RADIUS = builder.defineInRange("c4_explosion_radius", 14, 1, Integer.MAX_VALUE);
builder.pop(); builder.pop();
} }

View file

@ -161,11 +161,13 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
@Override @Override
public void baseTick() { public void baseTick() {
pitchO = this.getBodyPitch(); pitchO = this.getBodyPitch();
setBodyXRot(pitch * 0.9f); setBodyXRot(pitch * 0.97f);
propellerRotO = this.getPropellerRot(); propellerRotO = this.getPropellerRot();
super.baseTick(); super.baseTick();
setZRot(getRoll() * 0.9f);
if (this.level() instanceof ServerLevel serverLevel) { if (this.level() instanceof ServerLevel serverLevel) {
// 更新需要加载的区块 // 更新需要加载的区块
ChunkLoadTool.updateLoadedChunks(serverLevel, this, this.loadedChunks); ChunkLoadTool.updateLoadedChunks(serverLevel, this, this.loadedChunks);
@ -380,20 +382,19 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
if (!this.onGround()) { if (!this.onGround()) {
// left and right // left and right
if (rightInputDown) { if (rightInputDown) {
this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) - 0.3f); this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) - 0.28f);
} else if (this.leftInputDown) { } else if (this.leftInputDown) {
this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) + 0.3f); this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) + 0.28f);
} }
// forward and backward // forward and backward
if (forwardInputDown) { if (forwardInputDown) {
this.entityData.set(DELTA_X_ROT, this.entityData.get(DELTA_X_ROT) - 0.3f); this.entityData.set(DELTA_X_ROT, this.entityData.get(DELTA_X_ROT) - 0.25f);
} else if (backInputDown) { } else if (backInputDown) {
this.entityData.set(DELTA_X_ROT, this.entityData.get(DELTA_X_ROT) + 0.3f); this.entityData.set(DELTA_X_ROT, this.entityData.get(DELTA_X_ROT) + 0.23f);
} }
float f = (float) (0.97f - 0.02f * lastTickSpeed); this.setDeltaMovement(this.getDeltaMovement().multiply(0.84, 0.77, 0.84));
this.setDeltaMovement(this.getDeltaMovement().multiply(f, 0.9, f));
} else { } else {
this.setDeltaMovement(this.getDeltaMovement().multiply(0.8, 1, 0.8)); this.setDeltaMovement(this.getDeltaMovement().multiply(0.8, 1, 0.8));
@ -411,23 +412,23 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
boolean down = this.downInputDown; boolean down = this.downInputDown;
if (up) { if (up) {
this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + 0.01f, 0.15f)); this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + 0.03f, 0.2f));
} }
if (down) { if (down) {
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.01f, 0)); this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.02f, -0.1f));
} }
if (!(up || down)) { if (!(up || down)) {
if (this.getDeltaMovement().y() < 0) { if (this.getDeltaMovement().y() < 0) {
this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + 0.001f, 0.15f)); this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + 0.001f, 0.15f));
} else { } else {
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.001f, 0)); this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.001f, -0.1f));
} }
} }
this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) * 0.8f); this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) * 0.7f);
this.entityData.set(DELTA_X_ROT, this.entityData.get(DELTA_X_ROT) * 0.8f); this.entityData.set(DELTA_X_ROT, this.entityData.get(DELTA_X_ROT) * 0.7f);
this.entityData.set(PROPELLER_ROT, Mth.lerp(0.08f, this.entityData.get(PROPELLER_ROT), this.entityData.get(POWER))); this.entityData.set(PROPELLER_ROT, Mth.lerp(0.08f, this.entityData.get(PROPELLER_ROT), this.entityData.get(POWER)));
this.setPropellerRot(this.getPropellerRot() + 30 * this.entityData.get(PROPELLER_ROT)); this.setPropellerRot(this.getPropellerRot() + 30 * this.entityData.get(PROPELLER_ROT));
this.entityData.set(PROPELLER_ROT, this.entityData.get(PROPELLER_ROT) * 0.9995f); this.entityData.set(PROPELLER_ROT, this.entityData.get(PROPELLER_ROT) * 0.9995f);
@ -437,10 +438,10 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
setDeltaMovement(getDeltaMovement().add(0.0f, Math.min(Math.sin((90 - this.getBodyPitch()) * Mth.DEG_TO_RAD), Math.sin((90 + this.getRoll()) * Mth.DEG_TO_RAD)) * this.entityData.get(POWER), 0.0f)); setDeltaMovement(getDeltaMovement().add(0.0f, Math.min(Math.sin((90 - this.getBodyPitch()) * Mth.DEG_TO_RAD), Math.sin((90 + this.getRoll()) * Mth.DEG_TO_RAD)) * this.entityData.get(POWER), 0.0f));
Vector3f direction = getRightDirection().mul(Math.cos((this.getRoll() + 90) * Mth.DEG_TO_RAD) * 0.1f); Vector3f direction = getRightDirection().mul(Math.cos((this.getRoll() + 90) * Mth.DEG_TO_RAD) * 0.2f);
setDeltaMovement(getDeltaMovement().add(new Vec3(direction.x, direction.y, direction.z).scale(4))); setDeltaMovement(getDeltaMovement().add(new Vec3(direction.x, direction.y, direction.z).scale(4)));
Vector3f directionZ = getForwardDirection().mul(-Math.cos((this.getBodyPitch() + 90) * Mth.DEG_TO_RAD) * 0.1f); Vector3f directionZ = getForwardDirection().mul(-Math.cos((this.getBodyPitch() + 90) * Mth.DEG_TO_RAD) * 0.2f);
setDeltaMovement(getDeltaMovement().add(new Vec3(directionZ.x, directionZ.y, directionZ.z).scale(4))); setDeltaMovement(getDeltaMovement().add(new Vec3(directionZ.x, directionZ.y, directionZ.z).scale(4)));
Player controller = EntityFindUtil.findPlayer(this.level(), this.entityData.get(CONTROLLER)); Player controller = EntityFindUtil.findPlayer(this.level(), this.entityData.get(CONTROLLER));
@ -468,7 +469,12 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
public void hitEntityCrash(Player controller, Entity target) { public void hitEntityCrash(Player controller, Entity target) {
if (lastTickSpeed > 0.12) { if (lastTickSpeed > 0.12) {
if (this.entityData.get(KAMIKAZE_MODE) != 0 && 20 * lastTickSpeed > this.getHealth()) { if (this.entityData.get(KAMIKAZE_MODE) != 0 && 20 * lastTickSpeed > this.getHealth()) {
target.hurt(ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), this, controller), ExplosionConfig.DRONE_KAMIKAZE_HIT_DAMAGE.get()); if (this.entityData.get(KAMIKAZE_MODE) == 1) {
target.hurt(ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), this, controller), ExplosionConfig.DRONE_KAMIKAZE_HIT_DAMAGE.get());
} else if (this.entityData.get(KAMIKAZE_MODE) == 2) {
target.hurt(ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), this, controller), ExplosionConfig.DRONE_KAMIKAZE_HIT_DAMAGE_C4.get());
}
if (controller != null && controller.getMainHandItem().is(ModItems.MONITOR.get())) { if (controller != null && controller.getMainHandItem().is(ModItems.MONITOR.get())) {
Monitor.disLink(controller.getMainHandItem(), controller); Monitor.disLink(controller.getMainHandItem(), controller);
} }
@ -564,7 +570,13 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity {
explosion.explode(); explosion.explode();
ForgeEventFactory.onExplosionStart(this.level(), explosion); ForgeEventFactory.onExplosionStart(this.level(), explosion);
explosion.finalizeExplosion(false); explosion.finalizeExplosion(false);
ParticleTool.spawnMediumExplosionParticles(this.level(), this.position()); if (mode == 1) {
ParticleTool.spawnMediumExplosionParticles(this.level(), this.position());
}
if (mode == 2) {
ParticleTool.spawnHugeExplosionParticles(this.level(), this.position());
}
} }
@Override @Override

File diff suppressed because it is too large Load diff

View file

@ -104,7 +104,8 @@
"scale": [0.5, 0.5, 0.5] "scale": [0.5, 0.5, 0.5]
}, },
"gui": { "gui": {
"rotation": [90, 90, 0], "rotation": [45, 45, 0],
"translation": [0, 3.75, 0],
"scale": [0.8, 0.8, 0.8] "scale": [0.8, 0.8, 0.8]
}, },
"head": { "head": {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB