添加坦克的发射功能
This commit is contained in:
parent
b03efb454d
commit
1bb4f0373a
14 changed files with 230 additions and 262 deletions
|
@ -38,6 +38,7 @@ import static com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay.*;
|
||||||
import static com.atsuishio.superbwarfare.entity.vehicle.Ah6Entity.WEAPON_TYPE;
|
import static com.atsuishio.superbwarfare.entity.vehicle.Ah6Entity.WEAPON_TYPE;
|
||||||
import static com.atsuishio.superbwarfare.entity.vehicle.Lav150Entity.COAX_HEAT;
|
import static com.atsuishio.superbwarfare.entity.vehicle.Lav150Entity.COAX_HEAT;
|
||||||
import static com.atsuishio.superbwarfare.entity.vehicle.Lav150Entity.HEAT;
|
import static com.atsuishio.superbwarfare.entity.vehicle.Lav150Entity.HEAT;
|
||||||
|
import static com.atsuishio.superbwarfare.entity.vehicle.Yx100Entity.AMMO;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
||||||
public class VehicleHudOverlay {
|
public class VehicleHudOverlay {
|
||||||
|
@ -295,6 +296,14 @@ public class VehicleHudOverlay {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (player.getVehicle() instanceof Yx100Entity yx100) {
|
||||||
|
if (multiWeaponVehicle.getWeaponType() == 0) {
|
||||||
|
guiGraphics.drawString(mc.font, Component.literal("AP SHELL " + yx100.getAmmoCount(player) + " " + yx100.getEntityData().get(AMMO)), w / 2 - 33, h - 65, 0x66FF00, false);
|
||||||
|
} else {
|
||||||
|
guiGraphics.drawString(mc.font, Component.literal("HE SHELL " + yx100.getAmmoCount(player) + " " + yx100.getEntityData().get(AMMO)), w / 2 - 33, h - 65, 0x66FF00, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 血量
|
// 血量
|
||||||
double heal = mobileVehicle.getHealth() / mobileVehicle.getMaxHealth();
|
double heal = mobileVehicle.getHealth() / mobileVehicle.getMaxHealth();
|
||||||
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal(FormatTool.format0D(100 * heal)), w / 2 - 165, h / 2 - 46, Mth.hsvToRgb((float) heal / 3.745318352059925F, 1.0F, 1.0F), false);
|
guiGraphics.drawString(Minecraft.getInstance().font, Component.literal(FormatTool.format0D(100 * heal)), w / 2 - 165, h / 2 - 46, Mth.hsvToRgb((float) heal / 3.745318352059925F, 1.0F, 1.0F), false);
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.atsuishio.superbwarfare.entity.projectile;
|
||||||
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.entity.AnimatedEntity;
|
import com.atsuishio.superbwarfare.entity.AnimatedEntity;
|
||||||
|
import com.atsuishio.superbwarfare.entity.vehicle.VehicleEntity;
|
||||||
import com.atsuishio.superbwarfare.init.*;
|
import com.atsuishio.superbwarfare.init.*;
|
||||||
import com.atsuishio.superbwarfare.network.message.ClientIndicatorMessage;
|
import com.atsuishio.superbwarfare.network.message.ClientIndicatorMessage;
|
||||||
import com.atsuishio.superbwarfare.tools.ChunkLoadTool;
|
import com.atsuishio.superbwarfare.tools.ChunkLoadTool;
|
||||||
|
@ -162,6 +163,7 @@ public class CannonShellEntity extends ThrowableItemProjectile implements GeoEnt
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onHitEntity(EntityHitResult entityHitResult) {
|
public void onHitEntity(EntityHitResult entityHitResult) {
|
||||||
|
if (this.level() instanceof ServerLevel) {
|
||||||
Entity entity = entityHitResult.getEntity();
|
Entity entity = entityHitResult.getEntity();
|
||||||
entity.hurt(ModDamageTypes.causeCannonFireDamage(this.level().registryAccess(), this, this.getOwner()), this.damage);
|
entity.hurt(ModDamageTypes.causeCannonFireDamage(this.level().registryAccess(), this, this.getOwner()), this.damage);
|
||||||
|
|
||||||
|
@ -177,28 +179,18 @@ public class CannonShellEntity extends ThrowableItemProjectile implements GeoEnt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ParticleTool.cannonHitParticles(this.level(), this.position());
|
ParticleTool.cannonHitParticles(this.level(), this.position(), this);
|
||||||
|
|
||||||
Vec3 vec = this.getDeltaMovement();
|
|
||||||
double vec_x = vec.x;
|
|
||||||
double vec_y = vec.y;
|
|
||||||
double vec_z = vec.z;
|
|
||||||
|
|
||||||
this.setDeltaMovement(vec_x - 0.02 * vec_x, vec_y - 0.02 * vec_y, vec_z - 0.02 * vec_z);
|
|
||||||
|
|
||||||
this.durability -= 2;
|
|
||||||
if (this.durability <= 0) {
|
|
||||||
if (!this.level().isClientSide()) {
|
|
||||||
causeExplode(entity);
|
causeExplode(entity);
|
||||||
}
|
if (entity instanceof VehicleEntity) {
|
||||||
this.discard();
|
this.discard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onHitBlock(BlockHitResult blockHitResult) {
|
public void onHitBlock(BlockHitResult blockHitResult) {
|
||||||
super.onHitBlock(blockHitResult);
|
if (this.level() instanceof ServerLevel) {
|
||||||
|
|
||||||
int x = blockHitResult.getBlockPos().getX();
|
int x = blockHitResult.getBlockPos().getX();
|
||||||
int y = blockHitResult.getBlockPos().getY();
|
int y = blockHitResult.getBlockPos().getY();
|
||||||
int z = blockHitResult.getBlockPos().getZ();
|
int z = blockHitResult.getBlockPos().getZ();
|
||||||
|
@ -219,9 +211,6 @@ public class CannonShellEntity extends ThrowableItemProjectile implements GeoEnt
|
||||||
this.level().destroyBlock(blockPos, true);
|
this.level().destroyBlock(blockPos, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3 vec = this.getDeltaMovement();
|
|
||||||
this.setDeltaMovement(vec.multiply(0.4, 0.4, 0.4));
|
|
||||||
|
|
||||||
if (blockState.is(ModBlocks.SANDBAG.get()) || blockState.is(Blocks.NETHERITE_BLOCK)) {
|
if (blockState.is(ModBlocks.SANDBAG.get()) || blockState.is(Blocks.NETHERITE_BLOCK)) {
|
||||||
this.durability -= 10;
|
this.durability -= 10;
|
||||||
}
|
}
|
||||||
|
@ -235,34 +224,19 @@ public class CannonShellEntity extends ThrowableItemProjectile implements GeoEnt
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.durability <= 0) {
|
if (this.durability <= 0) {
|
||||||
if (!this.level().isClientSide()) {
|
|
||||||
causeExplodeBlock(blockHitResult);
|
causeExplodeBlock(blockHitResult);
|
||||||
this.discard();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (!this.level().isClientSide()) {
|
|
||||||
if (ExplosionConfig.EXPLOSION_DESTROY.get()) {
|
if (ExplosionConfig.EXPLOSION_DESTROY.get()) {
|
||||||
if (this.firstHit) {
|
if (this.firstHit) {
|
||||||
ParticleTool.cannonHitParticles(this.level(), this.position());
|
ParticleTool.cannonHitParticles(this.level(), this.position(), this);
|
||||||
causeExplodeBlock(blockHitResult);
|
causeExplodeBlock(blockHitResult);
|
||||||
this.firstHit = false;
|
this.firstHit = false;
|
||||||
this.setNoGravity(true);
|
}
|
||||||
} else {
|
}
|
||||||
apExplode(blockHitResult);
|
apExplode(blockHitResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (this.durability > 0) {
|
|
||||||
ModUtils.queueServerWork(2, () -> {
|
|
||||||
if (!this.level().isClientSide()) {
|
|
||||||
causeExplodeBlock(blockHitResult);
|
|
||||||
this.discard();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
|
@ -340,6 +314,7 @@ public class CannonShellEntity extends ThrowableItemProjectile implements GeoEnt
|
||||||
} else {
|
} else {
|
||||||
ParticleTool.spawnMediumExplosionParticles(this.level(), result.getLocation());
|
ParticleTool.spawnMediumExplosionParticles(this.level(), result.getLocation());
|
||||||
}
|
}
|
||||||
|
this.discard();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void apExplode(HitResult result) {
|
private void apExplode(HitResult result) {
|
||||||
|
@ -352,9 +327,9 @@ public class CannonShellEntity extends ThrowableItemProjectile implements GeoEnt
|
||||||
this,
|
this,
|
||||||
this.getOwner()),
|
this.getOwner()),
|
||||||
explosionDamage,
|
explosionDamage,
|
||||||
result.getLocation().x,
|
result.getLocation().x + 5 * getDeltaMovement().normalize().x,
|
||||||
result.getLocation().y,
|
result.getLocation().y + 5 * getDeltaMovement().normalize().y,
|
||||||
result.getLocation().z,
|
result.getLocation().z + 5 * getDeltaMovement().normalize().z,
|
||||||
radius,
|
radius,
|
||||||
ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).
|
ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).
|
||||||
setDamageMultiplier(1).setFireTime(fireTime);
|
setDamageMultiplier(1).setFireTime(fireTime);
|
||||||
|
@ -367,6 +342,7 @@ public class CannonShellEntity extends ThrowableItemProjectile implements GeoEnt
|
||||||
} else {
|
} else {
|
||||||
ParticleTool.spawnMediumExplosionParticles(this.level(), result.getLocation());
|
ParticleTool.spawnMediumExplosionParticles(this.level(), result.getLocation());
|
||||||
}
|
}
|
||||||
|
this.discard();
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlayState movementPredicate(AnimationState<CannonShellEntity> event) {
|
private PlayState movementPredicate(AnimationState<CannonShellEntity> event) {
|
||||||
|
|
|
@ -193,8 +193,8 @@ public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity,
|
||||||
.multiply(0.2f, ModDamageTypes.PROJECTILE_BOOM)
|
.multiply(0.2f, ModDamageTypes.PROJECTILE_BOOM)
|
||||||
.multiply(0.1f, ModDamageTypes.MINE)
|
.multiply(0.1f, ModDamageTypes.MINE)
|
||||||
.multiply(0.12f, ModDamageTypes.LUNGE_MINE)
|
.multiply(0.12f, ModDamageTypes.LUNGE_MINE)
|
||||||
.multiply(0.22f, ModDamageTypes.CANNON_FIRE)
|
.multiply(0.16f, ModDamageTypes.CANNON_FIRE)
|
||||||
.multiply(0.07f, ModTags.DamageTypes.PROJECTILE_ABSOLUTE)
|
.multiply(0.03f, ModTags.DamageTypes.PROJECTILE_ABSOLUTE)
|
||||||
.reduce(10);
|
.reduce(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,13 +139,13 @@ public class VehicleEntity extends Entity {
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
} else if (!player.isShiftKeyDown()) {
|
} else if (!player.isShiftKeyDown()) {
|
||||||
if (this.getFirstPassenger() == null) {
|
if (this.getFirstPassenger() == null) {
|
||||||
// player.setXRot(this.getXRot());
|
player.setXRot(this.getXRot());
|
||||||
// player.setYRot(this.getYRot());
|
player.setYRot(this.getYRot());
|
||||||
return player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS;
|
return player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS;
|
||||||
} else if (!(this.getFirstPassenger() instanceof Player)) {
|
} else if (!(this.getFirstPassenger() instanceof Player)) {
|
||||||
this.getFirstPassenger().stopRiding();
|
this.getFirstPassenger().stopRiding();
|
||||||
// player.setXRot(this.getXRot());
|
player.setXRot(this.getXRot());
|
||||||
// player.setYRot(this.getYRot());
|
player.setYRot(this.getYRot());
|
||||||
return player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS;
|
return player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS;
|
||||||
}
|
}
|
||||||
if (this.canAddPassenger(player)) {
|
if (this.canAddPassenger(player)) {
|
||||||
|
@ -468,7 +468,7 @@ public class VehicleEntity extends Entity {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Vec3 getDismountOffset(double vehicleWidth, double passengerWidth) {
|
protected Vec3 getDismountOffset(double vehicleWidth, double passengerWidth) {
|
||||||
double offset = (vehicleWidth + passengerWidth + (double) 1.0E-5f) / 2.0;
|
double offset = (vehicleWidth + passengerWidth + (double) 1.0E-5f) / 1.75;
|
||||||
float yaw = getYRot() + 90.0f;
|
float yaw = getYRot() + 90.0f;
|
||||||
float x = -Mth.sin(yaw * ((float) java.lang.Math.PI / 180));
|
float x = -Mth.sin(yaw * ((float) java.lang.Math.PI / 180));
|
||||||
float z = Mth.cos(yaw * ((float) java.lang.Math.PI / 180));
|
float z = Mth.cos(yaw * ((float) java.lang.Math.PI / 180));
|
||||||
|
|
|
@ -3,8 +3,7 @@ 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.ProjectileEntity;
|
import com.atsuishio.superbwarfare.entity.projectile.CannonShellEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.projectile.SmallCannonShellEntity;
|
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier;
|
import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier;
|
||||||
import com.atsuishio.superbwarfare.init.*;
|
import com.atsuishio.superbwarfare.init.*;
|
||||||
import com.atsuishio.superbwarfare.network.message.ShakeClientMessage;
|
import com.atsuishio.superbwarfare.network.message.ShakeClientMessage;
|
||||||
|
@ -58,15 +57,14 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
|
|
||||||
public static final EntityDataAccessor<Integer> FIRE_ANIM = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT);
|
public static final EntityDataAccessor<Integer> FIRE_ANIM = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT);
|
||||||
public static final EntityDataAccessor<Float> DELTA_ROT = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.FLOAT);
|
public static final EntityDataAccessor<Float> DELTA_ROT = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.FLOAT);
|
||||||
public static final EntityDataAccessor<Integer> HEAT = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT);
|
|
||||||
public static final EntityDataAccessor<Integer> COAX_HEAT = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT);
|
|
||||||
public static final EntityDataAccessor<Integer> AMMO = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT);
|
public static final EntityDataAccessor<Integer> AMMO = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT);
|
||||||
|
public static final EntityDataAccessor<Integer> LOADED_AMMO = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT);
|
||||||
public static final EntityDataAccessor<Integer> WEAPON_TYPE = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT);
|
public static final EntityDataAccessor<Integer> WEAPON_TYPE = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT);
|
||||||
public static final EntityDataAccessor<Float> TRACK_L = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.FLOAT);
|
public static final EntityDataAccessor<Float> TRACK_L = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.FLOAT);
|
||||||
public static final EntityDataAccessor<Float> TRACK_R = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.FLOAT);
|
public static final EntityDataAccessor<Float> TRACK_R = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.FLOAT);
|
||||||
|
|
||||||
public static final float MAX_HEALTH = VehicleConfig.BMP_2_HP.get();
|
public static final float MAX_HEALTH = 400;
|
||||||
public static final int MAX_ENERGY = VehicleConfig.BMP_2_MAX_ENERGY.get();
|
public static final int MAX_ENERGY = 5000000;
|
||||||
|
|
||||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||||
public float turretYRot;
|
public float turretYRot;
|
||||||
|
@ -77,8 +75,6 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
public float rightWheelRot;
|
public float rightWheelRot;
|
||||||
public float leftWheelRotO;
|
public float leftWheelRotO;
|
||||||
public float rightWheelRotO;
|
public float rightWheelRotO;
|
||||||
public boolean cannotFire;
|
|
||||||
public boolean cannotFireCoax;
|
|
||||||
public int reloadCoolDown;
|
public int reloadCoolDown;
|
||||||
|
|
||||||
public Yx100Entity(PlayMessages.SpawnEntity packet, Level world) {
|
public Yx100Entity(PlayMessages.SpawnEntity packet, Level world) {
|
||||||
|
@ -94,10 +90,9 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
protected void defineSynchedData() {
|
protected void defineSynchedData() {
|
||||||
super.defineSynchedData();
|
super.defineSynchedData();
|
||||||
this.entityData.define(AMMO, 0);
|
this.entityData.define(AMMO, 0);
|
||||||
|
this.entityData.define(LOADED_AMMO, 0);
|
||||||
this.entityData.define(FIRE_ANIM, 0);
|
this.entityData.define(FIRE_ANIM, 0);
|
||||||
this.entityData.define(DELTA_ROT, 0f);
|
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(WEAPON_TYPE, 0);
|
||||||
this.entityData.define(TRACK_L, 0f);
|
this.entityData.define(TRACK_L, 0f);
|
||||||
this.entityData.define(TRACK_R, 0f);
|
this.entityData.define(TRACK_R, 0f);
|
||||||
|
@ -106,11 +101,15 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
@Override
|
@Override
|
||||||
public void addAdditionalSaveData(CompoundTag compound) {
|
public void addAdditionalSaveData(CompoundTag compound) {
|
||||||
super.addAdditionalSaveData(compound);
|
super.addAdditionalSaveData(compound);
|
||||||
|
compound.putInt("LoadedAmmo", this.entityData.get(LOADED_AMMO));
|
||||||
|
compound.putInt("WeaponType", this.entityData.get(WEAPON_TYPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readAdditionalSaveData(CompoundTag compound) {
|
public void readAdditionalSaveData(CompoundTag compound) {
|
||||||
super.readAdditionalSaveData(compound);
|
super.readAdditionalSaveData(compound);
|
||||||
|
this.entityData.set(LOADED_AMMO, compound.getInt("LoadedAmmo"));
|
||||||
|
this.entityData.set(WEAPON_TYPE, compound.getInt("WeaponType"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -121,24 +120,22 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
@Override
|
@Override
|
||||||
public DamageModifier getDamageModifier() {
|
public DamageModifier getDamageModifier() {
|
||||||
return super.getDamageModifier()
|
return super.getDamageModifier()
|
||||||
.multiply(0.3f, DamageTypes.ARROW)
|
.immuneTo(DamageTypes.ARROW)
|
||||||
.multiply(0.3f, DamageTypes.TRIDENT)
|
.immuneTo(DamageTypes.TRIDENT)
|
||||||
.multiply(0.5f, DamageTypes.MOB_ATTACK)
|
.immuneTo(DamageTypes.MOB_ATTACK)
|
||||||
.multiply(0.4f, DamageTypes.MOB_ATTACK_NO_AGGRO)
|
.immuneTo(DamageTypes.MOB_ATTACK_NO_AGGRO)
|
||||||
.multiply(0.3f, DamageTypes.MOB_PROJECTILE)
|
.immuneTo(DamageTypes.MOB_PROJECTILE)
|
||||||
.multiply(0.2f, DamageTypes.PLAYER_ATTACK)
|
.immuneTo(DamageTypes.PLAYER_ATTACK)
|
||||||
.multiply(2.5f, DamageTypes.LAVA)
|
.immuneTo(ModTags.DamageTypes.PROJECTILE)
|
||||||
.multiply(1.2f, DamageTypes.EXPLOSION)
|
.immuneTo(ModDamageTypes.VEHICLE_STRIKE)
|
||||||
.multiply(1.2f, DamageTypes.PLAYER_EXPLOSION)
|
.multiply(0.75f, DamageTypes.EXPLOSION)
|
||||||
.multiply(0.4f, ModDamageTypes.CUSTOM_EXPLOSION)
|
.multiply(0.23f, ModDamageTypes.CUSTOM_EXPLOSION)
|
||||||
.multiply(0.4f, ModDamageTypes.PROJECTILE_BOOM)
|
.multiply(0.23f, ModDamageTypes.PROJECTILE_BOOM)
|
||||||
.multiply(0.14f, ModDamageTypes.MINE)
|
.multiply(0.13f, ModDamageTypes.MINE)
|
||||||
.multiply(0.18f, ModDamageTypes.LUNGE_MINE)
|
.multiply(0.15f, ModDamageTypes.LUNGE_MINE)
|
||||||
.multiply(0.3f, ModDamageTypes.CANNON_FIRE)
|
.multiply(0.2f, ModDamageTypes.CANNON_FIRE)
|
||||||
.multiply(0.02f, ModTags.DamageTypes.PROJECTILE)
|
.multiply(0.05f, ModTags.DamageTypes.PROJECTILE_ABSOLUTE)
|
||||||
.multiply(0.14f, ModTags.DamageTypes.PROJECTILE_ABSOLUTE)
|
.reduce(9);
|
||||||
.multiply(1.7f, ModDamageTypes.VEHICLE_STRIKE)
|
|
||||||
.reduce(8);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -176,49 +173,21 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
this.entityData.set(TRACK_L, 0f);
|
this.entityData.set(TRACK_L, 0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.entityData.get(HEAT) > 0) {
|
|
||||||
this.entityData.set(HEAT, this.entityData.get(HEAT) - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.entityData.get(FIRE_ANIM) > 0) {
|
if (this.entityData.get(FIRE_ANIM) > 0) {
|
||||||
this.entityData.set(FIRE_ANIM, this.entityData.get(FIRE_ANIM) - 1);
|
this.entityData.set(FIRE_ANIM, this.entityData.get(FIRE_ANIM) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.entityData.get(HEAT) < 40) {
|
if (reloadCoolDown == 70 && this.getFirstPassenger() instanceof Player player) {
|
||||||
cannotFire = false;
|
SoundTool.playLocalSound(player, ModSounds.YX_100_RELOAD.get());
|
||||||
}
|
|
||||||
|
|
||||||
if (this.entityData.get(COAX_HEAT) > 0) {
|
|
||||||
this.entityData.set(COAX_HEAT, this.entityData.get(COAX_HEAT) - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.entityData.get(COAX_HEAT) < 40) {
|
|
||||||
cannotFireCoax = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.level() instanceof ServerLevel) {
|
if (this.level() instanceof ServerLevel) {
|
||||||
if (reloadCoolDown > 0) {
|
if (reloadCoolDown > 0 && this.entityData.get(AMMO) > 0) {
|
||||||
reloadCoolDown--;
|
reloadCoolDown--;
|
||||||
}
|
}
|
||||||
this.handleAmmo();
|
this.handleAmmo();
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity driver = this.getFirstPassenger();
|
|
||||||
if (driver instanceof Player player) {
|
|
||||||
if (this.entityData.get(HEAT) > 100) {
|
|
||||||
cannotFire = true;
|
|
||||||
if (!player.level().isClientSide() && player instanceof ServerPlayer serverPlayer) {
|
|
||||||
SoundTool.playLocalSound(serverPlayer, ModSounds.MINIGUN_OVERHEAT.get(), 1f, 1f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.entityData.get(COAX_HEAT) > 100) {
|
|
||||||
cannotFireCoax = true;
|
|
||||||
if (!player.level().isClientSide() && player instanceof ServerPlayer serverPlayer) {
|
|
||||||
SoundTool.playLocalSound(serverPlayer, ModSounds.MINIGUN_OVERHEAT.get(), 1f, 1f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.onGround()) {
|
if (this.onGround()) {
|
||||||
float f0 = 0.54f + 0.25f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90;
|
float f0 = 0.54f + 0.25f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90;
|
||||||
this.setDeltaMovement(this.getDeltaMovement().add(this.getViewVector(1).normalize().scale(0.05 * this.getDeltaMovement().horizontalDistance())));
|
this.setDeltaMovement(this.getDeltaMovement().add(this.getViewVector(1).normalize().scale(0.05 * this.getDeltaMovement().horizontalDistance())));
|
||||||
|
@ -253,20 +222,6 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
|
|
||||||
gunnerAngle();
|
gunnerAngle();
|
||||||
lowHealthWarning();
|
lowHealthWarning();
|
||||||
|
|
||||||
// List<Entity> entities = this.getPassengers();
|
|
||||||
//
|
|
||||||
// for (var e : entities) {
|
|
||||||
// if (!(e instanceof Yx100GunEntity)) {
|
|
||||||
// Yx100GunEntity yx100Gun = new Yx100GunEntity(ModEntities.YX_100_GUN.get(), this.level());
|
|
||||||
// this.level().addFreshEntity(yx100Gun);
|
|
||||||
// yx100Gun.startRiding(this, true);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//// if (!(this.hasPassenger(yx100Gun))) {
|
|
||||||
////
|
|
||||||
//// }
|
|
||||||
this.refreshDimensions();
|
this.refreshDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,11 +236,28 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
}).mapToInt(stack -> stack.getOrCreateTag().getInt("RifleAmmo")).sum()
|
}).mapToInt(stack -> stack.getOrCreateTag().getInt("RifleAmmo")).sum()
|
||||||
+ this.getItemStacks().stream().filter(stack -> stack.is(ModItems.RIFLE_AMMO.get())).mapToInt(ItemStack::getCount).sum();
|
+ this.getItemStacks().stream().filter(stack -> stack.is(ModItems.RIFLE_AMMO.get())).mapToInt(ItemStack::getCount).sum();
|
||||||
|
|
||||||
|
boolean hasCreativeAmmo = player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get()));
|
||||||
|
|
||||||
if (this.getEntityData().get(WEAPON_TYPE) == 0) {
|
if (hasCreativeAmmo) {
|
||||||
this.entityData.set(AMMO, this.getItemStacks().stream().filter(stack -> stack.is(ModItems.SMALL_SHELL.get())).mapToInt(ItemStack::getCount).sum());
|
this.entityData.set(AMMO, 9999);
|
||||||
|
} else if (this.getEntityData().get(WEAPON_TYPE) == 0) {
|
||||||
|
this.entityData.set(AMMO, this.getItemStacks().stream().filter(stack -> stack.is(ModItems.AP_5_INCHES.get())).mapToInt(ItemStack::getCount).sum());
|
||||||
} else if (this.getEntityData().get(WEAPON_TYPE) == 1) {
|
} else if (this.getEntityData().get(WEAPON_TYPE) == 1) {
|
||||||
this.entityData.set(AMMO, ammoCount);
|
this.entityData.set(AMMO, this.getItemStacks().stream().filter(stack -> stack.is(ModItems.HE_5_INCHES.get())).mapToInt(ItemStack::getCount).sum());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getEntityData().get(LOADED_AMMO) == 0 && reloadCoolDown <= 0) {
|
||||||
|
if (this.getEntityData().get(WEAPON_TYPE) == 0 && (this.getItemStacks().stream().filter(stack -> stack.is(ModItems.AP_5_INCHES.get())).mapToInt(ItemStack::getCount).sum() > 0 || hasCreativeAmmo)) {
|
||||||
|
this.entityData.set(LOADED_AMMO, 1);
|
||||||
|
if (!hasCreativeAmmo) {
|
||||||
|
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.AP_5_INCHES.get())).findFirst().ifPresent(stack -> stack.shrink(1));
|
||||||
|
}
|
||||||
|
} else if (this.getEntityData().get(WEAPON_TYPE) == 1 && (this.getItemStacks().stream().filter(stack -> stack.is(ModItems.HE_5_INCHES.get())).mapToInt(ItemStack::getCount).sum() > 0 || hasCreativeAmmo)) {
|
||||||
|
this.entityData.set(LOADED_AMMO, 1);
|
||||||
|
if (!hasCreativeAmmo) {
|
||||||
|
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.HE_5_INCHES.get())).findFirst().ifPresent(stack -> stack.shrink(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,95 +271,65 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void vehicleShoot(Player player) {
|
public void vehicleShoot(Player player) {
|
||||||
|
if (reloadCoolDown > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Matrix4f transform = getBarrelTransform();
|
Matrix4f transform = getBarrelTransform();
|
||||||
|
float hitDamage = 0;
|
||||||
|
float explosionRadius = 0;
|
||||||
|
float explosionDamage = 0;
|
||||||
|
float fireProbability = 0;
|
||||||
|
int fireTime = 0;
|
||||||
|
int durability = 0;
|
||||||
|
float v = 0;
|
||||||
|
|
||||||
if (entityData.get(WEAPON_TYPE) == 0) {
|
if (entityData.get(WEAPON_TYPE) == 0) {
|
||||||
if (this.cannotFire) return;
|
hitDamage = 500;
|
||||||
float x = -0.1125f;
|
explosionRadius = 4;
|
||||||
float y = 0.174025f;
|
explosionDamage = 100;
|
||||||
float z = 4.2f;
|
fireProbability = 0;
|
||||||
|
durability = 60;
|
||||||
|
v = 40;
|
||||||
|
} else if (entityData.get(WEAPON_TYPE) == 1) {
|
||||||
|
hitDamage = 100;
|
||||||
|
explosionRadius = 10;
|
||||||
|
explosionDamage = 150;
|
||||||
|
fireProbability = 0.18F;
|
||||||
|
fireTime = 2;
|
||||||
|
durability = 1;
|
||||||
|
v = 25;
|
||||||
|
}
|
||||||
|
|
||||||
Vector4f worldPosition = transformPosition(transform, x, y, z);
|
Vector4f worldPosition = transformPosition(transform, 0, 0, 0);
|
||||||
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());
|
|
||||||
|
|
||||||
smallCannonShell.setPos(worldPosition.x - 1.1 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z - 1.1 * this.getDeltaMovement().z);
|
CannonShellEntity entityToSpawn = new CannonShellEntity(player, level(), hitDamage, explosionRadius, explosionDamage, fireProbability, fireTime)
|
||||||
smallCannonShell.shoot(getBarrelVector(1).x, getBarrelVector(1).y + 0.005f, getBarrelVector(1).z, 20,
|
.durability(durability);
|
||||||
0.25f);
|
|
||||||
this.level().addFreshEntity(smallCannonShell);
|
|
||||||
|
|
||||||
sendParticle((ServerLevel) this.level(), ParticleTypes.LARGE_SMOKE, worldPosition.x - 1.1 * this.getDeltaMovement().x, worldPosition.y, worldPosition.z - 1.1 * this.getDeltaMovement().z, 1, 0.02, 0.02, 0.02, 0, false);
|
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);
|
||||||
float pitch = this.entityData.get(HEAT) <= 60 ? 1 : (float) (1 - 0.011 * Math.abs(60 - this.entityData.get(HEAT)));
|
level().addFreshEntity(entityToSpawn);
|
||||||
|
|
||||||
if (!player.level().isClientSide) {
|
if (!player.level().isClientSide) {
|
||||||
if (player instanceof ServerPlayer serverPlayer) {
|
if (player instanceof ServerPlayer serverPlayer) {
|
||||||
serverPlayer.playSound(ModSounds.BMP_CANNON_FIRE_3P.get(), 4, pitch);
|
serverPlayer.playSound(ModSounds.BMP_CANNON_FIRE_3P.get(), 4, 1);
|
||||||
serverPlayer.playSound(ModSounds.LAV_CANNON_FAR.get(), 12, pitch);
|
serverPlayer.playSound(ModSounds.LAV_CANNON_FAR.get(), 12, 1);
|
||||||
serverPlayer.playSound(ModSounds.LAV_CANNON_VERYFAR.get(), 24, pitch);
|
serverPlayer.playSound(ModSounds.LAV_CANNON_VERYFAR.get(), 24, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.entityData.set(FIRE_ANIM, 20);
|
||||||
|
this.entityData.set(LOADED_AMMO, 0);
|
||||||
|
this.consumeEnergy(10000);
|
||||||
|
|
||||||
|
reloadCoolDown = 80;
|
||||||
|
|
||||||
Level level = player.level();
|
Level level = player.level();
|
||||||
final Vec3 center = new Vec3(this.getX(), this.getEyeY(), this.getZ());
|
final Vec3 center = new Vec3(this.getX(), this.getEyeY(), this.getZ());
|
||||||
|
|
||||||
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(4), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
|
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(8), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
|
||||||
if (target instanceof ServerPlayer serverPlayer) {
|
if (target instanceof ServerPlayer serverPlayer) {
|
||||||
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShakeClientMessage(6, 5, 9, this.getX(), this.getEyeY(), this.getZ()));
|
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShakeClientMessage(10, 8, 40, this.getX(), this.getEyeY(), this.getZ()));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.entityData.set(HEAT, this.entityData.get(HEAT) + 7);
|
|
||||||
this.entityData.set(FIRE_ANIM, 3);
|
|
||||||
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.SMALL_SHELL.get())).findFirst().ifPresent(stack -> stack.shrink(1));
|
|
||||||
} else if (entityData.get(WEAPON_TYPE) == 1) {
|
|
||||||
if (this.cannotFireCoax) return;
|
|
||||||
float x = 0.1125f;
|
|
||||||
float y = 0.174025f;
|
|
||||||
float z = 2f;
|
|
||||||
|
|
||||||
Vector4f worldPosition = transformPosition(transform, x, y, z);
|
|
||||||
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);
|
|
||||||
|
|
||||||
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,
|
|
||||||
0.25f);
|
|
||||||
this.level().addFreshEntity(projectileRight);
|
|
||||||
|
|
||||||
if (!hasCreativeAmmo) {
|
|
||||||
ItemStack ammoBox = this.getItemStacks().stream().filter(stack -> {
|
|
||||||
if (stack.is(ModItems.AMMO_BOX.get())) {
|
|
||||||
return stack.getOrCreateTag().getInt("RifleAmmo") > 0;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}).findFirst().orElse(ItemStack.EMPTY);
|
|
||||||
|
|
||||||
if (!ammoBox.isEmpty()) {
|
|
||||||
ammoBox.getOrCreateTag().putInt("RifleAmmo", Math.max(0, ammoBox.getOrCreateTag().getInt("RifleAmmo") - 1));
|
|
||||||
} else {
|
|
||||||
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.RIFLE_AMMO.get())).findFirst().ifPresent(stack -> stack.shrink(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.entityData.set(COAX_HEAT, this.entityData.get(COAX_HEAT) + 3);
|
|
||||||
this.entityData.set(FIRE_ANIM, 2);
|
|
||||||
|
|
||||||
if (!player.level().isClientSide) {
|
|
||||||
if (player instanceof ServerPlayer serverPlayer) {
|
|
||||||
serverPlayer.playSound(ModSounds.M_60_FIRE_3P.get(), 3, 1);
|
|
||||||
serverPlayer.playSound(ModSounds.M_60_FAR.get(), 6, 1);
|
|
||||||
serverPlayer.playSound(ModSounds.M_60_VERYFAR.get(), 12, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -695,17 +637,12 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canShoot(Player player) {
|
public boolean canShoot(Player player) {
|
||||||
if (entityData.get(WEAPON_TYPE) == 0) {
|
return this.entityData.get(LOADED_AMMO) > 0;
|
||||||
return (this.entityData.get(AMMO) > 0 || player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get()))) && !cannotFire;
|
|
||||||
} else if (entityData.get(WEAPON_TYPE) == 1) {
|
|
||||||
return (this.entityData.get(AMMO) > 0 || player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get()))) && !cannotFireCoax;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAmmoCount(Player player) {
|
public int getAmmoCount(Player player) {
|
||||||
return this.entityData.get(AMMO);
|
return this.entityData.get(LOADED_AMMO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -725,11 +662,22 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changeWeapon(int scroll) {
|
public void changeWeapon(int scroll) {
|
||||||
var type = (entityData.get(WEAPON_TYPE) + scroll + 3) % 3;
|
if (entityData.get(LOADED_AMMO) > 0 && this.reloadCoolDown == 0) {
|
||||||
|
this.reloadCoolDown = 80;
|
||||||
|
if (entityData.get(WEAPON_TYPE) == 0) {
|
||||||
|
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.AP_5_INCHES.get())).findFirst().ifPresent(stack -> stack.grow(1));
|
||||||
|
} else if (entityData.get(WEAPON_TYPE) == 1) {
|
||||||
|
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.HE_5_INCHES.get())).findFirst().ifPresent(stack -> stack.grow(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
entityData.set(LOADED_AMMO, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
var type = (entityData.get(WEAPON_TYPE) + scroll + 2) % 2;
|
||||||
entityData.set(WEAPON_TYPE, type);
|
entityData.set(WEAPON_TYPE, type);
|
||||||
|
|
||||||
var sound = switch (type) {
|
var sound = switch (type) {
|
||||||
case 0, 2 -> ModSounds.INTO_MISSILE.get();
|
case 0 -> ModSounds.INTO_MISSILE.get();
|
||||||
case 1 -> ModSounds.INTO_CANNON.get();
|
case 1 -> ModSounds.INTO_CANNON.get();
|
||||||
default -> throw new IllegalStateException("Unexpected type: " + type);
|
default -> throw new IllegalStateException("Unexpected type: " + type);
|
||||||
};
|
};
|
||||||
|
|
|
@ -761,7 +761,9 @@ public class ClientEventHandler {
|
||||||
} else if (multiWeaponVehicle.getWeaponType() == 2) {
|
} else if (multiWeaponVehicle.getWeaponType() == 2) {
|
||||||
player.playSound(ModSounds.BMP_MISSILE_FIRE_1P.get(), 1f, 1);
|
player.playSound(ModSounds.BMP_MISSILE_FIRE_1P.get(), 1f, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (iVehicle instanceof Yx100Entity) {
|
||||||
|
player.playSound(ModSounds.YX_100_FIRE_1P.get(), 1f, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,14 @@ public class ClientSoundHandler {
|
||||||
player.level().playLocalSound(BlockPos.containing(engineSoundPos), engineSound, mobileVehicle.getSoundSource(), 5 * (Mth.abs(mobileVehicle.getEntityData().get(POWER)) + Mth.abs(0.08f * mobileVehicle.getEntityData().get(DELTA_ROT)) - 0.004f) * distanceReduce * distanceReduce, (float) ((2 * Math.random() - 1) * 0.1f + 1), false);
|
player.level().playLocalSound(BlockPos.containing(engineSoundPos), engineSound, mobileVehicle.getSoundSource(), 5 * (Mth.abs(mobileVehicle.getEntityData().get(POWER)) + Mth.abs(0.08f * mobileVehicle.getEntityData().get(DELTA_ROT)) - 0.004f) * distanceReduce * distanceReduce, (float) ((2 * Math.random() - 1) * 0.1f + 1), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (e instanceof Yx100Entity yx100) {
|
||||||
|
distanceReduce = (float) Math.max((1 - distance / 64), 0);
|
||||||
|
if (player.getVehicle() == yx100) {
|
||||||
|
player.playSound(ModSounds.BMP_ENGINE_1P.get(), 1 * (Mth.abs(mobileVehicle.getEntityData().get(POWER)) + Mth.abs(0.08f * mobileVehicle.getEntityData().get(DELTA_ROT)) - 0.004f), (float) ((2 * Math.random() - 1) * 0.1f + 0.95f));
|
||||||
|
} else {
|
||||||
|
player.level().playLocalSound(BlockPos.containing(engineSoundPos), engineSound, mobileVehicle.getSoundSource(), 5 * (Mth.abs(mobileVehicle.getEntityData().get(POWER)) + Mth.abs(0.08f * mobileVehicle.getEntityData().get(DELTA_ROT)) - 0.004f) * distanceReduce * distanceReduce, (float) ((2 * Math.random() - 1) * 0.1f + 1), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (e instanceof DroneEntity drone) {
|
if (e instanceof DroneEntity drone) {
|
||||||
distanceReduce = (float) Math.max((1 - distance / 64), 0);
|
distanceReduce = (float) Math.max((1 - distance / 64), 0);
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
|
@ -417,5 +417,7 @@ public class ModSounds {
|
||||||
public static final RegistryObject<SoundEvent> BMP_STEP = REGISTRY.register("bmp_step", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("bmp_step")));
|
public static final RegistryObject<SoundEvent> BMP_STEP = REGISTRY.register("bmp_step", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("bmp_step")));
|
||||||
public static final RegistryObject<SoundEvent> WHEEL_STEP = REGISTRY.register("wheel_step", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("wheel_step")));
|
public static final RegistryObject<SoundEvent> WHEEL_STEP = REGISTRY.register("wheel_step", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("wheel_step")));
|
||||||
public static final RegistryObject<SoundEvent> LASER_TOWER_SHOOT = REGISTRY.register("laser_tower_shoot", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("laser_tower_shoot")));
|
public static final RegistryObject<SoundEvent> LASER_TOWER_SHOOT = REGISTRY.register("laser_tower_shoot", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("laser_tower_shoot")));
|
||||||
|
public static final RegistryObject<SoundEvent> YX_100_RELOAD = REGISTRY.register("yx_100_reload", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("yx_100_reload")));
|
||||||
|
public static final RegistryObject<SoundEvent> YX_100_FIRE_1P = REGISTRY.register("yx_100_fire_1p", () -> SoundEvent.createVariableRangeEvent(ModUtils.loc("yx_100_fire_1p")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
|
||||||
import com.atsuishio.superbwarfare.network.message.ShakeClientMessage;
|
import com.atsuishio.superbwarfare.network.message.ShakeClientMessage;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
|
@ -70,9 +69,6 @@ public class CustomExplosion extends Explosion {
|
||||||
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShakeClientMessage(20 + 0.02 * damage,3 * pRadius,50 + 0.05 * damage, pToBlowX, pToBlowY, pToBlowZ));
|
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShakeClientMessage(20 + 0.02 * damage,3 * pRadius,50 + 0.05 * damage, pToBlowX, pToBlowY, pToBlowZ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pLevel instanceof ServerLevel) {
|
|
||||||
pLevel.explode(source == null ? null : source.getEntity(), pToBlowX, pToBlowY, pToBlowZ, 0.5f * pRadius , ExplosionConfig.EXPLOSION_DESTROY.get() ? Level.ExplosionInteraction.BLOCK : Level.ExplosionInteraction.NONE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CustomExplosion(Level pLevel, @Nullable Entity pSource, @Nullable DamageSource source, float damage, double pToBlowX, double pToBlowY, double pToBlowZ, float pRadius) {
|
public CustomExplosion(Level pLevel, @Nullable Entity pSource, @Nullable DamageSource source, float damage, double pToBlowX, double pToBlowY, double pToBlowZ, float pRadius) {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
@ -158,10 +159,10 @@ public class ParticleTool {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void cannonHitParticles(Level level, Vec3 pos) {
|
public static void cannonHitParticles(Level level, Vec3 pos, Entity entity) {
|
||||||
double x = pos.x;
|
double x = pos.x + 0.5 * entity.getDeltaMovement().x;
|
||||||
double y = pos.y;
|
double y = pos.y + 0.5 * entity.getDeltaMovement().y;
|
||||||
double z = pos.z;
|
double z = pos.z + 0.5 * entity.getDeltaMovement().z;
|
||||||
|
|
||||||
if (level instanceof ServerLevel serverLevel) {
|
if (level instanceof ServerLevel serverLevel) {
|
||||||
sendParticle(serverLevel, ParticleTypes.EXPLOSION, x, y, z, 2, 0.5, 0.5, 0.5, 1, true);
|
sendParticle(serverLevel, ParticleTypes.EXPLOSION, x, y, z, 2, 0.5, 0.5, 0.5, 1, true);
|
||||||
|
|
|
@ -2,10 +2,13 @@ package com.atsuishio.superbwarfare.tools;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
|
import com.atsuishio.superbwarfare.config.server.ExplosionConfig;
|
||||||
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
import com.atsuishio.superbwarfare.init.ModDamageTypes;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.projectile.ThrowableItemProjectile;
|
import net.minecraft.world.entity.projectile.ThrowableItemProjectile;
|
||||||
import net.minecraft.world.level.Explosion;
|
import net.minecraft.world.level.Explosion;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -20,6 +23,7 @@ public class ProjectileTool {
|
||||||
explosion.explode();
|
explosion.explode();
|
||||||
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(projectile.level(), explosion);
|
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(projectile.level(), explosion);
|
||||||
explosion.finalizeExplosion(false);
|
explosion.finalizeExplosion(false);
|
||||||
|
|
||||||
if (radius <= 5) {
|
if (radius <= 5) {
|
||||||
ParticleTool.spawnSmallExplosionParticles(projectile.level(), projectile.position().add(projectile.getDeltaMovement().scale(0.5)));
|
ParticleTool.spawnSmallExplosionParticles(projectile.level(), projectile.position().add(projectile.getDeltaMovement().scale(0.5)));
|
||||||
} else if (radius > 5 && radius < 10) {
|
} else if (radius > 5 && radius < 10) {
|
||||||
|
@ -28,6 +32,12 @@ public class ProjectileTool {
|
||||||
ParticleTool.spawnHugeExplosionParticles(projectile.level(), projectile.position().add(projectile.getDeltaMovement().scale(0.5)));
|
ParticleTool.spawnHugeExplosionParticles(projectile.level(), projectile.position().add(projectile.getDeltaMovement().scale(0.5)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vec3 pos = projectile.position().add(projectile.getDeltaMovement().scale(0.5));
|
||||||
|
|
||||||
|
if (projectile.level() instanceof ServerLevel) {
|
||||||
|
projectile.level().explode(source == null ? null : source.getEntity(), pos.x, pos.y, pos.z, 0.5f * radius , ExplosionConfig.EXPLOSION_DESTROY.get() ? Level.ExplosionInteraction.BLOCK : Level.ExplosionInteraction.NONE);
|
||||||
|
}
|
||||||
|
|
||||||
projectile.discard();
|
projectile.discard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2867,5 +2867,21 @@
|
||||||
"stream": false
|
"stream": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"yx_100_reload": {
|
||||||
|
"sounds": [
|
||||||
|
{
|
||||||
|
"name": "superbwarfare:yx100/yx100_reload",
|
||||||
|
"stream": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"yx_100_fire_1p": {
|
||||||
|
"sounds": [
|
||||||
|
{
|
||||||
|
"name": "superbwarfare:yx100/yx100_fire_1p",
|
||||||
|
"stream": false
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
Binary file not shown.
Binary file not shown.
Loading…
Add table
Reference in a new issue