diff --git a/Movecraft/src/main/java/net/countercraft/movecraft/async/translation/TranslationTask.java b/Movecraft/src/main/java/net/countercraft/movecraft/async/translation/TranslationTask.java index 3e0aabef5..2de1ee195 100644 --- a/Movecraft/src/main/java/net/countercraft/movecraft/async/translation/TranslationTask.java +++ b/Movecraft/src/main/java/net/countercraft/movecraft/async/translation/TranslationTask.java @@ -368,15 +368,17 @@ else if (world.equals(craft.getWorld()) //Prevents CollisionExplosion crafts from exploding inside the craft. break; } - float explosionForce = craft.getType().getFloatProperty(CraftType.COLLISION_EXPLOSION); + float explosionForce; + if (location.getY() < craft.getWaterLine()) { + explosionForce = craft.getType().getFloatProperty(CraftType.UNDERWATER_COLLISION_EXPLOSION); + } + else { + explosionForce = craft.getType().getFloatProperty(CraftType.COLLISION_EXPLOSION); + } boolean incendiary = craft.getType().getBoolProperty(CraftType.INCENDIARY_ON_CRASH); if (craft.getType().getBoolProperty(CraftType.FOCUSED_EXPLOSION)) { explosionForce *= Math.min(oldHitBox.size(), craft.getType().getIntProperty(CraftType.MAX_SIZE)); } - //TODO: Account for underwater explosions - /*if (location.getY() < waterLine) { // underwater explosions require more force to do anything - explosionForce += 25;//TODO: find the correct amount - }*/ Location oldLocation = location.translate(-dx, -dy, -dz).toBukkit(craft.getWorld()); Location newLocation = location.toBukkit(world); if (!oldLocation.getBlock().getType().isAir()) { diff --git a/api/src/main/java/net/countercraft/movecraft/craft/type/CraftType.java b/api/src/main/java/net/countercraft/movecraft/craft/type/CraftType.java index 02644e8fd..98570e8e8 100644 --- a/api/src/main/java/net/countercraft/movecraft/craft/type/CraftType.java +++ b/api/src/main/java/net/countercraft/movecraft/craft/type/CraftType.java @@ -129,6 +129,7 @@ final public class CraftType { public static final NamespacedKey EXPLODE_ON_CRASH = buildKey("explode_on_crash"); public static final NamespacedKey INCENDIARY_ON_CRASH = buildKey("incendiary_on_crash"); public static final NamespacedKey COLLISION_EXPLOSION = buildKey("collision_explosion"); + public static final NamespacedKey UNDERWATER_COLLISION_EXPLOSION = buildKey("underwater_collision_explosion"); private static final NamespacedKey MIN_HEIGHT_LIMIT = buildKey("min_height_limit"); // Private key used as default for PER_WORLD_MIN_HEIGHT_LIMIT public static final NamespacedKey PER_WORLD_MIN_HEIGHT_LIMIT = buildKey("per_world_min_height_limit"); @@ -454,6 +455,7 @@ public static void registerTypeValidator(Predicate validator, String registerProperty(new FloatProperty("explodeOnCrash", EXPLODE_ON_CRASH, type -> 0F)); registerProperty(new BooleanProperty("incendiaryOnCrash", INCENDIARY_ON_CRASH, type -> false)); registerProperty(new FloatProperty("collisionExplosion", COLLISION_EXPLOSION, type -> 0F)); + registerProperty(new FloatProperty("underwaterCollisionExplosion", UNDERWATER_COLLISION_EXPLOSION, type -> type.getFloatProperty(COLLISION_EXPLOSION))); registerProperty(new IntegerProperty("minHeightLimit", MIN_HEIGHT_LIMIT, type -> Integer.MIN_VALUE)); registerProperty(new PerWorldProperty<>("perWorldMinHeightLimit", PER_WORLD_MIN_HEIGHT_LIMIT, (type, worldName) -> type.getIntProperty(MIN_HEIGHT_LIMIT)));