diff --git a/src/main/java/net/tfminecraft/vehicleframework/weapons/Weapon.java b/src/main/java/net/tfminecraft/vehicleframework/weapons/Weapon.java index a9e2422..1305d19 100644 --- a/src/main/java/net/tfminecraft/vehicleframework/weapons/Weapon.java +++ b/src/main/java/net/tfminecraft/vehicleframework/weapons/Weapon.java @@ -92,6 +92,8 @@ public Weapon(String key, ConfigurationSection config) { projectileClusterAmount = config.getInt("projectile-cluster-amount"); } damageData = new DamageData((List) config.getList("damage", new ArrayList())); + // Landing must not wreck guns; components already get FALL 0 from armour templates. + damageData.getModifiers().putIfAbsent("FALL", 0.0); if(config.isConfigurationSection("animations")) { animationHandler = new AnimationHandler(config.getConfigurationSection("animations")); } else { diff --git a/src/test/java/net/tfminecraft/vehicleframework/weapons/WeaponsCoverageTest.java b/src/test/java/net/tfminecraft/vehicleframework/weapons/WeaponsCoverageTest.java index 355f791..9f046bb 100644 --- a/src/test/java/net/tfminecraft/vehicleframework/weapons/WeaponsCoverageTest.java +++ b/src/test/java/net/tfminecraft/vehicleframework/weapons/WeaponsCoverageTest.java @@ -252,6 +252,18 @@ void configurationAndActiveCopiesPreserveAllWeaponFields() throws Exception { assertFalse(active.isControlled()); } + @Test + void fallDamageSparesWeaponsUnlessConfigured() throws Exception { + Weapon stored = new Weapon("aa", new YamlConfiguration()); + ActiveWeapon active = new ActiveWeapon(model, vehicle, stored, null); + active.damage("FALL", 40); + active.damage("PROJECTILE", 10); + assertEquals(10, active.getHealthData().getDamage()); + + Weapon fragile = new Weapon("fragile", Rig.yaml("damage: [fall(0.5)]\n")); + assertEquals(0.5, fragile.getDamageData().getModifier("FALL")); + } + @Test void defaultsAndFallbacksSupportEveryProjectileType() throws Exception { Weapon stored = new Weapon("default", new YamlConfiguration());