-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModCompat.txt
147 lines (113 loc) · 5.77 KB
/
ModCompat.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
Mods that we added compatibility so far are:
- Mekanism (Planned)
- Create (Planned)
===================
RadzRatz also made a tiny guide of the steps he did to load these items without problem over NeoForge for version 1.21.1
===================
// This guide is for adding compatibility with other mods (like Applied Energistics 2, Mekanism, etc.)
// without importing or using their API directly.
//By using part of this code as an Example to do it
// Step 1: Start by making sure your `commonSetup` method in your main mod class
// includes the call to `checkOtherMods` from your `ModCompatibility` class:
private void commonSetup(final FMLCommonSetupEvent event) {
System.out.println("Common setup is running.");
// Call your ModCompatibility methods here to check for other mods
ModCompatibility.checkOtherModsAppliedEnergistics2();
ModCompatibility.checkOtherModsMekanism(); // Add as many mod checks as needed
}
// Step 2: Implementing `ModCompatibility` class
// In this class, you will create methods to check if the other mods are loaded,
// and based on that, load the real or dummy items for those mods.
public class ModCompatibility {
// Applied Energistics 2 compatibility
public static void checkOtherModsAppliedEnergistics2() {
if (ModList.get().isLoaded("ae2")) {
// If AE2 is loaded, register real items
registerRealItemAE2Items();
} else {
// If AE2 is not loaded, register dummy items
registerDummyItemAE2Items();
}
}
public static void registerRealItemAE2Items() {
System.out.println("AE2 is loaded. Adding Multipress item.");
// Call your real item from the ModItems class here
Moditems.MULTIPRESS.get();
}
public static void registerDummyItemAE2Items() {
System.out.println("AE2 is not loaded. Adding DummyPress item.");
// Call your dummy item from the ModItems class here
Moditems.DUMMYPRESS.get();
}
// Now, you can do the same for other mods like Mekanism.
// Example for Mekanism:
public static void checkOtherModsMekanism() {
if (ModList.get().isLoaded("mekanism")) {
registerRealItemMekanism();
} else {
registerDummyItemMekanism();
}
}
public static void registerRealItemMekanism() {
System.out.println("Mekanism is loaded. Adding Mekanism item.");
Moditems.MEKANISM_ITEM.get();
}
public static void registerDummyItemMekanism() {
System.out.println("Mekanism is not loaded. Adding Dummy Mekanism item.");
Moditems.DUMMY_MEKANISM_ITEM.get();
}
}
// Step 3: Creative Mode Tab Integration
// In the ModCreativeTabs class, you need to add your real or dummy items conditionally:
public class ModCreativeModeTabs {
public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TAB =
DeferredRegister.create(Registries.CREATIVE_MODE_TAB, EternalItems.MOD_ID);
public static final Supplier<CreativeModeTab> ETERNAL_ITEMS_TAB = CREATIVE_MODE_TAB.register("eternal_items_tab",
() -> CreativeModeTab.builder().icon(() -> new ItemStack(Moditems.RATZ_HEAD.get()))
.title(Component.translatable("creativetab.eternalitems.eternal_items"))
.displayItems((itemDisplayParameters, output) -> {
// Here, you add all the general items
output.accept(Moditems.ANTIMATTER_FUSE);
output.accept(Moditems.ANGELS_STRING);
// Call the method that adds AE2 items conditionally
addAE2ItemsToTab(output);
// If adding Mekanism compatibility, do the same:
addMekanismItemsToTab(output);
}).build());
// Function to add AE2 items to the tab if AE2 is loaded
private static void addAE2ItemsToTab(CreativeModeTab.Output output) {
if (ModList.get().isLoaded("ae2")) {
System.out.println("Adding Multipress to the tab.");
output.accept(new ItemStack(Moditems.MULTIPRESS.get()));
} else {
System.out.println("Adding DummyPress to the tab.");
output.accept(new ItemStack(Moditems.DUMMYPRESS.get()));
}
}
// Function to add Mekanism items conditionally
private static void addMekanismItemsToTab(CreativeModeTab.Output output) {
if (ModList.get().isLoaded("mekanism")) {
System.out.println("Adding Mekanism item to the tab.");
output.accept(new ItemStack(Moditems.MEKANISM_ITEM.get()));
} else {
System.out.println("Adding Dummy Mekanism item to the tab.");
output.accept(new ItemStack(Moditems.DUMMY_MEKANISM_ITEM.get()));
}
}
// Don't forget to register the creative mode tabs
public static void register(IEventBus eventBus) {
CREATIVE_MODE_TAB.register(eventBus);
}
}
========================
Resume
Step 1: Make sure to call your checkOtherMods methods inside the commonSetup method of your main mod class.
Step 2: Inside the ModCompatibility class, you create different methods for each mod you want to check compatibility with.
For each mod, register both the real and dummy items depending on whether the mod is loaded or not.
Step 3: In your ModCreativeModeTabs class, conditionally add your real or dummy items to the creative mode tab based on the
presence of the other mod (AE2, Mekanism, etc.).
Final Note: Ensure that every item (real or dummy) is correctly registered in your ModItems class so that the game can load them properly.
With this setup, you can add compatibility for as many mods as you like by simply expanding the ModCompatibility class and adding new conditions
in the creative tab!
========================
Note: In case something in here is wrong, make sure to notify RadzRatz about the errors or typos you found!