Add licenses reorganize code

This commit is contained in:
Christian Weeks committed 2012-03-30 10:11:13 -04:00
1 parent 3197817a76
commit bdce70e891
21 files changed
+835 -137

No files matched your search

+13
View File
@@ -1,3 +1,16 @@
/*
* The FML Forge ModLoader 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;
+30
View File
@@ -0,0 +1,30 @@
/*
* The FML Forge ModLoader 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();
}
}
}
+85
View File
@@ -0,0 +1,85 @@
/*
* The FML Forge ModLoader 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,4 +1,17 @@
package fml.server;
/*
* The FML Forge ModLoader 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;
@@ -19,9 +32,10 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import net.minecraft.src.BaseMod;
import fml.Mod;
import fml.ml.ModLoaderModContainer;
public class Loader {
public enum Loader {
INSTANCE;
private enum State {
NOINIT, LOADING, PREINIT, INIT, POSTINIT, UP, ERRORED
};
@@ -38,8 +52,6 @@ public class Loader {
private static Pattern zipJar = Pattern.compile("([^\\s]+).(zip|jar)$");
private static Pattern modClass = Pattern.compile("(.*/)(mod\\_[^\\s]+).class$");
public static Loader instance;
public static void run() {
LOG.setLevel(Level.ALL);
FileHandler fileHandler;
@@ -52,20 +64,9 @@ public class Loader {
} catch (Exception e) {
// Whatever - give up
}
instance = new Loader();
}
private Loader() {
mods = new ArrayList<ModContainer>();
state = State.NOINIT;
load();
sortModList();
preModInit();
modInit();
postModInit();
state = State.UP;
// Make mod list immutable
mods=Collections.unmodifiableList(mods);
}
private void sortModList() {
@@ -229,4 +230,20 @@ public class Loader {
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;
}
}
+28
View File
@@ -0,0 +1,28 @@
/*
* The FML Forge ModLoader 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() {
}
}
+13
View File
@@ -1,3 +1,16 @@
/*
* The FML Forge ModLoader 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;
+31
View File
@@ -0,0 +1,31 @@
/*
* The FML Forge ModLoader 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);
}
}
+26
View File
@@ -0,0 +1,26 @@
/*
* The FML Forge ModLoader 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,5 +1,22 @@
package fml.server;
/*
* The FML Forge ModLoader 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 {
@@ -38,13 +55,13 @@ public class ModLoaderModContainer implements ModContainer {
}
@Override
public void tickStart(float tickTime) {
public void tickStart() {
if (isTicking) {
isTicking=mod.onTickInGame(tickTime);
isTicking=mod.onTickInGame(FMLHandler.INSTANCE.getServer());
}
}
@Override
public void tickEnd(float tickTime) {
public void tickEnd() {
// NOOP for modloader
}
+44
View File
@@ -0,0 +1,44 @@
/*
* The FML Forge ModLoader 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;
}
}
-16
View File
@@ -1,16 +0,0 @@
package fml.server;
public enum FMLHooks {
INSTANCE;
public void worldTickStart(float tickTime) {
for (ModContainer mod : Loader.getModList()) {
mod.tickStart(tickTime);
}
}
public void worldTickEnd(float tickTime) {
for (ModContainer mod : Loader.getModList()) {
mod.tickEnd(tickTime);
}
}
}
-50
View File
@@ -1,50 +0,0 @@
package fml.server;
import fml.Mod;
public class FMLModContainer implements ModContainer {
private Mod modDescriptor;
private
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);
}
}
-15
View File
@@ -1,15 +0,0 @@
package fml.server;
class LoaderException extends RuntimeException {
/**
*
*/
private static final long serialVersionUID = -5675297950958861378L;
public LoaderException(Exception wrapped) {
super(wrapped);
}
public LoaderException() {
}
}
-18
View File
@@ -1,18 +0,0 @@
package fml.server;
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);
}
}
-13
View File
@@ -1,13 +0,0 @@
package fml.server;
public interface ModContainer {
boolean wantsPreInit();
boolean wantsPostInit();
void preInit();
void init();
void postInit();
String getName();
void tickStart(float tickTime);
void tickEnd(float tickTime);
boolean matches(Object mod);
}
+15 -1
View File
@@ -1,9 +1,23 @@
/*
* The FML Forge ModLoader 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;
@@ -42,7 +56,7 @@ public abstract class BaseMod {
}
// boolean onTickInGame(float tick, Minecraft game);
public boolean onTickInGame(float tick) {
public boolean onTickInGame(MinecraftServer minecraftServer) {
return false;
}
+15 -2
View File
@@ -1,11 +1,24 @@
/*
* The FML Forge ModLoader 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.server.Loader;
import fml.server.ModLoaderModContainer;
import fml.Loader;
import fml.ml.ModLoaderModContainer;
import net.minecraft.src.Achievement;
import net.minecraft.src.BiomeGenBase;