本文整理了Java中net.minecraftforge.fml.common.Loader.instance()
方法的一些代码示例,展示了Loader.instance()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Loader.instance()
方法的具体详情如下:
包路径:net.minecraftforge.fml.common.Loader
类名称:Loader
方法名:instance
暂无
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
public InventoryTweaksModule()
{
try
{
this.api = (InvTweaksAPI) Class.forName( "invtweaks.forge.InvTweaksMod", true, Loader.instance().getModClassLoader() )
.getField( "instance" )
.get( null );
}
catch( Exception ex )
{
}
}
代码示例来源:origin: SlimeKnights/TinkersConstruct
public void preInit() {
if(!Loader.instance().isInState(LoaderState.PREINITIALIZATION)) {
TConstruct.log.error(
"Proxy.preInit has to be called during Pre-Initialisation.");
}
}
代码示例来源:origin: SlimeKnights/TinkersConstruct
public void init() {
if(!Loader.instance().isInState(LoaderState.INITIALIZATION)) {
TConstruct.log.error(
"Proxy.init has to be called during Initialisation.");
}
}
代码示例来源:origin: SlimeKnights/TinkersConstruct
public void postInit() {
if(!Loader.instance().isInState(LoaderState.POSTINITIALIZATION)) {
TConstruct.log.error(
"Proxy.postInit has to be called during Post-Initialisation.");
}
}
代码示例来源:origin: SlimeKnights/TinkersConstruct
public void registerModels() {
if(Loader.instance().hasReachedState(LoaderState.INITIALIZATION)) {
TConstruct.log.error(
"Proxy.registerModels has to be called during preInit. Otherwise the models wont be found on first load.");
}
}
代码示例来源:origin: SlimeKnights/TinkersConstruct
static void putMaterialTrace(String materialIdentifier) {
ModContainer activeMod = Loader.instance().activeModContainer();
materialRegisteredByMod.put(materialIdentifier, activeMod);
}
代码示例来源:origin: Vazkii/Botania
/**
* Registers a SubTileEntity, a new special flower. Look in the subtile package of the API.
* Call this during {@code RegistryEvent.Register<Block>}, and don't forget to register a model in BotaniaAPIClient.
*/
public static void registerSubTile(String key, Class<? extends SubTileEntity> subtileClass) {
subTiles.put(key, subtileClass);
subTileMods.put(key, Loader.instance().activeModContainer().getModId());
}
代码示例来源:origin: SlimeKnights/TinkersConstruct
protected TinkerCraftingEvent(ItemStack itemStack, EntityPlayer player, String message) {
this.itemStack = itemStack;
this.player = player;
message += "\n" + TextFormatting.ITALIC + "by " + Loader.instance().activeModContainer().getName();
this.message = message;
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
public AERecipeLoader()
{
this.mod = Loader.instance().getIndexedModList().get( AppEng.MOD_ID );
this.ctx = new JsonContext( AppEng.MOD_ID );
this.initFactories();
}
代码示例来源:origin: SlimeKnights/TinkersConstruct
public static void addTrait(ITrait trait) {
// Trait might already have been registered since modifiers and materials share traits
if(traits.containsKey(trait.getIdentifier())) {
return;
}
traits.put(trait.getIdentifier(), trait);
ModContainer activeMod = Loader.instance().activeModContainer();
putTraitTrace(trait.getIdentifier(), trait, activeMod);
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
public static boolean isModLoaded( final String modid )
{
try
{
// if this fails for some reason, try the other method.
return Loader.isModLoaded( modid );
}
catch( final Throwable ignored )
{
}
for( final ModContainer f : Loader.instance().getActiveModList() )
{
if( f.getModId().equals( modid ) )
{
return true;
}
}
return false;
}
代码示例来源:origin: SlimeKnights/TinkersConstruct
@Override
public void transform(BookData book, SectionData data) {
ContentListing listing = new ContentListing();
listing.title = book.translate(sectionName);
addPage(data, sectionName, "", listing);
// don't do stuff during preinit etc, we only want to fill it once everything is added
if(!Loader.instance().hasReachedState(LoaderState.POSTINITIALIZATION)) {
return;
}
MATERIAL_TYPES_ON_DISPLAY.forEach(type -> {
int pageIndex = data.pages.size();
generateContent(type, data);
if(pageIndex < data.pages.size()) {
listing.addEntry(getStatName(type), data.pages.get(pageIndex));
}
});
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
@Override
protected void renderHoveredToolTip( int mouseX, int mouseY )
{
final Slot slot = this.getSlot( mouseX, mouseY );
if( slot != null && slot instanceof IMEFluidSlot && slot.isEnabled() )
{
final IMEFluidSlot fluidSlot = (IMEFluidSlot) slot;
if( fluidSlot.getAEFluidStack() != null && fluidSlot.shouldRenderAsFluid() )
{
final IAEFluidStack fluidStack = fluidSlot.getAEFluidStack();
final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( fluidStack.getStackSize() / 1000.0 ) + " B";
final String modName = "" + TextFormatting.BLUE + TextFormatting.ITALIC + Loader.instance()
.getIndexedModList()
.get( Platform.getModId( fluidStack ) )
.getName();
final List<String> list = new ArrayList<>();
list.add( fluidStack.getFluidStack().getLocalizedName() );
list.add( formattedAmount );
list.add( modName );
this.drawHoveringText( list, mouseX, mouseY );
return;
}
}
super.renderHoveredToolTip( mouseX, mouseY );
}
代码示例来源:origin: SlimeKnights/TinkersConstruct
ModContainer activeMod = Loader.instance().activeModContainer();
putStatTrace(identifier, stats, activeMod);
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
final Loader loader = Loader.instance();
final List<ModContainer> mods = loader.getActiveModList();
代码示例来源:origin: sinkillerj/ProjectE
@Override
public void registerCustomEMC(@Nonnull Object o, long value)
{
Preconditions.checkNotNull(o);
boolean flag = Loader.instance().isInState(LoaderState.PREINITIALIZATION) || Loader.instance().isInState(LoaderState.INITIALIZATION) || Loader.instance().isInState(LoaderState.POSTINITIALIZATION);
Preconditions.checkState(flag, String.format("Mod %s tried to register EMC at an invalid time!", Loader.instance().activeModContainer().getModId()));
APICustomEMCMapper.instance.registerCustomEMC(o, value);
PECore.debugLog("Mod {} registered emc value {} for Object {}", Loader.instance().activeModContainer().getModId(), value, o);
}
代码示例来源:origin: sinkillerj/ProjectE
@Override
public void blacklistInterdiction(@Nonnull Class<? extends Entity> clazz)
{
Preconditions.checkNotNull(clazz);
Preconditions.checkState(Loader.instance().isInState(LoaderState.POSTINITIALIZATION), "Mod %s registering interdiction blacklist at incorrect time!", Loader.instance().activeModContainer().getModId());
doBlacklistInterdiction(clazz, Loader.instance().activeModContainer().getModId());
}
代码示例来源:origin: sinkillerj/ProjectE
@Override
public void blacklistSwiftwolf(@Nonnull Class<? extends Entity> clazz)
{
Preconditions.checkNotNull(clazz);
Preconditions.checkState(Loader.instance().isInState(LoaderState.POSTINITIALIZATION), "Mod %s registering SWRG repel at incorrect time!", Loader.instance().activeModContainer().getModId());
doBlacklistSwiftwolf(clazz, Loader.instance().activeModContainer().getModId());
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
final ModContainer imb = net.minecraftforge.fml.common.Loader.instance().getIndexedModList().get( "ImmibisCore" );
if( imb != null )
代码示例来源:origin: SleepyTrousers/EnderIO
@SubscribeEvent(priority = EventPriority.LOW)
public static void registerAddonBlocks(@Nonnull RegistryEvent.Register<Block> event) {
for (ModContainer modContainer : Loader.instance().getModList()) {
Object mod = modContainer.getMod();
if (mod instanceof IEnderIOAddon) {
((IEnderIOAddon) mod).injectBlocks(NullHelper.notnullF(event.getRegistry(), "RegistryEvent.Register<Block>.getRegistry()"));
}
}
}
内容来源于网络,如有侵权,请联系作者删除!