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

项目:CustomWorldGen    文件:FMLClientHandler.java   
private void detectOptifine()
{
    try
    {
        Class<?> optifineConfig = Class.forName("Config", false, Loader.instance().getModClassLoader());
        String optifineVersion = (String) optifineConfig.getField("VERSION").get(null);
        Map<String,Object> dummyOptifineMeta = ImmutableMap.<String,Object>builder().put("name", "Optifine").put("version", optifineVersion).build();
        InputStream optifineModInfoInputStream = getClass().getResourceAsStream("optifinemod.info");
        try
        {
            ModMetadata optifineMetadata = MetadataCollection.from(optifineModInfoInputStream, "optifine").getMetadataForId("optifine", dummyOptifineMeta);
            optifineContainer = new DummyModContainer(optifineMetadata);
            FMLLog.info("Forge Mod Loader has detected optifine %s, enabling compatibility features", optifineContainer.getVersion());
        }
        finally
        {
            IOUtils.closeQuietly(optifineModInfoInputStream);
        }
    }
    catch (Exception e)
    {
        optifineContainer = null;
    }
}
项目:CustomWorldGen    文件:NetworkDispatcher.java   
public void serverToClientHandshake(EntityPlayerMP player)
{
    this.player = player;
    Boolean fml = this.manager.channel().attr(NetworkRegistry.FML_MARKER).get();
    if (fml != null && fml)
    {
        //FML on client, send server hello
        //TODO: Make this cleaner as it uses netty magic 0.o
        insertIntoChannel();
    }
    else
    {
        serverInitiateHandshake();
        FMLLog.info("Connection received without FML marker, assuming vanilla.");
        this.completeServerSideConnection(ConnectionType.VANILLA);
    }
}
项目:CustomWorldGen    文件:FMLNetworkHandler.java   
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);
    }
}
项目:CustomWorldGen    文件:PersistentRegistryManager.java   
public static void revertToFrozen()
{
    if (!PersistentRegistry.FROZEN.isPopulated())
    {
        FMLLog.warning("Can't revert to frozen GameData state without freezing first.");
        return;
    }
    else
    {
        FMLLog.fine("Reverting to frozen data state.");
    }
    for (Map.Entry<ResourceLocation, FMLControlledNamespacedRegistry<?>> r : PersistentRegistry.ACTIVE.registries.entrySet())
    {
        final Class<? extends IForgeRegistryEntry> registrySuperType = PersistentRegistry.ACTIVE.getRegistrySuperType(r.getKey());
        loadRegistry(r.getKey(), PersistentRegistry.FROZEN, PersistentRegistry.ACTIVE, registrySuperType);
    }
    // the id mapping has reverted, fire remap events for those that care about id changes
    Loader.instance().fireRemapEvent(ImmutableMap.<ResourceLocation, Integer[]>of(), ImmutableMap.<ResourceLocation, Integer[]>of(), true);

    // the id mapping has reverted, ensure we sync up the object holders
    ObjectHolderRegistry.INSTANCE.applyObjectHolders();
    FMLLog.fine("Frozen state restored.");
}
项目:pnc-repressurized    文件:TintedOBJModel.java   
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
    ImmutableMap.Builder<String, TextureAtlasSprite> builder = ImmutableMap.builder();
    builder.put(ModelLoader.White.LOCATION.toString(), ModelLoader.White.INSTANCE);
    TextureAtlasSprite missing = bakedTextureGetter.apply(new ResourceLocation("missingno"));
    for (Map.Entry<String, Material> e : matLib.materials.entrySet())
    {
        if (e.getValue().getTexture().getTextureLocation().getResourcePath().startsWith("#"))
        {
            FMLLog.log.fatal("OBJLoader: Unresolved texture '{}' for obj model '{}'", e.getValue().getTexture().getTextureLocation().getResourcePath(), modelLocation);
            builder.put(e.getKey(), missing);
        }
        else
        {
            builder.put(e.getKey(), bakedTextureGetter.apply(e.getValue().getTexture().getTextureLocation()));
        }
    }
    builder.put("missingno", missing);
    return new TintedOBJBakedModel(this, state, format, builder.build());
}
项目:Soot    文件:Nope.java   
/**
 * Make forge not spew "dangerous alternative prefix" messages in this block.
 */
