diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java index 774a52db5..55f1a37f2 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java @@ -4,12 +4,14 @@ import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.config.server.VehicleConfig; import com.atsuishio.superbwarfare.entity.projectile.FlareDecoyEntity; -import com.atsuishio.superbwarfare.entity.projectile.HeliRocketEntity; import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.HelicopterEntity; 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.VehicleWeapon; import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.network.message.ShakeClientMessage; import com.atsuishio.superbwarfare.tools.AmmoType; @@ -70,7 +72,6 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity public static final EntityDataAccessor DELTA_ROT = SynchedEntityData.defineId(Ah6Entity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor PROPELLER_ROT = SynchedEntityData.defineId(Ah6Entity.class, EntityDataSerializers.FLOAT); - public static final EntityDataAccessor WEAPON_TYPE = SynchedEntityData.defineId(Ah6Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor AMMO = SynchedEntityData.defineId(Ah6Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor DECOY_COUNT = SynchedEntityData.defineId(Ah6Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor LOADED_ROCKET = SynchedEntityData.defineId(Ah6Entity.class, EntityDataSerializers.INT); @@ -99,13 +100,31 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity this.setMaxUpStep(1.1f); } + @Override + public VehicleWeapon[][] getAllWeapons() { + return new VehicleWeapon[][]{ + new VehicleWeapon[]{ + new ProjectileWeapon() + .damage(VehicleConfig.AH_6_CANNON_DAMAGE.get()) + .headShot(2) + .zoom(false) + .heBullet(1) + .bypassArmorRate(0.1f) + .sound(ModSounds.INTO_MISSILE.get()), + new HeliRocketWeapon() + .damage(VehicleConfig.AH_6_ROCKET_DAMAGE.get()) + .explosionDamage(VehicleConfig.AH_6_ROCKET_EXPLOSION_DAMAGE.get()) + .explosionRadius(VehicleConfig.AH_6_ROCKET_EXPLOSION_RADIUS.get()), + } + }; + } + @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(AMMO, 0); this.entityData.define(LOADED_ROCKET, 0); this.entityData.define(DELTA_ROT, 0f); - this.entityData.define(WEAPON_TYPE, 0); this.entityData.define(PROPELLER_ROT, 0f); this.entityData.define(DECOY_COUNT, 6); } @@ -519,13 +538,7 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity worldPositionLeft = transformPosition(transform, x, y, z); if (this.entityData.get(AMMO) > 0 || hasCreativeAmmo) { - ProjectileEntity projectileRight = new ProjectileEntity(player.level()) - .shooter(player) - .damage(VehicleConfig.AH_6_CANNON_DAMAGE.get()) - .headShot(2f) - .zoom(false) - .heBullet(1) - .bypassArmorRate(0.1f); + ProjectileEntity projectileRight = ((ProjectileWeapon) getWeapon(0)).create(player); projectileRight.setPos(worldPositionRight.x, worldPositionRight.y, worldPositionRight.z); projectileRight.shoot(player, this.getLookAngle().x, this.getLookAngle().y + 0.018, this.getLookAngle().z, 20, @@ -538,13 +551,7 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity } if (this.entityData.get(AMMO) > 0 || hasCreativeAmmo) { - ProjectileEntity projectileLeft = new ProjectileEntity(player.level()) - .shooter(player) - .damage(VehicleConfig.AH_6_CANNON_DAMAGE.get()) - .headShot(2f) - .zoom(false) - .heBullet(1) - .bypassArmorRate(0.1f); + ProjectileEntity projectileLeft = ((ProjectileWeapon) 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, @@ -593,25 +600,17 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity worldPositionRight = transformPosition(transform, -x, y, z); worldPositionLeft = transformPosition(transform, x, y, z); - if (fireIndex == 0) { - HeliRocketEntity heliRocketEntityRight = new HeliRocketEntity(player, player.level(), - VehicleConfig.AH_6_ROCKET_DAMAGE.get(), - VehicleConfig.AH_6_ROCKET_EXPLOSION_DAMAGE.get(), - VehicleConfig.AH_6_ROCKET_EXPLOSION_RADIUS.get()); + var heliRocketEntity = ((HeliRocketWeapon) getWeapon(0)).create(player); - heliRocketEntityRight.setPos(worldPositionRight.x, worldPositionRight.y, worldPositionRight.z); - heliRocketEntityRight.shoot(this.getLookAngle().x, this.getLookAngle().y + 0.008, this.getLookAngle().z, 7, 0.25f); - player.level().addFreshEntity(heliRocketEntityRight); + 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); fireIndex = 1; } else if (fireIndex == 1) { - HeliRocketEntity heliRocketEntityLeft = new HeliRocketEntity(player, player.level(), - VehicleConfig.AH_6_ROCKET_DAMAGE.get(), - VehicleConfig.AH_6_ROCKET_EXPLOSION_DAMAGE.get(), - VehicleConfig.AH_6_ROCKET_EXPLOSION_RADIUS.get()); - - heliRocketEntityLeft.setPos(worldPositionLeft.x, worldPositionLeft.y, worldPositionLeft.z); - heliRocketEntityLeft.shoot(this.getLookAngle().x, this.getLookAngle().y + 0.008, this.getLookAngle().z, 7, 0.25f); - player.level().addFreshEntity(heliRocketEntityLeft); + 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); fireIndex = 0; } @@ -728,34 +727,6 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity return 2; } - @Override - public void changeWeapon(int index, int value, boolean isScroll) { - if (index != 0) return; - - var type = isScroll ? (value + getWeaponType(0) + 2) % 2 : value; - - var sound = switch (type) { - case 0 -> ModSounds.INTO_MISSILE.get(); - case 1 -> ModSounds.INTO_CANNON.get(); - default -> null; - }; - if (sound == null) return; - - setWeaponType(0, type); - this.level().playSound(null, this, sound, this.getSoundSource(), 1, 1); - } - - @Override - public int getWeaponType(int index) { - if (index == 0) return entityData.get(WEAPON_TYPE); - return -1; - } - - @Override - public void setWeaponType(int index, int type) { - entityData.set(WEAPON_TYPE, type); - } - @Override public ResourceLocation getVehicleIcon() { return ModUtils.loc("textures/vehicle_icon/ah_6_icon.png"); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/AnnihilatorEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/AnnihilatorEntity.java index 57ec5fd2f..b490488b9 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/AnnihilatorEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/AnnihilatorEntity.java @@ -6,6 +6,8 @@ import com.atsuishio.superbwarfare.config.server.VehicleConfig; import com.atsuishio.superbwarfare.entity.vehicle.base.CannonEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.EnergyVehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier; +import com.atsuishio.superbwarfare.entity.vehicle.weapon.EmptyWeapon; +import com.atsuishio.superbwarfare.entity.vehicle.weapon.VehicleWeapon; import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.network.message.ShakeClientMessage; import com.atsuishio.superbwarfare.tools.*; @@ -82,6 +84,15 @@ public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity, this.noCulling = true; } + @Override + public VehicleWeapon[][] getAllWeapons() { + return new VehicleWeapon[][]{ + new VehicleWeapon[]{ + new EmptyWeapon() + } + }; + } + @Override protected void defineSynchedData() { super.defineSynchedData(); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java index 83770dba6..c9c58b641 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java @@ -3,13 +3,14 @@ package com.atsuishio.superbwarfare.entity.vehicle; import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.config.server.VehicleConfig; -import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity; -import com.atsuishio.superbwarfare.entity.projectile.SmallCannonShellEntity; -import com.atsuishio.superbwarfare.entity.projectile.WgMissileEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.LandArmorEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier; +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.entity.vehicle.weapon.WgMissileWeapon; import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.network.message.ShakeClientMessage; import com.atsuishio.superbwarfare.tools.AmmoType; @@ -97,6 +98,30 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit this.setMaxUpStep(1.5f); } + @Override + public VehicleWeapon[][] getAllWeapons() { + return new VehicleWeapon[][]{ + new VehicleWeapon[]{ + new SmallCannonShellWeapon() + .damage(VehicleConfig.BMP_2_CANNON_DAMAGE.get()) + .explosionDamage(VehicleConfig.BMP_2_CANNON_EXPLOSION_DAMAGE.get()) + .explosionRadius(VehicleConfig.BMP_2_CANNON_EXPLOSION_RADIUS.get().floatValue()) + .sound(ModSounds.INTO_MISSILE.get()) + , + new ProjectileWeapon() + .damage(9.5f) + .headShot(2) + .zoom(false) + .sound(ModSounds.INTO_CANNON.get()), + new WgMissileWeapon() + .damage(ExplosionConfig.WIRE_GUIDE_MISSILE_DAMAGE.get()) + .explosionDamage(ExplosionConfig.WIRE_GUIDE_MISSILE_EXPLOSION_DAMAGE.get()) + .explosionRadius(ExplosionConfig.WIRE_GUIDE_MISSILE_EXPLOSION_RADIUS.get()) + .sound(ModSounds.INTO_MISSILE.get()), + } + }; + } + @Override protected void defineSynchedData() { super.defineSynchedData(); @@ -105,7 +130,6 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit this.entityData.define(DELTA_ROT, 0f); this.entityData.define(HEAT, 0); this.entityData.define(COAX_HEAT, 0); - this.entityData.define(WEAPON_TYPE, 0); this.entityData.define(LOADED_MISSILE, 0); this.entityData.define(TRACK_L, 0f); this.entityData.define(TRACK_R, 0f); @@ -318,10 +342,7 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit float z = 4.2f; Vector4f worldPosition = transformPosition(transform, x, y, z); - SmallCannonShellEntity smallCannonShell = new SmallCannonShellEntity(player, this.level(), - VehicleConfig.BMP_2_CANNON_DAMAGE.get(), - VehicleConfig.BMP_2_CANNON_EXPLOSION_DAMAGE.get(), - VehicleConfig.BMP_2_CANNON_EXPLOSION_RADIUS.get().floatValue()); + var smallCannonShell = ((SmallCannonShellWeapon) getWeapon(0)).create(player); smallCannonShell.setPos(worldPosition.x - 1.1 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z - 1.1 * this.getDeltaMovement().z); smallCannonShell.shoot(getBarrelVector(1).x, getBarrelVector(1).y + 0.005f, getBarrelVector(1).z, 20, @@ -362,11 +383,7 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit boolean hasCreativeAmmo = player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get())); if (this.entityData.get(AMMO) > 0 || hasCreativeAmmo) { - ProjectileEntity projectileRight = new ProjectileEntity(player.level()) - .shooter(player) - .damage(9.5f) - .headShot(2f) - .zoom(false); + var projectileRight = ((ProjectileWeapon) getWeapon(0)).create(player); projectileRight.bypassArmorRate(0.2f); projectileRight.setPos(worldPosition.x - 1.1 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z - 1.1 * this.getDeltaMovement().z); @@ -404,10 +421,7 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit Matrix4f transformT = getBarrelTransform(); Vector4f worldPosition = transformPosition(transformT, 0, 1, 0); - WgMissileEntity wgMissileEntity = new WgMissileEntity(player, player.level(), - ExplosionConfig.WIRE_GUIDE_MISSILE_DAMAGE.get(), - ExplosionConfig.WIRE_GUIDE_MISSILE_EXPLOSION_DAMAGE.get(), - ExplosionConfig.WIRE_GUIDE_MISSILE_EXPLOSION_RADIUS.get()); + var wgMissileEntity = ((WgMissileWeapon) getWeapon(0)).create(player); wgMissileEntity.setPos(worldPosition.x, worldPosition.y, worldPosition.z); wgMissileEntity.shoot(getBarrelVector(1).x, 0, getBarrelVector(1).z, 2f, 0f); @@ -745,33 +759,6 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit return 3; } - @Override - public void changeWeapon(int index, int value, boolean isScroll) { - if (index != 0) return; - - var type = isScroll ? (value + getWeaponType(0) + 2) % 2 : value; - - var sound = switch (type) { - case 0, 2 -> ModSounds.INTO_MISSILE.get(); - case 1 -> ModSounds.INTO_CANNON.get(); - default -> null; - }; - if (sound == null) return; - - setWeaponType(0, type); - this.level().playSound(null, this, sound, this.getSoundSource(), 1, 1); - } - - @Override - public int getWeaponType(int index) { - return index == 0 ? entityData.get(WEAPON_TYPE) : -1; - } - - @Override - public void setWeaponType(int index, int type) { - if (index == 0) entityData.set(WEAPON_TYPE, type); - } - @Override public ResourceLocation getVehicleIcon() { return ModUtils.loc("textures/vehicle_icon/bmp2_icon.png"); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java index 479eca07b..7ef3df30f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java @@ -3,12 +3,13 @@ package com.atsuishio.superbwarfare.entity.vehicle; import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.config.server.VehicleConfig; -import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity; -import com.atsuishio.superbwarfare.entity.projectile.SmallCannonShellEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.LandArmorEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier; +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.*; import com.atsuishio.superbwarfare.network.message.ShakeClientMessage; import com.atsuishio.superbwarfare.tools.AmmoType; @@ -69,8 +70,6 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt public static final EntityDataAccessor HEAT = SynchedEntityData.defineId(Lav150Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor COAX_HEAT = SynchedEntityData.defineId(Lav150Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor AMMO = SynchedEntityData.defineId(Lav150Entity.class, EntityDataSerializers.INT); - public static final EntityDataAccessor WEAPON_TYPE = SynchedEntityData.defineId(Lav150Entity.class, EntityDataSerializers.INT); - public static final float MAX_HEALTH = VehicleConfig.LAV_150_HP.get(); public static final int MAX_ENERGY = VehicleConfig.LAV_150_MAX_ENERGY.get(); @@ -97,6 +96,24 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt this.setMaxUpStep(1.5f); } + @Override + public VehicleWeapon[][] getAllWeapons() { + return new VehicleWeapon[][]{ + new VehicleWeapon[]{ + new SmallCannonShellWeapon() + .damage(VehicleConfig.LAV_150_CANNON_DAMAGE.get()) + .explosionDamage(VehicleConfig.LAV_150_CANNON_EXPLOSION_DAMAGE.get()) + .explosionRadius(VehicleConfig.LAV_150_CANNON_EXPLOSION_RADIUS.get().floatValue()) + .sound(ModSounds.INTO_MISSILE.get()), + new ProjectileWeapon() + .damage(9.5f) + .headShot(2) + .zoom(false) + .sound(ModSounds.INTO_CANNON.get()), + } + }; + } + @Override protected void defineSynchedData() { super.defineSynchedData(); @@ -105,7 +122,6 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt this.entityData.define(DELTA_ROT, 0f); this.entityData.define(HEAT, 0); this.entityData.define(COAX_HEAT, 0); - this.entityData.define(WEAPON_TYPE, 0); } @Override @@ -289,10 +305,7 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt float z = 4f; Vector4f worldPosition = transformPosition(transform, x, y, z); - SmallCannonShellEntity smallCannonShell = new SmallCannonShellEntity(player, this.level(), - VehicleConfig.LAV_150_CANNON_DAMAGE.get(), - VehicleConfig.LAV_150_CANNON_EXPLOSION_DAMAGE.get(), - VehicleConfig.LAV_150_CANNON_EXPLOSION_RADIUS.get().floatValue()); + var smallCannonShell = ((SmallCannonShellWeapon) getWeapon(0)).create(player); smallCannonShell.setPos(worldPosition.x - 1.1 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z - 1.1 * this.getDeltaMovement().z); smallCannonShell.shoot(getBarrelVector(1).x, getBarrelVector(1).y + 0.005f, getBarrelVector(1).z, 20, @@ -333,17 +346,13 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt Vector4f worldPosition = transformPosition(transform, x, y, z); if (this.entityData.get(AMMO) > 0 || hasCreativeAmmo) { - ProjectileEntity projectileRight = new ProjectileEntity(player.level()) - .shooter(player) - .damage(9.5f) - .headShot(2f) - .zoom(false); + var projectile = ((ProjectileWeapon) getWeapon(0)).create(player); - projectileRight.bypassArmorRate(0.2f); - projectileRight.setPos(worldPosition.x - 1.1 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z - 1.1 * this.getDeltaMovement().z); - projectileRight.shoot(player, getBarrelVector(1).x, getBarrelVector(1).y + 0.002f, getBarrelVector(1).z, 36, + projectile.bypassArmorRate(0.2f); + projectile.setPos(worldPosition.x - 1.1 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z - 1.1 * this.getDeltaMovement().z); + projectile.shoot(player, getBarrelVector(1).x, getBarrelVector(1).y + 0.002f, getBarrelVector(1).z, 36, 0.25f); - this.level().addFreshEntity(projectileRight); + this.level().addFreshEntity(projectile); if (!hasCreativeAmmo) { ItemStack ammoBox = this.getItemStacks().stream().filter(stack -> { @@ -689,34 +698,6 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt return 3; } - @Override - public void changeWeapon(int index, int value, boolean isScroll) { - if (index != 0) return; - - int type = isScroll ? (value + getWeaponType(0) + 2) % 2 : value; - - var sound = switch (type) { - case 0 -> ModSounds.INTO_MISSILE.get(); - case 1 -> ModSounds.INTO_CANNON.get(); - default -> null; - }; - if (sound == null) return; - - setWeaponType(0, type); - this.level().playSound(null, this, sound, this.getSoundSource(), 1, 1); - } - - @Override - public int getWeaponType(int index) { - return index == 0 ? entityData.get(WEAPON_TYPE) : -1; - } - - @Override - public void setWeaponType(int index, int type) { - if (index != 0) return; - entityData.set(WEAPON_TYPE, type); - } - @Override public ResourceLocation getVehicleIcon() { return ModUtils.loc("textures/vehicle_icon/lav150_icon.png"); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java index 42f3faa56..976ccd42b 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java @@ -3,10 +3,11 @@ package com.atsuishio.superbwarfare.entity.vehicle; import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.config.server.VehicleConfig; -import com.atsuishio.superbwarfare.entity.projectile.CannonShellEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.CannonEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier; +import com.atsuishio.superbwarfare.entity.vehicle.weapon.CannonShellWeapon; +import com.atsuishio.superbwarfare.entity.vehicle.weapon.VehicleWeapon; import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.item.common.ammo.CannonShellItem; import com.atsuishio.superbwarfare.network.message.ShakeClientMessage; @@ -60,7 +61,6 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity public static final EntityDataAccessor PITCH = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor YAW = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.FLOAT); - public static final EntityDataAccessor WEAPON_TYPE = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.INT); public Mk42Entity(PlayMessages.SpawnEntity packet, Level world) { this(ModEntities.MK_42.get(), world); @@ -76,7 +76,28 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity this.entityData.define(COOL_DOWN, 0); this.entityData.define(PITCH, 0f); this.entityData.define(YAW, 0f); - this.entityData.define(WEAPON_TYPE, 0); + } + + @Override + public VehicleWeapon[][] getAllWeapons() { + return new VehicleWeapon[][]{ + new VehicleWeapon[]{ + new CannonShellWeapon() + .hitDamage(VehicleConfig.MK42_AP_DAMAGE.get()) + .explosionDamage(VehicleConfig.MK42_AP_EXPLOSION_DAMAGE.get()) + .explosionRadius(VehicleConfig.MK42_AP_EXPLOSION_RADIUS.get().floatValue()) + .durability(60) + .sound(ModSounds.CANNON_RELOAD.get()), + new CannonShellWeapon() + .hitDamage(VehicleConfig.MK42_HE_DAMAGE.get()) + .explosionDamage(VehicleConfig.MK42_HE_EXPLOSION_DAMAGE.get()) + .explosionRadius(VehicleConfig.MK42_HE_EXPLOSION_RADIUS.get().floatValue()) + .durability(1) + .fireProbability(0.18F) + .fireTime(2) + .sound(ModSounds.CANNON_RELOAD.get()), + } + }; } @Override @@ -252,33 +273,7 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity InventoryTool.consumeItem(player.getInventory().items, ammo, 1); } - float hitDamage; - float explosionRadius; - float explosionDamage; - float fireProbability; - int fireTime; - int durability; - - if (getWeaponType(0) == 0) { - // AP - hitDamage = VehicleConfig.MK42_AP_DAMAGE.get(); - explosionRadius = VehicleConfig.MK42_AP_EXPLOSION_RADIUS.get(); - explosionDamage = VehicleConfig.MK42_AP_EXPLOSION_DAMAGE.get(); - fireProbability = 0; - fireTime = 0; - durability = 60; - } else { - // HE - hitDamage = VehicleConfig.MK42_HE_DAMAGE.get(); - explosionRadius = VehicleConfig.MK42_HE_EXPLOSION_RADIUS.get(); - explosionDamage = VehicleConfig.MK42_HE_EXPLOSION_DAMAGE.get(); - fireProbability = 0.18F; - fireTime = 2; - durability = 1; - } - - CannonShellEntity entityToSpawn = new CannonShellEntity(player, level, hitDamage, explosionRadius, explosionDamage, fireProbability, fireTime) - .durability(durability); + var entityToSpawn = ((CannonShellWeapon) getWeapon(0)).create(player); entityToSpawn.setPos(this.getX(), this.getEyeY(), this.getZ()); entityToSpawn.shoot(this.getLookAngle().x, this.getLookAngle().y, this.getLookAngle().z, 15, 0.05f); @@ -352,32 +347,6 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity entity.setXRot(entity.getXRot() + f1 - f); } - @Override - public void setWeaponType(int index, int type) { - if (index != 0) return; - entityData.set(WEAPON_TYPE, type); - } - - @Override - public void changeWeapon(int index, int value, boolean isScroll) { - if (index != 0) return; - - int type = isScroll ? (value + getWeaponType(0) + 2) % 2 : value; - var sound = switch (type) { - case 0, 1 -> ModSounds.CANNON_RELOAD.get(); - default -> null; - }; - if (sound == null) return; - - setWeaponType(0, type); - this.level().playSound(null, this, sound, this.getSoundSource(), 1, 1); - } - - @Override - public int getWeaponType(int index) { - return index == 0 ? entityData.get(WEAPON_TYPE) : -1; - } - @Override public void onPassengerTurned(Entity entity) { this.clampRotation(entity); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java index f8776ed31..133db4c4a 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java @@ -3,10 +3,11 @@ package com.atsuishio.superbwarfare.entity.vehicle; import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.config.server.VehicleConfig; -import com.atsuishio.superbwarfare.entity.projectile.CannonShellEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.CannonEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier; +import com.atsuishio.superbwarfare.entity.vehicle.weapon.CannonShellWeapon; +import com.atsuishio.superbwarfare.entity.vehicle.weapon.VehicleWeapon; import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.item.common.ammo.CannonShellItem; import com.atsuishio.superbwarfare.network.message.ShakeClientMessage; @@ -62,8 +63,6 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); public static final float MAX_HEALTH = VehicleConfig.MLE1934_HP.get(); - public static final EntityDataAccessor WEAPON_TYPE = SynchedEntityData.defineId(Mle1934Entity.class, EntityDataSerializers.INT); - public Mle1934Entity(PlayMessages.SpawnEntity packet, Level world) { this(ModEntities.MLE_1934.get(), world); } @@ -72,6 +71,28 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt super(type, world); } + @Override + public VehicleWeapon[][] getAllWeapons() { + return new VehicleWeapon[][]{ + new VehicleWeapon[]{ + new CannonShellWeapon() + .hitDamage(VehicleConfig.MLE1934_AP_DAMAGE.get()) + .explosionDamage(VehicleConfig.MLE1934_AP_EXPLOSION_DAMAGE.get()) + .explosionRadius(VehicleConfig.MLE1934_AP_EXPLOSION_RADIUS.get().floatValue()) + .durability(70) + .sound(ModSounds.CANNON_RELOAD.get()), + new CannonShellWeapon() + .hitDamage(VehicleConfig.MLE1934_HE_DAMAGE.get()) + .explosionDamage(VehicleConfig.MLE1934_HE_EXPLOSION_DAMAGE.get()) + .explosionRadius(VehicleConfig.MLE1934_HE_EXPLOSION_RADIUS.get().floatValue()) + .durability(1) + .fireProbability(0.24F) + .fireTime(5) + .sound(ModSounds.CANNON_RELOAD.get()), + } + }; + } + @Override protected void defineSynchedData() { super.defineSynchedData(); @@ -79,7 +100,6 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt this.entityData.define(TYPE, 0); this.entityData.define(PITCH, 0f); this.entityData.define(YAW, 0f); - this.entityData.define(WEAPON_TYPE, 0); } @Override @@ -307,8 +327,7 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt leftPos.rotateY(-yRot * Mth.DEG_TO_RAD); // 左炮管 - CannonShellEntity entityToSpawnLeft = new CannonShellEntity(player, level, hitDamage, explosionRadius, explosionDamage, fireProbability, fireTime) - .durability(durability); + var entityToSpawnLeft = ((CannonShellWeapon) getWeapon(0)).create(player); entityToSpawnLeft.setPos(this.getX() + leftPos.x, this.getEyeY() - 0.2 + leftPos.y, @@ -352,8 +371,7 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt rightPos.rotateZ(-this.getXRot() * Mth.DEG_TO_RAD); rightPos.rotateY(-yRot * Mth.DEG_TO_RAD); - CannonShellEntity entityToSpawnRight = new CannonShellEntity(player, level, hitDamage, explosionRadius, explosionDamage, fireProbability, fireTime) - .durability(durability); + var entityToSpawnRight = ((CannonShellWeapon) getWeapon(0)).create(player); entityToSpawnRight.setPos(this.getX() + rightPos.x, this.getEyeY() - 0.2 + rightPos.y, @@ -447,32 +465,6 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt entity.setXRot(entity.getXRot() + f1 - f); } - @Override - public void setWeaponType(int index, int type) { - if (index != 0) return; - entityData.set(WEAPON_TYPE, type); - } - - @Override - public void changeWeapon(int index, int value, boolean isScroll) { - if (index != 0) return; - - int type = isScroll ? (value + getWeaponType(0) + 2) % 2 : value; - var sound = switch (type) { - case 0, 1 -> ModSounds.CANNON_RELOAD.get(); - default -> null; - }; - if (sound == null) return; - - setWeaponType(0, type); - this.level().playSound(null, this, sound, this.getSoundSource(), 1, 1); - } - - @Override - public int getWeaponType(int index) { - return index == 0 ? entityData.get(WEAPON_TYPE) : -1; - } - @Override public void onPassengerTurned(Entity entity) { this.clampRotation(entity); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java index 36fdc5665..fe7e50f0b 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java @@ -3,12 +3,13 @@ package com.atsuishio.superbwarfare.entity.vehicle; import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.config.server.VehicleConfig; -import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.ArmedVehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.LandArmorEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier; +import com.atsuishio.superbwarfare.entity.vehicle.weapon.ProjectileWeapon; +import com.atsuishio.superbwarfare.entity.vehicle.weapon.VehicleWeapon; import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.network.ModVariables; import com.atsuishio.superbwarfare.network.message.ShakeClientMessage; @@ -87,6 +88,18 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo super(type, world); } + @Override + public VehicleWeapon[][] getAllWeapons() { + return new VehicleWeapon[][]{ + new VehicleWeapon[]{ + new ProjectileWeapon() + .damage(VehicleConfig.SPEEDBOAT_GUN_DAMAGE.get()) + .headShot(2) + .zoom(false) + } + }; + } + @Override protected void defineSynchedData() { super.defineSynchedData(); @@ -241,11 +254,7 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo Vector4f worldPosition = transformPosition(transform, x, y, z); - ProjectileEntity projectile = new ProjectileEntity(player.level()) - .shooter(player) - .damage(VehicleConfig.SPEEDBOAT_GUN_DAMAGE.get()) - .headShot(2f) - .zoom(false); + var projectile = ((ProjectileWeapon) getWeapon(0)).create(player); projectile.bypassArmorRate(0.4f); projectile.setPos(worldPosition.x - 1.1 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z - 1.1 * this.getDeltaMovement().z); @@ -560,11 +569,6 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo return ModUtils.loc("textures/vehicle_icon/speedboat_icon.png"); } - @Override - public int getWeaponType(int index) { - return index == 0 ? 0 : -1; - } - @Override public float turretYRotO() { return turretYRotO; diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java index e0dee92b6..be9c41402 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java @@ -374,7 +374,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti Vector4f worldPosition = transformPosition(transform, 0, 0, 0); var cannonShell = (CannonShellWeapon) getWeapon(0); - var entityToSpawn = cannonShell.create(player, level()); + var entityToSpawn = cannonShell.create(player); entityToSpawn.setPos(worldPosition.x - 1.1 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z - 1.1 * this.getDeltaMovement().z); entityToSpawn.shoot(getBarrelVector(1).x, getBarrelVector(1).y + 0.005f, getBarrelVector(1).z, cannonShell.velocity, 0.02f); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java index 5f694b55e..03e4f9ee3 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java @@ -238,7 +238,7 @@ public abstract class VehicleEntity extends Entity { this.availableWeapons = new VehicleWeapon[this.getMaxPassengers()][]; var weapons = weaponVehicle.getAllWeapons(); - for (int i = 0; i < weapons.length || i < this.getMaxPassengers(); i++) { + for (int i = 0; i < weapons.length && i < this.getMaxPassengers(); i++) { this.availableWeapons[i] = weapons[i]; } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/WeaponVehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/WeaponVehicleEntity.java index 9b874f20b..40a7dc21f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/WeaponVehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/WeaponVehicleEntity.java @@ -54,9 +54,7 @@ public interface WeaponVehicleEntity extends ArmedVehicleEntity { /** * 获取所有可用武器列表 */ - default VehicleWeapon[][] getAllWeapons() { - return new VehicleWeapon[0][]; - } + VehicleWeapon[][] getAllWeapons(); /** * 获取该槽位可用的武器列表 diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/CannonShellWeapon.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/CannonShellWeapon.java index 1d0775673..b39b30cae 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/CannonShellWeapon.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/CannonShellWeapon.java @@ -2,7 +2,6 @@ package com.atsuishio.superbwarfare.entity.vehicle.weapon; import com.atsuishio.superbwarfare.entity.projectile.CannonShellEntity; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; public class CannonShellWeapon extends VehicleWeapon { public float hitDamage, explosionRadius, explosionDamage, fireProbability, velocity; @@ -43,9 +42,9 @@ public class CannonShellWeapon extends VehicleWeapon { return this; } - public CannonShellEntity create(Player player, Level level) { + public CannonShellEntity create(Player player) { return new CannonShellEntity(player, - level, + player.level(), this.hitDamage, this.explosionRadius, this.explosionDamage, diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/EmptyWeapon.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/EmptyWeapon.java new file mode 100644 index 000000000..8a2e6c54f --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/EmptyWeapon.java @@ -0,0 +1,4 @@ +package com.atsuishio.superbwarfare.entity.vehicle.weapon; + +public class EmptyWeapon extends VehicleWeapon { +} diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/HeliRocketWeapon.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/HeliRocketWeapon.java new file mode 100644 index 000000000..f765efd99 --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/HeliRocketWeapon.java @@ -0,0 +1,27 @@ +package com.atsuishio.superbwarfare.entity.vehicle.weapon; + +import com.atsuishio.superbwarfare.entity.projectile.HeliRocketEntity; +import net.minecraft.world.entity.LivingEntity; + +public class HeliRocketWeapon extends VehicleWeapon { + public float damage = 140, explosionDamage = 60, explosionRadius = 5; + + public HeliRocketWeapon damage(float damage) { + this.damage = damage; + return this; + } + + public HeliRocketWeapon explosionDamage(float explosionDamage) { + this.explosionDamage = explosionDamage; + return this; + } + + public HeliRocketWeapon explosionRadius(float explosionRadius) { + this.explosionRadius = explosionRadius; + return this; + } + + public HeliRocketEntity create(LivingEntity entity) { + return new HeliRocketEntity(entity, entity.level(), damage, explosionDamage, explosionRadius); + } +} diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/ProjectileWeapon.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/ProjectileWeapon.java index 41f32b0f4..b57de812d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/ProjectileWeapon.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/ProjectileWeapon.java @@ -6,6 +6,7 @@ import net.minecraft.world.entity.LivingEntity; public class ProjectileWeapon extends VehicleWeapon { public float headShot, damage, bypassArmorRate; public boolean zoom; + public int jhpLevel, heLevel; public ProjectileWeapon headShot(float headShot) { this.headShot = headShot; @@ -27,12 +28,24 @@ public class ProjectileWeapon extends VehicleWeapon { return this; } + public ProjectileWeapon jhpBullet(int jhpLevel) { + this.jhpLevel = jhpLevel; + return this; + } + + public ProjectileWeapon heBullet(int heLevel) { + this.heLevel = heLevel; + return this; + } + public ProjectileEntity create(LivingEntity shooter) { return new ProjectileEntity(shooter.level()) .shooter(shooter) .headShot(headShot) .damage(damage) .bypassArmorRate(bypassArmorRate) - .zoom(zoom); + .zoom(zoom) + .jhpBullet(jhpLevel) + .heBullet(heLevel); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/SmallCannonShellWeapon.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/SmallCannonShellWeapon.java new file mode 100644 index 000000000..10186463c --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/SmallCannonShellWeapon.java @@ -0,0 +1,27 @@ +package com.atsuishio.superbwarfare.entity.vehicle.weapon; + +import com.atsuishio.superbwarfare.entity.projectile.SmallCannonShellEntity; +import net.minecraft.world.entity.LivingEntity; + +public class SmallCannonShellWeapon extends VehicleWeapon { + public float damage = 40, explosionDamage = 80, explosionRadius = 5; + + public SmallCannonShellWeapon damage(float damage) { + this.damage = damage; + return this; + } + + public SmallCannonShellWeapon explosionDamage(float explosionDamage) { + this.explosionDamage = explosionDamage; + return this; + } + + public SmallCannonShellWeapon explosionRadius(float explosionRadius) { + this.explosionRadius = explosionRadius; + return this; + } + + public SmallCannonShellEntity create(LivingEntity entity) { + return new SmallCannonShellEntity(entity, entity.level(), damage, explosionDamage, explosionRadius); + } +} diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/WgMissileWeapon.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/WgMissileWeapon.java new file mode 100644 index 000000000..715cf6125 --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/WgMissileWeapon.java @@ -0,0 +1,27 @@ +package com.atsuishio.superbwarfare.entity.vehicle.weapon; + +import com.atsuishio.superbwarfare.entity.projectile.WgMissileEntity; +import net.minecraft.world.entity.LivingEntity; + +public class WgMissileWeapon extends VehicleWeapon { + public float damage = 250, explosionDamage = 200, explosionRadius = 10; + + public WgMissileWeapon damage(float damage) { + this.damage = damage; + return this; + } + + public WgMissileWeapon explosionDamage(float explosionDamage) { + this.explosionDamage = explosionDamage; + return this; + } + + public WgMissileWeapon explosionRadius(float explosionRadius) { + this.explosionRadius = explosionRadius; + return this; + } + + public WgMissileEntity create(LivingEntity entity) { + return new WgMissileEntity(entity, entity.level(), damage, explosionDamage, explosionRadius); + } +}