Java 类net.minecraftforge.fml.common.FMLContainer 实例源码

项目:CustomWorldGen    文件:IForgeRegistryEntry.java   
public final T setRegistryName(String name)
{
    if (getRegistryName() != null)
        throw new IllegalStateException("Attempted to set registry name with existing registry name! New: " + name + " Old: " + getRegistryName());

    int index = name.lastIndexOf(':');
    String oldPrefix = index == -1 ? "" : name.substring(0, index);
    name = index == -1 ? name : name.substring(index + 1);
    ModContainer mc = Loader.instance().activeModContainer();
    String prefix = mc == null || (mc instanceof InjectedModContainer && ((InjectedModContainer)mc).wrappedContainer instanceof FMLContainer) ? "minecraft" : mc.getModId().toLowerCase();
    if (!oldPrefix.equals(prefix) && oldPrefix.length() > 0)
    {
        FMLLog.bigWarning("Dangerous alternative prefix `%s` for name `%s`, expected `%s` invalid registry invocation/invalid name?", oldPrefix, name, prefix);
        prefix = oldPrefix;
    }
    this.registryName = new ResourceLocation(prefix, name);
    return (T)this;
}
项目:CrystalMod    文件:ModBlocks.java   
public static <T extends Block> T registerBlock(T block, ItemBlock itemBlock, String name) {
    String finalName = name;
    String lowerCase = name.toLowerCase();
    if (name != lowerCase) {
        ModLogger.warning("Registering a Block and Item that has a non-lowercase registry name! (" + name + " vs. "
                + lowerCase + ") setting it to " + lowerCase);
        finalName = lowerCase;

        ModContainer mc = Loader.instance().activeModContainer();
        String prefix = mc == null || (mc instanceof InjectedModContainer
                && ((InjectedModContainer) mc).wrappedContainer instanceof FMLContainer) ? "minecraft"
                        : mc.getModId().toLowerCase();
        MissingItemHandler.remapItems.put(new ResourceLocation(prefix, name), itemBlock);
        MissingItemHandler.remapBlocks.put(new ResourceLocation(prefix, name), block);
    }

    block.setUnlocalizedName(CrystalMod.prefix(finalName));
    block.setRegistryName(CrystalMod.resource(finalName));
    GameRegistry.register(block);
    GameRegistry.register(itemBlock.setRegistryName(CrystalMod.resource(finalName)));
    REGISTRY.put(finalName, block);
    return block;
}
项目:CustomWorldGen    文件:FMLNetworkHandler.java   
public static void registerChannel(FMLContainer container, Side side)
{
    channelPair = NetworkRegistry.INSTANCE.newChannel(container, "FML", new FMLRuntimeCodec(), new HandshakeCompletionHandler());
    EmbeddedChannel embeddedChannel = channelPair.get(Side.SERVER);
    embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.NOWHERE);

    if (side == Side.CLIENT)
    {
        addClientHandlers();
    }
}
项目:Bookshelf    文件:ModUtils.java   
/**
 * Creates a ResourceLocation for a string, using the active mod container as the owner of
 * the ID.
 *
 * @param id The id for the specific entry.
 * @return A ResourceLocation for the entry.
 */
public static ResourceLocation getIdForCurrentContainer (String id) {

    final int index = id.lastIndexOf(':');
    final String entryName = index == -1 ? id : id.substring(index + 1);
    final ModContainer mod = Loader.instance().activeModContainer();
    final String prefix = mod == null || mod instanceof InjectedModContainer && ((InjectedModContainer) mod).wrappedContainer instanceof FMLContainer ? "minecraft" : mod.getModId().toLowerCase();

    return new ResourceLocation(prefix, entryName);
}