public static void shutupForge(Runnable op) {
    Logger log = (Logger) FMLLog.log;
    try {
        Object privateConfig = ReflectionHelper.findField(Logger.class, "privateConfig").get(log);
        Field intLevelF = ReflectionHelper.findField(privateConfig.getClass(), "intLevel");
        int intLevel = (int) intLevelF.get(privateConfig);
        intLevelF.set(privateConfig, 299); // disable WARN logging

        try {
            op.run();
        } finally {
            intLevelF.set(privateConfig, intLevel);
        }
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}
项目:CustomWorldGen    文件:MultiModel.java   
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
    IBakedModel bakedBase = null;

    if (base != null)
        bakedBase = base.bake(state, format, bakedTextureGetter);

    ImmutableMap.Builder<String, IBakedModel> mapBuilder = ImmutableMap.builder();

    for (Entry<String, Pair<IModel, IModelState>> entry : parts.entrySet())
    {
        Pair<IModel, IModelState> pair = entry.getValue();
        mapBuilder.put(entry.getKey(), pair.getLeft().bake(new ModelStateComposition(state, pair.getRight()), format, bakedTextureGetter));
    }

    if(bakedBase == null && parts.isEmpty())
    {
        FMLLog.log(Level.ERROR, "MultiModel %s is empty (no base model or parts were provided/resolved)", location);
        IModel missing = ModelLoaderRegistry.getMissingModel();
        return missing.bake(missing.getDefaultState(), format, bakedTextureGetter);
    }
    return new Baked(location, true, bakedBase, mapBuilder.build());
}
项目:CustomWorldGen    文件:DimensionManager.java   
public static void setWorld(int id, WorldServer world, MinecraftServer server)
{
    if (world != null)
    {
        worlds.put(id, world);
        weakWorldMap.put(world, world);
        server.worldTickTimes.put(id, new long[100]);
        FMLLog.info("Loading dimension %d (%s) (%s)", id, world.getWorldInfo().getWorldName(), world.getMinecraftServer());
    }
    else
    {
        worlds.remove(id);
        server.worldTickTimes.remove(id);
        FMLLog.info("Unloading dimension %d", id);
    }

    ArrayList<WorldServer> tmp = new ArrayList<WorldServer>();
    if (worlds.get( 0) != null)
        tmp.add(worlds.get( 0));
    if (worlds.get(-1) != null)
        tmp.add(worlds.get(-1));
    if (worlds.get( 1) != null)
        tmp.add(worlds.get( 1));

    for (Entry<Integer, WorldServer> entry : worlds.entrySet())
    {
        int dim = entry.getKey();
        if (dim >= -1 && dim <= 1)
        {
            continue;
        }
        tmp.add(entry.getValue());
    }

    server.worldServers = tmp.toArray(new WorldServer[tmp.size()]);
}
项目:CustomWorldGen    文件:FMLFileResourcePack.java   
@Override
protected InputStream getInputStreamByName(String resourceName) throws IOException
{
    try
    {
        return super.getInputStreamByName(resourceName);
    }
    catch (IOException ioe)
    {
        if ("pack.mcmeta".equals(resourceName))
        {
            FMLLog.log(container.getName(), Level.DEBUG, "Mod %s is missing a pack.mcmeta file, substituting a dummy one", container.getName());
            return new ByteArrayInputStream(("{\n" +
                    " \"pack\": {\n"+
                    "   \"description\": \"dummy FML pack for "+container.getName()+"\",\n"+
                    "   \"pack_format\": 1\n"+
                    "}\n" +
                    "}").getBytes(Charsets.UTF_8));
        }
        else throw ioe;
    }
}
项目:CustomWorldGen    文件:FMLFolderResourcePack.java   
@Override
protected InputStream getInputStreamByName(String resourceName) throws IOException
{
    try
    {
        return super.getInputStreamByName(resourceName);
    }
    catch (IOException ioe)
    {
        if ("pack.mcmeta".equals(resourceName))
        {
            FMLLog.log(container.getName(), Level.DEBUG, "Mod %s is missing a pack.mcmeta file, substituting a dummy one", container.getName());
            return new ByteArrayInputStream(("{\n" +
                    " \"pack\": {\n"+
                    "   \"description\": \"dummy FML pack for "+container.getName()+"\",\n"+
                    "   \"pack_format\": 1\n"+
                    "}\n" +
                    "}").getBytes(Charsets.UTF_8));
        }
        else throw ioe;
    }
}
项目:CustomWorldGen    文件:FMLHandshakeMessage.java   
@Override
public void fromBytes(ByteBuf buffer)
{
    serverProtocolVersion = buffer.readByte();
    // Extended dimension support during login
    if (serverProtocolVersion > 1)
    {
        overrideDimension = buffer.readInt();
        FMLLog.fine("Server FML protocol version %d, 4 byte dimension received %d", serverProtocolVersion, overrideDimension);
    }
    else
    {
        FMLLog.info("Server FML protocol version %d, no additional data received", serverProtocolVersion);
    }
}
项目:CustomWorldGen    文件:NetworkDispatcher.java   
private void completeClientSideConnection(ConnectionType type)
{
    this.connectionType = type;
    FMLLog.info("[%s] Client side %s connection established", Thread.currentThread().getName(), this.connectionType.name().toLowerCase(Locale.ENGLISH));
    this.state = ConnectionState.CONNECTED;
    MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ClientConnectedToServerEvent(manager, this.connectionType.name()));
}
项目:CustomWorldGen    文件:NetworkDispatcher.java   
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
{
    // Stop the epic channel closed spam at close
    if (!(cause instanceof ClosedChannelException))
    {
        // Mute the reset by peer exception - it's disconnection noise
        if (cause.getMessage().contains("Connection reset by peer"))
        {
            FMLLog.log(Level.DEBUG, cause, "Muted NetworkDispatcher exception");
        }
        else
        {
            FMLLog.log(Level.ERROR, cause, "NetworkDispatcher exception");
        }
    }
    super.exceptionCaught(ctx, cause);
}
项目:CustomWorldGen    文件:OBJModel.java   
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
    ImmutableMap.Builder<String, TextureAtlasSprite> builder = ImmutableMap.builder();
    builder.put(ModelLoader.White.LOCATION.toString(), ModelLoader.White.INSTANCE);
    TextureAtlasSprite missing = bakedTextureGetter.apply(new ResourceLocation("missingno"));
    for (Map.Entry<String, Material> e : matLib.materials.entrySet())
    {
        if (e.getValue().getTexture().getTextureLocation().getResourcePath().startsWith("#"))
        {
            FMLLog.severe("OBJLoader: Unresolved texture '%s' for obj model '%s'", e.getValue().getTexture().getTextureLocation().getResourcePath(), modelLocation);
            builder.put(e.getKey(), missing);
        }
        else
        {
            builder.put(e.getKey(), bakedTextureGetter.apply(e.getValue().getTexture().getTextureLocation()));
        }
    }
    builder.put("missingno", missing);
    return new OBJBakedModel(this, state, format, builder.build());
}
项目:CustomWorldGen    文件:MinecraftForge.java   
/**
 * Method invoked by FML before any other mods are loaded.
 */
