调整A10起落架逻辑

This commit is contained in:
Atsuishio 2025-05-12 12:41:58 +08:00 committed by Light_Quanta
parent 1e1b58ffba
commit dd6d50fc6e
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
5 changed files with 18 additions and 19 deletions

View file

@ -194,7 +194,7 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, D
entity.level().playSound(null, entity.getOnPos(), entity instanceof Pig ? SoundEvents.PIG_HURT : ModSounds.MISSILE_WARNING.get(), SoundSource.PLAYERS, 2, 1f); entity.level().playSound(null, entity.getOnPos(), entity instanceof Pig ? SoundEvents.PIG_HURT : ModSounds.MISSILE_WARNING.get(), SoundSource.PLAYERS, 2, 1f);
} }
Vec3 targetPos = new Vec3(entity.getX(), entity.getEyeY() + (entity instanceof EnderDragon ? -3 : 0), entity.getZ()); Vec3 targetPos = new Vec3(entity.getX(), entity.getEyeY() + (entity instanceof EnderDragon ? -3 : 0) + 0.2 * distanceTo(entity), entity.getZ());
Vec3 toVec = getEyePosition().vectorTo(targetPos).normalize(); Vec3 toVec = getEyePosition().vectorTo(targetPos).normalize();
if (this.tickCount > 8) { if (this.tickCount > 8) {

View file

@ -58,7 +58,6 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
public static final EntityDataAccessor<Integer> LOADED_BOMB = SynchedEntityData.defineId(A10Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor<Integer> LOADED_BOMB = SynchedEntityData.defineId(A10Entity.class, EntityDataSerializers.INT);
public static final EntityDataAccessor<Integer> LOADED_MISSILE = SynchedEntityData.defineId(A10Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor<Integer> LOADED_MISSILE = SynchedEntityData.defineId(A10Entity.class, EntityDataSerializers.INT);
public static final EntityDataAccessor<Integer> FIRE_TIME = SynchedEntityData.defineId(A10Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor<Integer> FIRE_TIME = SynchedEntityData.defineId(A10Entity.class, EntityDataSerializers.INT);
public static final EntityDataAccessor<String> TARGET_UUID = SynchedEntityData.defineId(A10Entity.class, EntityDataSerializers.STRING); public static final EntityDataAccessor<String> TARGET_UUID = SynchedEntityData.defineId(A10Entity.class, EntityDataSerializers.STRING);
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
private float yRotSync; private float yRotSync;
@ -183,11 +182,11 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
lockingTargetO = getTargetUuid(); lockingTargetO = getTargetUuid();
super.baseTick(); super.baseTick();
float f = (float) Mth.clamp(Math.max((onGround() ? 0.88f : 0.885f) - 0.01 * getDeltaMovement().length(), 0.5) + 0.001f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90, 0.01, 0.99); float f = (float) Mth.clamp(Math.max((onGround() ? 0.805f : 0.81f) - 0.004 * getDeltaMovement().length(), 0.5) + 0.001f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90, 0.01, 0.99);
boolean forward = Mth.abs((float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) < 90; boolean forward = Mth.abs((float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) < 90;
this.setDeltaMovement(this.getDeltaMovement().add(this.getViewVector(1).scale((forward ? 0.13 : -0.02) * this.getDeltaMovement().length()))); this.setDeltaMovement(this.getDeltaMovement().add(this.getViewVector(1).scale((forward ? 0.23 : -0.02) * this.getDeltaMovement().length())));
this.setDeltaMovement(this.getDeltaMovement().multiply(f, f, f)); this.setDeltaMovement(this.getDeltaMovement().multiply(f, f, f));
if (this.isInWater() && this.tickCount % 4 == 0) { if (this.isInWater() && this.tickCount % 4 == 0) {
@ -291,7 +290,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
resetSeek(player); resetSeek(player);
} }
Entity entity = SeekTool.seekCustomSizeEntitiy(this, this.level(), 384, 20, 0.9, true); Entity entity = SeekTool.seekCustomSizeEntity(this, this.level(), 384, 20, 0.9, true);
if (entity != null) { if (entity != null) {
if (lockTime == 0) { if (lockTime == 0) {
setTargetUuid(String.valueOf(entity.getUUID())); setTargetUuid(String.valueOf(entity.getUUID()));
@ -359,7 +358,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
} }
if (backInputDown) { if (backInputDown) {
this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.002f, onGround() ? -0.04f : 0.05f)); this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.002f, onGround() ? -0.04f : 0.02f));
} }
} }
@ -382,8 +381,8 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
float roll = Mth.abs(Mth.clamp(getRoll() / 60, -1.5f, 1.5f)); float roll = Mth.abs(Mth.clamp(getRoll() / 60, -1.5f, 1.5f));
float addY = Mth.clamp(Math.max((this.onGround() ? 0.1f : 0.2f) * (float) Math.max(getDeltaMovement().dot(getViewVector(1)), 0), 0f) * diffY - 0.5f * this.entityData.get(DELTA_ROT), -1.5f * (roll + 1), 1.5f * (roll + 1)); float addY = Mth.clamp(Math.max((this.onGround() ? 0.1f : 0.2f) * (float) getDeltaMovement().length(), 0f) * diffY - 0.5f * this.entityData.get(DELTA_ROT), -2f * (roll + 1), 2f * (roll + 1));
float addX = Mth.clamp(Math.min((float) Math.max(getDeltaMovement().dot(getViewVector(1)) - 0.17, 0.01), 0.7f) * diffX, -2.4f, 2.4f); float addX = Mth.clamp(Math.min((float) Math.max(getDeltaMovement().dot(getViewVector(1)) - 0.15, 0.01), 0.7f) * diffX, -3.4f, 3.4f);
float addZ = this.entityData.get(DELTA_ROT) - (this.onGround() ? 0 : 0.01f) * diffY * (float) getDeltaMovement().dot(getViewVector(1)); float addZ = this.entityData.get(DELTA_ROT) - (this.onGround() ? 0 : 0.01f) * diffY * (float) getDeltaMovement().dot(getViewVector(1));
float i = getXRot() / 90; float i = getXRot() / 90;
@ -404,15 +403,15 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
this.setPropellerRot(this.getPropellerRot() + 30 * this.entityData.get(POWER)); this.setPropellerRot(this.getPropellerRot() + 30 * this.entityData.get(POWER));
// 起落架 // 起落架
if (!onGround() && getDeltaMovement().dot(getViewVector(1)) * 72 > 140) { if (!SeekTool.isOnGround(this, 15)) {
flyTime = Math.min(flyTime + 1, 20); flyTime = Math.min(flyTime + 1, 20);
} }
if (getDeltaMovement().dot(getViewVector(1)) * 72 < 140 && fly) { if (SeekTool.isOnGround(this, 15) && fly) {
flyTime = Math.max(flyTime - 1, 0); flyTime = Math.max(flyTime - 1, 0);
} }
if (!fly && flyTime == 20) { if (!fly && flyTime == 10) {
fly = true; fly = true;
} }
@ -434,7 +433,7 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity
this.consumeEnergy((int) (Mth.abs(this.entityData.get(POWER)) * VehicleConfig.A_10_MAX_ENERGY_COST.get())); this.consumeEnergy((int) (Mth.abs(this.entityData.get(POWER)) * VehicleConfig.A_10_MAX_ENERGY_COST.get()));
} }
this.setDeltaMovement(this.getDeltaMovement().add(getViewVector(1).scale(Math.max((90 + this.getXRot()) / 90, 0.8) * 0.4 * this.entityData.get(POWER)))); this.setDeltaMovement(this.getDeltaMovement().add(getViewVector(1).scale(Math.max((90 + this.getXRot()) / 90, 0.8) * 0.43 * this.entityData.get(POWER))));
double flapAngle = (getFlap1LRot() + getFlap1RRot()) / 2; double flapAngle = (getFlap1LRot() + getFlap1RRot()) / 2;
setDeltaMovement(getDeltaMovement().add(0.0f, Mth.clamp(Math.sin((onGround() ? 23 + flapAngle : -(getXRot() - 23) + flapAngle) * Mth.DEG_TO_RAD) * Math.sin((90 - this.getXRot()) * Mth.DEG_TO_RAD) * getDeltaMovement().dot(getViewVector(1)) * 0.063, -0.04, 0.065), 0.0f)); setDeltaMovement(getDeltaMovement().add(0.0f, Mth.clamp(Math.sin((onGround() ? 23 + flapAngle : -(getXRot() - 23) + flapAngle) * Mth.DEG_TO_RAD) * Math.sin((90 - this.getXRot()) * Mth.DEG_TO_RAD) * getDeltaMovement().dot(getViewVector(1)) * 0.063, -0.04, 0.065), 0.0f));
} }

