本文整理汇总了Java中cpw.mods.fml.common.ModContainer类的典型用法代码示例。如果您正苦于以下问题:Java ModContainer类的具体用法?Java ModContainer怎么用?Java ModContainer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ModContainer类属于cpw.mods.fml.common包,在下文中一共展示了ModContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRecipeName
import cpw.mods.fml.common.ModContainer; //导入依赖的package包/类
public String getRecipeName() {
if (this.displayItem == null) {
return "Documentation";
}
final String s = Item.itemRegistry.getNameForObject((Object)this.displayItem.getItem());
final String modid = s.split(":")[0];
if ("minecraft".equals(modid)) {
return "Minecraft";
}
final ModContainer selectedMod = Loader.instance().getIndexedModList().get(modid);
if (selectedMod == null) {
return modid;
}
if (!selectedMod.getMetadata().autogenerated) {
return selectedMod.getMetadata().name;
}
return selectedMod.getName();
}
示例2: channelName
import cpw.mods.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);
}
示例3: parseModItems
import cpw.mods.fml.common.ModContainer; //导入依赖的package包/类
private static void parseModItems() {
HashMap<String, ItemStackSet> modSubsets = new HashMap<String, ItemStackSet>();
for (Item item : (Iterable<Item>) Item.itemRegistry) {
UniqueIdentifier ident = GameRegistry.findUniqueIdentifierFor(item);
if(ident == null) {
NEIClientConfig.logger.error("Failed to find identifier for: "+item);
continue;
}
String modId = GameRegistry.findUniqueIdentifierFor(item).modId;
itemOwners.put(item, modId);
ItemStackSet itemset = modSubsets.get(modId);
if(itemset == null)
modSubsets.put(modId, itemset = new ItemStackSet());
itemset.with(item);
}
API.addSubset("Mod.Minecraft", modSubsets.remove("minecraft"));
for(Entry<String, ItemStackSet> entry : modSubsets.entrySet()) {
ModContainer mc = FMLCommonHandler.instance().findContainerFor(entry.getKey());
if(mc == null)
NEIClientConfig.logger.error("Missing container for "+entry.getKey());
else
API.addSubset("Mod."+mc.getName(), entry.getValue());
}
}
示例4: drawSlot
import cpw.mods.fml.common.ModContainer; //导入依赖的package包/类
@Override
protected void drawSlot(int listIndex, int var2, int var3, int var4, Tessellator var5)
{
ModContainer mc=mods.get(listIndex);
if (Loader.instance().getModState(mc)==ModState.DISABLED)
{
this.parent.getFontRenderer().func_78276_b(this.parent.getFontRenderer().func_78269_a(mc.getName(), listWidth - 10), this.left + 3 , var3 + 2, 0xFF2222);
this.parent.getFontRenderer().func_78276_b(this.parent.getFontRenderer().func_78269_a(mc.getDisplayVersion(), listWidth - 10), this.left + 3 , var3 + 12, 0xFF2222);
this.parent.getFontRenderer().func_78276_b(this.parent.getFontRenderer().func_78269_a("DISABLED", listWidth - 10), this.left + 3 , var3 + 22, 0xFF2222);
}
else
{
this.parent.getFontRenderer().func_78276_b(this.parent.getFontRenderer().func_78269_a(mc.getName(), listWidth - 10), this.left + 3 , var3 + 2, 0xFFFFFF);
this.parent.getFontRenderer().func_78276_b(this.parent.getFontRenderer().func_78269_a(mc.getDisplayVersion(), listWidth - 10), this.left + 3 , var3 + 12, 0xCCCCCC);
this.parent.getFontRenderer().func_78276_b(this.parent.getFontRenderer().func_78269_a(mc.getMetadata() !=null ? mc.getMetadata().getChildModCountString() : "Metadata not found", listWidth - 10), this.left + 3 , var3 + 22, 0xCCCCCC);
}
}
示例5: func_73863_a
import cpw.mods.fml.common.ModContainer; //导入依赖的package包/类
@Override
public void func_73863_a(int p_73863_1_, int p_73863_2_, float p_73863_3_)
{
this.func_146276_q_();
int offset = Math.max(85 - dupes.dupes.size() * 10, 10);
this.func_73732_a(this.field_146289_q, "Forge Mod Loader has found a problem with your minecraft installation", this.field_146294_l / 2, offset, 0xFFFFFF);
offset+=10;
this.func_73732_a(this.field_146289_q, "You have mod sources that are duplicate within your system", this.field_146294_l / 2, offset, 0xFFFFFF);
offset+=10;
this.func_73732_a(this.field_146289_q, "Mod Id : File name", this.field_146294_l / 2, offset, 0xFFFFFF);
offset+=5;
for (Entry<ModContainer, File> mc : dupes.dupes.entries())
{
offset+=10;
this.func_73732_a(this.field_146289_q, String.format("%s : %s", mc.getKey().getModId(), mc.getValue().getName()), this.field_146294_l / 2, offset, 0xEEEEEE);
}
}
示例6: func_73866_w_
import cpw.mods.fml.common.ModContainer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void func_73866_w_()
{
for (ModContainer mod : mods) {
listWidth=Math.max(listWidth,getFontRenderer().func_78256_a(mod.getName()) + 10);
listWidth=Math.max(listWidth,getFontRenderer().func_78256_a(mod.getVersion()) + 10);
}
listWidth=Math.min(listWidth, 150);
this.field_146292_n.add(new GuiButton(6, this.field_146294_l / 2 - 75, this.field_146295_m - 38, I18n.func_135052_a("gui.done")));
configModButton = new GuiButton(20, 10, this.field_146295_m - 60, this.listWidth, 20, "Config");
disableModButton = new GuiButton(21, 10, this.field_146295_m - 38, this.listWidth, 20, "Disable");
this.field_146292_n.add(configModButton);
this.field_146292_n.add(disableModButton);
this.modList=new GuiSlotModList(this, mods, listWidth);
this.modList.registerScrollButtons(this.field_146292_n, 7, 8);
}
示例7: func_73863_a
import cpw.mods.fml.common.ModContainer; //导入依赖的package包/类
@Override
public void func_73863_a(int p_73863_1_, int p_73863_2_, float p_73863_3_)
{
this.func_146276_q_();
int offset = Math.max(85 - (failedList.getVisitedNodes().size() + 3) * 10, 10);
this.func_73732_a(this.field_146289_q, "Forge Mod Loader has found a problem with your minecraft installation", this.field_146294_l / 2, offset, 0xFFFFFF);
offset+=10;
this.func_73732_a(this.field_146289_q, "A mod sorting cycle was detected and loading cannot continue", this.field_146294_l / 2, offset, 0xFFFFFF);
offset+=10;
this.func_73732_a(this.field_146289_q, String.format("The first mod in the cycle is %s", failedList.getFirstBadNode()), this.field_146294_l / 2, offset, 0xFFFFFF);
offset+=10;
this.func_73732_a(this.field_146289_q, "The remainder of the cycle involves these mods", this.field_146294_l / 2, offset, 0xFFFFFF);
offset+=5;
for (ModContainer mc : failedList.getVisitedNodes())
{
offset+=10;
this.func_73732_a(this.field_146289_q, String.format("%s : before: %s, after: %s", mc.toString(), mc.getDependants(), mc.getDependencies()), this.field_146294_l / 2, offset, 0xEEEEEE);
}
offset+=20;
this.func_73732_a(this.field_146289_q, "The file 'ForgeModLoader-client-0.log' contains more information", this.field_146294_l / 2, offset, 0xFFFFFF);
}
示例8: checkModList
import cpw.mods.fml.common.ModContainer; //导入依赖的package包/类
public static String checkModList(Map<String,String> listData, Side side)
{
List<ModContainer> rejects = Lists.newArrayList();
for (Entry<ModContainer, NetworkModHolder> networkMod : NetworkRegistry.INSTANCE.registry().entrySet())
{
boolean result = networkMod.getValue().check(listData, side);
if (!result)
{
rejects.add(networkMod.getKey());
}
}
if (rejects.isEmpty())
{
return null;
}
else
{
FMLLog.info("Rejecting connection %s: %s", side, rejects);
return String.format("Mod rejections %s",rejects);
}
}
示例9: newChannel
import cpw.mods.fml.common.ModContainer; //导入依赖的package包/类
/**
* INTERNAL Create a new channel pair with the specified name and channel handlers.
* This is used internally in forge and FML
*
* @param container The container to associate the channel with
* @param name The name for the channel
* @param handlers Some {@link ChannelHandler} for the channel
* @return an {@link EnumMap} of the pair of channels. keys are {@link Side}. There will always be two entries.
*/
public EnumMap<Side,FMLEmbeddedChannel> newChannel(ModContainer container, String name, ChannelHandler... handlers)
{
if (channels.containsKey(name) || name.startsWith("MC|") || name.startsWith("\u0001") || (name.startsWith("FML") && !("FML".equals(container.getModId()))))
{
throw new RuntimeException("That channel is already registered");
}
EnumMap<Side,FMLEmbeddedChannel> result = Maps.newEnumMap(Side.class);
for (Side side : Side.values())
{
FMLEmbeddedChannel channel = new FMLEmbeddedChannel(container, name, side, handlers);
channels.get(side).put(name,channel);
result.put(side, channel);
}
return result;
}
示例10: register
import cpw.mods.fml.common.ModContainer; //导入依赖的package包/类
private void register(Class<?> eventType, Object target, Method method, ModContainer owner)
{
try
{
Constructor<?> ctr = eventType.getConstructor();
ctr.setAccessible(true);
Event event = (Event)ctr.newInstance();
ASMEventHandler listener = new ASMEventHandler(target, method, owner);
event.getListenerList().register(busID, listener.getPriority(), listener);
ArrayList<IEventListener> others = listeners.get(target);
if (others == null)
{
others = new ArrayList<IEventListener>();
listeners.put(target, others);
}
others.add(listener);
}
catch (Exception e)
{
e.printStackTrace();
}
}
示例11: addPrefix
import cpw.mods.fml.common.ModContainer; //导入依赖的package包/类
/**
* Prefix the supplied name with the current mod id.
*
* If no mod id can be determined, minecraft will be assumed.
* The prefix is separated with a colon.
*
* If there's already a prefix, it'll be prefixed again if the new prefix
* doesn't match the old prefix, as used by vanilla calls to addObject.
*
* @param name name to prefix.
* @return prefixed name.
*/
private String addPrefix(String name)
{
int index = name.lastIndexOf(':');
String oldPrefix = index == -1 ? "" : name.substring(0, index);
String prefix;
ModContainer mc = Loader.instance().activeModContainer();
if (mc != null)
{
prefix = mc.getModId();
}
else // no mod container, assume minecraft
{
prefix = "minecraft";
}
if (!oldPrefix.equals(prefix))
{
name = prefix + ":" + name;
}
return name;
}
示例12: registerGlobalEntityID
import cpw.mods.fml.common.ModContainer; //导入依赖的package包/类
public static void registerGlobalEntityID(Class <? extends Entity > entityClass, String entityName, int id)
{
if (EntityList.field_75626_c.containsKey(entityClass))
{
ModContainer activeModContainer = Loader.instance().activeModContainer();
String modId = "unknown";
if (activeModContainer != null)
{
modId = activeModContainer.getModId();
}
else
{
FMLLog.severe("There is a rogue mod failing to register entities from outside the context of mod loading. This is incredibly dangerous and should be stopped.");
}
FMLLog.warning("The mod %s tried to register the entity class %s which was already registered - if you wish to override default naming for FML mod entities, register it here first", modId, entityClass);
return;
}
id = instance().validateAndClaimId(id);
EntityList.func_75618_a(entityClass, entityName, id);
}
示例13: loadLocalization
import cpw.mods.fml.common.ModContainer; //导入依赖的package包/类
/**
* Deprecated for removal in 1.8. Use the assets lang system
*/
@Deprecated
public void loadLocalization(String localizationFile, String lang, boolean isXML)
{
URL urlResource = this.getClass().getResource(localizationFile);
if (urlResource != null)
{
loadLocalization(urlResource, lang, isXML);
}
else
{
ModContainer activeModContainer = Loader.instance().activeModContainer();
if (activeModContainer!=null)
{
FMLLog.log(activeModContainer.getModId(), Level.ERROR, "The language resource %s cannot be located on the classpath. This is a programming error.", localizationFile);
}
else
{
FMLLog.log(Level.ERROR, "The language resource %s cannot be located on the classpath. This is a programming error.", localizationFile);
}
}
}
示例14: loadLanguagesFor
import cpw.mods.fml.common.ModContainer; //导入依赖的package包/类
public void loadLanguagesFor(ModContainer container, Side side)
{
File source = container.getSource();
try
{
if (source.isDirectory())
{
searchDirForLanguages(source, "", side);
}
else
{
searchZipForLanguages(source, side);
}
}
catch (IOException ioe)
{
}
}
示例15: requestPlayerTicket
import cpw.mods.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;
}