Introduce the client side FML

This commit is contained in:
Christian Weeks committed 2012-05-03 19:40:55 -04:00
1 parent 874d3f0b17
commit 904efdd4d8
8 files changed
+1096 -2

No files matched your search

@@ -0,0 +1,145 @@
package cpw.mods.fml.client;
import java.util.Collections;
import java.util.List;
public class ClientRegistry implements IMinecraftRegistry
{
@Override
public void addRecipe(ItemStack output, Object... params)
{
CraftingManager.func_20151_a().func_20153_a(output, params);
}
@Override
public void addShapelessRecipe(ItemStack output, Object... params)
{
CraftingManager.func_20151_a().func_21146_b(output, params);
}
@Override
public void addSmelting(int input, ItemStack output)
{
FurnaceRecipes.func_21162_a().func_21160_a(input, output);
}
@Override
public void registerBlock(Block block)
{
registerBlock(block, ItemBlock.class);
}
@Override
public void registerBlock(Block block, Class <? extends ItemBlock > itemclass)
{
try
{
assert block != null : "registerBlock: block cannot be null";
assert itemclass != null : "registerBlock: itemclass cannot be null";
int blockItemId = block.field_573_bc - 256;
itemclass.getConstructor(int.class).newInstance(blockItemId);
}
catch (Exception e)
{
//HMMM
}
}
@Override
public void registerEntityID(Class <? extends Entity > entityClass, String entityName, int id)
{
EntityList.addNewEntityListMapping(entityClass, entityName, id);
}
@Override
public void registerEntityID(Class <? extends Entity > entityClass, String entityName, int id, int backgroundEggColour, int foregroundEggColour)
{
EntityList.addNewEntityListMapping(entityClass, entityName, id, backgroundEggColour, foregroundEggColour);
}
@Override
public void registerTileEntity(Class <? extends TileEntity > tileEntityClass, String id)
{
TileEntity.addNewTileEntityMapping(tileEntityClass, id);
}
@Override
public void addBiome(BiomeGenBase biome)
{
//NOOP because the implementation idea is broken. Creating a BiomeGenBase adds the biome already.
}
@Override
public 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));
}
}
@Override
@SuppressWarnings("unchecked")
public 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);
}
}
@Override
public void removeBiome(BiomeGenBase biome)
{
// NOOP because broken
}
@Override
public 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);
}
}
}
}
@Override
@SuppressWarnings("unchecked")
public 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);
}
}
}
+327
View File
@@ -0,0 +1,327 @@
package net.minecraft.src;
/*
* 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
*/
import java.util.Random;
import net.minecraft.server.MinecraftServer;
import cpw.mods.fml.common.IConsoleHandler;
import cpw.mods.fml.common.ICraftingHandler;
import cpw.mods.fml.common.IDispenseHandler;
import cpw.mods.fml.common.INetworkHandler;
import cpw.mods.fml.common.IPickupNotifier;
import cpw.mods.fml.common.IPlayerTracker;
import cpw.mods.fml.common.IWorldGenerator;
public abstract class BaseMod implements IWorldGenerator, IPickupNotifier, IDispenseHandler, ICraftingHandler, INetworkHandler, IConsoleHandler, IPlayerTracker
{
// CALLBACK MECHANISMS
@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, byte xVelocity, byte 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 onPlayerLogin(Object player)
{
onClientLogin((EntityPlayer) player);
}
@Override
public void onPlayerLogout(Object player)
{
onClientLogout((EntityPlayer)player);
}
@Override
public 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_429_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);
}
}
@Override
public final boolean handleCommand(String command, Object... data)
{
return onServerCommand(command, (String)data[0], (ICommandListener)data[1]);
}
// 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)
{
}
/**
* Ticked every game tick if you have subscribed to tick events through {@link ModLoader#setInGameHook(BaseMod, boolean, boolean)}
* @param minecraftServer the server
* @return true to continue receiving ticks
*/
public boolean onTickInGame(MinecraftServer minecraftServer)
{
return false;
}
/**
* Not implemented because on the server you don't know who it's from
* {@link #onChatMessageReceived(EntityPlayer, Packet3Chat)}
* @param text
*/
@Deprecated
public void receiveChatPacket(String text)
{
}
/**
* Not implemented because on the server you don't know who it's from
* {@link #onPacket250Received(EntityPlayer, Packet250CustomPayload)}
* @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();
}
/**
* Called when a 250 packet is received on a channel registered to this mod
*
* @param source
* @param payload
*/
public void onPacket250Received(EntityPlayer source, Packet250CustomPayload payload)
{
}
/**
* Called when a chat message is received. Return true to stop further processing
* @param source
* @param chat
* @return true if you want to consume the message so it is not available for further processing
*/
public boolean onChatMessageReceived(EntityPlayer source, Packet3Chat chat)
{
return false;
}
/**
* Called when a server command is received
* @param command
* @return true if you want to consume the message so it is not available for further processing
*/
public boolean onServerCommand(String command, String sender, ICommandListener listener)
{
return false;
}
/**
* Called when a new client logs in.
*
* @param player
*/
public void onClientLogin(EntityPlayer player)
{
}
/**
* Called when a client logs out of the server.
*
* @param player
*/
public void onClientLogout(EntityPlayer player)
{
}
/**
*
* Called when a client changes dimensions on the server.
*
* @param player
*/
public void onClientDimensionChanged(EntityPlayer player)
{
}
// 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);
}
+620
View File
@@ -0,0 +1,620 @@
package net.minecraft.src;
/*
* 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
*/
import java.util.List;
import java.util.logging.Logger;
import net.minecraft.server.MinecraftServer;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ReflectionHelper;
import cpw.mods.fml.server.FMLServerHandler;
import cpw.mods.fml.server.ModLoaderModContainer;
public class ModLoader
{
/**
* Not used on the server.
*
* @param achievement
* @param name
* @param description
*/
public static void addAchievementDesc(Achievement achievement, String name, String description)
{
}
/**
* This method is a call in hook from modified external code. Implemented elsewhere.
*
* {@link FMLServerHandler#fuelLookup(int, int)}
* @param id
* @param metadata
* @return
*/
@Deprecated
public static int addAllFuel(int id, int metadata)
{
return 0;
}
/**
* This method is unimplemented in server versions to date.
*
* @param armor
* @return
*/
@Deprecated
public static int addArmor(String armor)
{
return 0;
}
/**
* This method adds the supplied biome to the set of candidate biomes for the default world generator type.
*
* @param biome
*/
public static void addBiome(BiomeGenBase biome)
{
FMLServerHandler.instance().addBiomeToDefaultWorldGenerator(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, FMLServerHandler.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, FMLServerHandler.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.
* {@link FMLServerHandler#tryDispensingEntity(World, double, double, double, byte, byte, ItemStack)}
* @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;
}
/**
* Remove a container and drop all the items in it on the ground around
* @param world
* @param x
* @param y
* @param z
*/
public static void genericContainerRemoval(World world, int x, int y, int z)
{
TileEntity te = world.func_451_k(x, y, z);
if (!(te instanceof IInventory))
{
return;
}
IInventory inv = (IInventory)te;
for (int l = 0; l < inv.func_83_a(); l++)
{
ItemStack itemstack = inv.func_82_a(l);
if (itemstack == null)
{
continue;
}
float f = world.field_803_m.nextFloat() * 0.8F + 0.1F;
float f1 = world.field_803_m.nextFloat() * 0.8F + 0.1F;
float f2 = world.field_803_m.nextFloat() * 0.8F + 0.1F;
while (itemstack.field_853_a > 0)
{
int i1 = world.field_803_m.nextInt(21) + 10;
if (i1 > itemstack.field_853_a)
{
i1 = itemstack.field_853_a ;
}
itemstack.field_853_a -= i1;
EntityItem entityitem = new EntityItem(world, (float)te.field_478_b + f, (float)te.field_483_c + f1, (float)te.field_482_d + f2, new ItemStack(itemstack.field_855_c, i1, itemstack.func_21125_h()));
float f3 = 0.05F;
entityitem.field_319_o = (float)world.field_803_m.nextGaussian() * f3;
entityitem.field_318_p = (float)world.field_803_m.nextGaussian() * f3 + 0.2F;
entityitem.field_317_q = (float)world.field_803_m.nextGaussian() * f3;
if (itemstack.func_40608_n())
{
entityitem.field_429_a.func_40604_d((NBTTagCompound)itemstack.func_40607_o().func_40468_b());
}
world.func_526_a(entityitem);
}
}
}
/**
* Get a list of all BaseMod loaded into the system
* {@link ModLoaderModContainer#findAll}
* @return
*/
public static List<BaseMod> getLoadedMods()
{
return ModLoaderModContainer.findAll();
}
/**
* Get a logger instance
* {@link FMLServerHandler#getFMLLogger()}
* @return
*/
public static Logger getLogger()
{
return FMLCommonHandler.instance().getFMLLogger();
}
/**
* Get a value from a field using reflection
* {@link ReflectionHelper#getPrivateValue(Class, Object, int)}
* @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
* {@link ReflectionHelper#getPrivateValue(Class, Object, String)}
* @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
* {@link Entity#getNextId()}
* @return
*/
public static int getUniqueEntityId()
{
return Entity.getNextId();
}
/**
* Is the named mod loaded?
* {@link Loader#isModLoaded(String)}
* @param modname
* @return
*/
public static boolean isModLoaded(String modname)
{
return Loader.isModLoaded(modname);
}
/**
* This method is a call in hook from modified external code. Implemented elsewhere.
* {@link FMLServerHandler#handlePacket250(Packet250CustomPayload, EntityPlayer)}
* @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);
}
/**
* Register the mod for packets on this channel. This only registers the channel with Forge Mod Loader, not
* with clients connecting- use BaseMod.onClientLogin to tell them about your custom channel
* {@link FMLCommonHandler#registerChannel(cpw.mods.fml.common.ModContainer, String)}
* @param mod
* @param channel
*/
public static void registerPacketChannel(BaseMod mod, String channel)
{
FMLCommonHandler.instance().registerChannel(ModLoaderModContainer.findContainerFor(mod), 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 and will likely corrupt worlds.
* @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, FMLServerHandler.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, FMLServerHandler.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);
}
/**
* Configuration is handled elsewhere
* {@link ModLoaderModContainer}
*/
@Deprecated
public static void saveConfig()
{
}
/**
* This method is unimplemented on the server: it is meant for clients to send chat to the server
* {@link FMLServerHandler#handleChatPacket(Packet3Chat, EntityPlayer)}
* @param text
*/
@Deprecated
public static void serverChat(String text)
{
}
/**
* Indicate that you want to receive ticks
*
* @param mod
* receiving the events
* @param enable
* indicates whether you want to recieve them or not
* @param useClock
* Not used in server side: all ticks are sent on the server side (no render subticks)
*/
public static void setInGameHook(BaseMod mod, boolean enable, boolean useClock)
{
ModLoaderModContainer mlmc = (ModLoaderModContainer) ModLoaderModContainer.findContainerFor(mod);
mlmc.setTicking(enable);
}
/**
* Set a private field to a value using reflection
* {@link ReflectionHelper#setPrivateValue(Class, Object, int, Object)}
* @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
* {@link ReflectionHelper#setPrivateValue(Class, Object, String, Object)}
* @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.
* {@link FMLServerHandler#onItemCrafted(EntityPlayer, ItemStack, IInventory)}
* @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.
* {@link FMLServerHandler#onItemSmelted(EntityPlayer, ItemStack)}
* @param player
* @param item
*/
@Deprecated
public static void takenFromFurnace(EntityPlayer player, ItemStack item)
{
}
/**
* Throw the offered exception. Likely will stop the game.
* {@link FMLServerHandler#raiseException(Throwable, String, boolean)}
* @param message
* @param e
*/
public static void throwException(String message, Throwable e)
{
FMLServerHandler.instance().raiseException(e, message, true);
}
/**
* Get the minecraft server instance
* {@link FMLServerHandler#getServer()}
* @return
*/
public static MinecraftServer getMinecraftServerInstance()
{
return FMLServerHandler.instance().getServer();
}
/**
* To properly implement packet 250 protocol you should always check your channel
* is active prior to sending the packet
*
* @param player
* @param channel
* @return
*/
public static boolean isChannelActive(EntityPlayer player, String channel)
{
return FMLCommonHandler.instance().isChannelActive(channel, player);
}
/**
* Stubbed method on the server to return a unique model id
*
*/
@Deprecated
public static int getUniqueBlockModelID(BaseMod mod, boolean flag) {
return 0;
}
}
View File
Whitespace-only changes.
@@ -11,7 +11,7 @@
* 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.modloader;
import java.io.File;
import java.io.FileReader;
@@ -37,6 +37,7 @@ import cpw.mods.fml.common.IWorldGenerator;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.LoaderException;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.server.FMLServerHandler;
public class ModLoaderModContainer implements ModContainer
{
File renamed without changes.
@@ -41,6 +41,7 @@ import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.IFMLSidedHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
/**
* Handles primary communication from hooked code into the system
+1 -1
View File
@@ -19,8 +19,8 @@ import net.minecraft.server.MinecraftServer;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ReflectionHelper;
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
import cpw.mods.fml.server.FMLServerHandler;
import cpw.mods.fml.server.ModLoaderModContainer;
public class ModLoader
{