diff --git a/mccore/src/main/java/minecrafttransportsimulator/jsondefs/JSONConfigSettings.java b/mccore/src/main/java/minecrafttransportsimulator/jsondefs/JSONConfigSettings.java index 507eb65f0..139c2cafd 100644 --- a/mccore/src/main/java/minecrafttransportsimulator/jsondefs/JSONConfigSettings.java +++ b/mccore/src/main/java/minecrafttransportsimulator/jsondefs/JSONConfigSettings.java @@ -93,7 +93,8 @@ public static class ConfigDamage { public JSONConfigEntry wheelBreakage = new JSONConfigEntry<>(true, "Whether or not wheels can be broken (go flat)."); public JSONConfigEntry wheelDamageIgnoreVelocity = new JSONConfigEntry<>(false, "Whether or not velocity is ignored when calculating wheel damage."); public JSONConfigEntry 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 propellerDamageFactor = new JSONConfigEntry<>(1.0D, "Factor for damage caused by a propeller."); + public JSONConfigEntry externalExplosionDamageFactor = new JSONConfigEntry<>(1.0D, "Factor for damage from external explosions when allowExternalDamage is enabled."); + public JSONConfigEntry propellerDamageFactor = new JSONConfigEntry<>(3.0D, "Factor for damage caused by a propeller."); public JSONConfigEntry jetDamageFactor = new JSONConfigEntry<>(1.0D, "Factor for damage caused by a jet engine."); public JSONConfigEntry wheelDamageFactor = new JSONConfigEntry<>(1.0D, "Factor for damage caused by wheels on vehicles."); public JSONConfigEntry crashDamageFactor = new JSONConfigEntry<>(1.0D, "Factor for damage caused by crashes."); diff --git a/mcinterfaceforge1122/src/main/java/mcinterface1122/BuilderEntityExisting.java b/mcinterfaceforge1122/src/main/java/mcinterface1122/BuilderEntityExisting.java index 1dcef4274..3104de937 100644 --- a/mcinterfaceforge1122/src/main/java/mcinterface1122/BuilderEntityExisting.java +++ b/mcinterfaceforge1122/src/main/java/mcinterface1122/BuilderEntityExisting.java @@ -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; diff --git a/mcinterfaceforge1165/src/main/java/mcinterface1165/BuilderEntityExisting.java b/mcinterfaceforge1165/src/main/java/mcinterface1165/BuilderEntityExisting.java index 6897175f5..583f3171d 100644 --- a/mcinterfaceforge1165/src/main/java/mcinterface1165/BuilderEntityExisting.java +++ b/mcinterfaceforge1165/src/main/java/mcinterface1165/BuilderEntityExisting.java @@ -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; diff --git a/mcinterfaceforge1182/src/main/java/mcinterface1182/BuilderEntityExisting.java b/mcinterfaceforge1182/src/main/java/mcinterface1182/BuilderEntityExisting.java index 992018856..5c9decb98 100644 --- a/mcinterfaceforge1182/src/main/java/mcinterface1182/BuilderEntityExisting.java +++ b/mcinterfaceforge1182/src/main/java/mcinterface1182/BuilderEntityExisting.java @@ -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; diff --git a/mcinterfaceforge1192/src/main/java/mcinterface1192/BuilderEntityExisting.java b/mcinterfaceforge1192/src/main/java/mcinterface1192/BuilderEntityExisting.java index 3e75364a8..6260e740f 100644 --- a/mcinterfaceforge1192/src/main/java/mcinterface1192/BuilderEntityExisting.java +++ b/mcinterfaceforge1192/src/main/java/mcinterface1192/BuilderEntityExisting.java @@ -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; diff --git a/mcinterfaceforge1201/src/main/java/mcinterface1201/BuilderEntityExisting.java b/mcinterfaceforge1201/src/main/java/mcinterface1201/BuilderEntityExisting.java index 6ec54dfb2..7b2d285e0 100644 --- a/mcinterfaceforge1201/src/main/java/mcinterface1201/BuilderEntityExisting.java +++ b/mcinterfaceforge1201/src/main/java/mcinterface1201/BuilderEntityExisting.java @@ -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;