-
Notifications
You must be signed in to change notification settings - Fork 14
Description
say-the-spire/src/main/java/sayTheSpire/buffers/CardBuffer.java
Lines 49 to 53 in df4c3fa
| } else { | |
| this.noFurtherUpgrade = false; | |
| AbstractCard upgradedCard = card.makeStatEquivalentCopy(); | |
| upgradedCard.upgrade(); | |
| upgradedCard.isLocked = card.isLocked; |
calling makeStatEquivalentCopy here can occasionally crash the games when interacting with interacting with modal choice cards from other mods. BaseMod tries to autogenerate a makeCopy method for custom cards, but will throw a runtime exception if the card doesn't have a 0-argument constructor:
@Override
public AbstractCard makeCopy() {
try{
return this.getClass().newInstance();
}catch(InstantiationException | IllegalAccessException e) {
throw new RuntimeException("BaseMod failed to auto-generate makeCopy for card: " + cardID);
}
}I've seen a user report this on the StS discord.
While it's possible to fix these issues by adding a makeCopy method to the offending cards, like in this pr, that requires action to be taken by each offending mod, which isn't likely. It'd be better to add some error handling around the makeStatEquivalentCopy call to increase cross-mod compatibility.
I would make a pr myself, but I'm not quite sure what the behaviour should be in the case a runtime exception is caught.