View file

@ -117,7 +117,7 @@ public class ModEntities {
public static final DeferredHolder<EntityType<?>, EntityType<PrismTankEntity>> PRISM_TANK = register("prism_tank", public static final DeferredHolder<EntityType<?>, EntityType<PrismTankEntity>> PRISM_TANK = register("prism_tank",
EntityType.Builder.of(PrismTankEntity::new, MobCategory.MISC).setTrackingRange(64).setUpdateInterval(1).fireImmune().sized(5f, 2.6f)); EntityType.Builder.of(PrismTankEntity::new, MobCategory.MISC).setTrackingRange(64).setUpdateInterval(1).fireImmune().sized(5f, 2.6f));
public static final DeferredHolder<EntityType<?>, EntityType<A10Entity>> A_10A = register("a_10a", public static final DeferredHolder<EntityType<?>, EntityType<A10Entity>> A_10A = register("a_10a",
EntityType.Builder.of(A10Entity::new, MobCategory.MISC).setTrackingRange(64).setUpdateInterval(1).fireImmune().sized(8.625f, 4f)); EntityType.Builder.of(A10Entity::new, MobCategory.MISC).setTrackingRange(64).setUpdateInterval(1).fireImmune().sized(6, 3.5f));
private static <T extends Entity> DeferredHolder<EntityType<?>, EntityType<T>> register(String name, EntityType.Builder<T> entityTypeBuilder) { private static <T extends Entity> DeferredHolder<EntityType<?>, EntityType<T>> register(String name, EntityType.Builder<T> entityTypeBuilder) {
return REGISTRY.register(name, () -> entityTypeBuilder.build(name)); return REGISTRY.register(name, () -> entityTypeBuilder.build(name));

View file

@ -66,13 +66,13 @@ public class SeekTool {
.orElse(null); .orElse(null);
} }
public static Entity seekCustomSizeEntitiy(Entity entity, Level level, double seekRange, double seekAngle, double size, boolean checkOnGround) { public static Entity seekCustomSizeEntity(Entity entity, Level level, double seekRange, double seekAngle, double size, boolean checkOnGround) {
return StreamSupport.stream(EntityFindUtil.getEntities(level).getAll().spliterator(), false) return StreamSupport.stream(EntityFindUtil.getEntities(level).getAll().spliterator(), false)
.filter(e -> { .filter(e -> {
if (e.distanceTo(entity) <= seekRange && calculateAngle(e, entity) < seekAngle if (e.distanceTo(entity) <= seekRange && calculateAngle(e, entity) < seekAngle
&& e != entity && e != entity
&& baseFilter(e) && baseFilter(e)
&& (!checkOnGround || isOnGround(e)) && (!checkOnGround || isOnGround(e, 10))
&& e.getBoundingBox().getSize() >= size && e.getBoundingBox().getSize() >= size
&& smokeFilter(e) && smokeFilter(e)
&& e.getVehicle() == null && e.getVehicle() == null
@ -133,7 +133,7 @@ public class SeekTool {
&& e != entity && e != entity
&& e.getBoundingBox().getSize() >= size && e.getBoundingBox().getSize() >= size
&& baseFilter(e) && baseFilter(e)
&& (!checkOnGround || isOnGround(e)) && (!checkOnGround || isOnGround(e, 10))
&& smokeFilter(e) && smokeFilter(e)
&& e.getVehicle() == null && e.getVehicle() == null
&& (!e.isAlliedTo(entity) || e.getTeam() == null || e.getTeam().getName().equals("TDM"))) { && (!e.isAlliedTo(entity) || e.getTeam() == null || e.getTeam().getName().equals("TDM"))) {
@ -212,9 +212,9 @@ public class SeekTool {
|| includedByConfig(entity); || includedByConfig(entity);
} }
public static boolean isOnGround(Entity entity) { public static boolean isOnGround(Entity entity, double height) {
AtomicBoolean onGround = new AtomicBoolean(false); AtomicBoolean onGround = new AtomicBoolean(false);
AABB aabb = entity.getBoundingBox().expandTowards(0, -10, 0); AABB aabb = entity.getBoundingBox().expandTowards(0, -height, 0);
BlockPos.betweenClosedStream(aabb).forEach((pos) -> { BlockPos.betweenClosedStream(aabb).forEach((pos) -> {
BlockState blockstate = entity.level().getBlockState(pos); BlockState blockstate = entity.level().getBlockState(pos);
if (!blockstate.is(Blocks.AIR)) { if (!blockstate.is(Blocks.AIR)) {

View file

@ -3098,7 +3098,7 @@
"a10_engine": { "a10_engine": {
"sounds": [ "sounds": [
{ {
"attenuation_distance": 160, "attenuation_distance": 256,
"stream": true, "stream": true,
"name": "superbwarfare:a10/a10_engine" "name": "superbwarfare:a10/a10_engine"
} }