BaseMod provides a number of hooks and a console.
Currently supported version: [EARLY_ACCESS_015]
(non beta)
- Java 8+
- ModTheSpire v2.2.1+ (https://github.com/kiooeht/ModTheSpire/releases)
- Java 8
- Maven
- CFR 124 (run this with Java 8, doesn't work well with 9)
- ModTheSpire (https://github.com/kiooeht/ModTheSpire)
- (If you haven't already)
mvn install
ModTheSpire Altenatively, modify pom.xml to point to a local copy of the JAR. - Copy
desktop-1.0.jar
from your Slay the Spire folder into../_lib
relative to the repo. - Decompile
desktop-1.0.jar
withjava -jar "cfr_0_124.jar" --comments false --showversion false --caseinsensitivefs true --outputdir "decompiled" --jarfilter com.megacrit.cardcrawl.* "desktop-1.0.jar"
- Run
_patch.bat
to automatically apply diffs - Run
mvn package
- Copy
target/BaseMod.jar
to your ModTheSpire mods directory. Maven will automatically do this after packaging if your mods directory is located at../_ModTheSpire/mods
relative to the repo.
Take a look at the wiki (https://github.com/daviscook477/BaseMod/wiki) to get started using BaseMod as either a console or a modding platform!
Default hotkey is `
, can be changed from BaseMod's settings screen.
deck add [id] {upgrades} {cardcount}
add card to deck (optional: integer # of upgrades) (optional: integer # of times you want to add this card) to add multiples of an unupgraded card use -1 as the upgrade amountdeck r [id]
remove card from deckdeck r all
remove all cards from deckdraw [num]
draw cardsenergy add [amount]
gain energyenergy inf
toggles infinite energyenergy r [amount]
lose energyfight [name]
enter combat with the specified encountergold add [amount]
gain goldgold r [amount]
lose goldhand add [id] {upgrades}
add card to hand with (optional: integer # of upgrades)hand r all
exhaust entire handhand r [id]
exhaust card from handinfo
toggle Settings.isInfokill all
kills all enemies in the current combatkill self
kills your characterpotion [pos] [id]
gain specified potion in specified slotrelic add [id]
generate relicrelic list
logs all relic poolsrelic r [id]
lose relicunlock always
always gain an unlock on death
BaseMod.subscribeTo...(this)
BaseMod.unsubscribeFrom...(this)
Implement the appropriate interface (ex. basemod.interfaces.PostInitializeSubscriber
)
All interfaces are in the package basemod.interfaces
(also receive is probably misspelled somewhere so sorry about that)
boolean receiveStartAct()
- After a new act is started.boolean receivePostCampfire()
- After a campfire action is performed. Returning false will allow another action to be performed.void receivePostDraw(AbstractCard)
- After a card is drawn.void receivePostExhaust(AbstractCard)
- After a card is exhausted.void receiveCardUse(AbstractCard)
- Directly after a card is used (can be used to add additional functionality to cards on use).void receivePostDungeonInitialize()
- After dungeon initialization completes.void receivePostEnergyRecharge()
- At the start of every player turn, after energy has recharged.void receivePostInitialize()
- One time only, at the end ofCardCrawlGame.initialize()
.boolean receivePreMonsterTurn(AbstractMonster)
- Before each monster takes its turn. Returning false will skip the monsters turn.void receiveRender(SpriteBatch)
- Under tips and the cursor, above everything else.void receivePostRender(SpriteBatch)
- Above everything.void receivePreStartGame()
- When starting a new game, before generating/loading the player.void receiveStartGame()
- When starting a new game or continuing, after generating/loading the player and before dungeon generation.void receivePreUpdate()
- Immediately after input is read.void receivePostUpdate()
- Immediately before input is disposed.boolean receivePostCreateStartingDeck(cardsToAdd)
- Immediately after the character's starting deck is created. Returning true will remove all the cards from the default starting deck. Add the cards you want to be in the starting deck tocardsToAdd
.boolean receievePostCreateStartingRelics(relicsToAdd)
- Immediately after the character's starting relics are created. Returning true will remove all the default relics from the player. Add the relics you want to be in the starting deck torelicsToAdd
.void receivePostCreateShopRelics(relics, sceenInstance)
- Immediately after the shop generates its relics. Modifyingrelics
will change the relics in the shop.screenInstance
is an instance of theShopScreen
.void receivePostCreateShopPotions(potions, screenInstance)
- Immediately after the shop generates its potions. Modifyingpotions
will change the potions in the shop.screenInstance
is an instance of theShopScreen
.void receiveEditCards
- When you should register any cards to add or remove withBaseMod.addCard
andBaseMod.removeCard
. Do NOT initialize any cards or register any cards to add or remove outside of this handler. Slay the Spire needs some things to be done in certain orders and this handler ensures that happens correctly. Note that removing any cards involved in game events is undefined behavior currently.void receiveEditRelics
- When you should register any relics to add or remove withBaseMod.addRelic
andBaseMod.removeRelic
. Do NOT initialize any relics or register any relics to add or remove outside of this handler. Slay the Spire needs some things to be done in certain orders and this handler ensures that happens correctly. Note that removing any relics involved in game events is undefined behavior currently.void receiveEditCharacters
- When you should register any characters to add or remove withBaseMod.addCharacter
andBaseMod.removeCharacter
. Do NOT initialize any characters or register any relics to add or remove outside of this handler. Slay the Spire needs some things to be done in certain orders and this handler ensures that happens correctly. Note that removing the default characters IS NOT supported at this time.void receiveSetUnlocks
- When you should register any custom unlocks. Note that removing any unlocks that exist in the base game won't work (it shouldn't crash but it won't do anything). Do NOT set up any custom unlocks outside of this handler. Slay The Spire needs some things to be done in certain orders and this handler ensures that happens correctly.
32x32 images that display under the title on the main menu. Clicking one opens that mods settings menu.
BaseMod.registerModBadge(Texture texture, String modName, String author, String description, ModPanel settingsPanel)
ModPanel.addButton(float x, float y, Consumer<ModButton> clickEvent)
ModPanel.addLabel(String text, float x, float y, Consumer<ModLabel> updateEvent)
- There is more here, but it is a big mess and is going to be cleaned up soon.
Example of setting up a basic mod badge with settings panel:
ModPanel settingsPanel = new ModPanel();
settingsPanel.addLabel("", 475.0f, 700.0f, (me) -> {
if (me.parent.waitingOnEvent) {
me.text = "Press key";
} else {
me.text = "Change console hotkey (" + Keys.toString(DevConsole.toggleKey) + ")";
}
});
settingsPanel.addButton(350.0f, 650.0f, (me) -> {
me.parent.waitingOnEvent = true;
oldInputProcessor = Gdx.input.getInputProcessor();
Gdx.input.setInputProcessor(new InputAdapter() {
@Override
public boolean keyUp(int keycode) {
DevConsole.toggleKey = keycode;
me.parent.waitingOnEvent = false;
Gdx.input.setInputProcessor(oldInputProcessor);
return true;
}
});
});
Texture badgeTexture = new Texture(Gdx.files.internal("img/BaseModBadge.png"));
registerModBadge(badgeTexture, MODNAME, AUTHOR, DESCRIPTION, settingsPanel);
Take a look at basemod.BaseModInit
to see the code used to create the ModBadge
for BaseMod.
CustomRelic(String id, Texture texture, AbstractRelic.RelicTier tier, AbstractRelic.LandingSound sfx)
BaseMod.addRelic(AbstractRelic relic, RelicType type)
(note:CustomRelic
extendsAbstractRelic
) andRelicType
indicates if this relic is shared between both characters orRED
only orGREEN
only.BaseMod.removeRelic(AbstractRelic relic, RelicType type)
removes a relic from the game (note: removing a relic used by an event is currently untested/undefined behavior)BaseMod.removeRelic(AbstractRelic relic)
removes a relic from the game without having to know itsRelicType
CustomCard(String id, String name, String img, int cost, String rawDescription, CardType type, CardColor color, CardRarity rarity, CardTarget target, int cardPool)
BaseMod.addCard(AbstractCard card)
(note:CustomCard
extendsAbstractCard
).BaseMod.removeCard(AbstractCard card)
removes a card from the game (note: removing a card used by an event is currently untested/undefined behavior)
The process for creating custom player characters is fairly involved but still not too complex. It is detailed below:
- To add a custom character there are two major steps. You need to register both a new color and a new character. Basically the Ironclad is RED, the Silent is GREEN, the unused content Crowbot is BLUE, etc... In making a custom character you would want to make a new color like maybe YELLOW or PURPLE or ORANGE.
- Since the base game represents colors using an enum we need to use ModTheSpire's enum patching feature. To do this create any class and add to it the following code:
@SpireEnum
public static AbstractCard.CardColor MY_NEW_COLOR;
- The base game also reprents players using an enum so we must do the same thing for the player enum. Use this code:
@SpireEnum
public static AbstractPlayer.PlayerClass MY_NEW_PLAYER_CHARACTER;
- To create a new color use
BaseMod.addColor
. This should be called in your mod'sinitialize
method. It does not need a special handler to work. The parameters are as follows:String color
(this should beMY_NEW_COLOR.toString()
),Color bgColor
(the background color for the card color),Color backColor
(the back color for the card color),Color frameColor
(the frame color for the card color),Color frameOutineColor
(the frame outline color for the card color),Color descBoxColor
(the description box color),Color trailVfxColor
(the trail vfx color),Color glowColor
(the glow color),String attackBg
(path to your attack bg texture for the card color, path starts relative to yourSlayTheSpire
folder),String skillBg
(path to your skill bg texture for the card color, path starts relative to yourSlayTheSpire
folder),String powerBg
(path to your power bg texture for the card color, path starts relative to yourSlayTheSpire
folder),String energyOrb
(path to your energy orb texture for the card color, path starts relative to yourSlayTheSpire
folder) - To create a new player character make a EditCharacterSubscriber and in the
receiveEditCharacters
method go ahead and callBaseMod.addCharacter
. The parameters are as follows:Class characterClass
(the actual java Class of your character, e.g.MyCharacterClass.class
),String titleString
(title string for the character),String classString
(class string for the character),String color
, (the color for this character; should beMy_New_Color.toString()
),String selectText
(select text for the character),String selectButton
(path to select button texture starting relative to theSlayTheSpire
folder),String portrait
(path to portrait texture starting relative to theSlayTheSpire
folder),String characterID
(this should beMY_NEW_PLAYER_CHARACTER.toString()
) - Now just be sure to add some cards for your custom character! When defining cards for your custom character rather than using
AbstractCard.CardColor.WHATEVER
go ahead and useMY_NEW_COLOR
instead. - Note that there are likely to be bugs with this feature since it is complex and new so use at your own risk and also please submit bug reports as issues on this repository.
- t-larson - Original author
- FlipskiZ -
hand
command, bug fixes - daviscook477 - Custom players, custom colors, custom cards, more API hooks, code cleanup, bugfixes