Bunch of hooks re-added : network is more complete now, lot of basemod cleanup, moving stuff into
the registry area
This commit is contained in:
parent
12927291a7
commit
f4b9055171
42 changed files with 539 additions and 487 deletions
|
@ -75,7 +75,6 @@ import net.minecraft.src.RenderBlocks;
|
|||
import net.minecraft.src.RenderEngine;
|
||||
import net.minecraft.src.RenderManager;
|
||||
import net.minecraft.src.RenderPlayer;
|
||||
import net.minecraft.src.SidedProxy;
|
||||
import net.minecraft.src.StringTranslate;
|
||||
import net.minecraft.src.TextureFX;
|
||||
import net.minecraft.src.TexturePackBase;
|
||||
|
@ -99,6 +98,7 @@ import cpw.mods.fml.common.ModMetadata;
|
|||
import cpw.mods.fml.common.ProxyInjector;
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import cpw.mods.fml.common.Side;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import cpw.mods.fml.common.modloader.ModLoaderHelper;
|
||||
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
|
||||
|
@ -274,14 +274,6 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
return INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the minecraft instance
|
||||
*/
|
||||
@Override
|
||||
public Object getMinecraftInstance()
|
||||
{
|
||||
return client;
|
||||
}
|
||||
/**
|
||||
* @param player
|
||||
* @param gui
|
||||
|
@ -303,20 +295,6 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
client.field_71424_I.func_76319_b();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.IFMLSidedHandler#getModLoaderPropertyFor(java.lang.reflect.Field)
|
||||
*/
|
||||
@Override
|
||||
public ModProperty getModLoaderPropertyFor(Field f)
|
||||
{
|
||||
if (f.isAnnotationPresent(MLProp.class))
|
||||
{
|
||||
MLProp prop = f.getAnnotation(MLProp.class);
|
||||
return new ModProperty(prop.info(), prop.min(), prop.max(), prop.name());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mods
|
||||
*/
|
||||
|
@ -344,38 +322,6 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
return Side.CLIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProxyInjector findSidedProxyOn(cpw.mods.fml.common.modloader.BaseMod mod)
|
||||
{
|
||||
for (Field f : mod.getClass().getDeclaredFields())
|
||||
{
|
||||
if (f.isAnnotationPresent(SidedProxy.class))
|
||||
{
|
||||
SidedProxy sp = f.getAnnotation(SidedProxy.class);
|
||||
return new ProxyInjector(sp.clientSide(), sp.serverSide(), sp.bukkitSide(), f);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentLanguage()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Properties getCurrentLanguageTable()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObjectName(Object minecraftObject)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasOptifine()
|
||||
{
|
||||
return optifineContainer!=null;
|
||||
|
|
|
@ -26,22 +26,13 @@ import cpw.mods.fml.common.IPlayerTracker;
|
|||
import cpw.mods.fml.common.IWorldGenerator;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
|
||||
public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
|
||||
public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseModProxy
|
||||
{
|
||||
// CALLBACK MECHANISMS
|
||||
|
||||
public void keyBindingEvent(Object keybinding)
|
||||
public final boolean doTickInGame(TickType tick, boolean tickEnd, Object... data)
|
||||
{
|
||||
this.keyboardEvent((KeyBinding)keybinding);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param minecraftInstance
|
||||
* @return
|
||||
*/
|
||||
public final boolean doTickInGame(TickType tick, boolean tickEnd, Object minecraftInstance, Object... data)
|
||||
{
|
||||
Minecraft mc = (Minecraft) minecraftInstance;
|
||||
Minecraft mc = FMLClientHandler.instance().getClient();
|
||||
boolean hasWorld = true;
|
||||
// World and render ticks
|
||||
if (tickEnd && ( tick==TickType.RENDER || tick==TickType.GAME ) && hasWorld) {
|
||||
|
@ -50,9 +41,9 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
|
|||
return true;
|
||||
}
|
||||
|
||||
public final boolean doTickInGUI(TickType tick, boolean tickEnd, Object minecraftInstance, Object... data)
|
||||
public final boolean doTickInGUI(TickType tick, boolean tickEnd, Object... data)
|
||||
{
|
||||
Minecraft mc = (Minecraft) minecraftInstance;
|
||||
Minecraft mc = FMLClientHandler.instance().getClient();
|
||||
if (tickEnd && ( tick==TickType.RENDER || tick==TickType.GAME ) || tick == TickType.GUILOAD) {
|
||||
return onTickInGUI((Float) data[0], mc, mc.field_71462_r);
|
||||
}
|
||||
|
@ -60,17 +51,22 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
|
|||
}
|
||||
|
||||
/**
|
||||
* @param minecraftInstance
|
||||
* @return
|
||||
*//*
|
||||
|
||||
*//**
|
||||
* @param renderers
|
||||
*/
|
||||
*//*
|
||||
public final void onRenderHarvest(Map renderers)
|
||||
{
|
||||
addRenderer((Map<Class<? extends Entity>,Render>)renderers);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*//**
|
||||
*
|
||||
*/
|
||||
*//*
|
||||
public final void onRegisterAnimations()
|
||||
{
|
||||
registerAnimation(FMLClientHandler.instance().getClient());
|
||||
|
@ -159,15 +155,16 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*//**
|
||||
* NO-OP on client side
|
||||
*/
|
||||
*//*
|
||||
@Override
|
||||
public final boolean handleCommand(String command, Object... data)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// BASEMOD API
|
||||
|
||||
*/ // BASEMOD API
|
||||
/**
|
||||
* Override if you wish to provide a fuel item for the furnace and return the fuel value of the item
|
||||
*
|
||||
|
|
|
@ -23,6 +23,7 @@ import cpw.mods.fml.client.BlockRenderManager;
|
|||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.client.TextureFXManager;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -35,17 +36,17 @@ public class FMLRenderAccessLibrary
|
|||
{
|
||||
public static Logger getLogger()
|
||||
{
|
||||
return FMLCommonHandler.instance().getFMLLogger();
|
||||
return FMLLog.getLogger();
|
||||
}
|
||||
|
||||
public static void log(Level level, String message)
|
||||
{
|
||||
getLogger().log(level, message);
|
||||
FMLLog.log(level, message);
|
||||
}
|
||||
|
||||
public static void log(Level level, String message, Throwable throwable)
|
||||
{
|
||||
getLogger().log(level, message, throwable);
|
||||
FMLLog.log(level, throwable, message);
|
||||
}
|
||||
|
||||
public static void setTextureDimensions(int textureId, int width, int height, List<TextureFX> textureFXList)
|
||||
|
|
|
@ -40,6 +40,7 @@ import cpw.mods.fml.common.network.NetworkRegistry;
|
|||
import cpw.mods.fml.common.network.Player;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
|
||||
public class ModLoader
|
||||
|
@ -128,7 +129,7 @@ public class ModLoader
|
|||
*/
|
||||
public static void addLocalization(String key, String lang, String value)
|
||||
{
|
||||
FMLCommonHandler.instance().addStringLocalization(key, lang, value);
|
||||
LanguageRegistry.instance().addStringLocalization(key, lang, value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -151,7 +152,7 @@ public class ModLoader
|
|||
*/
|
||||
public static void addName(Object instance, String lang, String name)
|
||||
{
|
||||
FMLCommonHandler.instance().addNameForObject(instance, lang, name);
|
||||
LanguageRegistry.instance().addNameForObject(instance, lang, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,12 +29,6 @@ public class DummyModContainer implements ModContainer
|
|||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProxyInjector findSidedProxy()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArtifactVersion> getDependants()
|
||||
{
|
||||
|
|
|
@ -72,8 +72,6 @@ public class FMLCommonHandler
|
|||
|
||||
private int uniqueEntityListId = 220;
|
||||
|
||||
private Map<String,Properties> modLanguageData=new HashMap<String,Properties>();
|
||||
|
||||
private List<IScheduledTickHandler> scheduledTicks = new ArrayList<IScheduledTickHandler>();
|
||||
|
||||
public void beginLoading(IFMLSidedHandler handler)
|
||||
|
@ -164,28 +162,6 @@ public class FMLCommonHandler
|
|||
return FMLLog.getLogger();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the minecraft logger (goes to the server log file)
|
||||
* @return
|
||||
*/
|
||||
public Logger getMinecraftLogger()
|
||||
{
|
||||
if (sidedDelegate == null)
|
||||
{
|
||||
throw new RuntimeException("sidedDelegate null when attempting to getMinecraftLogger, this is generally caused by you not installing FML properly, " +
|
||||
"or installing some other mod that edits Minecraft.class on top of FML such as ModLoader, do not do this. Reinstall FML properly and try again.");
|
||||
}
|
||||
return sidedDelegate.getMinecraftLogger();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public Object getMinecraftInstance()
|
||||
{
|
||||
return sidedDelegate.getMinecraftInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
|
@ -199,34 +175,10 @@ public class FMLCommonHandler
|
|||
* @param lang
|
||||
* @param value
|
||||
*/
|
||||
public void addStringLocalization(String key, String lang, String value)
|
||||
{
|
||||
Properties langPack=modLanguageData.get(lang);
|
||||
if (langPack==null) {
|
||||
langPack=new Properties();
|
||||
modLanguageData.put(lang, langPack);
|
||||
}
|
||||
langPack.put(key,value);
|
||||
|
||||
handleLanguageLoad(sidedDelegate.getCurrentLanguageTable(), lang);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param languagePack
|
||||
* @param lang
|
||||
*/
|
||||
public void handleLanguageLoad(Properties languagePack, String lang)
|
||||
{
|
||||
Properties usPack=modLanguageData.get("en_US");
|
||||
if (usPack!=null) {
|
||||
languagePack.putAll(usPack);
|
||||
}
|
||||
Properties langPack=modLanguageData.get(lang);
|
||||
if (langPack==null) {
|
||||
return;
|
||||
}
|
||||
languagePack.putAll(langPack);
|
||||
}
|
||||
|
||||
public Side getSide()
|
||||
{
|
||||
|
@ -238,25 +190,6 @@ public class FMLCommonHandler
|
|||
auxilliaryContainers.add(ticker);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from the furnace to lookup fuel values
|
||||
*
|
||||
* @param itemId
|
||||
* @param itemDamage
|
||||
* @return
|
||||
*/
|
||||
public int fuelLookup(int itemId, int itemDamage)
|
||||
{
|
||||
int fv = 0;
|
||||
return fv;
|
||||
}
|
||||
|
||||
public void addNameForObject(Object minecraftObject, String lang, String name) {
|
||||
String label=sidedDelegate.getObjectName(minecraftObject);
|
||||
addStringLocalization(label, lang, name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Raise an exception
|
||||
*
|
||||
|
@ -348,18 +281,6 @@ public class FMLCommonHandler
|
|||
return sidedDelegate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mod
|
||||
*/
|
||||
public void injectSidedProxyDelegate(ModContainer mod)
|
||||
{
|
||||
ProxyInjector injector = mod.findSidedProxy();
|
||||
if (injector != null)
|
||||
{
|
||||
injector.inject(mod, sidedDelegate.getSide());
|
||||
}
|
||||
}
|
||||
|
||||
public void handleWorldGeneration(int chunkX, int chunkZ, long worldSeed, Object... data)
|
||||
{
|
||||
GameRegistry.generateWorld(chunkX, chunkZ, worldSeed, data);
|
||||
|
|
|
@ -186,13 +186,6 @@ public class FMLModContainer implements ModContainer
|
|||
return modInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProxyInjector findSidedProxy()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean registerBus(EventBus bus, LoadController controller)
|
||||
{
|
||||
|
|
|
@ -13,28 +13,31 @@
|
|||
*/
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.IInventory;
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
/**
|
||||
* Return a crafting handler for the mod container to call
|
||||
*
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public interface ICraftingHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* The object array contains these three arguments
|
||||
*
|
||||
*
|
||||
* @param player
|
||||
* @param craftedItem
|
||||
* @param craftingGrid
|
||||
*/
|
||||
void onCrafting(Object... craftingParameters);
|
||||
void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix);
|
||||
|
||||
/**
|
||||
* The object array contains these two arguments
|
||||
* @param player
|
||||
* @param smeltedItem
|
||||
*/
|
||||
void onSmelting(Object... smeltingParameters);
|
||||
void onSmelting(EntityPlayer player, ItemStack item);
|
||||
}
|
||||
|
|
|
@ -7,32 +7,17 @@ import java.util.List;
|
|||
import java.util.Properties;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import cpw.mods.fml.common.modloader.BaseMod;
|
||||
import cpw.mods.fml.common.modloader.ModProperty;
|
||||
|
||||
public interface IFMLSidedHandler
|
||||
{
|
||||
Logger getMinecraftLogger();
|
||||
|
||||
Object getMinecraftInstance();
|
||||
|
||||
String getCurrentLanguage();
|
||||
|
||||
Properties getCurrentLanguageTable();
|
||||
|
||||
String getObjectName(Object minecraftObject);
|
||||
|
||||
void profileStart(String profileLabel);
|
||||
|
||||
void profileEnd();
|
||||
|
||||
ModProperty getModLoaderPropertyFor(Field f);
|
||||
|
||||
List<String> getAdditionalBrandingInformation();
|
||||
|
||||
Side getSide();
|
||||
|
||||
ProxyInjector findSidedProxyOn(BaseMod mod);
|
||||
|
||||
void haltGame(String message, Throwable exception);
|
||||
}
|
||||
|
|
8
fml/common/cpw/mods/fml/common/IFuelHandler.java
Normal file
8
fml/common/cpw/mods/fml/common/IFuelHandler.java
Normal file
|
@ -0,0 +1,8 @@
|
|||
package cpw.mods.fml.common;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public interface IFuelHandler
|
||||
{
|
||||
int getBurnTime(ItemStack fuel);
|
||||
}
|
|
@ -92,11 +92,6 @@ public class InjectedModContainer implements ModContainer
|
|||
return wrappedContainer.getProcessedVersion();
|
||||
}
|
||||
|
||||
public ProxyInjector findSidedProxy()
|
||||
{
|
||||
return wrappedContainer.findSidedProxy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNetworkMod()
|
||||
{
|
||||
|
|
|
@ -246,7 +246,7 @@ public class Loader
|
|||
*
|
||||
* If they provide the {@link Mod} annotation, they will be loaded as
|
||||
* "FML mods", which currently is effectively a NO-OP. If they are
|
||||
* determined to be {@link BaseMod} subclasses they are loaded as such.
|
||||
* determined to be {@link BaseModProxy} subclasses they are loaded as such.
|
||||
*
|
||||
* Finally, if they are successfully loaded as classes, they are then added
|
||||
* to the available mod list.
|
||||
|
|
|
@ -147,8 +147,6 @@ public interface ModContainer
|
|||
|
||||
ArtifactVersion getProcessedVersion();
|
||||
|
||||
ProxyInjector findSidedProxy();
|
||||
|
||||
boolean isImmutable();
|
||||
|
||||
boolean isNetworkMod();
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraft.src;
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
|
@ -32,15 +32,15 @@ public @interface SidedProxy
|
|||
* @return
|
||||
*/
|
||||
String clientSide() default "";
|
||||
|
||||
|
||||
/**
|
||||
* The name of the server side class to load and populate
|
||||
* @return
|
||||
*/
|
||||
String serverSide() default "";
|
||||
|
||||
|
||||
/**
|
||||
* The name of the a special bukkit plugin class to load and populate
|
||||
* The name of a special bukkit plugin class to load and populate
|
||||
*/
|
||||
String bukkitSide() default "";
|
||||
}
|
|
@ -15,6 +15,12 @@
|
|||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.IInventory;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.World;
|
||||
|
||||
import cpw.mods.fml.common.IConsoleHandler;
|
||||
import cpw.mods.fml.common.ICraftingHandler;
|
||||
|
@ -32,9 +38,8 @@ import cpw.mods.fml.common.TickType;
|
|||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public interface BaseMod extends IWorldGenerator, IPickupNotifier, IDispenseHandler, ICraftingHandler, INetworkHandler, IConsoleHandler, IPlayerTracker
|
||||
public interface BaseModProxy
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -45,16 +50,6 @@ public interface BaseMod extends IWorldGenerator, IPickupNotifier, IDispenseHand
|
|||
*/
|
||||
void load();
|
||||
|
||||
/**
|
||||
* @param tick
|
||||
* @param b
|
||||
* @param minecraftInstance
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
boolean doTickInGame(TickType tick, boolean b, Object minecraftInstance, Object... data);
|
||||
|
||||
boolean doTickInGUI(TickType tick, boolean b, Object minecraftInstance, Object... data);
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
|
@ -65,27 +60,16 @@ public interface BaseMod extends IWorldGenerator, IPickupNotifier, IDispenseHand
|
|||
*/
|
||||
String getPriorities();
|
||||
|
||||
/**
|
||||
* @param itemId
|
||||
* @param itemDamage
|
||||
* @return
|
||||
*/
|
||||
int addFuel(int itemId, int itemDamage);
|
||||
|
||||
/**
|
||||
* @param renderers
|
||||
*/
|
||||
void onRenderHarvest(Map renderers);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void onRegisterAnimations();
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
String getVersion();
|
||||
|
||||
void keyBindingEvent(Object keybinding);
|
||||
boolean doTickInGUI(TickType type, boolean end, Object... tickData);
|
||||
boolean doTickInGame(TickType type, boolean end, Object... tickData);
|
||||
void generateSurface(World w, Random random, int i, int j);
|
||||
void generateNether(World w, Random random, int i, int j);
|
||||
int addFuel(int itemId, int damage);
|
||||
void takenFromCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix);
|
||||
void takenFromFurnace(EntityPlayer player, ItemStack item);
|
||||
}
|
|
@ -27,13 +27,13 @@ import cpw.mods.fml.common.TickType;
|
|||
public class BaseModTicker implements ITickHandler
|
||||
{
|
||||
|
||||
private BaseMod mod;
|
||||
private BaseModProxy mod;
|
||||
private EnumSet<TickType> ticks;
|
||||
private boolean clockTickTrigger;
|
||||
private boolean sendGuiTicks;
|
||||
|
||||
|
||||
BaseModTicker(BaseMod mod, boolean guiTicker)
|
||||
BaseModTicker(BaseModProxy mod, boolean guiTicker)
|
||||
{
|
||||
this.mod = mod;
|
||||
this.ticks = EnumSet.of(TickType.WORLDLOAD);
|
||||
|
@ -97,11 +97,11 @@ public class BaseModTicker implements ITickHandler
|
|||
boolean keepTicking=true;
|
||||
if (sendGuiTicks)
|
||||
{
|
||||
keepTicking = mod.doTickInGUI(type, end, FMLCommonHandler.instance().getMinecraftInstance(), tickData);
|
||||
keepTicking = mod.doTickInGUI(type, end, tickData);
|
||||
}
|
||||
else
|
||||
{
|
||||
keepTicking = mod.doTickInGame(type, end, FMLCommonHandler.instance().getMinecraftInstance(), tickData);
|
||||
keepTicking = mod.doTickInGame(type, end, tickData);
|
||||
}
|
||||
if (!keepTicking) {
|
||||
ticks.remove(type);
|
||||
|
@ -125,7 +125,7 @@ public class BaseModTicker implements ITickHandler
|
|||
/**
|
||||
* @param mod2
|
||||
*/
|
||||
public void setMod(BaseMod mod)
|
||||
public void setMod(BaseModProxy mod)
|
||||
{
|
||||
this.mod = mod;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import net.minecraft.src.NetHandler;
|
||||
import net.minecraft.src.NetworkManager;
|
||||
import cpw.mods.fml.common.network.IConnectionHandler;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
|
||||
public class ModLoaderConnectionHandler implements IConnectionHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public void playerLoggedIn(Player player, NetHandler netHandler, NetworkManager manager)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.IInventory;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import cpw.mods.fml.common.ICraftingHandler;
|
||||
|
||||
public class ModLoaderCraftingHelper implements ICraftingHandler
|
||||
{
|
||||
|
||||
private BaseModProxy mod;
|
||||
|
||||
public ModLoaderCraftingHelper(BaseModProxy mod)
|
||||
{
|
||||
this.mod = mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix)
|
||||
{
|
||||
mod.takenFromCrafting(player, item, craftMatrix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSmelting(EntityPlayer player, ItemStack item)
|
||||
{
|
||||
mod.takenFromFurnace(player, item);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import net.minecraft.src.ItemStack;
|
||||
import cpw.mods.fml.common.IFuelHandler;
|
||||
|
||||
public class ModLoaderFuelHelper implements IFuelHandler
|
||||
{
|
||||
|
||||
private BaseModProxy mod;
|
||||
|
||||
public ModLoaderFuelHelper(BaseModProxy mod)
|
||||
{
|
||||
this.mod = mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBurnTime(ItemStack fuel)
|
||||
{
|
||||
return mod.addFuel(fuel.field_77993_c, fuel.field_77993_c);
|
||||
}
|
||||
|
||||
}
|
|
@ -17,10 +17,14 @@ package cpw.mods.fml.common.modloader;
|
|||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.src.BaseMod;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.ICraftingHandler;
|
||||
import cpw.mods.fml.common.IFuelHandler;
|
||||
import cpw.mods.fml.common.IWorldGenerator;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import cpw.mods.fml.common.network.IPacketHandler;
|
||||
|
@ -111,6 +115,21 @@ public class ModLoaderHelper
|
|||
|
||||
public static IPacketHandler buildPacketHandlerFor(BaseMod mod)
|
||||
{
|
||||
return null;
|
||||
return new ModLoaderPacketHandler(mod);
|
||||
}
|
||||
|
||||
public static IWorldGenerator buildWorldGenHelper(BaseModProxy mod)
|
||||
{
|
||||
return new ModLoaderWorldGenerator(mod);
|
||||
}
|
||||
|
||||
public static IFuelHandler buildFuelHelper(BaseModProxy mod)
|
||||
{
|
||||
return new ModLoaderFuelHelper(mod);
|
||||
}
|
||||
|
||||
public static ICraftingHandler buildCraftingHelper(BaseModProxy mod)
|
||||
{
|
||||
return new ModLoaderCraftingHelper(mod);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,9 +31,12 @@ import java.util.Map;
|
|||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraft.src.MLProp;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
|
||||
|
@ -54,6 +57,8 @@ import cpw.mods.fml.common.LoaderState;
|
|||
import cpw.mods.fml.common.ModClassLoader;
|
||||
import cpw.mods.fml.common.LoaderState.ModState;
|
||||
import cpw.mods.fml.common.MetadataCollection;
|
||||
import cpw.mods.fml.common.discovery.ASMDataTable;
|
||||
import cpw.mods.fml.common.discovery.ASMDataTable.ASMData;
|
||||
import cpw.mods.fml.common.discovery.ContainerType;
|
||||
import cpw.mods.fml.common.event.FMLConstructionEvent;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
|
@ -73,7 +78,7 @@ import cpw.mods.fml.common.TickType;
|
|||
public class ModLoaderModContainer implements ModContainer
|
||||
{
|
||||
private static final ProxyInjector NULLPROXY = new ProxyInjector("","","",null);
|
||||
public BaseMod mod;
|
||||
public BaseModProxy mod;
|
||||
private File modSource;
|
||||
public List<ArtifactVersion> requirements = Lists.newArrayList();
|
||||
public ArrayList<ArtifactVersion> dependencies = Lists.newArrayList();
|
||||
|
@ -104,8 +109,7 @@ public class ModLoaderModContainer implements ModContainer
|
|||
* We only instantiate this for "not mod mods"
|
||||
* @param instance
|
||||
*/
|
||||
ModLoaderModContainer(BaseMod instance) {
|
||||
FMLCommonHandler.instance().addAuxilliaryModContainer(this);
|
||||
ModLoaderModContainer(BaseModProxy instance) {
|
||||
this.mod=instance;
|
||||
this.gameTickHandler = new BaseModTicker(instance, false);
|
||||
this.guiTickHandler = new BaseModTicker(instance, true);
|
||||
|
@ -114,9 +118,8 @@ public class ModLoaderModContainer implements ModContainer
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private void configureMod(Class<? extends BaseMod> modClazz)
|
||||
private void configureMod(Class<? extends BaseModProxy> modClazz, ASMDataTable asmData)
|
||||
{
|
||||
IFMLSidedHandler sideHandler = FMLCommonHandler.instance().getSidedDelegate();
|
||||
File configDir = Loader.instance().getConfigDir();
|
||||
File modConfig = new File(configDir, String.format("%s.cfg", modClazzName));
|
||||
Properties props = new Properties();
|
||||
|
@ -144,20 +147,32 @@ public class ModLoaderModContainer implements ModContainer
|
|||
StringBuffer comments = new StringBuffer();
|
||||
comments.append("MLProperties: name (type:default) min:max -- information\n");
|
||||
|
||||
|
||||
List<ModProperty> mlPropFields = Lists.newArrayList();
|
||||
try
|
||||
{
|
||||
for (Field f : modClazz.getDeclaredFields())
|
||||
for (ASMData dat : Sets.union(asmData.getAnnotationsFor(this).get("net.minecraft.src.MLProp"), asmData.getAnnotationsFor(this).get("MLProp")))
|
||||
{
|
||||
if (!Modifier.isStatic(f.getModifiers()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ModProperty property = sideHandler.getModLoaderPropertyFor(f);
|
||||
if (property == null)
|
||||
if (dat.getClassName().equals(modClazzName))
|
||||
{
|
||||
try
|
||||
{
|
||||
mlPropFields.add(new ModProperty(modClazz.getDeclaredField(dat.getObjectName()), dat.getAnnotationInfo()));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log(Level.WARNING, e, "An error occured trying to access field %s in mod %s", dat.getObjectName(), getModId());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (ModProperty property : mlPropFields)
|
||||
{
|
||||
if (!Modifier.isStatic(property.field().getModifiers()))
|
||||
{
|
||||
FMLLog.info("The MLProp field %s in mod %s appears not to be static", property.field().getName(), getModId());
|
||||
continue;
|
||||
}
|
||||
Field f = property.field();
|
||||
String propertyName = property.name().length() > 0 ? property.name() : f.getName();
|
||||
String propertyValue = null;
|
||||
Object defaultValue = null;
|
||||
|
@ -328,7 +343,7 @@ public class ModLoaderModContainer implements ModContainer
|
|||
}
|
||||
|
||||
@Deprecated
|
||||
public static ModContainer findContainerFor(BaseMod mod)
|
||||
public static ModContainer findContainerFor(BaseModProxy mod)
|
||||
{
|
||||
return FMLCommonHandler.instance().findContainerFor(mod);
|
||||
}
|
||||
|
@ -350,7 +365,7 @@ public class ModLoaderModContainer implements ModContainer
|
|||
* @param <A>
|
||||
* @return
|
||||
*/
|
||||
public static <A extends BaseMod> List<A> findAll(Class<A> clazz)
|
||||
public static <A extends BaseModProxy> List<A> findAll(Class<A> clazz)
|
||||
{
|
||||
ArrayList<A> modList = new ArrayList<A>();
|
||||
|
||||
|
@ -417,19 +432,6 @@ public class ModLoaderModContainer implements ModContainer
|
|||
return mod.getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProxyInjector findSidedProxy()
|
||||
{
|
||||
if (sidedProxy==null) {
|
||||
sidedProxy = FMLCommonHandler.instance().getSidedDelegate().findSidedProxyOn(mod);
|
||||
if (sidedProxy == null)
|
||||
{
|
||||
sidedProxy = NULLPROXY;
|
||||
}
|
||||
}
|
||||
return sidedProxy == NULLPROXY ? null : sidedProxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
|
@ -491,10 +493,10 @@ public class ModLoaderModContainer implements ModContainer
|
|||
{
|
||||
ModClassLoader modClassLoader = event.getModClassLoader();
|
||||
modClassLoader.addFile(modSource);
|
||||
Class<? extends BaseMod> modClazz = (Class<? extends BaseMod>) Class.forName(modClazzName, true, modClassLoader);
|
||||
configureMod(modClazz);
|
||||
Class<? extends BaseModProxy> modClazz = (Class<? extends BaseModProxy>) Class.forName(modClazzName, true, modClassLoader);
|
||||
configureMod(modClazz, event.getASMHarvestedData());
|
||||
isNetworkMod = FMLNetworkHandler.instance().registerNetworkMod(this, modClazz, event.getASMHarvestedData());
|
||||
mod = (BaseMod)modClazz.newInstance();
|
||||
mod = (BaseModProxy)modClazz.newInstance();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -515,7 +517,9 @@ public class ModLoaderModContainer implements ModContainer
|
|||
this.guiTickHandler.setMod(mod);
|
||||
TickRegistry.registerTickHandler(this.gameTickHandler);
|
||||
TickRegistry.registerTickHandler(this.guiTickHandler);
|
||||
GameRegistry.registerWorldGenerator(this.mod);
|
||||
GameRegistry.registerWorldGenerator(ModLoaderHelper.buildWorldGenHelper(mod));
|
||||
GameRegistry.registerFuelHandler(ModLoaderHelper.buildFuelHelper(mod));
|
||||
GameRegistry.registerCraftingHandler(ModLoaderHelper.buildCraftingHelper(mod));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import net.minecraft.src.BaseMod;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.NetworkManager;
|
||||
import net.minecraft.src.Packet250CustomPayload;
|
||||
import cpw.mods.fml.common.network.IPacketHandler;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
|
||||
public class ModLoaderPacketHandler implements IPacketHandler
|
||||
{
|
||||
private BaseMod mod;
|
||||
|
||||
public ModLoaderPacketHandler(BaseMod mod)
|
||||
{
|
||||
this.mod = mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(NetworkManager manager, Packet250CustomPayload packet, Player player)
|
||||
{
|
||||
mod.onPacket250Received((EntityPlayer) player, packet);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.src.ChunkProviderGenerate;
|
||||
import net.minecraft.src.ChunkProviderHell;
|
||||
import net.minecraft.src.IChunkProvider;
|
||||
import net.minecraft.src.World;
|
||||
|
||||
import cpw.mods.fml.common.IWorldGenerator;
|
||||
|
||||
public class ModLoaderWorldGenerator implements IWorldGenerator
|
||||
{
|
||||
private BaseModProxy mod;
|
||||
|
||||
public ModLoaderWorldGenerator(BaseModProxy mod)
|
||||
{
|
||||
this.mod = mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(Random random, int chunkX, int chunkZ, Object... additionalData)
|
||||
{
|
||||
World w = (World) additionalData[0];
|
||||
IChunkProvider cp = (IChunkProvider) additionalData[1];
|
||||
|
||||
if (cp instanceof ChunkProviderGenerate)
|
||||
{
|
||||
mod.generateSurface(w, random, chunkX << 4, chunkZ << 4);
|
||||
}
|
||||
else if (cp instanceof ChunkProviderHell)
|
||||
{
|
||||
mod.generateNether(w, random, chunkX << 4, chunkZ << 4);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -15,6 +15,8 @@
|
|||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
|
@ -26,20 +28,25 @@ public class ModProperty
|
|||
private double min;
|
||||
private double max;
|
||||
private String name;
|
||||
private Field field;
|
||||
|
||||
public ModProperty(String info, double min, double max, String name)
|
||||
public ModProperty(Field f, String info, double min, double max, String name)
|
||||
{
|
||||
this.field = f;
|
||||
this.info = info;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.name = name;
|
||||
}
|
||||
public ModProperty(Field field, Map<String, Object> annotationInfo)
|
||||
{
|
||||
this(field, (String)annotationInfo.get("info"), (Double)annotationInfo.get("min"), (Double)annotationInfo.get("max"), (String)annotationInfo.get("name"));
|
||||
}
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String name()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return name;
|
||||
}
|
||||
/**
|
||||
|
@ -47,7 +54,6 @@ public class ModProperty
|
|||
*/
|
||||
public double min()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return min;
|
||||
}
|
||||
/**
|
||||
|
@ -55,7 +61,6 @@ public class ModProperty
|
|||
*/
|
||||
public double max()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return max;
|
||||
}
|
||||
/**
|
||||
|
@ -63,7 +68,11 @@ public class ModProperty
|
|||
*/
|
||||
public String info()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return info;
|
||||
}
|
||||
|
||||
public Field field()
|
||||
{
|
||||
return field;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,5 +5,11 @@ import net.minecraft.src.Packet250CustomPayload;
|
|||
|
||||
public interface IPacketHandler
|
||||
{
|
||||
public void onPacketData(NetworkManager manager, Packet250CustomPayload packet);
|
||||
/**
|
||||
* Recieve a packet from one of the registered channels for this packet handler
|
||||
* @param manager The network manager this packet arrived from
|
||||
* @param packet The packet itself
|
||||
* @param player A dummy interface representing the player - it can be cast into a real player instance if needed
|
||||
*/
|
||||
public void onPacketData(NetworkManager manager, Packet250CustomPayload packet, Player player);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class NetworkRegistry
|
|||
/**
|
||||
* A map of the packet handlers for packets
|
||||
*/
|
||||
private Map<String, IPacketHandler> packetHandlers = Maps.newHashMap();
|
||||
private Multimap<String, IPacketHandler> packetHandlers = ArrayListMultimap.create();
|
||||
/**
|
||||
* A linked set of registered connection handlers
|
||||
*/
|
||||
|
@ -151,8 +151,10 @@ public class NetworkRegistry
|
|||
{
|
||||
if (activeChannels.containsEntry(player, packet.field_73630_a))
|
||||
{
|
||||
IPacketHandler handler = packetHandlers.get(packet.field_73630_a);
|
||||
handler.onPacketData(network, packet);
|
||||
for (IPacketHandler handler : packetHandlers.get(packet.field_73630_a))
|
||||
{
|
||||
handler.onPacketData(network, packet, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
package cpw.mods.fml.common.registry;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraft.src.BiomeGenBase;
|
||||
import net.minecraft.src.CraftingManager;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.FurnaceRecipes;
|
||||
import net.minecraft.src.IInventory;
|
||||
import net.minecraft.src.IRecipe;
|
||||
import net.minecraft.src.ItemBlock;
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
@ -15,9 +18,13 @@ import net.minecraft.src.TileEntity;
|
|||
import net.minecraft.src.WorldType;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.ICraftingHandler;
|
||||
import cpw.mods.fml.common.IFuelHandler;
|
||||
import cpw.mods.fml.common.IWorldGenerator;
|
||||
import cpw.mods.fml.common.LoaderException;
|
||||
import cpw.mods.fml.common.Mod.Block;
|
||||
|
@ -27,7 +34,9 @@ public class GameRegistry
|
|||
{
|
||||
private static Multimap<ModContainer, BlockProxy> blockRegistry = ArrayListMultimap.create();
|
||||
private static Multimap<ModContainer, ItemProxy> itemRegistry = ArrayListMultimap.create();
|
||||
private static Set<IWorldGenerator> worldGenerators = new HashSet<IWorldGenerator>();
|
||||
private static Set<IWorldGenerator> worldGenerators = Sets.newHashSet();
|
||||
private static List<IFuelHandler> fuelHandlers = Lists.newArrayList();
|
||||
private static List<ICraftingHandler> craftingHandlers = Lists.newArrayList();
|
||||
|
||||
public static void registerWorldGenerator(IWorldGenerator generator)
|
||||
{
|
||||
|
@ -110,9 +119,45 @@ public class GameRegistry
|
|||
{
|
||||
WorldType.field_77137_b.addNewBiome(biome);
|
||||
}
|
||||
|
||||
|
||||
public static void removeBiome(BiomeGenBase biome)
|
||||
{
|
||||
WorldType.field_77137_b.removeBiome(biome);
|
||||
}
|
||||
|
||||
public static void registerFuelHandler(IFuelHandler handler)
|
||||
{
|
||||
fuelHandlers.add(handler);
|
||||
}
|
||||
public static int getFuelValue(ItemStack itemStack)
|
||||
{
|
||||
int fuelValue = 0;
|
||||
for (IFuelHandler handler : fuelHandlers)
|
||||
{
|
||||
fuelValue = Math.max(fuelValue, handler.getBurnTime(itemStack));
|
||||
}
|
||||
return fuelValue;
|
||||
}
|
||||
|
||||
public static void registerCraftingHandler(ICraftingHandler handler)
|
||||
{
|
||||
craftingHandlers.add(handler);
|
||||
}
|
||||
|
||||
public static void onItemCrafted(EntityPlayer player, ItemStack item, IInventory craftMatrix)
|
||||
{
|
||||
for (ICraftingHandler handler : craftingHandlers)
|
||||
{
|
||||
handler.onCrafting(player, item, craftMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
public static void onItemSmelted(EntityPlayer player, ItemStack item)
|
||||
{
|
||||
for (ICraftingHandler handler : craftingHandlers)
|
||||
{
|
||||
handler.onSmelting(player, item);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
package cpw.mods.fml.common.registry;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import net.minecraft.src.StringTranslate;
|
||||
|
||||
public class LanguageRegistry
|
||||
{
|
||||
private static final LanguageRegistry INSTANCE = new LanguageRegistry();
|
||||
|
||||
private Map<String,Properties> modLanguageData=new HashMap<String,Properties>();
|
||||
|
||||
public static LanguageRegistry instance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public void addStringLocalization(String key, String lang, String value)
|
||||
{
|
||||
Properties langPack=modLanguageData.get(lang);
|
||||
if (langPack==null) {
|
||||
langPack=new Properties();
|
||||
modLanguageData.put(lang, langPack);
|
||||
}
|
||||
langPack.put(key,value);
|
||||
|
||||
loadLanguageTable(StringTranslate.func_74808_a().field_74815_b, lang);
|
||||
}
|
||||
|
||||
|
||||
public void addNameForObject(Object objectToName, String lang, String name)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void loadLanguageTable(Properties languagePack, String lang)
|
||||
{
|
||||
Properties usPack=modLanguageData.get("en_US");
|
||||
if (usPack!=null) {
|
||||
languagePack.putAll(usPack);
|
||||
}
|
||||
Properties langPack=modLanguageData.get(lang);
|
||||
if (langPack==null) {
|
||||
return;
|
||||
}
|
||||
languagePack.putAll(langPack);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,8 @@
|
|||
# Marker interfaces to add to minecraft - helps in bukkit and client/server unification
|
||||
# Only runs at runtime because it's not necessary at compile time
|
||||
# entityplayer -> network/player
|
||||
of cpw/mods/fml/common/network/Player
|
||||
of cpw/mods/fml/common/network/Player
|
||||
# block -> blockproxy
|
||||
aif cpw/mods/fml/common/registry/BlockProxy
|
||||
# item -> itemproxy
|
||||
rg cpw/mods/fml/common/registry/ItemProxy
|
|
@ -13,6 +13,7 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
|
|||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.network.IPacketHandler;
|
||||
import cpw.mods.fml.common.network.NetworkMod;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import cpw.mods.fml.common.ModMetadata;
|
||||
|
||||
@Mod(modid="MockMod", name="Mock Mod",version="1.2.3", dependencies="before:mod_testMod", useMetadata=true)
|
||||
|
@ -22,7 +23,7 @@ public class MockMod
|
|||
public static class PacketHandler implements IPacketHandler
|
||||
{
|
||||
@Override
|
||||
public void onPacketData(NetworkManager manager, Packet250CustomPayload packet)
|
||||
public void onPacketData(NetworkManager manager, Packet250CustomPayload packet, Player player)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import cpw.mods.fml.common.ITickHandler;
|
|||
import cpw.mods.fml.common.TickType;
|
||||
import cpw.mods.fml.common.network.IPacketHandler;
|
||||
import cpw.mods.fml.common.network.NetworkMod;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import cpw.mods.fml.common.registry.TickRegistry;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
|
@ -16,7 +17,7 @@ public class mod_testMod extends BaseMod {
|
|||
public static class PacketHandler implements IPacketHandler
|
||||
{
|
||||
@Override
|
||||
public void onPacketData(NetworkManager manager, Packet250CustomPayload packet)
|
||||
public void onPacketData(NetworkManager manager, Packet250CustomPayload packet, Player player)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
17
fml/patches/common/net/minecraft/src/SlotCrafting.java.patch
Normal file
17
fml/patches/common/net/minecraft/src/SlotCrafting.java.patch
Normal file
|
@ -0,0 +1,17 @@
|
|||
--- ../src-base/common/net/minecraft/src/SlotCrafting.java
|
||||
+++ ../src-work/common/net/minecraft/src/SlotCrafting.java
|
||||
@@ -1,4 +1,6 @@
|
||||
package net.minecraft.src;
|
||||
+
|
||||
+import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class SlotCrafting extends Slot
|
||||
{
|
||||
@@ -83,6 +85,7 @@
|
||||
|
||||
public void func_75213_b(ItemStack p_75213_1_)
|
||||
{
|
||||
+ GameRegistry.onItemCrafted(field_75238_b, p_75213_1_, field_75239_a);
|
||||
this.func_75208_c(p_75213_1_);
|
||||
|
||||
for (int var2 = 0; var2 < this.field_75239_a.func_70302_i_(); ++var2)
|
20
fml/patches/common/net/minecraft/src/SlotFurnace.java.patch
Normal file
20
fml/patches/common/net/minecraft/src/SlotFurnace.java.patch
Normal file
|
@ -0,0 +1,20 @@
|
|||
--- ../src-base/common/net/minecraft/src/SlotFurnace.java
|
||||
+++ ../src-work/common/net/minecraft/src/SlotFurnace.java
|
||||
@@ -1,4 +1,6 @@
|
||||
package net.minecraft.src;
|
||||
+
|
||||
+import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class SlotFurnace extends Slot
|
||||
{
|
||||
@@ -72,7 +74,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
+
|
||||
this.field_75228_b = 0;
|
||||
+
|
||||
+ GameRegistry.onItemSmelted(field_75229_a, p_75208_1_);
|
||||
|
||||
if (p_75208_1_.field_77993_c == Item.field_77703_o.field_77779_bT)
|
||||
{
|
|
@ -0,0 +1,19 @@
|
|||
--- ../src-base/minecraft/net/minecraft/src/StringTranslate.java
|
||||
+++ ../src-work/minecraft/net/minecraft/src/StringTranslate.java
|
||||
@@ -7,6 +7,8 @@
|
||||
import java.util.IllegalFormatException;
|
||||
import java.util.Properties;
|
||||
import java.util.TreeMap;
|
||||
+
|
||||
+import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
|
||||
public class StringTranslate
|
||||
{
|
||||
@@ -134,6 +136,7 @@
|
||||
this.field_74813_d = p_74810_1_;
|
||||
this.field_74815_b = var2;
|
||||
}
|
||||
+ LanguageRegistry.instance().loadLanguageTable(this.field_74815_b, this.field_74813_d);
|
||||
}
|
||||
|
||||
public String func_74811_c()
|
|
@ -0,0 +1,27 @@
|
|||
--- ../src-base/minecraft/net/minecraft/src/TileEntityFurnace.java
|
||||
+++ ../src-work/minecraft/net/minecraft/src/TileEntityFurnace.java
|
||||
@@ -1,4 +1,6 @@
|
||||
package net.minecraft.src;
|
||||
+
|
||||
+import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class TileEntityFurnace extends TileEntity implements IInventory
|
||||
{
|
||||
@@ -268,8 +270,15 @@
|
||||
return 300;
|
||||
}
|
||||
}
|
||||
-
|
||||
- return var2 instanceof ItemTool && ((ItemTool)var2).func_77861_e().equals("WOOD") ? 200 : (var2 instanceof ItemSword && ((ItemSword)var2).func_77825_f().equals("WOOD") ? 200 : (var2 instanceof ItemHoe && ((ItemHoe)var2).func_77842_f().equals("WOOD") ? 200 : (var1 == Item.field_77669_D.field_77779_bT ? 100 : (var1 == Item.field_77705_m.field_77779_bT ? 1600 : (var1 == Item.field_77775_ay.field_77779_bT ? 20000 : (var1 == Block.field_71987_y.field_71990_ca ? 100 : (var1 == Item.field_77731_bo.field_77779_bT ? 2400 : 0)))))));
|
||||
+ if (var2 instanceof ItemTool && ((ItemTool) var2).func_77861_e().equals("WOOD")) return 200;
|
||||
+ if (var2 instanceof ItemSword && ((ItemSword) var2).func_77825_f().equals("WOOD")) return 200;
|
||||
+ if (var2 instanceof ItemHoe && ((ItemHoe) var2).func_77842_f().equals("WOOD")) return 200;
|
||||
+ if (var1 == Item.field_77669_D.field_77779_bT) return 100;
|
||||
+ if (var1 == Item.field_77705_m.field_77779_bT) return 1600;
|
||||
+ if (var1 == Item.field_77775_ay.field_77779_bT) return 20000;
|
||||
+ if (var1 == Block.field_71987_y.field_71990_ca) return 100;
|
||||
+ if (var1 == Item.field_77731_bo.field_77779_bT) return 2400;
|
||||
+ return GameRegistry.getFuelValue(p_70398_0_);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
--- ../src-base/minecraft_server/net/minecraft/src/ServerConfigurationManager.java
|
||||
+++ ../src-work/minecraft_server/net/minecraft/src/ServerConfigurationManager.java
|
||||
@@ -9,6 +9,8 @@
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
+
|
||||
+import cpw.mods.fml.common.network.FMLNetworkHandler;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
public abstract class ServerConfigurationManager
|
||||
@@ -54,6 +56,7 @@
|
||||
ChunkCoordinates var5 = var4.func_72861_E();
|
||||
this.func_72381_a(p_72355_2_, (EntityPlayerMP)null, var4);
|
||||
NetServerHandler var6 = new NetServerHandler(this.field_72400_f, p_72355_1_, p_72355_2_);
|
||||
+ FMLNetworkHandler.handlePlayerLogin(p_72355_2_, var6, p_72355_1_);
|
||||
var6.func_72567_b(new Packet1Login(p_72355_2_.field_70157_k, var4.func_72912_H().func_76067_t(), p_72355_2_.field_71134_c.func_73081_b(), var4.func_72912_H().func_76093_s(), var4.field_73011_w.field_76574_g, var4.field_73013_u, var4.func_72800_K(), this.func_72352_l()));
|
||||
var6.func_72567_b(new Packet6SpawnPosition(var5.field_71574_a, var5.field_71572_b, var5.field_71573_c));
|
||||
var6.func_72567_b(new Packet202PlayerAbilities(p_72355_2_.field_71075_bZ));
|
|
@ -0,0 +1,19 @@
|
|||
--- ../src-base/minecraft_server/net/minecraft/src/StringTranslate.java
|
||||
+++ ../src-work/minecraft_server/net/minecraft/src/StringTranslate.java
|
||||
@@ -7,6 +7,8 @@
|
||||
import java.util.IllegalFormatException;
|
||||
import java.util.Properties;
|
||||
import java.util.TreeMap;
|
||||
+
|
||||
+import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
|
||||
public class StringTranslate
|
||||
{
|
||||
@@ -134,6 +136,7 @@
|
||||
this.field_74813_d = p_74810_1_;
|
||||
this.field_74815_b = var2;
|
||||
}
|
||||
+ LanguageRegistry.instance().loadLanguageTable(this.field_74815_b, this.field_74813_d);
|
||||
}
|
||||
|
||||
public String func_74805_b(String p_74805_1_)
|
|
@ -0,0 +1,26 @@
|
|||
--- ../src-base/minecraft_server/net/minecraft/src/TileEntityFurnace.java
|
||||
+++ ../src-work/minecraft_server/net/minecraft/src/TileEntityFurnace.java
|
||||
@@ -1,4 +1,6 @@
|
||||
package net.minecraft.src;
|
||||
+
|
||||
+import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class TileEntityFurnace extends TileEntity implements IInventory
|
||||
{
|
||||
@@ -254,7 +256,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
- return var2 instanceof ItemTool && ((ItemTool)var2).func_77861_e().equals("WOOD") ? 200 : (var2 instanceof ItemSword && ((ItemSword)var2).func_77825_f().equals("WOOD") ? 200 : (var2 instanceof ItemHoe && ((ItemHoe)var2).func_77842_f().equals("WOOD") ? 200 : (var1 == Item.field_77669_D.field_77779_bT ? 100 : (var1 == Item.field_77705_m.field_77779_bT ? 1600 : (var1 == Item.field_77775_ay.field_77779_bT ? 20000 : (var1 == Block.field_71987_y.field_71990_ca ? 100 : (var1 == Item.field_77731_bo.field_77779_bT ? 2400 : 0)))))));
|
||||
+ if (var2 instanceof ItemTool && ((ItemTool) var2).func_77861_e().equals("WOOD")) return 200;
|
||||
+ if (var2 instanceof ItemSword && ((ItemSword) var2).func_77825_f().equals("WOOD")) return 200;
|
||||
+ if (var2 instanceof ItemHoe && ((ItemHoe) var2).func_77842_f().equals("WOOD")) return 200;
|
||||
+ if (var1 == Item.field_77669_D.field_77779_bT) return 100;
|
||||
+ if (var1 == Item.field_77705_m.field_77779_bT) return 1600;
|
||||
+ if (var1 == Item.field_77775_ay.field_77779_bT) return 20000;
|
||||
+ if (var1 == Block.field_71987_y.field_71990_ca) return 100;
|
||||
+ if (var1 == Item.field_77731_bo.field_77779_bT) return 2400;
|
||||
+ return GameRegistry.getFuelValue(p_70398_0_);
|
||||
}
|
||||
}
|
||||
|
|
@ -41,7 +41,6 @@ import net.minecraft.src.Packet1Login;
|
|||
import net.minecraft.src.Packet250CustomPayload;
|
||||
import net.minecraft.src.Packet3Chat;
|
||||
import net.minecraft.src.Profiler;
|
||||
import net.minecraft.src.SidedProxy;
|
||||
import net.minecraft.src.StringTranslate;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.src.WorldType;
|
||||
|
@ -133,13 +132,6 @@ public class FMLServerHandler implements IFMLSidedHandler
|
|||
return INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMinecraftInstance()
|
||||
{
|
||||
return server;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.IFMLSidedHandler#profileStart(java.lang.String)
|
||||
*/
|
||||
|
@ -175,56 +167,4 @@ public class FMLServerHandler implements IFMLSidedHandler
|
|||
{
|
||||
return Side.SERVER;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.IFMLSidedHandler#findSidedProxyOn(cpw.mods.fml.common.modloader.BaseMod)
|
||||
*/
|
||||
@Override
|
||||
public ProxyInjector findSidedProxyOn(cpw.mods.fml.common.modloader.BaseMod mod)
|
||||
{
|
||||
for (Field f : mod.getClass().getDeclaredFields())
|
||||
{
|
||||
if (f.isAnnotationPresent(SidedProxy.class))
|
||||
{
|
||||
SidedProxy sp = f.getAnnotation(SidedProxy.class);
|
||||
return new ProxyInjector(sp.clientSide(), sp.serverSide(), sp.bukkitSide(), f);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getMinecraftLogger()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentLanguage()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Properties getCurrentLanguageTable()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObjectName(Object minecraftObject)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModProperty getModLoaderPropertyFor(Field f)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,118 +24,30 @@ import cpw.mods.fml.common.IPickupNotifier;
|
|||
import cpw.mods.fml.common.IPlayerTracker;
|
||||
import cpw.mods.fml.common.IWorldGenerator;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import cpw.mods.fml.server.FMLServerHandler;
|
||||
|
||||
public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
|
||||
public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseModProxy
|
||||
{
|
||||
// CALLBACK MECHANISMS
|
||||
public void keyBindingEvent(Object keybinding){}
|
||||
|
||||
/**
|
||||
* @param minecraftInstance
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public final boolean doTickInGame(TickType tick, boolean tickEnd, Object minecraftInstance, Object... data)
|
||||
public final boolean doTickInGame(TickType tick, boolean tickEnd, Object... data)
|
||||
{
|
||||
if (tick==TickType.GAME && tickEnd) {
|
||||
return onTickInGame((MinecraftServer)minecraftInstance);
|
||||
return onTickInGame(FMLServerHandler.instance().getServer());
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public final boolean doTickInGUI(TickType tick, boolean tickEnd, Object minecraftInstance, Object... data)
|
||||
public final boolean doTickInGUI(TickType tick, boolean tickEnd, Object... data)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onCrafting(Object... craftingParameters)
|
||||
{
|
||||
takenFromCrafting((EntityPlayer)craftingParameters[0], (ItemStack)craftingParameters[1], (IInventory)craftingParameters[2]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onSmelting(Object... smeltingParameters)
|
||||
{
|
||||
takenFromFurnace((EntityPlayer)smeltingParameters[0], (ItemStack)smeltingParameters[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean dispense(double x, double y, double z, int xVelocity, int zVelocity, Object... data)
|
||||
{
|
||||
return dispenseEntity((World)data[0], x, y, z, xVelocity, zVelocity, (ItemStack)data[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean onChat(Object... data)
|
||||
{
|
||||
return onChatMessageReceived((EntityPlayer)data[1], (Packet3Chat)data[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onServerLogin(Object handler) {
|
||||
// NOOP
|
||||
}
|
||||
|
||||
public final void onServerLogout() {
|
||||
// NOOP
|
||||
}
|
||||
@Override
|
||||
public final void onPlayerLogin(Object player)
|
||||
{
|
||||
onClientLogin((EntityPlayer) player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onPlayerLogout(Object player)
|
||||
{
|
||||
onClientLogout((EntityPlayer)player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onPlayerChangedDimension(Object player)
|
||||
{
|
||||
onClientDimensionChanged((EntityPlayer)player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onPacket250Packet(Object... data)
|
||||
{
|
||||
onPacket250Received((EntityPlayer)data[1], (Packet250CustomPayload)data[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void notifyPickup(Object... pickupData)
|
||||
{
|
||||
EntityItem item = (EntityItem) pickupData[0];
|
||||
EntityPlayer player = (EntityPlayer) pickupData[1];
|
||||
onItemPickup(player, item.field_70294_a);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void generate(Random random, int chunkX, int chunkZ, Object... additionalData)
|
||||
{
|
||||
World w = (World) additionalData[0];
|
||||
IChunkProvider cp = (IChunkProvider) additionalData[1];
|
||||
|
||||
if (cp instanceof ChunkProviderGenerate)
|
||||
{
|
||||
generateSurface(w, random, chunkX << 4, chunkZ << 4);
|
||||
}
|
||||
else if (cp instanceof ChunkProviderHell)
|
||||
{
|
||||
generateNether(w, random, chunkX << 4, chunkZ << 4);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* NO-OP on client side
|
||||
*/
|
||||
@Override
|
||||
public final boolean handleCommand(String command, Object... data)
|
||||
{
|
||||
return onServerCommand(command, (String)data[0], (ICommandManager)data[1]);
|
||||
}
|
||||
// BASEMOD API
|
||||
/**
|
||||
* Override if you wish to provide a fuel item for the furnace and return the fuel value of the item
|
||||
|
|
|
@ -29,6 +29,7 @@ import cpw.mods.fml.common.network.Player;
|
|||
import cpw.mods.fml.server.FMLServerHandler;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
|
||||
public class ModLoader
|
||||
{
|
||||
|
@ -110,7 +111,7 @@ public class ModLoader
|
|||
*/
|
||||
public static void addLocalization(String key, String lang, String value)
|
||||
{
|
||||
FMLCommonHandler.instance().addStringLocalization(key, lang, value);
|
||||
LanguageRegistry.instance().addStringLocalization(key, lang, value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -133,7 +134,7 @@ public class ModLoader
|
|||
*/
|
||||
public static void addName(Object instance, String lang, String name)
|
||||
{
|
||||
FMLCommonHandler.instance().addNameForObject(instance, lang, name);
|
||||
LanguageRegistry.instance().addNameForObject(instance, lang, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,46 +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.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface SidedProxy
|
||||
{
|
||||
/**
|
||||
* The name of the client side class to load and populate
|
||||
* @return
|
||||
*/
|
||||
String clientSide() default "";
|
||||
|
||||
/**
|
||||
* The name of the server side class to load and populate
|
||||
* @return
|
||||
*/
|
||||
String serverSide() default "";
|
||||
|
||||
/**
|
||||
* The name of the a special bukkit plugin class to load and populate
|
||||
*/
|
||||
String bukkitSide() default "";
|
||||
}
|
Loading…
Reference in a new issue