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 ed5112695..3e0aabef5 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 @@ -9,6 +9,7 @@ import net.countercraft.movecraft.craft.Craft; import net.countercraft.movecraft.craft.CraftManager; import net.countercraft.movecraft.craft.SinkingCraft; +import net.countercraft.movecraft.craft.SubCraft; import net.countercraft.movecraft.craft.type.CraftType; import net.countercraft.movecraft.events.CraftCollisionEvent; import net.countercraft.movecraft.events.CraftCollisionExplosionEvent; @@ -357,7 +358,16 @@ else if (world.equals(craft.getWorld()) } } else if ((craft.getType().getFloatProperty(CraftType.COLLISION_EXPLOSION) > 0F) && System.currentTimeMillis() - craft.getOrigPilotTime() > craft.getType().getIntProperty(CraftType.EXPLOSION_ARMING_TIME)) { + Craft parentCraft = null; + if (craft instanceof SubCraft) { + parentCraft = ((SubCraft) craft).getParent(); + } for (MovecraftLocation location : collisionBox) { + if (parentCraft != null && parentCraft.getHitBox().contains(location) + && !parentCraft.getType().getBoolProperty(CraftType.ALLOW_INTERNAL_COLLISION_EXPLOSION)) { + //Prevents CollisionExplosion crafts from exploding inside the craft. + break; + } float explosionForce = craft.getType().getFloatProperty(CraftType.COLLISION_EXPLOSION); boolean incendiary = craft.getType().getBoolProperty(CraftType.INCENDIARY_ON_CRASH); if (craft.getType().getBoolProperty(CraftType.FOCUSED_EXPLOSION)) { 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 53c08d139..02644e8fd 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 @@ -190,6 +190,8 @@ final public class CraftType { public static final NamespacedKey CRUISE_ON_PILOT_LIFETIME = buildKey("cruise_on_pilot_lifetime"); public static final NamespacedKey EXPLOSION_ARMING_TIME = buildKey("explosion_arming_time"); + + public static final NamespacedKey ALLOW_INTERNAL_COLLISION_EXPLOSION = buildKey("allow_internal_collision_explosion"); //endregion @Contract("_ -> new") @@ -566,6 +568,7 @@ else if (o instanceof Integer) registerProperty(new BooleanProperty("mergePistonExtensions", MERGE_PISTON_EXTENSIONS, type -> false)); registerProperty(new IntegerProperty("cruiseOnPilotLifetime", CRUISE_ON_PILOT_LIFETIME, type -> 15*20)); registerProperty(new IntegerProperty("explosionArmingTime", EXPLOSION_ARMING_TIME, type -> 1000)); + registerProperty(new BooleanProperty("allowInternalCollisionExplosion", ALLOW_INTERNAL_COLLISION_EXPLOSION, type -> false)); /* Craft type transforms */ // Convert speed to TICK_COOLDOWN