小鸟改用小口径炮弹,载具第三人称开火时将使用第三人称射击音效,优化部分音频

This commit is contained in:
Atsuishio 2025-05-04 02:30:33 +08:00 committed by Light_Quanta
parent 053702df35
commit 53748fad73
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
17 changed files with 200 additions and 160 deletions

View file

@ -27,6 +27,6 @@ public class SmallCannonShellModel extends GeoModel<SmallCannonShellEntity> {
@Override
public void setCustomAnimations(SmallCannonShellEntity animatable, long instanceId, AnimationState animationState) {
GeoBone bone = getAnimationProcessor().getBone("bone");
bone.setScaleY((float) (1 + animatable.getDeltaMovement().length()));
bone.setScaleY((float) (1 + 2 * animatable.getDeltaMovement().length()));
}
}

View file

@ -60,6 +60,8 @@ public class VehicleConfig {
public static ModConfigSpec.IntValue AH_6_MAX_ENERGY_COST;
public static ModConfigSpec.IntValue AH_6_MAX_ENERGY;
public static ModConfigSpec.IntValue AH_6_CANNON_DAMAGE;
public static ModConfigSpec.IntValue AH_6_CANNON_EXPLOSION_DAMAGE;
public static ModConfigSpec.DoubleValue AH_6_CANNON_EXPLOSION_RADIUS;
public static ModConfigSpec.IntValue AH_6_ROCKET_DAMAGE;
public static ModConfigSpec.IntValue AH_6_ROCKET_EXPLOSION_DAMAGE;
public static ModConfigSpec.IntValue AH_6_ROCKET_EXPLOSION_RADIUS;
@ -278,7 +280,13 @@ public class VehicleConfig {
AH_6_MAX_ENERGY = builder.defineInRange("ah_6_max_energy", 5000000, 0, 2147483647);
builder.comment("The cannon damage of AH-6");
AH_6_CANNON_DAMAGE = builder.defineInRange("ah_6_cannon_damage", 20, 1, 10000000);
AH_6_CANNON_DAMAGE = builder.defineInRange("ah_6_cannon_damage", 25, 1, 10000000);
builder.comment("The cannon explosion damage of AH-6");
AH_6_CANNON_EXPLOSION_DAMAGE = builder.defineInRange("ah_6_cannon_explosion_damage", 13, 1, 10000000);
builder.comment("The cannon explosion damage of AH-6");
AH_6_CANNON_EXPLOSION_RADIUS = builder.defineInRange("ah_6_cannon_explosion_damage", 4d, 1, 10000000);
builder.comment("The rocket damage of AH-6");
AH_6_ROCKET_DAMAGE = builder.defineInRange("ah_6_rocket_damage", 80, 1, 10000000);
@ -309,7 +317,7 @@ public class VehicleConfig {
LAV_150_CANNON_EXPLOSION_DAMAGE = builder.defineInRange("lav_150_cannon_explosion_damage", 12, 1, 10000000);
builder.comment("The rocket explosion radius of LAV-150");
LAV_150_CANNON_EXPLOSION_RADIUS = builder.defineInRange("lav_150_cannon_explosion_radius", 3d, 1d, 10000000d);
LAV_150_CANNON_EXPLOSION_RADIUS = builder.defineInRange("lav_150_cannon_explosion_radius", 4d, 1d, 10000000d);
builder.pop();
@ -350,7 +358,7 @@ public class VehicleConfig {
BMP_2_CANNON_EXPLOSION_DAMAGE = builder.defineInRange("bmp_2_cannon_explosion_damage", 15, 1, 10000000);
builder.comment("The cannon explosion radius of BMP-2");
BMP_2_CANNON_EXPLOSION_RADIUS = builder.defineInRange("bmp_2_cannon_explosion_radius", 3.2d, 1d, 10000000d);
BMP_2_CANNON_EXPLOSION_RADIUS = builder.defineInRange("bmp_2_cannon_explosion_radius", 4d, 1d, 10000000d);
builder.pop();

View file

@ -13,19 +13,16 @@ import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.damagesource.DamageTypes;
import net.minecraft.world.entity.AreaEffectCloud;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.entity.projectile.ThrownPotion;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BellBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.entity.EntityTypeTest;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.Vec3;
@ -38,10 +35,10 @@ import software.bernie.geckolib.animation.AnimatableManager;
import software.bernie.geckolib.util.GeckoLibUtil;
public class SmallCannonShellEntity extends FastThrowableProjectile implements GeoEntity {
private float damage = 40.0f;
private float explosionDamage = 80f;
private float explosionRadius = 5f;
private boolean aa;
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
public SmallCannonShellEntity(EntityType<? extends SmallCannonShellEntity> type, Level world) {
@ -49,47 +46,12 @@ public class SmallCannonShellEntity extends FastThrowableProjectile implements G
this.noCulling = true;
}
public SmallCannonShellEntity(LivingEntity entity, Level level, float damage, float explosionDamage, float explosionRadius) {
public SmallCannonShellEntity(LivingEntity entity, Level level, float damage, float explosionDamage, float explosionRadius, boolean aa) {
super(ModEntities.SMALL_CANNON_SHELL.get(), entity, level);
this.damage = damage;
this.explosionDamage = explosionDamage;
this.explosionRadius = explosionRadius;
}
@Override
public boolean hurt(DamageSource source, float amount) {
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.DRAGON_BREATH))
return false;
if (source.is(DamageTypes.WITHER))
return false;
if (source.is(DamageTypes.WITHER_SKULL))
return false;
if (source.getDirectEntity() instanceof Projectile) {
source.getDirectEntity().discard();
}
if (source.getEntity() instanceof Projectile) {
source.getEntity().discard();
}
this.discard();
causeExplode(position());
return super.hurt(source, amount);
}
@Override
public boolean isPickable() {
return !this.isRemoved();
this.aa = aa;
}
@Override
@ -105,8 +67,6 @@ public class SmallCannonShellEntity extends FastThrowableProjectile implements G
@Override
protected void onHitEntity(@NotNull EntityHitResult result) {
Entity entity = result.getEntity();
if (result.getEntity() instanceof SmallCannonShellEntity) return;
if (this.level() instanceof ServerLevel) {
if (this.getOwner() instanceof LivingEntity living) {
if (!living.level().isClientSide() && living instanceof ServerPlayer player) {
@ -122,7 +82,7 @@ public class SmallCannonShellEntity extends FastThrowableProjectile implements G
}
if (this.tickCount > 0) {
causeExplode(result.getLocation());
causeExplode(result.getLocation(), true);
}
this.discard();
}
@ -137,12 +97,12 @@ public class SmallCannonShellEntity extends FastThrowableProjectile implements G
bell.attemptToRing(this.level(), resultPos, blockHitResult.getDirection());
}
if (this.level() instanceof ServerLevel) {
causeExplode(blockHitResult.getLocation());
causeExplode(blockHitResult.getLocation(), false);
}
this.discard();
}
private void causeExplode(Vec3 vec3) {
private void causeExplode(Vec3 vec3, boolean hitEntity) {
CustomExplosion explosion = new CustomExplosion(this.level(), this,
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(),
this,
@ -152,7 +112,7 @@ public class SmallCannonShellEntity extends FastThrowableProjectile implements G
vec3.y,
vec3.z,
explosionRadius,
ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).
hitEntity ? Explosion.BlockInteraction.KEEP : (ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP)).
setDamageMultiplier(1.25f);
explosion.explode();
EventHooks.onExplosionStart(this.level(), explosion);
@ -175,10 +135,33 @@ public class SmallCannonShellEntity extends FastThrowableProjectile implements G
if (this.tickCount > 200 || this.isInWater()) {
if (this.level() instanceof ServerLevel && !onGround()) {
causeExplode(position());
causeExplode(position(), false);
}
this.discard();
}
if (aa) {
crushProjectile(getDeltaMovement());
}
}
public void crushProjectile(Vec3 velocity) {
if (this.level() instanceof ServerLevel) {
var frontBox = getBoundingBox().inflate(3).expandTowards(velocity);
var entities = level().getEntities(
EntityTypeTest.forClass(Projectile.class), frontBox, entity -> entity != this).stream()
.filter(entity -> !(entity instanceof SmallCannonShellEntity) && (entity.getBbWidth() >= 0.3 || entity.getBbHeight() >= 0.3))
.toList();
for (var entity : entities) {
causeExplode(entity.position(), false);
entity.discard();
this.discard();
}
}
}
@Override

View file

@ -10,13 +10,12 @@ import com.atsuishio.superbwarfare.entity.vehicle.base.ThirdPersonCameraPosition
import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity;
import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier;
import com.atsuishio.superbwarfare.entity.vehicle.weapon.HeliRocketWeapon;
import com.atsuishio.superbwarfare.entity.vehicle.weapon.ProjectileWeapon;
import com.atsuishio.superbwarfare.entity.vehicle.weapon.SmallCannonShellWeapon;
import com.atsuishio.superbwarfare.entity.vehicle.weapon.VehicleWeapon;
import com.atsuishio.superbwarfare.init.ModDamageTypes;
import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.network.message.receive.ShakeClientMessage;
import com.atsuishio.superbwarfare.tools.Ammo;
import com.atsuishio.superbwarfare.tools.CustomExplosion;
import com.atsuishio.superbwarfare.tools.InventoryTool;
@ -39,10 +38,8 @@ import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.event.EventHooks;
import net.neoforged.neoforge.network.PacketDistributor;
import org.jetbrains.annotations.NotNull;
import org.joml.Math;
import org.joml.Matrix4f;
@ -53,8 +50,6 @@ import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
import software.bernie.geckolib.animation.AnimatableManager;
import software.bernie.geckolib.util.GeckoLibUtil;
import java.util.Comparator;
import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle;
public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity, HelicopterEntity, WeaponVehicleEntity {
@ -84,12 +79,10 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
public VehicleWeapon[][] initWeapons() {
return new VehicleWeapon[][]{
new VehicleWeapon[]{
new ProjectileWeapon()
new SmallCannonShellWeapon()
.damage(VehicleConfig.AH_6_CANNON_DAMAGE.get())
.headShot(2)
.zoom(false)
.heBullet(1)
.bypassArmorRate(0.1f)
.explosionDamage(VehicleConfig.AH_6_CANNON_EXPLOSION_DAMAGE.get().floatValue())
.explosionRadius(VehicleConfig.AH_6_CANNON_EXPLOSION_RADIUS.get().floatValue())
.sound(ModSounds.INTO_CANNON.get())
.icon(Mod.loc("textures/screens/vehicle_weapon/cannon_20mm.png")),
new HeliRocketWeapon()
@ -211,7 +204,7 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
return Ammo.HEAVY.get(stack) > 0;
}
return false;
}).mapToInt(Ammo.HEAVY::get).sum() + countItem(ModItems.HEAVY_AMMO.get());
}).mapToInt(Ammo.HEAVY::get).sum() + countItem(ModItems.SMALL_SHELL.get());
if ((hasItem(ModItems.ROCKET_70.get()) || InventoryTool.hasCreativeAmmoBox(player)) && reloadCoolDown == 0 && this.getEntityData().get(LOADED_ROCKET) < 14) {
this.entityData.set(LOADED_ROCKET, this.getEntityData().get(LOADED_ROCKET) + 1);
@ -524,9 +517,6 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
float y;
float z;
Vector4f worldPositionRight;
Vector4f worldPositionLeft;
if (getWeaponIndex(0) == 0) {
if (this.cannotFire) return;
@ -534,30 +524,24 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
y = 0.62f - 1.45f;
z = 0.8f;
worldPositionRight = transformPosition(transform, -x, y, z);
worldPositionLeft = transformPosition(transform, x, y, z);
Vector4f worldPosition;
if (this.entityData.get(AMMO) > 0 || hasCreativeAmmo) {
ProjectileEntity projectileRight = ((ProjectileWeapon) getWeapon(0)).create(player).setGunItemId(this.getType().getDescriptionId());
projectileRight.setPos(worldPositionRight.x, worldPositionRight.y, worldPositionRight.z);
projectileRight.shoot(player, this.getLookAngle().x, this.getLookAngle().y + 0.018, this.getLookAngle().z, 20,
(float) 0.2);
this.level().addFreshEntity(projectileRight);
sendParticle((ServerLevel) this.level(), ParticleTypes.LARGE_SMOKE, worldPositionRight.x, worldPositionRight.y, worldPositionRight.z, 1, 0, 0, 0, 0, false);
if (!InventoryTool.hasCreativeAmmoBox(player)) {
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.HEAVY_AMMO.get())).findFirst().ifPresent(stack -> stack.shrink(1));
}
if (fireIndex == 0) {
worldPosition = transformPosition(transform, -x, y, z);
fireIndex = 1;
} else {
worldPosition = transformPosition(transform, x, y, z);
fireIndex = 0;
}
if (this.entityData.get(AMMO) > 0 || hasCreativeAmmo) {
ProjectileEntity projectileLeft = ((ProjectileWeapon) getWeapon(0)).create(player).setGunItemId(this.getType().getDescriptionId());
var entityToSpawn = ((SmallCannonShellWeapon) getWeapon(0)).create(player);
projectileLeft.setPos(worldPositionLeft.x, worldPositionLeft.y, worldPositionLeft.z);
projectileLeft.shoot(player, this.getLookAngle().x, this.getLookAngle().y + 0.018, this.getLookAngle().z, 20,
(float) 0.2);
this.level().addFreshEntity(projectileLeft);
sendParticle((ServerLevel) this.level(), ParticleTypes.LARGE_SMOKE, worldPositionLeft.x, worldPositionLeft.y, worldPositionLeft.z, 1, 0, 0, 0, 0, false);
entityToSpawn.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
entityToSpawn.shoot(getLookAngle().x, getLookAngle().y + 0.008, getLookAngle().z, 20, 0.15f);
level().addFreshEntity(entityToSpawn);
sendParticle((ServerLevel) this.level(), ParticleTypes.LARGE_SMOKE, worldPosition.x, worldPosition.y, worldPosition.z, 1, 0, 0, 0, 0, false);
if (!hasCreativeAmmo) {
ItemStack ammoBox = this.getItemStacks().stream().filter(stack -> {
@ -570,13 +554,13 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
if (!ammoBox.isEmpty()) {
Ammo.HEAVY.add(ammoBox, -1);
} else {
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.HEAVY_AMMO.get())).findFirst().ifPresent(stack -> stack.shrink(1));
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.SMALL_SHELL.get())).findFirst().ifPresent(stack -> stack.shrink(1));
}
}
}
this.entityData.set(HEAT, this.entityData.get(HEAT) + 5);
this.entityData.set(HEAT, this.entityData.get(HEAT) + 4);
if (!player.level().isClientSide) {
if (player instanceof ServerPlayer serverPlayer) {
@ -585,37 +569,27 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
serverPlayer.playSound(ModSounds.HELICOPTER_CANNON_VERYFAR.get(), 24, 1);
}
}
Level level = player.level();
final Vec3 center = new Vec3(this.getX(), this.getEyeY(), this.getZ());
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(6), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
if (target instanceof ServerPlayer serverPlayer) {
PacketDistributor.sendToPlayer(serverPlayer, new ShakeClientMessage(6, 4, 8, this.getX(), this.getEyeY(), this.getZ()));
}
}
} else if (getWeaponIndex(0) == 1 && this.getEntityData().get(LOADED_ROCKET) > 0) {
x = 1.7f;
y = 0.62f - 1.45f;
z = 0.8f;
worldPositionRight = transformPosition(transform, -x, y, z);
worldPositionLeft = transformPosition(transform, x, y, z);
var heliRocketEntity = ((HeliRocketWeapon) getWeapon(0)).create(player);
Vector4f worldPosition;
if (fireIndex == 0) {
heliRocketEntity.setPos(worldPositionRight.x, worldPositionRight.y, worldPositionRight.z);
heliRocketEntity.shoot(this.getLookAngle().x, this.getLookAngle().y + 0.008, this.getLookAngle().z, 7, 0.25f);
player.level().addFreshEntity(heliRocketEntity);
worldPosition = transformPosition(transform, -x, y, z);
fireIndex = 1;
} else if (fireIndex == 1) {
heliRocketEntity.setPos(worldPositionLeft.x, worldPositionLeft.y, worldPositionLeft.z);
heliRocketEntity.shoot(this.getLookAngle().x, this.getLookAngle().y + 0.008, this.getLookAngle().z, 7, 0.25f);
player.level().addFreshEntity(heliRocketEntity);
} else {
worldPosition = transformPosition(transform, x, y, z);
fireIndex = 0;
}
heliRocketEntity.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
heliRocketEntity.shoot(this.getLookAngle().x, this.getLookAngle().y + 0.008, this.getLookAngle().z, 7, 0.25f);
player.level().addFreshEntity(heliRocketEntity);
if (!player.level().isClientSide) {
if (player instanceof ServerPlayer serverPlayer) {
serverPlayer.playSound(ModSounds.HELICOPTER_ROCKET_FIRE_3P.get(), 6, 1);
@ -624,21 +598,12 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
this.entityData.set(LOADED_ROCKET, this.getEntityData().get(LOADED_ROCKET) - 1);
reloadCoolDown = 30;
Level level = player.level();
final Vec3 center = new Vec3(this.getX(), this.getEyeY(), this.getZ());
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(6), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
if (target instanceof ServerPlayer serverPlayer) {
PacketDistributor.sendToPlayer(serverPlayer, new ShakeClientMessage(6, 5, 7, this.getX(), this.getEyeY(), this.getZ()));
}
}
}
}
@Override
public int mainGunRpm(Player player) {
return 360;
return 500;
}
@Override

