2016-10-20 02:56:31 +02:00
|
|
|
package binnie.core;
|
|
|
|
|
|
2017-04-23 04:31:40 +03:00
|
|
|
import net.minecraft.block.Block;
|
2016-10-20 02:56:31 +02:00
|
|
|
import net.minecraft.item.Item;
|
2017-04-23 04:31:40 +03:00
|
|
|
import net.minecraft.item.ItemStack;
|
2016-10-20 02:56:31 +02:00
|
|
|
|
|
|
|
|
import cpw.mods.fml.common.Loader;
|
|
|
|
|
import cpw.mods.fml.common.registry.GameRegistry;
|
2023-01-28 19:14:12 -08:00
|
|
|
|
2017-04-23 04:31:40 +03:00
|
|
|
public class Mods {
|
2023-01-28 19:14:12 -08:00
|
|
|
|
2024-09-26 10:59:20 -04:00
|
|
|
public static final Mod forestry = new Mod("Forestry");
|
|
|
|
|
public static final Mod ic2 = new Mod("IC2");
|
|
|
|
|
public static final Mod botania = new Mod("Botania");
|
|
|
|
|
public static final Mod extraBiomes = new Mod("ExtrabiomesXL");
|
|
|
|
|
public static final Mod dreamcraft = new Mod("dreamcraft");
|
2024-09-25 03:31:38 -04:00
|
|
|
public static final Mod buildcraftCore = new Mod("BuildCraft|Core");
|
2016-10-20 02:56:31 +02:00
|
|
|
|
2022-07-03 12:17:51 +08:00
|
|
|
private static Item findItem(String modId, String name) {
|
|
|
|
|
Item stack = GameRegistry.findItem(modId, name);
|
2024-09-26 10:59:20 -04:00
|
|
|
if (stack == null && forestry.matchID(modId)) {
|
2022-07-03 12:17:51 +08:00
|
|
|
throw new RuntimeException("Item not found: " + modId + ":" + name);
|
|
|
|
|
}
|
|
|
|
|
return stack;
|
|
|
|
|
}
|
2016-10-20 02:56:31 +02:00
|
|
|
|
2022-07-03 12:17:51 +08:00
|
|
|
private static ItemStack findItemStack(String modId, String name, int stackSize) {
|
|
|
|
|
ItemStack stack = GameRegistry.findItemStack(modId, name, stackSize);
|
2024-09-26 10:59:20 -04:00
|
|
|
if (stack == null && forestry.matchID(modId)) {
|
2022-07-03 12:17:51 +08:00
|
|
|
throw new RuntimeException("Stack not found: " + modId + ":" + name);
|
|
|
|
|
}
|
|
|
|
|
return stack;
|
|
|
|
|
}
|
2016-10-20 02:56:31 +02:00
|
|
|
|
2022-07-03 12:17:51 +08:00
|
|
|
private static Block findBlock(String modId, String name) {
|
|
|
|
|
Block stack = GameRegistry.findBlock(modId, name);
|
2024-09-26 10:59:20 -04:00
|
|
|
if (stack == null && forestry.matchID(modId)) {
|
2022-07-03 12:17:51 +08:00
|
|
|
throw new RuntimeException("Block not found: " + modId + ":" + name);
|
|
|
|
|
}
|
|
|
|
|
return stack;
|
|
|
|
|
}
|
2016-10-20 02:56:31 +02:00
|
|
|
|
2022-07-03 12:17:51 +08:00
|
|
|
public static class Mod {
|
2023-01-28 19:14:12 -08:00
|
|
|
|
2024-09-26 10:59:20 -04:00
|
|
|
private final String modid;
|
|
|
|
|
private final boolean isLoaded;
|
2016-10-20 02:56:31 +02:00
|
|
|
|
2022-07-03 12:17:51 +08:00
|
|
|
private Mod(String id) {
|
2024-09-26 10:59:20 -04:00
|
|
|
modid = id;
|
|
|
|
|
isLoaded = Loader.isModLoaded(id);
|
2022-07-03 12:17:51 +08:00
|
|
|
}
|
2016-10-20 02:56:31 +02:00
|
|
|
|
2022-07-03 12:17:51 +08:00
|
|
|
public Item item(String name) {
|
2024-09-26 10:59:20 -04:00
|
|
|
return findItem(modid, name);
|
2022-07-03 12:17:51 +08:00
|
|
|
}
|
2016-10-20 02:56:31 +02:00
|
|
|
|
2022-07-03 12:17:51 +08:00
|
|
|
public Block block(String name) {
|
2024-09-26 10:59:20 -04:00
|
|
|
return findBlock(modid, name);
|
2022-07-03 12:17:51 +08:00
|
|
|
}
|
2016-10-20 02:56:31 +02:00
|
|
|
|
2022-07-03 12:17:51 +08:00
|
|
|
public ItemStack stack(String name, int stackSize) {
|
2024-09-26 10:59:20 -04:00
|
|
|
return findItemStack(modid, name, stackSize);
|
2022-07-03 12:17:51 +08:00
|
|
|
}
|
2016-10-20 02:56:31 +02:00
|
|
|
|
2022-07-03 12:17:51 +08:00
|
|
|
public ItemStack stack(String name) {
|
|
|
|
|
return stack(name, 1);
|
|
|
|
|
}
|
2016-10-20 02:56:31 +02:00
|
|
|
|
2022-07-03 12:17:51 +08:00
|
|
|
public ItemStack stack(String string, int i, int j) {
|
|
|
|
|
return new ItemStack(item(string), i, j);
|
|
|
|
|
}
|
2016-10-20 02:56:31 +02:00
|
|
|
|
2022-07-03 12:17:51 +08:00
|
|
|
public boolean active() {
|
2024-09-26 10:59:20 -04:00
|
|
|
return isLoaded;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean matchID(final String id) {
|
|
|
|
|
return modid.equals(id);
|
2022-07-03 12:17:51 +08:00
|
|
|
}
|
|
|
|
|
}
|
2016-10-20 02:56:31 +02:00
|
|
|
}
|