本文整理汇总了Java中net.minecraftforge.fml.common.LoaderState类的典型用法代码示例。如果您正苦于以下问题:Java LoaderState类的具体用法?Java LoaderState怎么用?Java LoaderState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LoaderState类属于net.minecraftforge.fml.common包,在下文中一共展示了LoaderState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import net.minecraftforge.fml.common.LoaderState; //导入依赖的package包/类
@Nonnull
@Override
public Fluid get() {
if (!Loader.instance().hasReachedState(LoaderState.INITIALIZATION)) {
return defaultValue;
}
if (defaultFluid == null) {
FluidRegistry.getFluid(defaultValueName);
}
if (value == null || valueGeneration != generation) {
if (serverConfig != null && serverConfig.containsKey(keyname)) {
value = FluidRegistry.getFluid((String) serverConfig.get(keyname));
} else {
value = FluidRegistry.getFluid(config.getString(keyname, section, defaultValueName, text));
if (!inInit && config.hasChanged()) {
config.save();
}
}
valueGeneration = generation;
}
return NullHelper.first(value, defaultFluid, defaultValue);
}
示例2: isIc2Available
import net.minecraftforge.fml.common.LoaderState; //导入依赖的package包/类
public static boolean isIc2Available() {
if (ic2Available != null) return ic2Available;
boolean loaded = Loader.isModLoaded("IC2");
if (Loader.instance().hasReachedState(LoaderState.CONSTRUCTING)) {
ic2Available = loaded;
}
return loaded;
}
示例3: registerRecipe
import net.minecraftforge.fml.common.LoaderState; //导入依赖的package包/类
@Load(LoaderState.INITIALIZATION)
public void registerRecipe(){
itemSet.forEach(item -> {
if (item.getItem() instanceof IRecipeProvider) {
// check is a provider
IRecipeProvider provider = (IRecipeProvider) item.getItem();
Arrays.stream(provider.createRecipes()).forEach(GameData::register_impl);
} else if (item.getItem() instanceof IRecipe){
// check if is a recipe
registerRecipe(item.getAnnotation().value(), (IRecipe) item.getItem());
}
});
}
示例4: enqueueStartupMessage
import net.minecraftforge.fml.common.LoaderState; //导入依赖的package包/类
private static boolean enqueueStartupMessage(String modTarget, IMCMessage message)
{
if (Loader.instance().activeModContainer() == null)
{
return false;
}
enqueueMessage(Loader.instance().activeModContainer(), modTarget, message);
return Loader.isModLoaded(modTarget) && !Loader.instance().hasReachedState(LoaderState.POSTINITIALIZATION);
}
示例5: enableUniversalBucket
import net.minecraftforge.fml.common.LoaderState; //导入依赖的package包/类
/**
* Enables the universal bucket in forge.
* Has to be called before pre-initialization.
* Actually just call it statically in your mod class.
*/
public static void enableUniversalBucket()
{
if (Loader.instance().hasReachedState(LoaderState.PREINITIALIZATION))
{
FMLLog.getLogger().log(Level.ERROR, "Trying to activate the universal filled bucket too late. Call it statically in your Mods class. Mod: {}", Loader.instance().activeModContainer().getName());
}
else
{
universalBucketEnabled = true;
}
}
示例6: setPermissionHandler
import net.minecraftforge.fml.common.LoaderState; //导入依赖的package包/类
/**
* <b>Only use this in PreInit state!</b>
*/
public static void setPermissionHandler(IPermissionHandler handler)
{
Preconditions.checkNotNull(handler, "Permission handler can't be null!");
Preconditions.checkState(Loader.instance().getLoaderState().ordinal() <= LoaderState.PREINITIALIZATION.ordinal(), "Can't register after IPermissionHandler PreInit!");
FMLLog.log(Level.WARN, "Replacing " + permissionHandler.getClass().getName() + " with " + handler.getClass().getName());
permissionHandler = handler;
}
示例7: registerNode
import net.minecraftforge.fml.common.LoaderState; //导入依赖的package包/类
/**
* <b>Only use this after PreInit state!</b>
*
* @param node Permission node, best if it's lowercase and contains '.' (e.g. <code>"modid.subgroup.permission_id"</code>)
* @param level Default permission level for this node. If not isn't registered, it's level is going to be 'NONE'
* @param desc Optional description of the node
*/
public static String registerNode(String node, DefaultPermissionLevel level, String desc)
{
Preconditions.checkNotNull(node, "Permission node can't be null!");
Preconditions.checkNotNull(level, "Permission level can't be null!");
Preconditions.checkNotNull(desc, "Permission description can't be null!");
Preconditions.checkArgument(!node.isEmpty(), "Permission node can't be empty!");
Preconditions.checkState(Loader.instance().getLoaderState().ordinal() > LoaderState.PREINITIALIZATION.ordinal(), "Can't register permission nodes before Init!");
permissionHandler.registerNode(node, level, desc);
return node;
}
示例8: construct
import net.minecraftforge.fml.common.LoaderState; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
public void construct(FMLConstructionEvent event) {
super.construct(event);
getLoaderManager().invoke(event, LoaderState.CONSTRUCTING, Side.CLIENT);
}
示例9: loadDrinkRecipes
import net.minecraftforge.fml.common.LoaderState; //导入依赖的package包/类
@Load(LoaderState.AVAILABLE)
public void loadDrinkRecipes() {
FruitEnumLoader fruitLoader = FoodCraftReloaded.getProxy().getLoaderManager().getLoader(FruitEnumLoader.class).get();
VegetableEnumLoader vegetableLoader = FoodCraftReloaded.getProxy().getLoaderManager().getLoader(VegetableEnumLoader.class).get();
for (FruitType fruitType : FruitType.values()) {
RecipeManager.getInstance().addRecipe(new DrinkRecipe(new ItemStack[]{new ItemStack(fruitLoader.getInstanceMap(ItemFruit.class).get(fruitType))}, new FluidStack(fruitLoader.getFluidJuiceEnumMap().get(fruitType), 1000)));
}
for (VegetableType vegetableType : VegetableType.values()) {
RecipeManager.getInstance().addRecipe(new DrinkRecipe(new ItemStack[]{new ItemStack(vegetableLoader.getInstanceMap(ItemVegetable.class).get(vegetableType))}, new FluidStack(vegetableLoader.getFluidJuiceEnumMap().get(vegetableType), 1000)));
}
// ForgeRegistries.RECIPES.register(new CakeRecipe().setRegistryName(FoodCraftReloaded.MODID, "cake_recipe"));
}
示例10: loadColors
import net.minecraftforge.fml.common.LoaderState; //导入依赖的package包/类
@Load(side = Side.CLIENT, value = LoaderState.POSTINITIALIZATION)
@SideOnly(Side.CLIENT)
public void loadColors() {
try {
Field field = ItemColors.class.getDeclaredField("itemColorMap");
field.setAccessible(true);
Map<IRegistryDelegate<Item>, IItemColor> itemColorMap = (Map<IRegistryDelegate<Item>, IItemColor>) field.get(Minecraft.getMinecraft().getItemColors());
cachedLiqueurs.forEach(liqueur -> itemColorMap.entrySet().stream().filter(entry -> entry.getKey().get().equals(liqueur)).forEach(entry -> Minecraft.getMinecraft().getItemColors().registerItemColorHandler(entry.getValue(), entry.getKey().get())));
} catch (Exception e) {
FoodCraftReloaded.getLogger().error("Cannot get custom mesh definitions", e);
}
}
示例11: tileCompat
import net.minecraftforge.fml.common.LoaderState; //导入依赖的package包/类
@SubscribeEvent
public static void tileCompat(AttachCapabilitiesEvent<TileEntity> ace) {
if (Loader.instance().hasReachedState(LoaderState.SERVER_ABOUT_TO_START)) {
final TileEntity te = ace.getObject();
if (te == null || blacklisted(te)) return;
ace.addCapability(COMPAT, new LazyEnergyCapProvider(te));
}
}
示例12: registerEntity
import net.minecraftforge.fml.common.LoaderState; //导入依赖的package包/类
/** Registers an entity as possible backpack carrier, meaning
* they'll get constructed with an IBackpack capability.
* Must be called in pre-initialization phase (or before). */
public static void registerEntity(String entityID, RenderOptions renderOptions) {
if (entityID == null) throw new NullPointerException("entityID must not be null");
if (getDefaultEntityEntry(entityID) != null)
throw new IllegalArgumentException("entityID '" + entityID + "' has already been registered");
if (Loader.instance().getLoaderState().compareTo(LoaderState.PREINITIALIZATION) > 0)
throw new IllegalStateException("Must be called during (or before) pre-initialization phase.");
_defaultEntities.add(new BackpackEntityEntry(entityID, renderOptions, new ArrayList<>(), true));
}
示例13: registerBackpack
import net.minecraftforge.fml.common.LoaderState; //导入依赖的package包/类
/** Registers a backpack to randomly spawn on the specified entity.
* Must be called after registerEntity, in pre-initialization phase (or before).
*
* @param entityID The entity to register to spawn with this backpack.
*
* @param entryID String uniquely identifying this entry for this entity.
* For example "wearblebackpacks:default".
* @param backpack Backpack item ID to spawn on the entity.
* For example "wearablebackpacks:backpack".
* @param chance Chance in 1 out of X. For example 100 = 1% and 1000 = 0.1%.
* @param lootTable Loot table for the backpack when spawned on this mob (if any).
* @param colorRange A range of colors to spawn the backpack with, or null if default.
**/
public static void registerBackpack(String entityID,
String entryID, String backpack, int chance,
String lootTable, ColorRange colorRange) {
if (entityID == null) throw new NullPointerException("entityID must not be null");
if (entryID == null) throw new NullPointerException("entryID must not be null");
BackpackEntityEntry entityEntry = getDefaultEntityEntry(entityID);
if (entityEntry == null) new IllegalStateException("entityID '" + entityID + "' has not been registered yet");
if (entityEntry._backpackEntries.stream().anyMatch(e -> e.id.equals(entryID)))
throw new IllegalArgumentException("entryID '" + entryID + "' has already been used for entityID '" + entityID + "'");
if (Loader.instance().getLoaderState().compareTo(LoaderState.PREINITIALIZATION) > 0)
throw new IllegalStateException("Must be called during (or before) pre-initialization phase.");
entityEntry._backpackEntries.add(new BackpackEntry(entryID, backpack, chance, lootTable, colorRange, true));
}
示例14: registerMessageHandler
import net.minecraftforge.fml.common.LoaderState; //导入依赖的package包/类
@Load(LoaderState.INITIALIZATION)
public static void registerMessageHandler(){
PanguCore.getNetwork().registerMessage(Handler.class, Context.class, Network.getNextID(), Side.SERVER);
}
示例15: preInit
import net.minecraftforge.fml.common.LoaderState; //导入依赖的package包/类
@Override
public void preInit(FMLPreInitializationEvent event) {
super.preInit(event);
Proxy.INSTANCE.invoke(event, LoaderState.PREINITIALIZATION, Side.CLIENT);
}