优化近防炮攻击移动靶提前量
This commit is contained in:
parent
d2aeaa6a0a
commit
2d6dd4cf35
2 changed files with 19 additions and 19 deletions
|
@ -63,24 +63,26 @@ public class SmallCannonShellEntity extends FastThrowableProjectile implements G
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onHitEntity(EntityHitResult result) {
|
protected void onHitEntity(EntityHitResult result) {
|
||||||
Entity entity = result.getEntity();
|
if (this.level() instanceof ServerLevel) {
|
||||||
if (this.getOwner() instanceof LivingEntity living) {
|
Entity entity = result.getEntity();
|
||||||
if (!living.level().isClientSide() && living instanceof ServerPlayer player) {
|
if (this.getOwner() instanceof LivingEntity living) {
|
||||||
living.level().playSound(null, living.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
|
if (!living.level().isClientSide() && living instanceof ServerPlayer player) {
|
||||||
PacketDistributor.sendToPlayer(player, new ClientIndicatorMessage(0, 5));
|
living.level().playSound(null, living.blockPosition(), ModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
|
||||||
|
PacketDistributor.sendToPlayer(player, new ClientIndicatorMessage(0, 5));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
entity.hurt(ModDamageTypes.causeCannonFireDamage(this.level().registryAccess(), this, this.getOwner()), damage);
|
entity.hurt(ModDamageTypes.causeCannonFireDamage(this.level().registryAccess(), this, this.getOwner()), damage);
|
||||||
|
|
||||||
if (entity instanceof LivingEntity) {
|
if (entity instanceof LivingEntity) {
|
||||||
entity.invulnerableTime = 0;
|
entity.invulnerableTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.tickCount > 0 && this.level() instanceof ServerLevel) {
|
if (this.tickCount > 0) {
|
||||||
causeExplode(result.getLocation());
|
causeExplode(result.getLocation());
|
||||||
|
}
|
||||||
|
this.discard();
|
||||||
}
|
}
|
||||||
this.discard();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -267,7 +267,7 @@ public class Hpj11Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3 targetPos = new Vec3(target.getX(), target.getY() + target.getBbHeight() / 2, target.getZ());
|
Vec3 targetPos = new Vec3(target.getX(), target.getY() + target.getBbHeight() / 2, target.getZ()).add(target.getDeltaMovement().scale(2.5));
|
||||||
Vec3 targetVec = barrelRootPos.vectorTo(targetPos).normalize();
|
Vec3 targetVec = barrelRootPos.vectorTo(targetPos).normalize();
|
||||||
|
|
||||||
double d0 = targetVec.x;
|
double d0 = targetVec.x;
|
||||||
|
@ -280,11 +280,9 @@ public class Hpj11Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
float diffY = Math.clamp(-90f, 90f, Mth.wrapDegrees(targetY - this.getYRot()));
|
float diffY = Math.clamp(-90f, 90f, Mth.wrapDegrees(targetY - this.getYRot()));
|
||||||
|
|
||||||
turretTurnSound(0, diffY, 1.1f);
|
turretTurnSound(0, diffY, 1.1f);
|
||||||
|
this.setYRot(this.getYRot() + Mth.clamp(0.9f * diffY, -20f, 20f));
|
||||||
|
|
||||||
this.setYRot(this.getYRot() + Mth.clamp(0.5f * diffY, -60f, 60f));
|
if (VectorTool.calculateAngle(getViewVector(1), targetVec) < 3) {
|
||||||
this.setRot(this.getYRot(), this.getXRot());
|
|
||||||
|
|
||||||
if (VectorTool.calculateAngle(getViewVector(1), targetVec) < 1) {
|
|
||||||
if (checkNoClip(target) && entityData.get(AMMO) > 0) {
|
if (checkNoClip(target) && entityData.get(AMMO) > 0) {
|
||||||
vehicleShoot(player, 0);
|
vehicleShoot(player, 0);
|
||||||
} else {
|
} else {
|
||||||
|
@ -421,7 +419,7 @@ public class Hpj11Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
Vector4f worldPosition = transformPosition(transform, 0f, 0.4f, 2.6875f);
|
Vector4f worldPosition = transformPosition(transform, 0f, 0.4f, 2.6875f);
|
||||||
|
|
||||||
entityToSpawn.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
|
entityToSpawn.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
|
||||||
entityToSpawn.shoot(getLookAngle().x, getLookAngle().y, getLookAngle().z, 40, 0.3f);
|
entityToSpawn.shoot(getLookAngle().x, getLookAngle().y, getLookAngle().z, 50, 0.5f);
|
||||||
level().addFreshEntity(entityToSpawn);
|
level().addFreshEntity(entityToSpawn);
|
||||||
|
|
||||||
if (!player.level().isClientSide) {
|
if (!player.level().isClientSide) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue