Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public static class ConfigDamage {
public JSONConfigEntry<Boolean> wheelBreakage = new JSONConfigEntry<>(true, "Whether or not wheels can be broken (go flat).");
public JSONConfigEntry<Boolean> wheelDamageIgnoreVelocity = new JSONConfigEntry<>(false, "Whether or not velocity is ignored when calculating wheel damage.");
public JSONConfigEntry<Boolean> allowExternalDamage = new JSONConfigEntry<>(true, "Whether or not non-IV things can damage vehicles. This is normally false, as external damage is a hassle for most people, but can be true if you want other mod's guns to be able to attack vehicles in addition to IV's.");
public JSONConfigEntry<Double> propellerDamageFactor = new JSONConfigEntry<>(1.0D, "Factor for damage caused by a propeller.");
public JSONConfigEntry<Double> externalExplosionDamageFactor = new JSONConfigEntry<>(1.0D, "Factor for damage from external explosions when allowExternalDamage is enabled.");
public JSONConfigEntry<Double> propellerDamageFactor = new JSONConfigEntry<>(3.0D, "Factor for damage caused by a propeller.");
public JSONConfigEntry<Double> jetDamageFactor = new JSONConfigEntry<>(1.0D, "Factor for damage caused by a jet engine.");
public JSONConfigEntry<Double> wheelDamageFactor = new JSONConfigEntry<>(1.0D, "Factor for damage caused by wheels on vehicles.");
public JSONConfigEntry<Double> crashDamageFactor = new JSONConfigEntry<>(1.0D, "Factor for damage caused by crashes.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,13 @@ public boolean attackEntityFrom(DamageSource source, float amount) {
if (lastExplosionPosition != null && source.isExplosion()) {
//We encountered an explosion. These may or may not have have entities linked to them. Depends on if
//it's a player firing a gun that had a bullet, or a random TNT lighting in the world.
//Explosions, unlike other damage sources, can hit multiple collision boxes on an entity at once.
//Explosions can hit multiple boxes at once. Apply damage once to the core entity to prevent
//parts from forwarding duplicate explosive damage back into the same vehicle.
BoundingBox explosiveBounds = new BoundingBox(lastExplosionPosition, amount, amount, amount);
for (BoundingBox box : interactAttackBoxes.getBoxes()) {
if (box.intersects(explosiveBounds)) {
multipart.attack(new Damage(amount, box, null, playerSource, null).setExplosive());
multipart.attack(new Damage(amount * ConfigSystem.settings.damage.externalExplosionDamageFactor.value, null, null, playerSource, null).setExplosive());
break;
}
}
lastExplosionPosition = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,13 @@ public boolean hurt(DamageSource source, float amount) {
if (lastExplosionPosition != null && source.isExplosion()) {
//We encountered an explosion. These may or may not have have entities linked to them. Depends on if
//it's a player firing a gun that had a bullet, or a random TNT lighting in the world.
//Explosions, unlike other damage sources, can hit multiple collision boxes on an entity at once.
//Explosions can hit multiple boxes at once. Apply damage once to the core entity to prevent
//parts from forwarding duplicate explosive damage back into the same vehicle.
BoundingBox explosiveBounds = new BoundingBox(lastExplosionPosition, amount, amount, amount);
for (BoundingBox box : interactAttackBoxes.getBoxes()) {
if (box.intersects(explosiveBounds)) {
multipart.attack(new Damage(amount, box, null, playerSource, null).setExplosive());
multipart.attack(new Damage(amount * ConfigSystem.settings.damage.externalExplosionDamageFactor.value, null, null, playerSource, null).setExplosive());
break;
}
}
lastExplosionPosition = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,13 @@ public boolean hurt(DamageSource source, float amount) {
if (lastExplosionPosition != null && source.isExplosion()) {
//We encountered an explosion. These may or may not have have entities linked to them. Depends on if
//it's a player firing a gun that had a bullet, or a random TNT lighting in the world.
//Explosions, unlike other damage sources, can hit multiple collision boxes on an entity at once.
//Explosions can hit multiple boxes at once. Apply damage once to the core entity to prevent
//parts from forwarding duplicate explosive damage back into the same vehicle.
BoundingBox explosiveBounds = new BoundingBox(lastExplosionPosition, amount, amount, amount);
for (BoundingBox box : interactAttackBoxes.getBoxes()) {
if (box.intersects(explosiveBounds)) {
multipart.attack(new Damage(amount, box, null, playerSource, null).setExplosive());
multipart.attack(new Damage(amount * ConfigSystem.settings.damage.externalExplosionDamageFactor.value, null, null, playerSource, null).setExplosive());
break;
}
}
lastExplosionPosition = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,13 @@ public boolean hurt(DamageSource source, float amount) {
if (lastExplosionPosition != null && source.isExplosion()) {
//We encountered an explosion. These may or may not have have entities linked to them. Depends on if
//it's a player firing a gun that had a bullet, or a random TNT lighting in the world.
//Explosions, unlike other damage sources, can hit multiple collision boxes on an entity at once.
//Explosions can hit multiple boxes at once. Apply damage once to the core entity to prevent
//parts from forwarding duplicate explosive damage back into the same vehicle.
BoundingBox explosiveBounds = new BoundingBox(lastExplosionPosition, amount, amount, amount);
for (BoundingBox box : interactAttackBoxes.getBoxes()) {
if (box.intersects(explosiveBounds)) {
multipart.attack(new Damage(amount, box, null, playerSource, null).setExplosive());
multipart.attack(new Damage(amount * ConfigSystem.settings.damage.externalExplosionDamageFactor.value, null, null, playerSource, null).setExplosive());
break;
}
}
lastExplosionPosition = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,13 @@ public boolean hurt(DamageSource source, float amount) {
if (lastExplosionPosition != null && source.is(DamageTypeTags.IS_EXPLOSION)) {
//We encountered an explosion. These may or may not have have entities linked to them. Depends on if
//it's a player firing a gun that had a bullet, or a random TNT lighting in the world.
//Explosions, unlike other damage sources, can hit multiple collision boxes on an entity at once.
//Explosions can hit multiple boxes at once. Apply damage once to the core entity to prevent
//parts from forwarding duplicate explosive damage back into the same vehicle.
BoundingBox explosiveBounds = new BoundingBox(lastExplosionPosition, amount, amount, amount);
for (BoundingBox box : interactAttackBoxes.getBoxes()) {
if (box.intersects(explosiveBounds)) {
multipart.attack(new Damage(amount, box, null, playerSource, null).setExplosive());
multipart.attack(new Damage(amount * ConfigSystem.settings.damage.externalExplosionDamageFactor.value, null, null, playerSource, null).setExplosive());
break;
}
}
lastExplosionPosition = null;
Expand Down