public static void initialize()
{
    FMLLog.info("MinecraftForge v%s Initialized", ForgeVersion.getVersion());

    OreDictionary.getOreName(0);

    UsernameCache.load();
    // Load before all the mods, so MC owns the MC fluids
    FluidRegistry.validateFluidRegistry();
    ForgeHooks.initTools();

    //For all the normal CrashReport classes to be defined. We're in MC's classloader so this should all be fine
    new CrashReport("ThisIsFake", new Exception("Not real"));
}
项目:CustomWorldGen    文件:FMLIndexedMessageToMessageCodec.java   
@Override
protected final void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception
{
    testMessageValidity(msg);
    ByteBuf payload = msg.payload().duplicate();
    if (payload.readableBytes() < 1)
    {
        FMLLog.log(Level.ERROR, "The FMLIndexedCodec has received an empty buffer on channel %s, likely a result of a LAN server issue. Pipeline parts : %s", ctx.channel().attr(NetworkRegistry.FML_CHANNEL), ctx.pipeline().toString());
    }
    byte discriminator = payload.readByte();
    Class<? extends A> clazz = discriminators.get(discriminator);
    if(clazz == null)
    {
        throw new NullPointerException("Undefined message for discriminator " + discriminator + " in channel " + msg.channel());
    }
    A newMsg = clazz.newInstance();
    ctx.attr(INBOUNDPACKETTRACKER).get().set(new WeakReference<FMLProxyPacket>(msg));
    decodeInto(ctx, payload.slice(), newMsg);
    out.add(newMsg);
}
项目:CustomWorldGen    文件:ForgeChunkManager.java   
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;
}
项目:CustomWorldGen    文件:ModDiscoverer.java   
public void findModDirMods(File modsDir, File[] supplementalModFileCandidates)
{
    File[] modList = FileListHelper.sortFileList(modsDir, null);
    modList = FileListHelper.sortFileList(ObjectArrays.concat(modList, supplementalModFileCandidates, File.class));
    for (File modFile : modList)
    {
        // skip loaded coremods
        if (CoreModManager.getIgnoredMods().contains(modFile.getName()))
        {
            FMLLog.finer("Skipping already parsed coremod or tweaker %s", modFile.getName());
        }
        else if (modFile.isDirectory())
        {
            FMLLog.fine("Found a candidate mod directory %s", modFile.getName());
            addCandidate(new ModCandidate(modFile, modFile, ContainerType.DIR));
        }
        else
        {
            Matcher matcher = zipJar.matcher(modFile.getName());

            if (matcher.matches())
            {
                FMLLog.fine("Found a candidate zip or jar file %s", matcher.group(0));
                addCandidate(new ModCandidate(modFile, modFile, ContainerType.JAR));
            }
            else
            {
                FMLLog.fine("Ignoring unknown file %s in mods directory", modFile.getName());
            }
        }
    }
}
项目:CustomWorldGen    文件:DirectoryDiscoverer.java   
@Override
public List<ModContainer> discover(ModCandidate candidate, ASMDataTable table)
{
    this.table = table;
    List<ModContainer> found = Lists.newArrayList();
    FMLLog.fine("Examining directory %s for potential mods", candidate.getModContainer().getName());
    exploreFileSystem("", candidate.getModContainer(), found, candidate, null);
    for (ModContainer mc : found)
    {
        table.addContainer(mc);
    }
    return found;
}
项目:CustomWorldGen    文件:ModCandidate.java   
public List<ModContainer> explore(ASMDataTable table)
{
    this.table = table;
    this.mods = sourceType.findMods(this, table);
    if (!baseModCandidateTypes.isEmpty())
    {
        FMLLog.info("Attempting to reparse the mod container %s", getModContainer().getName());
        this.mods = sourceType.findMods(this, table);
    }
    return this.mods;
}
项目:CustomWorldGen    文件:FMLPostInitializationEvent.java   
/**
 * Build an object depending on if a specific target mod is loaded or not.
 *
 * Usually would be used to access an object from the other mod.
 *
 * @param modId The modId I conditionally want to build an object for
 * @param className The name of the class I wish to instantiate
 * @return An optional containing the object if possible, or null if not
 */
