mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-25 14:34:28 +00:00
Build system
This commit is contained in:
1 parent
84d4f7765c
commit
31d2c84541
14 files changed
+152
-1
No files matched your search
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package fml;
|
||||
|
||||
import net.minecraft.src.BiomeGenBase;
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.Entity;
|
||||
import net.minecraft.src.EntityLiving;
|
||||
import net.minecraft.src.EnumCreatureType;
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemBlock;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
public class CommonRegistry {
|
||||
static void addRecipe(ItemStack output, Object... params) {
|
||||
}
|
||||
|
||||
static void addShapelessRecipe(ItemStack output, Object... params) {
|
||||
}
|
||||
|
||||
static void addSmelting(int input, ItemStack output) {
|
||||
}
|
||||
|
||||
public static void registerBlock(Block block) {
|
||||
Block.blocksList[block.blockID]=block;
|
||||
}
|
||||
|
||||
public static void registerBlock(Block block, Class<? extends ItemBlock> itemclass) {
|
||||
registerBlock(block);
|
||||
try {
|
||||
ItemBlock bl=itemclass.getConstructor(int.class).newInstance(block.blockID);
|
||||
Item.itemsList[bl.shiftedIndex-256]=bl;
|
||||
} catch (Exception e) {
|
||||
//HMMM
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerEntityID(Class<? extends Entity> entityClass, String entityName, int id) {
|
||||
}
|
||||
|
||||
public static void registerEntityID(Class<? extends Entity> entityClass, String entityName, int id, int background, int foreground) {
|
||||
}
|
||||
|
||||
public static void registerTileEntity(Class<? extends TileEntity> tileEntityClass, String id) {
|
||||
}
|
||||
|
||||
public static void addBiome(BiomeGenBase biome) {
|
||||
}
|
||||
|
||||
public static void addSpawn(Class<? extends EntityLiving> entityClass, int weightedProb, int min, int max, EnumCreatureType spawnList) {
|
||||
}
|
||||
|
||||
public static void addSpawn(Class<? extends EntityLiving> entityClass, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeGenBase... biomes) {
|
||||
}
|
||||
|
||||
public static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList) {
|
||||
}
|
||||
|
||||
public static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeGenBase... biomes) {
|
||||
}
|
||||
|
||||
public static void removeBiome(BiomeGenBase biome) {
|
||||
}
|
||||
|
||||
public static void removeSpawn(Class<? extends EntityLiving> entityClass, EnumCreatureType spawnList) {
|
||||
}
|
||||
|
||||
public static void removeSpawn(Class<? extends EntityLiving> entityClass, EnumCreatureType spawnList, BiomeGenBase... biomes) {
|
||||
}
|
||||
|
||||
public static void removeSpawn(String entityName, EnumCreatureType spawnList) {
|
||||
}
|
||||
|
||||
public static void removeSpawn(String entityName, EnumCreatureType spawnList, BiomeGenBase... biomes) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package fml;
|
||||
|
||||
|
||||
public enum FMLHooks {
|
||||
INSTANCE;
|
||||
public void serverTickStart() {
|
||||
for (ModContainer mod : Loader.getModList()) {
|
||||
mod.tickStart();
|
||||
}
|
||||
}
|
||||
|
||||
public void serverTickEnd() {
|
||||
for (ModContainer mod : Loader.getModList()) {
|
||||
mod.tickEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package fml;
|
||||
|
||||
|
||||
public class FMLModContainer implements ModContainer {
|
||||
private Mod modDescriptor;
|
||||
private Object modInstance;
|
||||
public FMLModContainer(Class<?> clazz) {
|
||||
modDescriptor=clazz.getAnnotation(Mod.class);
|
||||
|
||||
try {
|
||||
modInstance=clazz.newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wantsPreInit() {
|
||||
return modDescriptor.wantsPreInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wantsPostInit() {
|
||||
return modDescriptor.wantsPostInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public static ModContainer buildFor(Class<?> clazz) {
|
||||
return new FMLModContainer(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickStart() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickEnd() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Object mod) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,249 +0,0 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package fml;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.FileHandler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.SimpleFormatter;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import net.minecraft.src.BaseMod;
|
||||
import fml.ml.ModLoaderModContainer;
|
||||
|
||||
public enum Loader {
|
||||
INSTANCE;
|
||||
private enum State {
|
||||
NOINIT, LOADING, PREINIT, INIT, POSTINIT, UP, ERRORED
|
||||
};
|
||||
|
||||
private static State state;
|
||||
private static Logger LOG = Logger.getLogger("ForgeModLoader.Loader");
|
||||
|
||||
private static List<ModContainer> mods;
|
||||
|
||||
private static Map<String,ModContainer> namedMods;
|
||||
|
||||
private static ModClassLoader modClassLoader;
|
||||
|
||||
private static Pattern zipJar = Pattern.compile("([^\\s]+).(zip|jar)$");
|
||||
private static Pattern modClass = Pattern.compile("(.*/)(mod\\_[^\\s]+).class$");
|
||||
|
||||
public static void run() {
|
||||
LOG.setLevel(Level.ALL);
|
||||
FileHandler fileHandler;
|
||||
try {
|
||||
fileHandler = new FileHandler("ForgeModLoader-%g.log", 0, 3);
|
||||
System.setProperty("java.util.logging.SimpleFormatter.format", "%1$tc %2$s%n%4$s: %5$s%6$s%n");
|
||||
fileHandler.setFormatter(new SimpleFormatter());
|
||||
fileHandler.setLevel(Level.ALL);
|
||||
LOG.addHandler(fileHandler);
|
||||
} catch (Exception e) {
|
||||
// Whatever - give up
|
||||
}
|
||||
}
|
||||
|
||||
private Loader() {
|
||||
}
|
||||
|
||||
private void sortModList() {
|
||||
// NOOP for a minute
|
||||
}
|
||||
|
||||
private void preModInit() {
|
||||
state = State.PREINIT;
|
||||
for (ModContainer mod : mods) {
|
||||
if (mod.wantsPreInit()) {
|
||||
LOG.finer(String.format("Pre-initializing %s", mod.getName()));
|
||||
mod.preInit();
|
||||
namedMods.put(mod.getName(), mod);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void modInit() {
|
||||
state = State.INIT;
|
||||
for (ModContainer mod : mods) {
|
||||
LOG.finer(String.format("Initializing %s", mod.getName()));
|
||||
mod.init();
|
||||
}
|
||||
}
|
||||
|
||||
private void postModInit() {
|
||||
state = State.POSTINIT;
|
||||
for (ModContainer mod : mods) {
|
||||
if (mod.wantsPostInit()) {
|
||||
LOG.finer(String.format("Post-initializing %s", mod.getName()));
|
||||
mod.postInit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void load() {
|
||||
File modsDir = new File(".", "mods");
|
||||
String canonicalModsPath;
|
||||
try {
|
||||
canonicalModsPath = modsDir.getCanonicalPath();
|
||||
} catch (IOException ioe) {
|
||||
LOG.severe(String.format("Failed to resolve mods directory mods %s", modsDir.getAbsolutePath()));
|
||||
LOG.throwing("fml.server.Loader", "initialize", ioe);
|
||||
throw new LoaderException(ioe);
|
||||
}
|
||||
if (!modsDir.exists()) {
|
||||
LOG.fine(String.format("No mod directory found, creating one: %s", canonicalModsPath));
|
||||
try {
|
||||
modsDir.mkdir();
|
||||
} catch (Exception e) {
|
||||
LOG.throwing("fml.server.Loader", "initialize", e);
|
||||
throw new LoaderException(e);
|
||||
}
|
||||
}
|
||||
if (!modsDir.isDirectory()) {
|
||||
LOG.severe(String.format("Attempting to load mods from %s, which is not a directory", canonicalModsPath));
|
||||
LoaderException loaderException = new LoaderException();
|
||||
LOG.throwing("fml.server.Loader", "initialize", loaderException);
|
||||
throw loaderException;
|
||||
}
|
||||
File[] modList = modsDir.listFiles();
|
||||
// Sort the files into alphabetical order first
|
||||
Arrays.sort(modList);
|
||||
|
||||
state = State.LOADING;
|
||||
for (File modFile : modList) {
|
||||
if (modFile.isDirectory()) {
|
||||
LOG.info(String.format("Found directory %s. Attempting load", modFile.getName()));
|
||||
attemptDirLoad(modFile);
|
||||
LOG.info(String.format("Directory %s loaded successfully", modFile.getName()));
|
||||
} else {
|
||||
Matcher matcher = zipJar.matcher(modFile.getName());
|
||||
if (matcher.matches()) {
|
||||
LOG.info(String.format("Found zip or jar file %s. Attempting load.", matcher.group(0)));
|
||||
attemptFileLoad(modFile);
|
||||
LOG.info(String.format("File %s loaded successfully.", matcher.group(0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (state == State.ERRORED) {
|
||||
LOG.severe("A problem has occured during mod loading. Giving up now");
|
||||
throw new RuntimeException("Giving up please");
|
||||
}
|
||||
}
|
||||
|
||||
private void attemptDirLoad(File modDir) {
|
||||
extendClassLoader(modDir);
|
||||
|
||||
File[] content = modDir.listFiles(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return modClass.matcher(name).find();
|
||||
}
|
||||
});
|
||||
for (File modClassFile : content) {
|
||||
String clazzName = modClass.matcher(modClassFile.getName()).group(2);
|
||||
LOG.fine(String.format("Found a mod class %s in directory %s. Attempting to load it", clazzName, modDir.getName()));
|
||||
loadModClass(modDir, modClassFile.getName(), clazzName);
|
||||
LOG.fine(String.format("Successfully loaded mod class %s", modClassFile.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
private void loadModClass(File classSource, String classFileName, String clazzName) {
|
||||
try {
|
||||
System.out.printf("Loading %s\n", clazzName);
|
||||
Class<?> clazz = Class.forName(clazzName, false, modClassLoader);
|
||||
System.out.printf("Got %s\n", clazz);
|
||||
if (clazz.isAnnotationPresent(Mod.class)) {
|
||||
// an FML mod
|
||||
mods.add(FMLModContainer.buildFor(clazz));
|
||||
} else if (BaseMod.class.isAssignableFrom(clazz)) {
|
||||
LOG.fine(String.format("ModLoader BaseMod class found: %s. Loading", clazzName));
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends BaseMod> bmClazz = (Class<? extends BaseMod>) clazz;
|
||||
ModContainer mc=new ModLoaderModContainer(bmClazz);
|
||||
mods.add(mc);
|
||||
LOG.fine(String.format("ModLoader BaseMod class loaded: %s.", clazzName));
|
||||
} else {
|
||||
// Unrecognized
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.warning(String.format("Failed to load mod class %s in %s", classFileName, classSource.getName()));
|
||||
LOG.throwing("fml.server.Loader", "attemptLoad", e);
|
||||
state = State.ERRORED;
|
||||
}
|
||||
}
|
||||
|
||||
private void extendClassLoader(File file) {
|
||||
if (modClassLoader == null) {
|
||||
modClassLoader = new ModClassLoader();
|
||||
}
|
||||
try {
|
||||
modClassLoader.addFile(file);
|
||||
} catch (MalformedURLException e) {
|
||||
throw new LoaderException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void attemptFileLoad(File modFile) {
|
||||
extendClassLoader(modFile);
|
||||
|
||||
try {
|
||||
ZipFile jar = new ZipFile(modFile);
|
||||
for (ZipEntry ze : Collections.list(jar.entries())) {
|
||||
Matcher match = modClass.matcher(ze.getName());
|
||||
if (match.matches()) {
|
||||
String pkg = match.group(1).replace('/', '.');
|
||||
String clazzName = pkg + match.group(2);
|
||||
LOG.fine(String.format("Found a mod class %s in file %s. Attempting to load it", clazzName, modFile.getName()));
|
||||
loadModClass(modFile, ze.getName(), clazzName);
|
||||
LOG.fine(String.format("Mod class %s loaded successfully", clazzName, modFile.getName()));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.warning(String.format("Zip file %s failed to read properly", modFile.getName()));
|
||||
LOG.throwing("fml.server.Loader", "attemptFileLoad", e);
|
||||
state = State.ERRORED;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<ModContainer> getModList() {
|
||||
return mods;
|
||||
}
|
||||
|
||||
public void loadMods() {
|
||||
state = State.NOINIT;
|
||||
mods = new ArrayList<ModContainer>();
|
||||
load();
|
||||
sortModList();
|
||||
// Make mod list immutable
|
||||
mods=Collections.unmodifiableList(mods);
|
||||
preModInit();
|
||||
}
|
||||
|
||||
public void initializeMods() {
|
||||
modInit();
|
||||
postModInit();
|
||||
state = State.UP;
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package fml;
|
||||
|
||||
public class LoaderException extends RuntimeException {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -5675297950958861378L;
|
||||
|
||||
public LoaderException(Exception wrapped) {
|
||||
super(wrapped);
|
||||
}
|
||||
|
||||
public LoaderException() {
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package fml;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Mod {
|
||||
String name() default "";
|
||||
String version() default "";
|
||||
boolean wantsPreInit() default false;
|
||||
boolean wantsPostInit() default false;
|
||||
public @interface PreInit {}
|
||||
public @interface Init {}
|
||||
public @interface PostInit {}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package fml;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
public class ModClassLoader extends URLClassLoader {
|
||||
|
||||
public ModClassLoader() {
|
||||
super(new URL[0]);
|
||||
}
|
||||
|
||||
public void addFile(File modFile) throws MalformedURLException {
|
||||
URL url=modFile.toURI().toURL();
|
||||
super.addURL(url);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package fml;
|
||||
|
||||
public interface ModContainer {
|
||||
boolean wantsPreInit();
|
||||
boolean wantsPostInit();
|
||||
void preInit();
|
||||
void init();
|
||||
void postInit();
|
||||
String getName();
|
||||
void tickStart();
|
||||
void tickEnd();
|
||||
boolean matches(Object mod);
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package fml.ml;
|
||||
|
||||
import fml.Loader;
|
||||
import fml.LoaderException;
|
||||
import fml.ModContainer;
|
||||
import fml.obf.FMLHandler;
|
||||
import net.minecraft.src.BaseMod;
|
||||
|
||||
public class ModLoaderModContainer implements ModContainer {
|
||||
private Class<? extends BaseMod> modClazz;
|
||||
private BaseMod mod;
|
||||
private boolean isTicking;
|
||||
public ModLoaderModContainer(Class<? extends BaseMod> modClazz) {
|
||||
this.modClazz=modClazz;
|
||||
}
|
||||
|
||||
public boolean wantsPreInit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean wantsPostInit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
try {
|
||||
mod=modClazz.newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new LoaderException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
mod.load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
mod.modsLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickStart() {
|
||||
if (isTicking) {
|
||||
isTicking=mod.onTickInGame(FMLHandler.INSTANCE.getServer());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void tickEnd() {
|
||||
// NOOP for modloader
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return mod!=null?mod.getName():null;
|
||||
}
|
||||
|
||||
public static ModContainer findContainerFor(BaseMod mod) {
|
||||
for (ModContainer mc :Loader.getModList()) {
|
||||
if (mc.matches(mod)) {
|
||||
return mc;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Object mod) {
|
||||
return modClazz.isInstance(mod);
|
||||
}
|
||||
|
||||
public void setTicking(boolean enable) {
|
||||
isTicking=enable;
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package fml.obf;
|
||||
|
||||
import fml.FMLHooks;
|
||||
import fml.Loader;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
public enum FMLHandler {
|
||||
INSTANCE;
|
||||
private MinecraftServer server;
|
||||
|
||||
public void onPreLoad(MinecraftServer minecraftServer) {
|
||||
INSTANCE.server=minecraftServer;
|
||||
Loader.INSTANCE.loadMods();
|
||||
}
|
||||
|
||||
public void onLoadComplete() {
|
||||
Loader.INSTANCE.initializeMods();
|
||||
}
|
||||
|
||||
public void onPreTick() {
|
||||
FMLHooks.INSTANCE.serverTickStart();
|
||||
}
|
||||
|
||||
public void onPostTick() {
|
||||
FMLHooks.INSTANCE.serverTickEnd();
|
||||
}
|
||||
|
||||
public MinecraftServer getServer() {
|
||||
return server;
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import fml.Mod;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.IInventory;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.Packet250CustomPayload;
|
||||
import net.minecraft.src.World;
|
||||
|
||||
public abstract class BaseMod {
|
||||
int addFuel(int id, int metadata) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean dispenseEntity(World world, double x, double y, double z, int xVel, int zVel, ItemStack item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void generateNether(World world, Random random, int chunkX, int chunkZ) {
|
||||
}
|
||||
|
||||
public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
|
||||
}
|
||||
|
||||
public String getName() { return ""; }
|
||||
|
||||
public String getPriorities() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract String getVersion();
|
||||
|
||||
public abstract void load();
|
||||
|
||||
public void modsLoaded() {
|
||||
}
|
||||
|
||||
public void onItemPickup(EntityPlayer player, ItemStack item) {
|
||||
}
|
||||
|
||||
// boolean onTickInGame(float tick, Minecraft game);
|
||||
public boolean onTickInGame(MinecraftServer minecraftServer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void receiveChatPacket(String text) {
|
||||
}
|
||||
|
||||
public void receiveCustomPacket(Packet250CustomPayload packet) {
|
||||
}
|
||||
|
||||
public void takenFromCrafting(EntityPlayer player, ItemStack item, IInventory matrix) {
|
||||
}
|
||||
|
||||
public void takenFromFurnace(EntityPlayer player, ItemStack item) {
|
||||
|
||||
}
|
||||
|
||||
// void addRenderer(Map<Class<? extends Entity>, Render> renderers);
|
||||
// void registerAnimation(Minecraft game);
|
||||
// void renderInvBlock(RenderBlocks renderer, Block block, int metadata, int modelID);
|
||||
// boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelID);
|
||||
// boolean onTickInGUI(float tick, Minecraft game, GuiScreen gui);
|
||||
// void keyboardEvent(KeyBinding event);
|
||||
}
|
||||
@@ -1,212 +0,0 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import fml.CommonRegistry;
|
||||
import fml.Loader;
|
||||
import fml.ml.ModLoaderModContainer;
|
||||
|
||||
import net.minecraft.src.Achievement;
|
||||
import net.minecraft.src.BiomeGenBase;
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.Entity;
|
||||
import net.minecraft.src.EntityLiving;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.EnumCreatureType;
|
||||
import net.minecraft.src.IChunkProvider;
|
||||
import net.minecraft.src.IInventory;
|
||||
import net.minecraft.src.ItemBlock;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.Packet250CustomPayload;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
|
||||
public class ModLoader {
|
||||
static void addAchievementDesc(Achievement achievement, String name, String description) {
|
||||
}
|
||||
|
||||
static int addAllFuel(int id, int metadata) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int addArmor(String armor) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void addBiome(BiomeGenBase biome) {
|
||||
}
|
||||
|
||||
static void addLocalization(String key, String value) {
|
||||
}
|
||||
|
||||
static void addLocalization(String key, String lang, String value) {
|
||||
}
|
||||
|
||||
static void addName(Object instance, String name) {
|
||||
}
|
||||
|
||||
static void addName(Object instance, String lang, String name) {
|
||||
}
|
||||
|
||||
static int addOverride(String fileToOverride, String fileToAdd) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void addOverride(String path, String overlayPath, int index) {
|
||||
}
|
||||
|
||||
static void addRecipe(ItemStack output, Object... params) {
|
||||
}
|
||||
|
||||
static void addShapelessRecipe(ItemStack output, Object... params) {
|
||||
}
|
||||
|
||||
static void addSmelting(int input, ItemStack output) {
|
||||
}
|
||||
|
||||
static void addSpawn(Class<? extends EntityLiving> entityClass, int weightedProb, int min, int max, EnumCreatureType spawnList) {
|
||||
}
|
||||
|
||||
static void addSpawn(Class<? extends EntityLiving> entityClass, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeGenBase... biomes) {
|
||||
}
|
||||
|
||||
static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList) {
|
||||
}
|
||||
|
||||
static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeGenBase... biomes) {
|
||||
}
|
||||
|
||||
static boolean dispenseEntity(World world, double x, double y, double z, int xVel, int zVel, ItemStack item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static void genericContainerRemoval(World world, int x, int y, int z) {
|
||||
}
|
||||
|
||||
static List<BaseMod> getLoadedMods() {
|
||||
return null;
|
||||
}
|
||||
|
||||
static Logger getLogger() {
|
||||
return null;
|
||||
}
|
||||
|
||||
static <T, E> T getPrivateValue(Class<? super E> instanceclass, E instance, int fieldindex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
static <T, E> T getPrivateValue(Class<? super E> instanceclass, E instance, String field) {
|
||||
return null;
|
||||
}
|
||||
|
||||
static int getUniqueBlockModelID(BaseMod mod, boolean full3DItem) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int getUniqueEntityId() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int getUniqueSpriteIndex(String path) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static boolean isModLoaded(String modname) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static void loadConfig() {
|
||||
}
|
||||
|
||||
static void onItemPickup(EntityPlayer player, ItemStack item) {
|
||||
}
|
||||
|
||||
static void populateChunk(IChunkProvider generator, int chunkX, int chunkZ, World world) {
|
||||
}
|
||||
|
||||
static void receivePacket(Packet250CustomPayload packet) {
|
||||
}
|
||||
|
||||
static void registerBlock(Block block) {
|
||||
CommonRegistry.registerBlock(block);
|
||||
}
|
||||
|
||||
static void registerBlock(Block block, Class<? extends ItemBlock> itemclass) {
|
||||
CommonRegistry.registerBlock(block, itemclass);
|
||||
}
|
||||
|
||||
static void registerEntityID(Class<? extends Entity> entityClass, String entityName, int id) {
|
||||
CommonRegistry.registerEntityID(entityClass, entityName, id);
|
||||
}
|
||||
|
||||
static void registerEntityID(Class<? extends Entity> entityClass, String entityName, int id, int background, int foreground) {
|
||||
CommonRegistry.registerEntityID(entityClass, entityName, id, background, foreground);
|
||||
}
|
||||
|
||||
static void registerPacketChannel(BaseMod mod, String channel) {
|
||||
}
|
||||
|
||||
static void registerTileEntity(Class<? extends TileEntity> tileEntityClass, String id) {
|
||||
CommonRegistry.registerTileEntity(tileEntityClass, id);
|
||||
}
|
||||
|
||||
static void removeBiome(BiomeGenBase biome) {
|
||||
CommonRegistry.removeBiome(biome);
|
||||
}
|
||||
|
||||
static void removeSpawn(Class<? extends EntityLiving> entityClass, EnumCreatureType spawnList) {
|
||||
CommonRegistry.removeSpawn(entityClass, spawnList);
|
||||
}
|
||||
|
||||
static void removeSpawn(Class<? extends EntityLiving> entityClass, EnumCreatureType spawnList, BiomeGenBase... biomes) {
|
||||
CommonRegistry.removeSpawn(entityClass, spawnList, biomes);
|
||||
}
|
||||
|
||||
static void removeSpawn(String entityName, EnumCreatureType spawnList) {
|
||||
CommonRegistry.removeSpawn(entityName, spawnList);
|
||||
}
|
||||
|
||||
static void removeSpawn(String entityName, EnumCreatureType spawnList, BiomeGenBase... biomes) {
|
||||
CommonRegistry.removeSpawn(entityName, spawnList, biomes);
|
||||
}
|
||||
|
||||
static void saveConfig() {
|
||||
}
|
||||
|
||||
static void serverChat(String text) {
|
||||
}
|
||||
|
||||
static void setInGameHook(BaseMod mod, boolean enable, boolean useClock) {
|
||||
ModLoaderModContainer mlmc=(ModLoaderModContainer) ModLoaderModContainer.findContainerFor(mod);
|
||||
mlmc.setTicking(enable);
|
||||
}
|
||||
|
||||
static <T, E> void setPrivateValue(Class<? super T> instanceclass, T instance, int fieldindex, E value) {
|
||||
}
|
||||
|
||||
static <T, E> void setPrivateValue(Class<? super T> instanceclass, T instance, String field, E value) {
|
||||
}
|
||||
|
||||
static void takenFromCrafting(EntityPlayer player, ItemStack item, IInventory matrix) {
|
||||
}
|
||||
|
||||
static void takenFromFurnace(EntityPlayer player, ItemStack item) {
|
||||
}
|
||||
|
||||
static void throwException(String message, Throwable e) {
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user