尝试提取武器参数
This commit is contained in:
parent
e13ddc7f5d
commit
39ca3a2537
4 changed files with 131 additions and 41 deletions
|
@ -3,12 +3,12 @@ package com.atsuishio.superbwarfare.entity.vehicle;
|
||||||
import com.atsuishio.superbwarfare.ModUtils;
|
import com.atsuishio.superbwarfare.ModUtils;
|
||||||
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
|
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
|
||||||
import com.atsuishio.superbwarfare.config.server.VehicleConfig;
|
import com.atsuishio.superbwarfare.config.server.VehicleConfig;
|
||||||
import com.atsuishio.superbwarfare.entity.projectile.CannonShellEntity;
|
|
||||||
import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity;
|
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.LandArmorEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.LandArmorEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier;
|
import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier;
|
||||||
|
import com.atsuishio.superbwarfare.entity.vehicle.weapon.CannonShellWeapon;
|
||||||
|
import com.atsuishio.superbwarfare.entity.vehicle.weapon.ProjectileWeapon;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.weapon.VehicleWeapon;
|
import com.atsuishio.superbwarfare.entity.vehicle.weapon.VehicleWeapon;
|
||||||
import com.atsuishio.superbwarfare.init.*;
|
import com.atsuishio.superbwarfare.init.*;
|
||||||
import com.atsuishio.superbwarfare.network.message.ShakeClientMessage;
|
import com.atsuishio.superbwarfare.network.message.ShakeClientMessage;
|
||||||
|
@ -117,11 +117,33 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
// TODO 正确实现武器创建
|
// TODO 正确实现武器创建
|
||||||
return new VehicleWeapon[][]{
|
return new VehicleWeapon[][]{
|
||||||
new VehicleWeapon[]{
|
new VehicleWeapon[]{
|
||||||
new VehicleWeapon().sound(ModSounds.INTO_MISSILE.get()),
|
// AP
|
||||||
new VehicleWeapon().sound(ModSounds.INTO_CANNON.get()),
|
new CannonShellWeapon()
|
||||||
|
.hitDamage(500)
|
||||||
|
.explosionRadius(4)
|
||||||
|
.explosionDamage(100)
|
||||||
|
.fireProbability(0)
|
||||||
|
.fireTime(0)
|
||||||
|
.durability(60)
|
||||||
|
.velocity(40)
|
||||||
|
.sound(ModSounds.INTO_MISSILE.get()),
|
||||||
|
// HE
|
||||||
|
new CannonShellWeapon()
|
||||||
|
.hitDamage(100)
|
||||||
|
.explosionRadius(10)
|
||||||
|
.explosionDamage(150)
|
||||||
|
.fireProbability(0.18F)
|
||||||
|
.fireTime(2)
|
||||||
|
.durability(1)
|
||||||
|
.sound(ModSounds.INTO_CANNON.get()),
|
||||||
},
|
},
|
||||||
new VehicleWeapon[]{
|
new VehicleWeapon[]{
|
||||||
new VehicleWeapon(),
|
// 机枪
|
||||||
|
new ProjectileWeapon()
|
||||||
|
.damage(VehicleConfig.SPEEDBOAT_GUN_DAMAGE.get())
|
||||||
|
.headShot(2)
|
||||||
|
.zoom(false)
|
||||||
|
.bypassArmorRate(0.4f),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -344,37 +366,14 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
public void vehicleShoot(Player player, int type) {
|
public void vehicleShoot(Player player, int type) {
|
||||||
if (reloadCoolDown == 0 && type == 0) {
|
if (reloadCoolDown == 0 && type == 0) {
|
||||||
Matrix4f transform = getBarrelTransform();
|
Matrix4f transform = getBarrelTransform();
|
||||||
float hitDamage, explosionRadius, explosionDamage, fireProbability;
|
|
||||||
int fireTime, durability;
|
|
||||||
float v;
|
|
||||||
|
|
||||||
if (getWeaponType(0) == 0) {
|
|
||||||
hitDamage = 500;
|
|
||||||
explosionRadius = 4;
|
|
||||||
explosionDamage = 100;
|
|
||||||
fireProbability = 0;
|
|
||||||
fireTime = 0;
|
|
||||||
durability = 60;
|
|
||||||
v = 40;
|
|
||||||
} else if (getWeaponType(0) == 1) {
|
|
||||||
hitDamage = 100;
|
|
||||||
explosionRadius = 10;
|
|
||||||
explosionDamage = 150;
|
|
||||||
fireProbability = 0.18F;
|
|
||||||
fireTime = 2;
|
|
||||||
durability = 1;
|
|
||||||
v = 25;
|
|
||||||
} else {
|
|
||||||
throw new IllegalStateException("Unexpected value: " + getWeaponType(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector4f worldPosition = transformPosition(transform, 0, 0, 0);
|
Vector4f worldPosition = transformPosition(transform, 0, 0, 0);
|
||||||
|
|
||||||
CannonShellEntity entityToSpawn = new CannonShellEntity(player, level(), hitDamage, explosionRadius, explosionDamage, fireProbability, fireTime)
|
var cannonShell = (CannonShellWeapon) getWeapon(0);
|
||||||
.durability(durability);
|
var entityToSpawn = cannonShell.create(player, level());
|
||||||
|
|
||||||
entityToSpawn.setPos(worldPosition.x - 1.1 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z - 1.1 * this.getDeltaMovement().z);
|
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, v, 0.02f);
|
entityToSpawn.shoot(getBarrelVector(1).x, getBarrelVector(1).y + 0.005f, getBarrelVector(1).z, cannonShell.velocity, 0.02f);
|
||||||
level().addFreshEntity(entityToSpawn);
|
level().addFreshEntity(entityToSpawn);
|
||||||
|
|
||||||
if (!player.level().isClientSide) {
|
if (!player.level().isClientSide) {
|
||||||
|
@ -451,16 +450,13 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
Matrix4f transform = getGunTransform();
|
Matrix4f transform = getGunTransform();
|
||||||
Vector4f worldPosition = transformPosition(transform, 0, -0.25f, 0);
|
Vector4f worldPosition = transformPosition(transform, 0, -0.25f, 0);
|
||||||
|
|
||||||
ProjectileEntity projectile = new ProjectileEntity(player.level())
|
var projectile = (ProjectileWeapon) getWeapon(1);
|
||||||
.shooter(player)
|
var projectileEntity = projectile.create(player);
|
||||||
.damage(VehicleConfig.SPEEDBOAT_GUN_DAMAGE.get())
|
|
||||||
.headShot(2f)
|
|
||||||
.zoom(false);
|
|
||||||
|
|
||||||
projectile.bypassArmorRate(0.4f);
|
projectileEntity.setPos(worldPosition.x - 1.1 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z - 1.1 * this.getDeltaMovement().z);
|
||||||
projectile.setPos(worldPosition.x - 1.1 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z - 1.1 * this.getDeltaMovement().z);
|
projectileEntity.shoot(getGunVector(1).x, getGunVector(1).y + 0.005f, getGunVector(1).z, 20, 0.3f);
|
||||||
projectile.shoot(getGunVector(1).x, getGunVector(1).y + 0.005f, getGunVector(1).z, 20, 0.3f);
|
|
||||||
this.level().addFreshEntity(projectile);
|
this.level().addFreshEntity(projectileEntity);
|
||||||
|
|
||||||
float pitch = this.entityData.get(MACHINE_GUN_HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - this.entityData.get(MACHINE_GUN_HEAT)));
|
float pitch = this.entityData.get(MACHINE_GUN_HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - this.entityData.get(MACHINE_GUN_HEAT)));
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
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;
|
||||||
|
public int fireTime, durability;
|
||||||
|
|
||||||
|
public CannonShellWeapon hitDamage(float hitDamage) {
|
||||||
|
this.hitDamage = hitDamage;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CannonShellWeapon explosionRadius(float explosionRadius) {
|
||||||
|
this.explosionRadius = explosionRadius;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CannonShellWeapon explosionDamage(float explosionDamage) {
|
||||||
|
this.explosionDamage = explosionDamage;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CannonShellWeapon fireProbability(float fireProbability) {
|
||||||
|
this.fireProbability = fireProbability;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CannonShellWeapon velocity(float velocity) {
|
||||||
|
this.velocity = velocity;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CannonShellWeapon fireTime(int fireTime) {
|
||||||
|
this.fireTime = fireTime;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CannonShellWeapon durability(int durability) {
|
||||||
|
this.durability = durability;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CannonShellEntity create(Player player, Level level) {
|
||||||
|
return new CannonShellEntity(player,
|
||||||
|
level,
|
||||||
|
this.hitDamage,
|
||||||
|
this.explosionRadius,
|
||||||
|
this.explosionDamage,
|
||||||
|
this.fireProbability,
|
||||||
|
this.fireTime
|
||||||
|
).durability(this.durability);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.atsuishio.superbwarfare.entity.vehicle.weapon;
|
||||||
|
|
||||||
|
import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity;
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
|
||||||
|
public class ProjectileWeapon extends VehicleWeapon {
|
||||||
|
public float headShot, damage, bypassArmorRate;
|
||||||
|
public boolean zoom;
|
||||||
|
|
||||||
|
public ProjectileWeapon headShot(float headShot) {
|
||||||
|
this.headShot = headShot;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProjectileWeapon damage(float damage) {
|
||||||
|
this.damage = damage;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProjectileWeapon bypassArmorRate(float bypassArmorRate) {
|
||||||
|
this.bypassArmorRate = bypassArmorRate;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProjectileWeapon zoom(boolean zoom) {
|
||||||
|
this.zoom = zoom;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProjectileEntity create(LivingEntity shooter) {
|
||||||
|
return new ProjectileEntity(shooter.level())
|
||||||
|
.shooter(shooter)
|
||||||
|
.headShot(headShot)
|
||||||
|
.damage(damage)
|
||||||
|
.bypassArmorRate(bypassArmorRate)
|
||||||
|
.zoom(zoom);
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
public class VehicleWeapon {
|
public abstract class VehicleWeapon {
|
||||||
|
|
||||||
// 武器的图标
|
// 武器的图标
|
||||||
public ResourceLocation icon;
|
public ResourceLocation icon;
|
||||||
|
|
Loading…
Add table
Reference in a new issue