Everything except ordering

This commit is contained in:
Christian Weeks 2012-04-02 23:06:30 -04:00
parent 9e404a48c5
commit 971de1c2b4
18 changed files with 674 additions and 59 deletions

View File

@ -15,17 +15,24 @@ package cpw.mods.fml.common;
public enum FMLHooks {
INSTANCE;
public void serverTickStart() {
public class FMLHooks {
private static final FMLHooks INSTANCE=new FMLHooks();
public void gameTickStart() {
for (ModContainer mod : Loader.getModList()) {
mod.tickStart();
}
}
public void serverTickEnd() {
public void gameTickEnd() {
for (ModContainer mod : Loader.getModList()) {
mod.tickEnd();
}
}
/**
* @return the instance
*/
public static FMLHooks instance() {
return INSTANCE;
}
}

View File

@ -12,6 +12,9 @@
*/
package cpw.mods.fml.common;
import java.util.ArrayList;
import java.util.List;
public class FMLModContainer implements ModContainer {
private Mod modDescriptor;
private Object modInstance;
@ -141,4 +144,49 @@ public class FMLModContainer implements ModContainer {
return null;
}
/* (non-Javadoc)
* @see cpw.mods.fml.common.ModContainer#wantsCraftingNotification()
*/
@Override
public boolean wantsCraftingNotification() {
// TODO Auto-generated method stub
return false;
}
/* (non-Javadoc)
* @see cpw.mods.fml.common.ModContainer#getCraftingHandler()
*/
@Override
public ICraftingHandler getCraftingHandler() {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see cpw.mods.fml.common.ModContainer#getDependencies()
*/
@Override
public List<String> getDependencies() {
// TODO Auto-generated method stub
return new ArrayList<String>(0);
}
/* (non-Javadoc)
* @see cpw.mods.fml.common.ModContainer#getPreDepends()
*/
@Override
public List<String> getPreDepends() {
// TODO Auto-generated method stub
return new ArrayList<String>(0);
}
/* (non-Javadoc)
* @see cpw.mods.fml.common.ModContainer#getPostDepends()
*/
@Override
public List<String> getPostDepends() {
// TODO Auto-generated method stub
return new ArrayList<String>(0);
}
}

View File

@ -0,0 +1,34 @@
/*
* 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 cpw.mods.fml.common;
/**
* @author cpw
*
*/
public interface ICraftingHandler {
/**
* @param player
* @param craftedItem
* @param craftingGrid
*/
void onCrafting(Object... craftingParameters);
/**
* @param player
* @param smeltedItem
*/
void onSmelting(Object... smeltingParameters);
}

View File

@ -78,7 +78,14 @@ public class Loader {
}
private void sortModList() {
// NOOP for a minute
for (ModContainer mod : mods) {
if (!namedMods.keySet().containsAll(mod.getDependencies())) {
log.severe(String.format("The mod %s requires mods %s to be available, one or more are not", mod.getName(),mod.getDependencies()));
LoaderException le=new LoaderException();
log.throwing("Loader", "sortModList", le);
throw new LoaderException();
}
}
}
private void preModInit() {
@ -207,9 +214,9 @@ public class Loader {
if (clazz.isAnnotationPresent(Mod.class)) {
// an FML mod
mods.add(FMLModContainer.buildFor(clazz));
} else if (FMLHandler.INSTANCE.isModLoaderMod(clazz)) {
} else if (FMLHandler.instance().isModLoaderMod(clazz)) {
log.fine(String.format("ModLoader BaseMod class %s found, loading", clazzName));
ModContainer mc=FMLHandler.INSTANCE.loadBaseModMod(clazz,classSource.getCanonicalPath());
ModContainer mc=FMLHandler.instance().loadBaseModMod(clazz,classSource.getCanonicalPath());
mods.add(mc);
log.fine(String.format("ModLoader BaseMod class %s loaded", clazzName));
} else {
@ -267,10 +274,10 @@ public class Loader {
mods = new ArrayList<ModContainer>();
namedMods = new HashMap<String,ModContainer>();
load();
preModInit();
sortModList();
// Make mod list immutable
mods=Collections.unmodifiableList(mods);
preModInit();
}
public void initializeMods() {

View File

@ -13,6 +13,8 @@
*/
package cpw.mods.fml.common;
import java.util.List;
public interface ModContainer {
@ -34,4 +36,9 @@ public interface ModContainer {
IPickupNotifier getPickupNotifier();
boolean wantsToDispense();
IDispenseHandler getDispenseHandler();
boolean wantsCraftingNotification();
ICraftingHandler getCraftingHandler();
List<String> getDependencies();
List<String> getPreDepends();
List<String> getPostDepends();
}

View File

@ -10,10 +10,12 @@
* 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 cpw.mods.fml.server;
package cpw.mods.fml.common;
import java.lang.reflect.Field;
import cpw.mods.fml.server.FMLHandler;
public class ReflectionHelper {
@SuppressWarnings("unchecked")
public static <T, E> T getPrivateValue(Class<? super E> classToAccess, E instance, int fieldIndex) {

View File

@ -13,6 +13,8 @@
*/
package net.minecraft.src;
import java.util.Collections;
import java.util.List;
public class CommonRegistry {
public static void addRecipe(ItemStack output, Object... params) {
@ -55,33 +57,56 @@ public class CommonRegistry {
}
public static void addBiome(BiomeGenBase biome) {
//NOOP because the implementation idea is broken. Creating a BiomeGenBase adds the biome already.
}
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(Class<? extends EntityLiving> entityClass, int weightedProb, int min, int max, EnumCreatureType typeOfCreature, BiomeGenBase... biomes) {
for (BiomeGenBase biome : biomes) {
@SuppressWarnings("unchecked")
List<SpawnListEntry> spawns=biome.func_25055_a(typeOfCreature);
for (SpawnListEntry entry : spawns) {
//Adjusting an existing spawn entry
if (entry.field_25145_a==entityClass) {
entry.field_35483_d=weightedProb;
entry.field_35484_b=min;
entry.field_35485_c=max;
break;
}
}
spawns.add(new SpawnListEntry(entityClass, weightedProb, min, max));
}
}
@SuppressWarnings("unchecked")
public static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeGenBase... biomes) {
Class<? extends Entity> entityClazz=EntityList.getEntityToClassMapping().get(entityName);
if (EntityLiving.class.isAssignableFrom(entityClazz)) {
addSpawn((Class<? extends EntityLiving>) entityClazz,weightedProb,min,max,spawnList,biomes);
}
}
public static void removeBiome(BiomeGenBase biome) {
// NOOP because broken
}
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(Class<? extends EntityLiving> entityClass, EnumCreatureType typeOfCreature, BiomeGenBase... biomes) {
for (BiomeGenBase biome : biomes) {
@SuppressWarnings("unchecked")
List<SpawnListEntry> spawns=biome.func_25055_a(typeOfCreature);
for (SpawnListEntry entry : Collections.unmodifiableList(spawns)) {
if (entry.field_25145_a==entityClass) {
spawns.remove(entry);
}
}
}
}
@SuppressWarnings("unchecked")
public static void removeSpawn(String entityName, EnumCreatureType spawnList, BiomeGenBase... biomes) {
Class<? extends Entity> entityClazz=EntityList.getEntityToClassMapping().get(entityName);
if (EntityLiving.class.isAssignableFrom(entityClazz)) {
removeSpawn((Class<? extends EntityLiving>) entityClazz,spawnList,biomes);
}
}
}

View File

@ -13,7 +13,7 @@
var1.start();
ConsoleLogManager.func_641_a();
field_6038_a.info("Starting minecraft server version 1.2.5");
+ FMLHandler.INSTANCE.onPreLoad(this);
+ FMLHandler.instance().onPreLoad(this);
if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L)
{
@ -21,7 +21,7 @@
field_6038_a.warning("To change this, set \"online-mode\" to \"true\" in the server.settings file.");
}
+ FMLHandler.INSTANCE.onLoadComplete();
+ FMLHandler.instance().onLoadComplete();
this.field_6033_f = new ServerConfigurationManager(this);
this.field_6028_k[0] = new EntityTracker(this, 0);
this.field_6028_k[1] = new EntityTracker(this, -1);
@ -29,7 +29,7 @@
var7 = 0L;
}
+ FMLHandler.INSTANCE.onPreTick();
+ FMLHandler.instance().onPreTick();
var3 += var7;
var1 = var5;
@ -37,7 +37,7 @@
this.func_6018_h();
}
}
+ FMLHandler.INSTANCE.onPostTick();
+ FMLHandler.instance().onPostTick();
}
}
else

View File

@ -14,7 +14,7 @@
else
{
- if (var12.field_855_c == Item.field_4148_j.field_234_aS)
+ if (FMLHandler.INSTANCE.tryDispensingEntity(p_21036_1_, var13, var15, var17, var9, var10, var12)) {
+ if (FMLHandler.instance().tryDispensingEntity(p_21036_1_, var13, var15, var17, var9, var10, var12)) {
+ ;
+ }
+ else if (var12.field_855_c == Item.field_4148_j.field_234_aS)

View File

@ -13,7 +13,7 @@
if (this.field_730_c != null)
{
this.field_730_c.func_4055_a(p_4055_1_, p_4055_2_, p_4055_3_);
+ FMLHandler.INSTANCE.onChunkPopulate(p_4055_1_, p_4055_2_, p_4055_3_, this.field_726_g, this.field_730_c);
+ FMLHandler.instance().onChunkPopulate(p_4055_1_, p_4055_2_, p_4055_3_, this.field_726_g, this.field_730_c);
var4.func_336_e();
}
}

View File

@ -0,0 +1,11 @@
--- src-reference/minecraft_server/net/minecraft/src/Entity.java 0000-00-00 00:00:00.000000000 -0000
+++ src-work/minecraft_server/net/minecraft/src/Entity.java 0000-00-00 00:00:00.000000000 -0000
@@ -1463,4 +1463,8 @@
{
return true;
}
+
+ public static int getNextId() {
+ return field_384_a++;
+ }
}

View File

@ -12,7 +12,7 @@
if (this.field_433_ad == 0 && p_6093_1_.field_416_aj.func_201_a(this.field_429_a))
{
+ FMLHandler.INSTANCE.notifyItemPickup(this,p_6093_1_);
+ FMLHandler.instance().notifyItemPickup(this,p_6093_1_);
if (this.field_429_a.field_855_c == Block.field_582_K.field_573_bc)
{
p_6093_1_.func_27017_a(AchievementList.field_25131_c);

View File

@ -1,6 +1,6 @@
--- src-reference/minecraft_server/net/minecraft/src/EntityList.java 0000-00-00 00:00:00.000000000 -0000
+++ src-work/minecraft_server/net/minecraft/src/EntityList.java 0000-00-00 00:00:00.000000000 -0000
@@ -166,4 +166,12 @@
@@ -166,4 +166,17 @@
func_46122_a(EntityVillager.class, "Villager", 120, 5651507, 12422002);
func_563_a(EntityEnderCrystal.class, "EnderCrystal", 200);
}
@ -11,5 +11,10 @@
+
+ public static void addNewEntityListMapping(Class<? extends Entity> entityClass, String entityName, int id, int backgroundEggColour, int foregroundEggColour) {
+ func_46122_a(entityClass,entityName,id,backgroundEggColour,foregroundEggColour);
+ }
+
+ @SuppressWarnings("unchecked")
+ public static Map<String,Class<? extends Entity>> getEntityToClassMapping() {
+ return field_849_a;
+ }
}

View File

@ -13,7 +13,7 @@
{
int var1 = p_194_1_.func_569_a().field_234_aS;
- return var1 < 256 && Block.field_542_n[var1].field_553_bn == Material.field_524_c ? 300 : (var1 == Item.field_209_B.field_234_aS ? 100 : (var1 == Item.field_168_k.field_234_aS ? 1600 : (var1 == Item.field_201_aw.field_234_aS ? 20000 : (var1 == Block.field_6047_y.field_573_bc ? 100 : (var1 == Item.field_40239_bm.field_234_aS ? 2400 : 0)))));
+ return var1 < 256 && Block.field_542_n[var1].field_553_bn == Material.field_524_c ? 300 : (var1 == Item.field_209_B.field_234_aS ? 100 : (var1 == Item.field_168_k.field_234_aS ? 1600 : (var1 == Item.field_201_aw.field_234_aS ? 20000 : (var1 == Block.field_6047_y.field_573_bc ? 100 : (var1 == Item.field_40239_bm.field_234_aS ? 2400 : FMLHandler.INSTANCE.fuelLookup(var1, p_194_1_.func_21125_h()))))));
+ return var1 < 256 && Block.field_542_n[var1].field_553_bn == Material.field_524_c ? 300 : (var1 == Item.field_209_B.field_234_aS ? 100 : (var1 == Item.field_168_k.field_234_aS ? 1600 : (var1 == Item.field_201_aw.field_234_aS ? 20000 : (var1 == Block.field_6047_y.field_573_bc ? 100 : (var1 == Item.field_40239_bm.field_234_aS ? 2400 : FMLHandler.instance().fuelLookup(var1, p_194_1_.func_21125_h()))))));
}
}

View File

@ -12,6 +12,7 @@
*/
package cpw.mods.fml.server;
import java.util.ArrayList;
import java.util.Random;
import java.util.logging.Logger;
@ -21,18 +22,23 @@ import cpw.mods.fml.common.ModContainer;
import net.minecraft.server.MinecraftServer;
import net.minecraft.src.BaseMod;
import net.minecraft.src.BiomeGenBase;
import net.minecraft.src.EntityItem;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.IChunkProvider;
import net.minecraft.src.IInventory;
import net.minecraft.src.ItemStack;
import net.minecraft.src.World;
public enum FMLHandler {
INSTANCE;
public class FMLHandler {
private static final FMLHandler INSTANCE=new FMLHandler();
private MinecraftServer server;
private BiomeGenBase[] defaultOverworldBiomes;
public void onPreLoad(MinecraftServer minecraftServer) {
INSTANCE.server = minecraftServer;
server = minecraftServer;
Loader.instance().loadMods();
}
@ -41,11 +47,11 @@ public enum FMLHandler {
}
public void onPreTick() {
FMLHooks.INSTANCE.serverTickStart();
FMLHooks.instance().gameTickStart();
}
public void onPostTick() {
FMLHooks.INSTANCE.serverTickEnd();
FMLHooks.instance().gameTickEnd();
}
public MinecraftServer getServer() {
@ -123,4 +129,45 @@ public enum FMLHandler {
}
return false;
}
/**
* @return the instance
*/
public static FMLHandler instance() {
return INSTANCE;
}
/**
* @return
*/
public BiomeGenBase[] getDefaultOverworldBiomes() {
if (defaultOverworldBiomes==null) {
ArrayList<BiomeGenBase> biomes=new ArrayList<BiomeGenBase>(20);
for (int i=0; i<23; i++) {
if ("Sky".equals(BiomeGenBase.field_35521_a[i].field_6163_m) || "Hell".equals(BiomeGenBase.field_35521_a[i].field_6163_m)) {
continue;
}
biomes.add(BiomeGenBase.field_35521_a[i]);
}
defaultOverworldBiomes=new BiomeGenBase[biomes.size()];
biomes.toArray(defaultOverworldBiomes);
}
return defaultOverworldBiomes;
}
public void onItemCrafted(EntityPlayer player, ItemStack craftedItem, IInventory craftingGrid) {
for (ModContainer mod : Loader.getModList()) {
if (mod.wantsCraftingNotification()) {
mod.getCraftingHandler().onCrafting(player,craftedItem,craftingGrid);
}
}
}
public void onItemSmelted(EntityPlayer player, ItemStack smeltedItem) {
for (ModContainer mod : Loader.getModList()) {
if (mod.wantsCraftingNotification()) {
mod.getCraftingHandler().onSmelting(player,smeltedItem);
}
}
}
}

View File

@ -14,9 +14,12 @@
package cpw.mods.fml.server;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;
import net.minecraft.src.BaseMod;
import cpw.mods.fml.common.ICraftingHandler;
import cpw.mods.fml.common.IDispenseHandler;
import cpw.mods.fml.common.IPickupNotifier;
import cpw.mods.fml.common.IWorldGenerator;
@ -64,7 +67,7 @@ public class ModLoaderModContainer implements ModContainer {
@Override
public void tickStart() {
if (isTicking) {
isTicking=mod.onTickInGame(FMLHandler.INSTANCE.getServer());
isTicking=mod.onTickInGame(FMLHandler.instance().getServer());
}
}
@Override
@ -155,4 +158,55 @@ public class ModLoaderModContainer implements ModContainer {
public IDispenseHandler getDispenseHandler() {
return mod;
}
/* (non-Javadoc)
* @see cpw.mods.fml.common.ModContainer#wantsCraftingNotification()
*/
@Override
public boolean wantsCraftingNotification() {
return true;
}
/* (non-Javadoc)
* @see cpw.mods.fml.common.ModContainer#getCraftingHandler()
*/
@Override
public ICraftingHandler getCraftingHandler() {
return mod;
}
/* (non-Javadoc)
* @see cpw.mods.fml.common.ModContainer#getDependencies()
*/
@Override
public List<String> getDependencies() {
ArrayList<String> dependencies=new ArrayList<String>(10);
if (mod.getPriorities()==null || mod.getPriorities().length()==0) {
return dependencies;
}
StringTokenizer st=new StringTokenizer(mod.getPriorities(),";");
for (; st.hasMoreTokens(); ) {
String dep=st.nextToken();
String[] depparts=dep.split(":");
if (depparts.length<2) {
throw new LoaderException();
}
if ("required-before".equals(depparts[0]) || "required-after".equals(depparts[0])) {
dependencies.add(depparts[1]);
}
}
return dependencies;
}
@Override
public List<String> getPreDepends() {
// TODO Auto-generated method stub
return null;
}
@Override
public List<String> getPostDepends() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -15,23 +15,26 @@ package net.minecraft.src;
import java.util.Random;
import net.minecraft.server.MinecraftServer;
import cpw.mods.fml.common.ICraftingHandler;
import cpw.mods.fml.common.IDispenseHandler;
import cpw.mods.fml.common.IPickupNotifier;
import cpw.mods.fml.common.IWorldGenerator;
public abstract class BaseMod implements IWorldGenerator, IPickupNotifier, IDispenseHandler {
public int addFuel(int id, int metadata) {
return 0;
public abstract class BaseMod implements IWorldGenerator, IPickupNotifier, IDispenseHandler, ICraftingHandler {
// CALLBACK MECHANISMS
@Override
public void onCrafting(Object... craftingParameters) {
takenFromCrafting((EntityPlayer)craftingParameters[0], (ItemStack)craftingParameters[1], (IInventory)craftingParameters[2]);
}
@Override
public void onSmelting(Object... smeltingParameters) {
takenFromFurnace((EntityPlayer)smeltingParameters[0], (ItemStack)smeltingParameters[1]);
}
@Override
public boolean dispense(double x, double y, double z, byte xVelocity, byte zVelocity, Object... data) {
return dispenseEntity((World)data[0], x, y, z, xVelocity, zVelocity, (ItemStack)data[1]);
}
public boolean dispenseEntity(World world, double x, double y, double z, int xVel, int zVel, ItemStack item) {
return false;
}
@Override
public void notifyPickup(Object... pickupData) {
@ -52,27 +55,90 @@ public abstract class BaseMod implements IWorldGenerator, IPickupNotifier, IDisp
}
}
// BASEMOD API
/**
* Override if you wish to provide a fuel item for the furnace and return the fuel value of the item
* @param id
* @param metadata
* @return
*/
public int addFuel(int id, int metadata) {
return 0;
}
/**
* Override if you wish to perform some action other than just dispensing the item from the dispenser
* @param world
* @param x
* @param y
* @param z
* @param xVel
* @param zVel
* @param item
* @return
*/
public boolean dispenseEntity(World world, double x, double y, double z, int xVel, int zVel, ItemStack item) {
return false;
}
/**
* Override if you wish to generate Nether (Hell biome) blocks
* @param world
* @param random
* @param chunkX
* @param chunkZ
*/
public void generateNether(World world, Random random, int chunkX, int chunkZ) {
}
/**
* Override if you wish to generate Overworld (not hell or the end) blocks
* @param world
* @param random
* @param chunkX
* @param chunkZ
*/
public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
}
/**
* Return the name of your mod. Defaults to the class name
* @return
*/
public String getName() {
return getClass().getSimpleName();
}
/**
* Get your mod priorities
* @return
*/
public String getPriorities() {
return null;
}
/**
* Return the version of your mod
* @return
*/
public abstract String getVersion();
/**
* Load your mod
*/
public abstract void load();
/**
* Finish loading your mod
*/
public void modsLoaded() {
}
/**
* Handle item pickup
* @param player
* @param item
*/
public void onItemPickup(EntityPlayer player, ItemStack item) {
}
@ -85,28 +151,55 @@ public abstract class BaseMod implements IWorldGenerator, IPickupNotifier, IDisp
return false;
}
/**
* Not implemented because on the server you don't know who it's from
* @param text
*/
@Deprecated
public void receiveChatPacket(String text) {
}
/**
* Not implemented because on the server you don't know who it's from
* @param packet
*/
@Deprecated
public void receiveCustomPacket(Packet250CustomPayload packet) {
}
/**
* Called when someone crafts an item from a crafting table
* @param player
* @param item
* @param matrix
*/
public void takenFromCrafting(EntityPlayer player, ItemStack item, IInventory matrix) {
}
/**
* Called when someone takes a smelted item from a furnace
*
* @param player
* @param item
*/
public void takenFromFurnace(EntityPlayer player, ItemStack item) {
}
/**
* The identifier string for the mod- used in client<->server negotiation
*/
@Override
public String toString() {
return getName()+" "+getVersion();
}
// Spare client junk
// -------
// 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);
@Override
public String toString() {
return getName()+" "+getVersion();
}
}

View File

@ -16,9 +16,9 @@ import java.util.List;
import java.util.logging.Logger;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ReflectionHelper;
import cpw.mods.fml.server.FMLHandler;
import cpw.mods.fml.server.ModLoaderModContainer;
import cpw.mods.fml.server.ReflectionHelper;
import net.minecraft.server.MinecraftServer;
@ -38,147 +38,386 @@ import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
public class ModLoader {
/**
*
* @param achievement
* @param name
* @param description
*/
public static void addAchievementDesc(Achievement achievement, String name, String description) {
// NOOP on the server??
}
/**
* This method is a call in hook from modified external code. Implemented elsewhere.
* @param id
* @param metadata
* @return
*/
@Deprecated
public static int addAllFuel(int id, int metadata) {
return 0;
}
/**
* This method has been unimplemented in server implementations for some time.
*
* @param armor
* @return
*/
@Deprecated
public static int addArmor(String armor) {
return 0;
}
/**
* This method does not work. Creation of a BiomeGenBase is sufficient to populate this array
*
* @param biome
*/
@Deprecated
public static void addBiome(BiomeGenBase biome) {
}
/**
* Unimplemented on the server as it does not generate names
* @param key
* @param value
*/
@Deprecated
public static void addLocalization(String key, String value) {
}
/**
* Unimplemented on the server as it does not generate names
* @param key
* @param lang
* @param value
*/
@Deprecated
public static void addLocalization(String key, String lang, String value) {
}
/**
* Unimplemented on the server as it does not generate names
* @param instance
* @param name
*/
@Deprecated
public static void addName(Object instance, String name) {
}
/**
* Unimplemented on the server as it does not generate names
* @param instance
* @param lang
* @param name
*/
@Deprecated
public static void addName(Object instance, String lang, String name) {
}
/**
* Unimplemented on the server as it does not render textures
* @param fileToOverride
* @param fileToAdd
* @return
*/
@Deprecated
public static int addOverride(String fileToOverride, String fileToAdd) {
return 0;
}
/**
* Unimplemented on the server as it does not render textures
* @param path
* @param overlayPath
* @param index
*/
@Deprecated
public static void addOverride(String path, String overlayPath, int index) {
}
/**
* Add a Shaped Recipe
* @param output
* @param params
*/
public static void addRecipe(ItemStack output, Object... params) {
CommonRegistry.addRecipe(output, params);
}
/**
* Add a shapeless recipe
* @param output
* @param params
*/
public static void addShapelessRecipe(ItemStack output, Object... params) {
CommonRegistry.addShapelessRecipe(output, params);
}
/**
* Add a new product to be smelted
* @param input
* @param output
*/
public static void addSmelting(int input, ItemStack output) {
CommonRegistry.addSmelting(input, output);
}
/**
* Add a mob to the spawn list
* @param entityClass
* @param weightedProb
* @param min
* @param max
* @param spawnList
*/
public static void addSpawn(Class<? extends EntityLiving> entityClass, int weightedProb, int min, int max, EnumCreatureType spawnList) {
CommonRegistry.addSpawn(entityClass, weightedProb, min, max, spawnList);
CommonRegistry.addSpawn(entityClass, weightedProb, min, max, spawnList, FMLHandler.instance().getDefaultOverworldBiomes());
}
/**
* Add a mob to the spawn list
* @param entityClass
* @param weightedProb
* @param min
* @param max
* @param spawnList
* @param biomes
*/
public static void addSpawn(Class<? extends EntityLiving> entityClass, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeGenBase... biomes) {
CommonRegistry.addSpawn(entityClass, weightedProb, min, max, spawnList, biomes);
}
/**
* Add a mob to the spawn list
* @param entityName
* @param weightedProb
* @param min
* @param max
* @param spawnList
*/
public static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList) {
CommonRegistry.addSpawn(entityName, weightedProb, min, max, spawnList);
CommonRegistry.addSpawn(entityName, weightedProb, min, max, spawnList, FMLHandler.instance().getDefaultOverworldBiomes());
}
/**
* Add a mob to the spawn list
* @param entityName
* @param weightedProb
* @param min
* @param max
* @param spawnList
* @param biomes
*/
public static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeGenBase... biomes) {
CommonRegistry.addSpawn(entityName, weightedProb, min, max, spawnList, biomes);
}
/**
* This method is a call in hook from modified external code. Implemented elsewhere.
* @param world
* @param x
* @param y
* @param z
* @param xVel
* @param zVel
* @param item
* @return
*/
@Deprecated
public static boolean dispenseEntity(World world, double x, double y, double z, int xVel, int zVel, ItemStack item) {
return false;
}
/**
* Currently unimplemented
* @param world
* @param x
* @param y
* @param z
*/
public static void genericContainerRemoval(World world, int x, int y, int z) {
}
/**
* Get a list of all BaseMod loaded into the system
* @return
*/
public static List<BaseMod> getLoadedMods() {
return ModLoaderModContainer.findAll();
}
/**
* Get a logger instance
* @return
*/
public static Logger getLogger() {
return FMLHandler.getFMLLogger();
}
/**
* Get a value from a field using reflection
* @param instanceclass
* @param instance
* @param fieldindex
* @return
*/
public static <T, E> T getPrivateValue(Class<? super E> instanceclass, E instance, int fieldindex) {
return ReflectionHelper.getPrivateValue(instanceclass, instance, fieldindex);
}
/**
* Get a value from a field using reflection
* @param instanceclass
* @param instance
* @param field
* @return
*/
public static <T, E> T getPrivateValue(Class<? super E> instanceclass, E instance, String field) {
return ReflectionHelper.getPrivateValue(instanceclass, instance, field);
}
/**
* Get a new unique entity id
* @return
*/
public static int getUniqueEntityId() {
return 0;
return Entity.getNextId();
}
/**
* Is the named mod loaded?
* @param modname
* @return
*/
public static boolean isModLoaded(String modname) {
return Loader.isModLoaded(modname);
}
/**
* Unimplemented on the server. New code that didn't exist prior to this implementation
* @param packet
*/
@Deprecated
public static void receivePacket(Packet250CustomPayload packet) {
}
/**
* Register a new block
* @param block
*/
public static void registerBlock(Block block) {
CommonRegistry.registerBlock(block);
}
/**
* Register a new block
* @param block
* @param itemclass
*/
public static void registerBlock(Block block, Class<? extends ItemBlock> itemclass) {
CommonRegistry.registerBlock(block, itemclass);
}
/**
* Register a new entity ID
* @param entityClass
* @param entityName
* @param id
*/
public static void registerEntityID(Class<? extends Entity> entityClass, String entityName, int id) {
CommonRegistry.registerEntityID(entityClass, entityName, id);
}
/**
* Register a new entity ID
* @param entityClass
* @param entityName
* @param id
* @param background
* @param foreground
*/
public static void registerEntityID(Class<? extends Entity> entityClass, String entityName, int id, int background, int foreground) {
CommonRegistry.registerEntityID(entityClass, entityName, id, background, foreground);
}
/**
* Unimplemented at present
* @param mod
* @param channel
*/
public static void registerPacketChannel(BaseMod mod, String channel) {
}
/**
* Register a new tile entity class
* @param tileEntityClass
* @param id
*/
public static void registerTileEntity(Class<? extends TileEntity> tileEntityClass, String id) {
CommonRegistry.registerTileEntity(tileEntityClass, id);
}
/**
* Remove a biome. This code will probably not work correctly.
* @param biome
*/
@Deprecated
public static void removeBiome(BiomeGenBase biome) {
CommonRegistry.removeBiome(biome);
}
/**
* Remove a spawn
* @param entityClass
* @param spawnList
*/
public static void removeSpawn(Class<? extends EntityLiving> entityClass, EnumCreatureType spawnList) {
CommonRegistry.removeSpawn(entityClass, spawnList);
CommonRegistry.removeSpawn(entityClass, spawnList, FMLHandler.instance().getDefaultOverworldBiomes());
}
/**
* Remove a spawn
* @param entityClass
* @param spawnList
* @param biomes
*/
public static void removeSpawn(Class<? extends EntityLiving> entityClass, EnumCreatureType spawnList, BiomeGenBase... biomes) {
CommonRegistry.removeSpawn(entityClass, spawnList, biomes);
}
/**
* Remove a spawn
* @param entityName
* @param spawnList
*/
public static void removeSpawn(String entityName, EnumCreatureType spawnList) {
CommonRegistry.removeSpawn(entityName, spawnList);
CommonRegistry.removeSpawn(entityName, spawnList, FMLHandler.instance().getDefaultOverworldBiomes());
}
/**
* Remove a spawn
* @param entityName
* @param spawnList
* @param biomes
*/
public static void removeSpawn(String entityName, EnumCreatureType spawnList, BiomeGenBase... biomes) {
CommonRegistry.removeSpawn(entityName, spawnList, biomes);
}
/**
* This implementation of the modloader API does not have "configuration" to save.
*/
public static void saveConfig() {
}
/**
* This method is unimplemented on the server: it is meant for clients to send chat to the server
* @param text
*/
@Deprecated
public static void serverChat(String text) {
}
@ -197,25 +436,61 @@ public class ModLoader {
mlmc.setTicking(enable);
}
/**
* Set a private field to a value using reflection
* @param instanceclass
* @param instance
* @param fieldindex
* @param value
*/
public static <T, E> void setPrivateValue(Class<? super T> instanceclass, T instance, int fieldindex, E value) {
ReflectionHelper.setPrivateValue(instanceclass, instance, fieldindex, value);
}
/**
* Set a private field to a value using reflection
* @param instanceclass
* @param instance
* @param field
* @param value
*/
public static <T, E> void setPrivateValue(Class<? super T> instanceclass, T instance, String field, E value) {
ReflectionHelper.setPrivateValue(instanceclass, instance, field, value);
}
/**
* This method is a call in hook from modified external code. Implemented elsewhere.
* @param player
* @param item
* @param matrix
*/
@Deprecated
public static void takenFromCrafting(EntityPlayer player, ItemStack item, IInventory matrix) {
}
/**
* This method is a call in hook from modified external code. Implemented elsewhere.
* @param player
* @param item
*/
@Deprecated
public static void takenFromFurnace(EntityPlayer player, ItemStack item) {
}
/**
* Throw the offered exception. Likely will stop the game.
* @param message
* @param e
*/
public static void throwException(String message, Throwable e) {
FMLHandler.INSTANCE.raiseException(e, message, true);
FMLHandler.instance().raiseException(e, message, true);
}
/**
* Get the minecraft server instance
* @return
*/
public static MinecraftServer getMinecraftServerInstance() {
return FMLHandler.INSTANCE.getServer();
return FMLHandler.instance().getServer();
}
}