View file

@ -94,6 +94,7 @@ public class Hpj11Entity extends ContainerMobileVehicleEntity implements GeoEnti
.damage(VehicleConfig.HPJ11_DAMAGE.get().floatValue())
.explosionDamage(VehicleConfig.HPJ11_EXPLOSION_DAMAGE.get().floatValue())
.explosionRadius(VehicleConfig.HPJ11_EXPLOSION_RADIUS.get().floatValue())
.aa(true)
.icon(Mod.loc("textures/screens/vehicle_weapon/cannon_30mm.png"))
}
};

View file

@ -7,6 +7,8 @@ public class SmallCannonShellWeapon extends VehicleWeapon {
public float damage = 40, explosionDamage = 80, explosionRadius = 5;
public boolean aa = false;
public SmallCannonShellWeapon damage(float damage) {
this.damage = damage;
return this;
@ -22,7 +24,12 @@ public class SmallCannonShellWeapon extends VehicleWeapon {
return this;
}
public SmallCannonShellWeapon aa(boolean aa) {
this.aa = aa;
return this;
}
public SmallCannonShellEntity create(LivingEntity entity) {
return new SmallCannonShellEntity(entity, entity.level(), damage, explosionDamage, explosionRadius);
return new SmallCannonShellEntity(entity, entity.level(), damage, explosionDamage, explosionRadius, aa);
}
}

View file

@ -868,53 +868,106 @@ public class ClientEventHandler {
if (iVehicle instanceof Ah6Entity ah6Entity) {
float pitch = ah6Entity.getEntityData().get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - ah6Entity.getEntityData().get(HEAT)));
if (ah6Entity.getWeaponIndex(0) == 0) {
player.playSound(ModSounds.HELICOPTER_CANNON_FIRE_1P.get(), 1f, pitch);
} else if (ah6Entity.getWeaponIndex(0) == 1) {
player.playSound(ModSounds.HELICOPTER_ROCKET_FIRE_1P.get(), 1f, 1);
}
}
if (iVehicle instanceof Lav150Entity lav150) {
if (lav150.getWeaponIndex(0) == 0) {
float pitch = lav150.getEntityData().get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - lav150.getEntityData().get(HEAT)));
player.playSound(ModSounds.LAV_CANNON_FIRE_1P.get(), 1f, pitch);
player.playSound(ModSounds.SHELL_CASING_50CAL.get(), 0.3f, 1);
} else if (lav150.getWeaponIndex(0) == 1) {
float pitch = lav150.getEntityData().get(COAX_HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - lav150.getEntityData().get(COAX_HEAT)));
player.playSound(ModSounds.COAX_FIRE_1P.get(), 1f, pitch);
if (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON) {
if (ah6Entity.getWeaponIndex(0) == 0) {
player.playSound(ModSounds.HELICOPTER_CANNON_FIRE_1P.get(), 1f, pitch);
} else if (ah6Entity.getWeaponIndex(0) == 1) {
player.playSound(ModSounds.HELICOPTER_ROCKET_FIRE_1P.get(), 1f, 1);
}
} else {
if (ah6Entity.getWeaponIndex(0) == 0) {
player.playSound(ModSounds.HELICOPTER_CANNON_FIRE_3P.get(), 4f, pitch);
} else if (ah6Entity.getWeaponIndex(0) == 1) {
player.playSound(ModSounds.HELICOPTER_ROCKET_FIRE_3P.get(), 4f, 1);
}
}
}
if (iVehicle instanceof Bmp2Entity bmp2) {
if (bmp2.getWeaponIndex(0) == 0) {
float pitch = bmp2.getEntityData().get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - bmp2.getEntityData().get(HEAT)));
player.playSound(ModSounds.BMP_CANNON_FIRE_1P.get(), 1f, pitch);
player.playSound(ModSounds.SHELL_CASING_50CAL.get(), 0.3f, 1);
} else if (bmp2.getWeaponIndex(0) == 1) {
float pitch = bmp2.getEntityData().get(COAX_HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - bmp2.getEntityData().get(COAX_HEAT)));
player.playSound(ModSounds.COAX_FIRE_1P.get(), 1f, pitch);
} else if (bmp2.getWeaponIndex(0) == 2) {
player.playSound(ModSounds.BMP_MISSILE_FIRE_1P.get(), 1f, 1);
}
}
if (iVehicle instanceof Yx100Entity yx100) {
if (type == 1) {
float pitch = yx100.getEntityData().get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - yx100.getEntityData().get(HEAT)));
player.playSound(ModSounds.M_2_FIRE_1P.get(), 1f, pitch);
player.playSound(ModSounds.SHELL_CASING_50CAL.get(), 0.3f, 1);
} else if (type == 0) {
if (yx100.getWeaponIndex(0) == 0 || yx100.getWeaponIndex(0) == 1) {
player.playSound(ModSounds.YX_100_FIRE_1P.get(), 1f, 1);
} else if (yx100.getWeaponIndex(0) == 2) {
float pitch = yx100.getEntityData().get(COAX_HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - yx100.getEntityData().get(COAX_HEAT)));
player.playSound(ModSounds.M_2_FIRE_1P.get(), 1f, pitch);
if (iVehicle instanceof Lav150Entity lav150) {
if (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON) {
if (lav150.getWeaponIndex(0) == 0) {
float pitch = lav150.getEntityData().get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - lav150.getEntityData().get(HEAT)));
player.playSound(ModSounds.LAV_CANNON_FIRE_1P.get(), 1f, pitch);
player.playSound(ModSounds.SHELL_CASING_50CAL.get(), 0.3f, 1);
} else if (lav150.getWeaponIndex(0) == 1) {
float pitch = lav150.getEntityData().get(COAX_HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - lav150.getEntityData().get(COAX_HEAT)));
player.playSound(ModSounds.COAX_FIRE_1P.get(), 1f, pitch);
}
} else {
if (lav150.getWeaponIndex(0) == 0) {
float pitch = lav150.getEntityData().get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - lav150.getEntityData().get(HEAT)));
player.playSound(ModSounds.LAV_CANNON_FIRE_3P.get(), 4f, pitch);
} else if (lav150.getWeaponIndex(0) == 1) {
float pitch = lav150.getEntityData().get(COAX_HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - lav150.getEntityData().get(COAX_HEAT)));
player.playSound(ModSounds.M_60_FIRE_3P.get(), 4f, pitch);
}
}
}
if (iVehicle instanceof Bmp2Entity bmp2) {
if (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON) {
if (bmp2.getWeaponIndex(0) == 0) {
float pitch = bmp2.getEntityData().get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - bmp2.getEntityData().get(HEAT)));
player.playSound(ModSounds.BMP_CANNON_FIRE_1P.get(), 1f, pitch);
player.playSound(ModSounds.SHELL_CASING_50CAL.get(), 0.3f, 1);
} else if (bmp2.getWeaponIndex(0) == 1) {
float pitch = bmp2.getEntityData().get(COAX_HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - bmp2.getEntityData().get(COAX_HEAT)));
player.playSound(ModSounds.COAX_FIRE_1P.get(), 1f, pitch);
} else if (bmp2.getWeaponIndex(0) == 2) {
player.playSound(ModSounds.BMP_MISSILE_FIRE_1P.get(), 1f, 1);
}
} else {
if (bmp2.getWeaponIndex(0) == 0) {
float pitch = bmp2.getEntityData().get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - bmp2.getEntityData().get(HEAT)));
player.playSound(ModSounds.BMP_CANNON_FIRE_3P.get(), 4f, pitch);
} else if (bmp2.getWeaponIndex(0) == 1) {
float pitch = bmp2.getEntityData().get(COAX_HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - bmp2.getEntityData().get(COAX_HEAT)));
player.playSound(ModSounds.M_60_FIRE_3P.get(), 4f, pitch);
} else if (bmp2.getWeaponIndex(0) == 2) {
player.playSound(ModSounds.BMP_MISSILE_FIRE_3P.get(), 4f, 1);
}
}
}
if (iVehicle instanceof Yx100Entity yx100) {
if (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON) {
if (type == 1) {
float pitch = yx100.getEntityData().get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - yx100.getEntityData().get(HEAT)));
player.playSound(ModSounds.M_2_FIRE_1P.get(), 1f, pitch);
player.playSound(ModSounds.SHELL_CASING_50CAL.get(), 0.3f, 1);
} else if (type == 0) {
if (yx100.getWeaponIndex(0) == 0 || yx100.getWeaponIndex(0) == 1) {
player.playSound(ModSounds.YX_100_FIRE_1P.get(), 1f, 1);
} else if (yx100.getWeaponIndex(0) == 2) {
float pitch = yx100.getEntityData().get(COAX_HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - yx100.getEntityData().get(COAX_HEAT)));
player.playSound(ModSounds.M_2_FIRE_1P.get(), 1f, pitch);
player.playSound(ModSounds.SHELL_CASING_50CAL.get(), 0.3f, 1);
}
}
} else {
if (type == 1) {
float pitch = yx100.getEntityData().get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - yx100.getEntityData().get(HEAT)));
player.playSound(ModSounds.M_2_FIRE_3P.get(), 4f, pitch);
} else if (type == 0) {
if (yx100.getWeaponIndex(0) == 0 || yx100.getWeaponIndex(0) == 1) {
player.playSound(ModSounds.YX_100_FIRE_3P.get(), 4f, 1);
} else if (yx100.getWeaponIndex(0) == 2) {
float pitch = yx100.getEntityData().get(COAX_HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - yx100.getEntityData().get(COAX_HEAT)));
player.playSound(ModSounds.M_2_FIRE_3P.get(), 4f, pitch);
}
}
}
}
if (iVehicle instanceof PrismTankEntity prismTank) {
if (prismTank.getWeaponIndex(0) == 0) {
player.playSound(ModSounds.PRISM_FIRE_1P.get(), 1f, 1);
if (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON) {
if (prismTank.getWeaponIndex(0) == 0) {
player.playSound(ModSounds.PRISM_FIRE_1P.get(), 1f, 1);
}
} else {
if (prismTank.getWeaponIndex(0) == 0) {
player.playSound(ModSounds.PRISM_FIRE_3P.get(), 4f, 1);
}
}
}
}