public Optional<?> buildSoftDependProxy(String modId, String className, Object... arguments)
{
    if (Loader.isModLoaded(modId))
    {
        Class<?>[] args = Lists.transform(Lists.newArrayList(arguments),new Function<Object, Class<?>>() {
            @Nullable
            @Override
            public Class<?> apply(@Nullable Object input) {
                return input.getClass();
            }
        }).toArray(new Class[0]);
        try
        {
            Class<?> clz = Class.forName(className,true,Loader.instance().getModClassLoader());
            Constructor<?> ct = clz.getConstructor(args);
            return Optional.fromNullable(ct.newInstance(arguments));
        }
        catch (Exception e)
        {
            FMLLog.getLogger().log(Level.INFO, "An error occurred trying to build a soft depend proxy",e);
            return Optional.absent();
        }
    }
    return Optional.absent();
}
项目:CustomWorldGen    文件:B3DLoader.java   
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
    ImmutableMap.Builder<String, TextureAtlasSprite> builder = ImmutableMap.builder();
    TextureAtlasSprite missing = bakedTextureGetter.apply(new ResourceLocation("missingno"));
    for(Map.Entry<String, ResourceLocation> e : textures.entrySet())
    {
        if(e.getValue().getResourcePath().startsWith("#"))
        {
            FMLLog.severe("unresolved texture '%s' for b3d model '%s'", e.getValue().getResourcePath(), modelLocation);
            builder.put(e.getKey(), missing);
        }
        else
        {
            builder.put(e.getKey(), bakedTextureGetter.apply(e.getValue()));
        }
    }
    builder.put("missingno", missing);
    return new BakedWrapper(model.getRoot(), state, smooth, gui3d, format, meshes, builder.build());
}
项目:CustomWorldGen    文件:GameData.java   
public GameData()
{
    iBlockRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.BLOCKS, Block.class, new ResourceLocation("minecraft:air"), MIN_BLOCK_ID, MAX_BLOCK_ID, true, BlockCallbacks.INSTANCE, BlockCallbacks.INSTANCE, BlockCallbacks.INSTANCE, BlockCallbacks.INSTANCE);
    iItemRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.ITEMS, Item.class, null, MIN_ITEM_ID, MAX_ITEM_ID, true, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE);
    iPotionRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.POTIONS, Potion.class, null, MIN_POTION_ID, MAX_POTION_ID, false, PotionCallbacks.INSTANCE, PotionCallbacks.INSTANCE, PotionCallbacks.INSTANCE, null);
    iBiomeRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.BIOMES, Biome.class, null, MIN_BIOME_ID, MAX_BIOME_ID, false, BiomeCallbacks.INSTANCE, BiomeCallbacks.INSTANCE, BiomeCallbacks.INSTANCE, null);
    iSoundEventRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.SOUNDEVENTS, SoundEvent.class, null, MIN_SOUND_ID, MAX_SOUND_ID, false, null, null, null, null);
    ResourceLocation WATER = new ResourceLocation("water");
    iPotionTypeRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.POTIONTYPES, PotionType.class, WATER, MIN_POTIONTYPE_ID, MAX_POTIONTYPE_ID, false, null, null, null, null);
    iEnchantmentRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.ENCHANTMENTS, Enchantment.class, null, MIN_ENCHANTMENT_ID, MAX_ENCHANTMENT_ID, false, null, null, null, null);

    try
    {
        blockField = FinalFieldHelper.makeWritable(ReflectionHelper.findField(ItemBlock.class, "block", "field_150939" + "_a"));
    }
    catch (Exception e)
    {
        FMLLog.log(Level.FATAL, e, "Cannot access the 'block' field from ItemBlock, this is fatal!");
        throw Throwables.propagate(e);
    }
}
项目:CustomWorldGen    文件:GameData.java   
/**
 * Prefix the supplied name with the current mod id.
 * <p/>
 * If no mod id can be determined, minecraft will be assumed.
 * The prefix is separated with a colon.
 * <p/>
 * 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 ResourceLocation addPrefix(String name)
{
    int index = name.lastIndexOf(':');
    String oldPrefix = index == -1 ? "" : name.substring(0, index);
    name = index == -1 ? name : name.substring(index + 1);
    String prefix;
    ModContainer mc = Loader.instance().activeModContainer();

    if (mc != null)
    {
        prefix = mc.getModId().toLowerCase();
    }
    else // no mod container, assume minecraft
    {
        prefix = "minecraft";
    }

    if (!oldPrefix.equals(prefix) && oldPrefix.length() > 0)
    {
        FMLLog.bigWarning("Dangerous alternative prefix %s for name %s, invalid registry invocation/invalid name?", prefix, name);
        prefix = oldPrefix;
    }

    return new ResourceLocation(prefix, name);
}
项目:CustomWorldGen    文件:EntityRegistry.java   
private void doModEntityRegistration(Class<? extends Entity> entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates)
{
    ModContainer mc = FMLCommonHandler.instance().findContainerFor(mod);
    EntityRegistration er = new EntityRegistration(mc, entityClass, entityName, id, trackingRange, updateFrequency, sendsVelocityUpdates);
    try
    {
        entityClassRegistrations.put(entityClass, er);
        entityNames.put(entityName, mc);
        if (!EntityList.CLASS_TO_NAME.containsKey(entityClass))
        {
            String entityModName = String.format("%s.%s", mc.getModId(), entityName);
            EntityList.CLASS_TO_NAME.put(entityClass, entityModName);
            EntityList.NAME_TO_CLASS.put(entityModName, entityClass);
            FMLLog.finer("Automatically registered mod %s entity %s as %s", mc.getModId(), entityName, entityModName);
        }
        else
        {
            FMLLog.fine("Skipping automatic mod %s entity registration for already registered class %s", mc.getModId(), entityClass.getName());
        }
    }
    catch (IllegalArgumentException e)
    {
        FMLLog.log(Level.WARN, e, "The mod %s tried to register the entity (name,class) (%s,%s) one or both of which are already registered", mc.getModId(), entityName, entityClass.getName());
        return;
    }
    entityRegistrations.put(mc, er);
}
项目:CustomWorldGen    文件:PersistentRegistryManager.java   
private <T extends IForgeRegistryEntry<T>> FMLControlledNamespacedRegistry<T> createRegistry(ResourceLocation registryName, Class<T> type, ResourceLocation defaultObjectKey, int minId, int maxId, IForgeRegistry.AddCallback<T> addCallback, IForgeRegistry.ClearCallback<T> clearCallback, IForgeRegistry.CreateCallback<T> createCallback, IForgeRegistry.SubstitutionCallback<T> substitutionCallback)
{
    Set<Class<?>> parents = Sets.newHashSet();
    findSuperTypes(type, parents);
    SetView<Class<?>> overlappedTypes = Sets.intersection(parents, registrySuperTypes.keySet());
    if (!overlappedTypes.isEmpty())
    {
        Class<?> foundType = overlappedTypes.iterator().next();
        FMLLog.severe("Found existing registry of type %1s named %2s, you cannot create a new registry (%3s) with type %4s, as %4s has a parent of that type", foundType, registrySuperTypes.get(foundType), registryName, type);
        throw new IllegalArgumentException("Duplicate registry parent type found - you can only have one registry for a particular super type");
    }
    FMLControlledNamespacedRegistry<T> fmlControlledNamespacedRegistry = new FMLControlledNamespacedRegistry<T>(defaultObjectKey, minId, maxId, type, registries, addCallback, clearCallback, createCallback, substitutionCallback);
    registries.put(registryName, fmlControlledNamespacedRegistry);
    registrySuperTypes.put(type, registryName);
    return getRegistry(registryName, type);
}
项目:CustomWorldGen    文件:ConfigManager.java   
public static void loadData(ASMDataTable data)
{
    FMLLog.fine("Loading @Config anotation data");
    for (ASMData target : data.getAll(Config.class.getName()))
    {
        String modid = (String)target.getAnnotationInfo().get("modid");
        Multimap<Config.Type, ASMData> map = asm_data.get(modid);
        if (map == null)
        {
            map = ArrayListMultimap.create();
            asm_data.put(modid, map);
        }

        EnumHolder tholder = (EnumHolder)target.getAnnotationInfo().get("type");
        Config.Type type = tholder == null ? Config.Type.INSTANCE : Config.Type.valueOf(tholder.getValue());

        map.put(type, target);
    }
}
项目:CustomWorldGen    文件:PersistentRegistryManager.java   
public static void freezeVanilla()
{
    FMLLog.fine("Creating vanilla freeze snapshot");
    for (Map.Entry<ResourceLocation, FMLControlledNamespacedRegistry<?>> r : PersistentRegistry.ACTIVE.registries.entrySet())
    {
        // This has to be performed prior to invoking the method so the compiler can precompute the type bounds for the method
        final Class<? extends IForgeRegistryEntry> registrySuperType = PersistentRegistry.ACTIVE.getRegistrySuperType(r.getKey());
        loadRegistry(r.getKey(), PersistentRegistry.ACTIVE, PersistentRegistry.VANILLA, registrySuperType);
    }
    forAllRegistries(PersistentRegistry.VANILLA, ValidateRegistryFunction.OPERATION);
    FMLLog.fine("Vanilla freeze snapshot created");
}
项目:CustomWorldGen    文件:ChunkIOExecutor.java   
public static void dropQueuedChunkLoad(World world, int x, int z, Runnable runnable)
{
    QueuedChunk key = new QueuedChunk(x, z, world);
    ChunkIOProvider task = tasks.get(key);
    if (task == null)
    {
        FMLLog.warning("Attempted to dequeue chunk that wasn't queued? %d @ (%d, %d)", world.provider.getDimension(), x, z);
        return;
    }

    task.removeCallback(runnable);

    if (!task.hasCallback())
    {
        tasks.remove(key);
        pool.remove(task);
    }
}
项目:CustomWorldGen    文件:FMLControlledNamespacedRegistry.java   
public void loadIds(Map<ResourceLocation, Integer> ids, Map<ResourceLocation, Integer> missingIds, Map<ResourceLocation, Integer[]> remappedIds, FMLControlledNamespacedRegistry<I> currentRegistry, ResourceLocation registryName)
{
    for (Map.Entry<ResourceLocation, Integer> entry : ids.entrySet())
    {
        ResourceLocation itemName = entry.getKey();
        int newId = entry.getValue();
        int currId = currentRegistry.getId(itemName);

        if (currId == -1)
        {
            FMLLog.info("Found a missing id from the world %s", itemName);
            missingIds.put(entry.getKey(), newId);
            continue; // no block/item -> nothing to add
        }
        else if (currId != newId)
        {
            FMLLog.fine("Fixed %s id mismatch %s: %d (init) -> %d (map).", registryName, itemName, currId, newId);
            remappedIds.put(itemName, new Integer[] {currId, newId});
        }
        I obj = currentRegistry.getRaw(itemName);
        I sub = obj;
        // If we have an object in the originals set, we use that for initial adding - substitute activation will readd the substitute if neceessary later
        if (currentRegistry.substitutionOriginals.containsKey(itemName))
        {
            obj = currentRegistry.substitutionOriginals.get(itemName);
        }
        add(newId, itemName, obj);
        if (currentRegistry.substitutionOriginals.containsKey(itemName) && substitutionCallback != null)
        {
            substitutionCallback.onSubstituteActivated(slaves, sub, obj, itemName);
        }
    }
}
项目:CustomWorldGen    文件:ForgeMessage.java   
@Override
void fromBytes(ByteBuf bytes)
{
    int listSize = bytes.readInt();
    for (int i = 0; i < listSize; i++) {
        String fluidName = ByteBufUtils.readUTF8String(bytes);
        int fluidId = bytes.readInt();
        fluidIds.put(FluidRegistry.getFluid(fluidName), fluidId);
    }
    // do we have a defaults list?

    if (bytes.isReadable())
    {
        for (int i = 0; i < listSize; i++)
        {
            defaultFluids.add(ByteBufUtils.readUTF8String(bytes));
        }
    }
    else
    {
        FMLLog.getLogger().log(Level.INFO, "Legacy server message contains no default fluid list - there may be problems with fluids");
        defaultFluids.clear();
    }
}
项目:CustomWorldGen    文件:RecipeSorter.java   
public static void sortCraftManager()
{
    bake();
    FMLLog.fine("Sorting recipes");
    warned.clear();
    Collections.sort(CraftingManager.getInstance().getRecipeList(), INSTANCE);
}
项目:CustomWorldGen    文件:RecipeSorter.java   
private static int getPriority(IRecipe recipe)
{
    Class<?> cls = recipe.getClass();
    Integer ret = priorities.get(cls);

    if (ret == null)
    {
        if (!warned.contains(cls))
        {
            FMLLog.bigWarning("Unknown recipe class! %s Modders need to register their recipe types with %s", cls.getName(), RecipeSorter.class.getName());
            warned.add(cls);
        }
        cls = cls.getSuperclass();
        while (cls != Object.class)
        {
            ret = priorities.get(cls);
            if (ret != null)
            {
                priorities.put(recipe.getClass(), ret);
                FMLLog.fine("    Parent Found: %d - %s", ret, cls.getName());
                return ret;
            }
        }
    }

    return ret == null ? 0 : ret;
}
项目:CustomWorldGen    文件:ForgeChunkManager.java   
static void captureConfig(File configDir)
{
    cfgFile = new File(configDir,"forgeChunkLoading.cfg");
    config = new Configuration(cfgFile, true);
    try
    {
        config.load();
    }
    catch (Exception e)
    {
        File dest = new File(cfgFile.getParentFile(),"forgeChunkLoading.cfg.bak");
        if (dest.exists())
        {
            dest.delete();
        }
        cfgFile.renameTo(dest);
        FMLLog.log(Level.ERROR, e, "A critical error occurred reading the forgeChunkLoading.cfg file, defaults will be used - the invalid file is backed up at forgeChunkLoading.cfg.bak");
    }
    syncConfigDefaults();
}
项目:InControl    文件:ConfigSetup.java   
private static void readMainConfig() {
    Configuration cfg = mainConfig;
    try {
        cfg.load();
        cfg.addCustomCategoryComment(GeneralConfiguration.CATEGORY_GENERAL, "General settings");

        GeneralConfiguration.init(cfg);
    } catch (Exception e1) {
        FMLLog.log(Level.ERROR, e1, "Problem loading config file!");
    } finally {
        if (mainConfig.hasChanged()) {
            mainConfig.save();
        }
    }
}
项目:ChatBomb    文件:LogUtility.java   
public static void debug(String format, Object... data) {
    FMLLog.log(TAG, Level.DEBUG, format, data);
}
项目:ChatBomb    文件:LogUtility.java   
public static void info(String format, Object... data) {
    FMLLog.log(TAG, Level.INFO, format, data);
}
项目:ChatBomb    文件:LogUtility.java   
public static void error(String format, Object... data) {
    FMLLog.log(TAG, Level.INFO, format, data);
}
项目:Got-Wood    文件:BlockWoodSlab.java   
private Item getSlabItem() {
    if (this.slabItem == null) {
        FMLLog.severe("getting item for slab: %s, %s", this.getRegistryName().getResourceDomain(), this.wood.getName() + "_slab");
        this.slabItem = Item.REGISTRY.getObject(new ResourceLocation(this.getRegistryName().getResourceDomain(), this.wood.getName() + "_slab"));
    }
    return this.slabItem;
}
项目:interactionwheel    文件:ConfigSetup.java   
private static void readMainConfig() {
    Configuration cfg = mainConfig;
    try {
        cfg.load();
        cfg.addCustomCategoryComment(GeneralConfiguration.CATEGORY_GENERAL, "General settings");

        GeneralConfiguration.init(cfg);
    } catch (Exception e1) {
        FMLLog.log(Level.ERROR, e1, "Problem loading config file!");
    } finally {
        if (mainConfig.hasChanged()) {
            mainConfig.save();
        }
    }
}