本文整理匯總了Java中net.minecraftforge.fml.common.ModContainer.getModId方法的典型用法代碼示例。如果您正苦於以下問題:Java ModContainer.getModId方法的具體用法?Java ModContainer.getModId怎麽用?Java ModContainer.getModId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraftforge.fml.common.ModContainer
的用法示例。
在下文中一共展示了ModContainer.getModId方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: IGWSupportNotifier
import net.minecraftforge.fml.common.ModContainer; //導入方法依賴的package包/類
/**
* Needs to be instantiated somewhere in your mod's loading stage.
*/
public IGWSupportNotifier() {
if (FMLCommonHandler.instance().getSide() == Side.CLIENT && !Loader.isModLoaded("IGWMod")) {
File dir = new File(".", "config");
Configuration config = new Configuration(new File(dir, "IGWMod.cfg"));
config.load();
if (config.get(Configuration.CATEGORY_GENERAL, "enable_missing_notification", true, "When enabled, this will notify players when IGW-Mod is not installed even though mods add support.").getBoolean()) {
ModContainer mc = Loader.instance().activeModContainer();
String modid = mc.getModId();
List<ModContainer> loadedMods = Loader.instance().getActiveModList();
for (ModContainer container : loadedMods) {
if (container.getModId().equals(modid)) {
supportingMod = container.getName();
MinecraftForge.EVENT_BUS.register(this);
ClientCommandHandler.instance.registerCommand(new CommandDownloadIGW());
break;
}
}
}
config.save();
}
}
示例2: requestPlayerTicket
import net.minecraftforge.fml.common.ModContainer; //導入方法依賴的package包/類
public static Ticket requestPlayerTicket(Object mod, String player, World world, Type type)
{
ModContainer mc = getContainer(mod);
if (mc == null)
{
FMLLog.log(Level.ERROR, "Failed to locate the container for mod instance %s (%s : %x)", mod, mod.getClass().getName(), System.identityHashCode(mod));
return null;
}
if (playerTickets.get(player).size()>playerTicketLength)
{
FMLLog.warning("Unable to assign further chunkloading tickets to player %s (on behalf of mod %s)", player, mc.getModId());
return null;
}
Ticket ticket = new Ticket(mc.getModId(),type,world,player);
playerTickets.put(player, ticket);
tickets.get(world).put("Forge", ticket);
return ticket;
}
示例3: registerRitual
import net.minecraftforge.fml.common.ModContainer; //導入方法依賴的package包/類
public static void registerRitual(IRitual ritual, String name) {
if(Strings.isNullOrEmpty(name)) {
throw new IllegalArgumentException("Attempted to register a ritual with no name: " + ritual);
}
if(ritual == null) {
throw new NullPointerException("The ritual cannot be null");
}
ModContainer mod = Loader.instance().activeModContainer();
if(mod == null) {
name = "minecraft:" + name;
} else {
name = mod.getModId() + ":" + name;
}
HashBiMap<String, IRitualRecipe> recipes = HashBiMap.create();
NAMED_RITUALS.put(name, ritual);
RITUALS_RECIPES.put(ritual, recipes);
}
示例4: getRitual
import net.minecraftforge.fml.common.ModContainer; //導入方法依賴的package包/類
public static IRitual getRitual(String ritual) {
if(Strings.isNullOrEmpty(ritual)) {
throw new IllegalArgumentException("Attempted to find a ritual with no name: " + ritual);
}
if(ritual.indexOf(":") == -1) {
ModContainer mod = Loader.instance().activeModContainer();
if(mod == null) {
ritual = "minecraft:" + ritual;
} else {
ritual = mod.getModId() + ":" + ritual;
}
}
return NAMED_RITUALS.get(ritual);
}
示例5: channelName
import net.minecraftforge.fml.common.ModContainer; //導入方法依賴的package包/類
public static String channelName(Object channelKey) {
if (channelKey instanceof String) {
return (String) channelKey;
}
if (channelKey instanceof ModContainer) {
String s = ((ModContainer) channelKey).getModId();
if (s.length() > 20) {
throw new IllegalArgumentException("Mod ID (" + s + ") too long for use as channel (20 chars). Use a string identifier");
}
return s;
}
ModContainer mc = FMLCommonHandler.instance().findContainerFor(channelKey);
if (mc != null) {
return mc.getModId();
}
throw new IllegalArgumentException("Invalid channel: " + channelKey);
}
示例6: IGWSupportNotifier
import net.minecraftforge.fml.common.ModContainer; //導入方法依賴的package包/類
/**
* Needs to be instantiated somewhere in your mod's loading stage.
*/
public IGWSupportNotifier(){
if(FMLCommonHandler.instance().getSide() == Side.CLIENT && !Loader.isModLoaded("IGWMod")) {
File dir = new File(".", "config");
Configuration config = new Configuration(new File(dir, "IGWMod.cfg"));
config.load();
if(config.get(Configuration.CATEGORY_GENERAL, "enable_missing_notification", true, "When enabled, this will notify players when IGW-Mod is not installed even though mods add support.").getBoolean()) {
ModContainer mc = Loader.instance().activeModContainer();
String modid = mc.getModId();
List<ModContainer> loadedMods = Loader.instance().getActiveModList();
for(ModContainer container : loadedMods) {
if(container.getModId().equals(modid)) {
supportingMod = container.getName();
MinecraftForge.EVENT_BUS.register(this);
ClientCommandHandler.instance.registerCommand(new CommandDownloadIGW());
break;
}
}
}
config.save();
}
}
示例7: getCurrentMod
import net.minecraftforge.fml.common.ModContainer; //導入方法依賴的package包/類
protected static String getCurrentMod() {
ModContainer container = Loader.instance().activeModContainer();
if (container == null) {
throw new IllegalStateException("Objects MUST be created inside a mod");
}
return container.getModId();
}
示例8: createHelper
import net.minecraftforge.fml.common.ModContainer; //導入方法依賴的package包/類
private static ContentHelper createHelper(CS4Mod mod)
{
ModContainer container = FMLCommonHandler.instance().findContainerFor(mod);
File modDirectory = container.getSource();
return new ContentHelperImpl(container.getModId(), modDirectory);
}
示例9: applyModContainer
import net.minecraftforge.fml.common.ModContainer; //導入方法依賴的package包/類
@Override
public void applyModContainer(ModContainer activeContainer)
{
this.modContainer = activeContainer;
this.modMetadata = activeContainer.getMetadata();
this.sourceFile = activeContainer.getSource();
this.suggestedConfigFile = new File(configurationDir, activeContainer.getModId()+".cfg");
}
示例10: ticketCountAvailableFor
import net.minecraftforge.fml.common.ModContainer; //導入方法依賴的package包/類
/**
* Discover the available tickets for the mod in the world
*
* @param mod The mod that will own the tickets
* @param world The world
* @return The count of tickets left for the mod in the supplied world
*/
public static int ticketCountAvailableFor(Object mod, World world)
{
ModContainer container = getContainer(mod);
if (container!=null)
{
String modId = container.getModId();
int allowedCount = getMaxTicketLengthFor(modId);
return allowedCount - tickets.get(world).get(modId).size();
}
else
{
return 0;
}
}
示例11: requestTicket
import net.minecraftforge.fml.common.ModContainer; //導入方法依賴的package包/類
/**
* Request a chunkloading ticket of the appropriate type for the supplied mod
*
* @param mod The mod requesting a ticket
* @param world The world in which it is requesting the ticket
* @param type The type of ticket
* @return A ticket with which to register chunks for loading, or null if no further tickets are available
*/
public static Ticket requestTicket(Object mod, World world, Type type)
{
ModContainer container = getContainer(mod);
if (container == null)
{
FMLLog.log(Level.ERROR, "Failed to locate the container for mod instance %s (%s : %x)", mod, mod.getClass().getName(), System.identityHashCode(mod));
return null;
}
String modId = container.getModId();
if (!callbacks.containsKey(modId))
{
FMLLog.severe("The mod %s has attempted to request a ticket without a listener in place", modId);
throw new RuntimeException("Invalid ticket request");
}
int allowedCount = getMaxTicketLengthFor(modId);
if (tickets.get(world).get(modId).size() >= allowedCount)
{
if (!warnedMods.contains(modId))
{
FMLLog.info("The mod %s has attempted to allocate a chunkloading ticket beyond it's currently allocated maximum : %d", modId, allowedCount);
warnedMods.add(modId);
}
return null;
}
Ticket ticket = new Ticket(modId, type, world);
tickets.get(world).put(modId, ticket);
return ticket;
}
示例12: getNameForRecipe
import net.minecraftforge.fml.common.ModContainer; //導入方法依賴的package包/類
/**
* Genereates a unique name based of the active mod, and the itemstack that the recipe outputs
*
* @param output an itemstack, usualy the one the the recipe produces
* @return a unique ResourceLocation based off the item item
*/
public static ResourceLocation getNameForRecipe(ItemStack output) {
ModContainer activeContainer = Loader.instance().activeModContainer();
ResourceLocation baseLoc = new ResourceLocation(activeContainer.getModId(), output.getItem().getRegistryName().getResourcePath());
ResourceLocation recipeLoc = baseLoc;
int index = 0;
while (CraftingManager.REGISTRY.containsKey(recipeLoc)) {
index++;
recipeLoc = new ResourceLocation(activeContainer.getModId(), baseLoc.getResourcePath() + "_" + index);
}
return recipeLoc;
}
示例13: addToReportList
import net.minecraftforge.fml.common.ModContainer; //導入方法依賴的package包/類
static void addToReportList(MCSimpleAnalytics mcSimpleAnalytics) {
try (ACLock acl = lock.lockAC()) {
if (!initialized) {
initialized = true;
FMLCommonHandler.instance().bus().register(new ActivityReportTickEventHandler());
}
// check if an analytics object with the same keys and client status is already in the list
for (MCSimpleAnalytics analytics : analyticsList) {
if (analytics.gameKey().equals(mcSimpleAnalytics.gameKey())
&& analytics.secretKey().equals(mcSimpleAnalytics.secretKey())
&& (analytics.isClient == mcSimpleAnalytics.isClient)) {
String mod;
try {
ModContainer activeMod = Loader.instance().activeModContainer();
StringBuilder sb = new StringBuilder(activeMod.getModId());
sb.append(" -> ").append(activeMod.getName());
mod = sb.toString();
} catch (Exception e) {
mod = "Some mod";
}
System.err.println(mod + " tried to instantiate an MCSimpleAnalytics instance with a key pair that was already registered!"
+ " If you see this message, please report it to the mod developer!");
return;
}
}
// otherwise add to the list
analyticsList.add(mcSimpleAnalytics);
}
}
示例14: addToReportList
import net.minecraftforge.fml.common.ModContainer; //導入方法依賴的package包/類
static void addToReportList(MCSimpleAnalytics mcSimpleAnalytics) {
try (ACLock acl = lock.lockAC()) {
if (!initialized) {
initialized = true;
MinecraftForge.EVENT_BUS.register(new ActivityReportTickEventHandler());
}
// check if an analytics object with the same keys and client status is already in the list
for (MCSimpleAnalytics analytics : analyticsList) {
if (analytics.gameKey().equals(mcSimpleAnalytics.gameKey())
&& analytics.secretKey().equals(mcSimpleAnalytics.secretKey())
&& (analytics.isClient == mcSimpleAnalytics.isClient)) {
String mod;
try {
ModContainer activeMod = Loader.instance().activeModContainer();
StringBuilder sb = new StringBuilder(activeMod.getModId());
sb.append(" -> ").append(activeMod.getName());
mod = sb.toString();
} catch (Exception e) {
mod = "Some mod";
}
System.err.println(mod + " tried to instantiate an MCSimpleAnalytics instance with a key pair that was already registered!"
+ " If you see this message, please report it to the mod developer!");
return;
}
}
// otherwise add to the list
analyticsList.add(mcSimpleAnalytics);
}
}
示例15: addUpdateToList
import net.minecraftforge.fml.common.ModContainer; //導入方法依賴的package包/類
public static void addUpdateToList(ModContainer mod, VersionContainer.Version version)
{
Update update = new Update(mod.getModId());
update.displayName = mod.getName();
update.oldVersion = mod.getVersion();
update.newVersion = version.getModVersion();
if (version.getUpdateURL() != null && !version.getUpdateURL().isEmpty())
{
update.updateURL = version.getUpdateURL();
}
update.isDirectLink = version.isDirectLink();
if (!version.getChangeLog().isEmpty())
{
StringBuilder builder = new StringBuilder();
for (String changeLogLine : version.getChangeLog())
{
builder.append(changeLogLine).append("\n");
}
update.changeLog = builder.toString();
}
if (version.getNewFileName() != null && !version.getNewFileName().isEmpty())
{
update.newFileName = version.getNewFileName();
}
UpdateHandler.addUpdate(update);
}