2016-10-20 02:56:31 +02:00
|
|
|
package binnie.core;
|
|
|
|
|
|
|
|
|
|
import cpw.mods.fml.common.Loader;
|
|
|
|
|
import cpw.mods.fml.common.registry.GameRegistry;
|
2017-04-23 04:31:40 +03:00
|
|
|
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
|
|
|
|
|
import cpw.mods.fml.common.versioning.Restriction;
|
|
|
|
|
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
|
|
|
|
2017-04-23 04:31:40 +03:00
|
|
|
public class Mods {
|
2016-10-20 02:56:31 +02:00
|
|
|
public static Mod Forestry;
|
|
|
|
|
public static Mod IC2;
|
|
|
|
|
public static Mod Botania;
|
|
|
|
|
private static boolean WARN;
|
|
|
|
|
|
2017-04-23 04:31:40 +03:00
|
|
|
private static Item findItem(String modId, String name) {
|
|
|
|
|
Item stack = GameRegistry.findItem(modId, name);
|
|
|
|
|
if (stack == null && Mods.WARN && modId.equals("Forestry")) {
|
2016-10-20 02:56:31 +02:00
|
|
|
throw new RuntimeException("Item not found: " + modId + ":" + name);
|
|
|
|
|
}
|
|
|
|
|
return stack;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-23 04:31:40 +03:00
|
|
|
private static ItemStack findItemStack(String modId, String name, int stackSize) {
|
|
|
|
|
ItemStack stack = GameRegistry.findItemStack(modId, name, stackSize);
|
|
|
|
|
if (stack == null && Mods.WARN && modId.equals("Forestry")) {
|
2016-10-20 02:56:31 +02:00
|
|
|
throw new RuntimeException("Stack not found: " + modId + ":" + name);
|
|
|
|
|
}
|
|
|
|
|
return stack;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-23 04:31:40 +03:00
|
|
|
private static Block findBlock(String modId, String name) {
|
|
|
|
|
Block stack = GameRegistry.findBlock(modId, name);
|
|
|
|
|
if (stack == null && Mods.WARN && modId.equals("Forestry")) {
|
2016-10-20 02:56:31 +02:00
|
|
|
throw new RuntimeException("Block not found: " + modId + ":" + name);
|
|
|
|
|
}
|
|
|
|
|
return stack;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static {
|
|
|
|
|
Mods.Forestry = new Mod("Forestry") {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean dev() {
|
2017-04-23 04:31:40 +03:00
|
|
|
String forVersion = Loader.instance().getIndexedModList().get("Forestry").getVersion();
|
|
|
|
|
Restriction rest = new Restriction(new DefaultArtifactVersion("3.6"), true, null, false);
|
2016-10-20 02:56:31 +02:00
|
|
|
return rest.containsVersion(new DefaultArtifactVersion(forVersion));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
Mods.IC2 = new Mod("IC2");
|
|
|
|
|
Mods.Botania = new Mod("Botania");
|
|
|
|
|
Mods.WARN = true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-23 04:31:40 +03:00
|
|
|
public static class Mod {
|
2016-10-20 02:56:31 +02:00
|
|
|
private String id;
|
|
|
|
|
|
2017-04-23 04:31:40 +03:00
|
|
|
private Mod(String id) {
|
2016-10-20 02:56:31 +02:00
|
|
|
this.id = id;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-23 04:31:40 +03:00
|
|
|
public Item item(String name) {
|
2016-10-20 02:56:31 +02:00
|
|
|
return findItem(this.id, name);
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-23 04:31:40 +03:00
|
|
|
public Block block(String name) {
|
2016-10-20 02:56:31 +02:00
|
|
|
return findBlock(this.id, name);
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-23 04:31:40 +03:00
|
|
|
public ItemStack stack(String name, int stackSize) {
|
2016-10-20 02:56:31 +02:00
|
|
|
return findItemStack(this.id, name, stackSize);
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-23 04:31:40 +03:00
|
|
|
public ItemStack stack(String name) {
|
2016-10-20 02:56:31 +02:00
|
|
|
return this.stack(name, 1);
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-23 04:31:40 +03:00
|
|
|
public ItemStack stack(String string, int i, int j) {
|
2016-10-20 02:56:31 +02:00
|
|
|
return new ItemStack(this.item(string), i, j);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean active() {
|
|
|
|
|
return Loader.isModLoaded(this.id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean dev() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|