If you uninstall the hullmod granting extra logistics slot, resulting in too-many-logistics-mods, the topmost (IE, the first-added) Logistics hullmod is automatically kicked off the ship. (I guess it got voted off by the others.)
Ah, ok, cool! Fixed up the number-of-logistics mod display in the tooltip, btw.
What confuses me now is this is your method signature:
public void applyEffectsBeforeShipCreation(ShipAPI ship, MutableShipStatsAPI stats, String id)
But that's not actually a method in HullModEffect. The methods there are:
void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id);
void applyEffectsAfterShipCreation(ShipAPI ship, String id);
So your code as is seems like it wouldn't work at all, i.e. that method would just never get called. But it'd still compile, because the base class has (empty) implementations of the two actual methods that get called. Am I missing something? That fact that this is working for you kinda makes me wonder if what you posted and what you're actually running are the same thing...
Ack! I skipped a step in my edit, yes. >_< That had been confusing the hell out of me. This is what I've currently got going:
package data.hullmods;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.impl.hullmods.BaseLogisticsHullMod; // Let me see if this fixes it...
import com.fs.starfarer.api.impl.campaign.ids.Stats; //Needed this to grab MAX_LOGISTICS_HULLMODS_MOD
import com.fs.starfarer.api.combat.ShipAPI; // Needed for vanilla incompatibility catch - I think.
// import data.scripts.util.MagicIncompatibleHullmods; //Needed for handling incompatibilities with hullmods not in my mod.
import com.fs.starfarer.api.Global; // Needed to grab the alert sound to play.
public class sd_AHM_LogisticSlot extends BaseHullMod {
private static final int LOGISTICS_HULLMOD_SLOTS_BONUS = 1;
public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getDynamic().getMod(Stats.MAX_LOGISTICS_HULLMODS_MOD).modifyFlat(id, LOGISTICS_HULLMOD_SLOTS_BONUS);
}
public String getDescriptionParam(int index, HullSize hullsize) {
if (index == 0) return "" + LOGISTICS_HULLMOD_SLOTS_BONUS;
return null;
}
}
And here, it is working as-expected:
At maximum hullmods it won't let me add more, by giving me the tooltip (in this case, I had set the maximum Logistics hullmods to 3 in settings previously).
Adding the Logistics Slot increaser allows me to add another Logistics hullmod again...
Having done so, it now correctly prohibits me from adding
another logistics hullmod, though the tooltip does not accurately reflect that my new Logistics hullmod cap is 4 rather than three.
Lastly, removing the Logistics Slot Increaser does
not give me back its OP and let me keep a freebie logistics mod; it kicks the topmost logistic mod off the ship.
Now I just need to troubleshoot why, if I'm at the logistics mod cap, my clone-alternates of Augmented Drive Field are still showing as permissible in the shipyard UI, and, if taken, will kick off the topmost Logistics hullmod.
They both have the Logistics tag in the hull_mods.csv and they both extend BaseLogisticsHullMod...