ModTweaker/src/main/java/modtweaker2/helpers/ForgeHelper.java

46 lines
1.4 KiB
Java
Raw Normal View History

package modtweaker2.helpers;
2015-01-11 20:59:45 +01:00
import net.minecraft.item.ItemStack;
2016-07-09 22:30:50 +02:00
import net.minecraft.util.text.translation.I18n;
2015-01-11 20:59:45 +01:00
import net.minecraftforge.common.ForgeHooks;
2016-02-27 13:21:27 +01:00
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
2015-01-11 20:59:45 +01:00
2016-07-09 22:30:50 +02:00
import java.util.List;
import java.util.Map;
import static modtweaker2.helpers.ReflectionHelper.*;
2015-01-11 20:59:45 +01:00
public class ForgeHelper {
2015-07-07 12:00:17 +02:00
@SuppressWarnings("rawtypes")
2015-01-11 20:59:45 +01:00
public static Map translate = null;
2015-07-07 12:00:17 +02:00
@SuppressWarnings("rawtypes")
2015-01-11 20:59:45 +01:00
public static List seeds = null;
static {
try {
seeds = getStaticObject(ForgeHooks.class, "seedList");
2016-07-09 22:30:50 +02:00
translate = getFinalObject(getStaticObject(I18n.class, "localizedName", "field_74839_a"), "languageList", "field_74816_c");
2016-02-27 13:21:27 +01:00
} catch (Exception e) {
}
2015-01-11 20:59:45 +01:00
}
2015-07-07 12:00:17 +02:00
private ForgeHelper() {
}
2015-01-11 20:59:45 +01:00
public static Object getSeedEntry(ItemStack stack, int weight) {
2016-02-27 13:21:27 +01:00
Object seedEntry = getInstance(getConstructor("net.minecraftforge.common.ForgeHooks$SeedEntry", ItemStack.class, int.class), stack, weight);
2015-07-07 12:00:17 +02:00
if (seedEntry == null) {
2015-01-11 20:59:45 +01:00
throw new NullPointerException("Failed to instantiate SeedEntry");
}
2015-07-07 12:00:17 +02:00
return seedEntry;
2015-01-11 20:59:45 +01:00
}
public static boolean isLangActive(String lang) {
2016-02-27 13:21:27 +01:00
return FMLCommonHandler.instance().getSide() == Side.SERVER ? null : FMLClientHandler.instance().getCurrentLanguage().equals(lang);
2015-01-11 20:59:45 +01:00
}
}