View file

@ -53,7 +53,7 @@ public class ModEntities {
// Fast Projectiles
public static final DeferredHolder<EntityType<?>, EntityType<SmallCannonShellEntity>> SMALL_CANNON_SHELL = register("small_cannon_shell",
EntityType.Builder.<SmallCannonShellEntity>of(SmallCannonShellEntity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(false).noSave().setTrackingRange(64).setUpdateInterval(1).sized(0.75f, 0.75f));
EntityType.Builder.<SmallCannonShellEntity>of(SmallCannonShellEntity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(false).noSave().setTrackingRange(64).setUpdateInterval(1).sized(0.25f, 0.25f));
public static final DeferredHolder<EntityType<?>, EntityType<RpgRocketEntity>> RPG_ROCKET = register("rpg_rocket",
EntityType.Builder.<RpgRocketEntity>of(RpgRocketEntity::new, MobCategory.MISC).setShouldReceiveVelocityUpdates(false).noSave().setTrackingRange(64).setUpdateInterval(1).sized(0.5f, 0.5f));
public static final DeferredHolder<EntityType<?>, EntityType<MortarShellEntity>> MORTAR_SHELL = register("mortar_shell",

View file

@ -115,7 +115,7 @@ public class ModItems {
public static final DeferredHolder<Item, RgoGrenade> RGO_GRENADE = AMMO.register("rgo_grenade", RgoGrenade::new);
public static final DeferredHolder<Item, ClaymoreMine> CLAYMORE_MINE = AMMO.register("claymore_mine", ClaymoreMine::new);
public static final DeferredHolder<Item, C4Bomb> C4_BOMB = AMMO.register("c4_bomb", C4Bomb::new);
public static final DeferredHolder<Item, Item> SMALL_SHELL = AMMO.register("small_shell", () -> new Item(new Item.Properties()));
public static final DeferredHolder<Item, Item> SMALL_SHELL = AMMO.register("small_shell", SmallShellItem::new);
public static final DeferredHolder<Item, Item> ROCKET_70 = AMMO.register("rocket_70", () -> new Item(new Item.Properties()));
public static final DeferredHolder<Item, Item> WIRE_GUIDE_MISSILE = AMMO.register("wire_guide_missile", () -> new Item(new Item.Properties()));
public static final DeferredHolder<Item, Item> SWARM_DRONE = AMMO.register("swarm_drone", () -> new Item(new Item.Properties()));

View file

@ -0,0 +1,23 @@
package com.atsuishio.superbwarfare.item;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.List;
public class SmallShellItem extends Item {
public SmallShellItem() {
super(new Properties());
}
// TODO 正确添加翻译字段
@Override
@ParametersAreNonnullByDefault
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
tooltipComponents.add(Component.translatable("20mm ~ 40mm").withStyle(ChatFormatting.GRAY));
}
}