Adding Compatibility in Your Mod - RobertSkalko/Mine-and-Slash GitHub Wiki
To add support to your mod using the Mine and Slash API, simply create a new class and call the MineAndSlashAPI.
EX:
MineAndSlashAPI.addCompatibleItem("modid:theitem", new ConfigItem().setType(new Staff()));
The above example would add your item as a Staff type. You can see all the ConfigItem settings you can set HERE.
All the valid gear types can be found below:
Gear Types
-
Boots
-
Pants
-
Helmet
-
Chest
-
Ring
-
Sword
-
Necklace
-
Bracelet
-
Bow
-
Charm
-
Hammer
-
Staff
-
Axe
-
Shield
To add support to your mod using the Mine and Slash API, simply create a new class and call the MineAndSlashAPI.
EX:
MineAndSlashAPI.addCompatibleItem("modid:theitem", new ConfigItem().setType(Staff.INSTANCE));
The above example would add your item as a Staff type. You can see all the ConfigItem settings you can set HERE.
All the valid gear types can be found below:
Gear Types
-
LeatherChest
-
LeatherHelmet
-
LeatherPants
-
LeatherBoots
-
ClothChest
-
ClothHelmet
-
ClothPants
-
ClothBoots
-
PlateBoots
-
PlatePants
-
PlateHelmet
-
PlateChest
-
Shield
-
Torch
-
Ring
-
Necklace
-
Bracelet
-
Charm
-
Bow
-
Hammer
-
Staff
-
Axe
-
CrossBow
-
Wand
-
Sword
To add compatibility to you mod, you can do it one of two ways.
Via Command
To easily the needed jsons, you simply load up Mine and Slash along side your mod and run the command
/slash generate compatible_items yourmodid
this will create a set of jsons located in ~/config/Mine and Slash/generated/yourmodid
. Take the folder yourmodid and move it to your mods ~/scr/main/resources/data/
folder, first creating the following path like so mmorpg/compatible_items/
and putting them in the compatible_items folder. Your items now have built-in compatibility with Mine and Slash.
In Code
First thing you want to do is add something like this to your main class file.
EX:
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public static class GatherDataSubscriber {
@SubscribeEvent
public static void gatherData(GatherDataEvent event) {
DataGenerator gen = event.getGenerator();
if (event.includeServer()) {
gen.addProvider(new TheClassYouHaveYourItemList().getDataPackCreator(gen));
}
}
}
Then create the TheClassYouHaveYourItemList class you referenced above.
EX from AzureDooms WoW Weapons using the Mine and Slash generator system:
public class TheClassYouHaveYourItemList {
public static String ID = "compatible_items";
public TheClassYouHaveYourItemList() {
}
public SlashDataProvider getDataPackCreator(DataGenerator gen) {
return new CompatibleItemProvider(gen, getList(), ID);
}
public static List<CompatibleItem> getList() {
List<String> SWORDS = Stream.of("wowweapons:thunderfury", "wowweapons:armageddon", "wowweapons:frostmourne",
"wowweapons:ashbringer", "wowweapons:swordofathousandtruths").collect(Collectors.toList());
List<CompatibleItem> items = new ArrayList<>();
try {
for (String sword : SWORDS) {
OldConfigItem config = new OldConfigItem().setGenerationWeights(1000, 200, 0).setMaxRarity(5)
.setMinRarity(0).setSalvagable(true).setType(Sword.INSTANCE)
.setdropsAsLoot(Config.SERVER.USE_MINESLASHLOOTSYSTEM.get());
String id = sword;
CompatibleItem neww = config.convertToNewFormat();
neww.guid = id;
neww.item_id = id;
items.add(neww);
}
} catch (
Exception e) {
e.printStackTrace();
}
return items;
}
}
Now will want you run the runData config that is generated for IDE when first set up your Forge MDK. This will create a set of jsons located in ~/src/generated/resources/data/mmorpg/compatible_items/yourmodid
. Take the folder mmorpg and move it to your mods ~/scr/main/resources/data/
folder. Your items now have built-in compatibility with Mine and Slash.