    001/*
    002 * The FML Forge Mod Loader suite. Copyright (C) 2012 cpw
    003 *
    004 * 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
    005 * Software Foundation; either version 2.1 of the License, or any later version.
    006 *
    007 * 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
    008 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    009 *
    010 * 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
    011 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
    012 */
    013package net.minecraft.src;
    014
    015import static cpw.mods.fml.relauncher.Side.CLIENT;
    016
    017import java.awt.image.BufferedImage;
    018import java.util.Collections;
    019import java.util.List;
    020import java.util.Map;
    021import java.util.logging.Logger;
    022
    023import net.minecraft.block.Block;
    024import net.minecraft.block.BlockDispenser;
    025import net.minecraft.client.*;
    026import net.minecraft.client.gui.GuiScreen;
    027import net.minecraft.client.multiplayer.NetClientHandler;
    028import net.minecraft.client.renderer.RenderBlocks;
    029import net.minecraft.client.renderer.RenderEngine;
    030import net.minecraft.client.renderer.entity.Render;
    031import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
    032import net.minecraft.client.settings.KeyBinding;
    033import net.minecraft.command.ICommand;
    034import net.minecraft.dispenser.IBehaviorDispenseItem;
    035import net.minecraft.entity.Entity;
    036import net.minecraft.entity.EntityLiving;
    037import net.minecraft.entity.EnumCreatureType;
    038import net.minecraft.entity.player.EntityPlayer;
    039import net.minecraft.entity.player.EntityPlayerMP;
    040import net.minecraft.inventory.Container;
    041import net.minecraft.inventory.IInventory;
    042import net.minecraft.item.Item;
    043import net.minecraft.item.ItemBlock;
    044import net.minecraft.item.ItemStack;
    045import net.minecraft.network.NetServerHandler;
    046import net.minecraft.network.packet.Packet;
    047import net.minecraft.network.packet.Packet1Login;
    048import net.minecraft.network.packet.Packet250CustomPayload;
    049import net.minecraft.server.*;
    050import net.minecraft.stats.Achievement;
    051import net.minecraft.tileentity.TileEntity;
    052import net.minecraft.world.IBlockAccess;
    053import net.minecraft.world.World;
    054import net.minecraft.world.WorldType;
    055import net.minecraft.world.biome.BiomeGenBase;
    056import net.minecraft.world.chunk.IChunkProvider;
    057import cpw.mods.fml.client.FMLClientHandler;
    058import cpw.mods.fml.client.TextureFXManager;
    059import cpw.mods.fml.client.modloader.ModLoaderClientHelper;
    060import cpw.mods.fml.client.modloader.ModLoaderKeyBindingHandler;
    061import cpw.mods.fml.client.registry.ClientRegistry;
    062import cpw.mods.fml.client.registry.KeyBindingRegistry;
    063import cpw.mods.fml.client.registry.RenderingRegistry;
    064import cpw.mods.fml.common.FMLCommonHandler;
    065import cpw.mods.fml.common.FMLLog;
    066import cpw.mods.fml.common.Loader;
    067import cpw.mods.fml.common.ObfuscationReflectionHelper;
    068import cpw.mods.fml.common.modloader.ModLoaderHelper;
    069import cpw.mods.fml.common.modloader.ModLoaderModContainer;
    070import cpw.mods.fml.common.network.NetworkRegistry;
    071import cpw.mods.fml.common.network.PacketDispatcher;
    072import cpw.mods.fml.common.network.Player;
    073import cpw.mods.fml.common.registry.EntityRegistry;
    074import cpw.mods.fml.common.registry.GameRegistry;
    075import cpw.mods.fml.common.registry.LanguageRegistry;
    076import cpw.mods.fml.relauncher.SideOnly;
    077import cpw.mods.fml.server.FMLServerHandler;
    078
    079public class ModLoader
    080{
    081    public static final String fmlMarker = "This is an FML marker";
    082    // TODO dirty workaround for millinaire
    083    @Deprecated
    084    public static final Map<String,Map<String,String>> localizedStrings=Collections.emptyMap();
    085
    086    /**
    087     * Adds localization info for an achievement, Not used on the server.
    088     *
    089     * @param achievement The achievement to name
    090     * @param name The name
    091     * @param description The description
    092     */
    093    public static void addAchievementDesc(Achievement achievement, String name, String description)
    094    {
    095        String achName=achievement.getName();
    096        addLocalization(achName, name);
    097        addLocalization(achName+".desc", description);
    098    }
    099
    100    /**
    101     * This method is a call in hook from modified external code. Implemented elsewhere.
    102     *
    103     * {@link GameRegistry#getFuelValue(ItemStack)}
    104     *
    105     * @param id The Item ID
    106     * @param metadata The Item Metadata
    107     * @return The fuel strength, in ticks, 0 if unhandled
    108     */
    109    @Deprecated
    110    public static int addAllFuel(int id, int metadata)
    111    {
    112        return 0;
    113    }
    114
    115    @Deprecated
    116    @SideOnly(CLIENT)
    117    public static void addAllRenderers(Map<Class<? extends Entity>, Render> renderers)
    118    {
    119    }
    120
    121    /**
    122     * Adds a new prefix to the armor texture list
    123     *
    124     * {@link RenderingRegistry#addNewArmourRendererPrefix(String)}
    125     *
    126     * @param armor The new armor prefix
    127     * @return The new armor index
    128     */
    129    @SideOnly(CLIENT)
    130    public static int addArmor(String armor)
    131    {
    132        return RenderingRegistry.addNewArmourRendererPrefix(armor);
    133    }
    134
    135    /**
    136     * This method adds the supplied biome to the set of candidate biomes for the default world generator type.
    137     *
    138     * @param biome The biome to add
    139     */
    140    public static void addBiome(BiomeGenBase biome)
    141    {
    142        GameRegistry.addBiome(biome);
    143    }
    144
    145    public static void addEntityTracker(BaseMod mod, Class<? extends Entity> entityClass, int entityTypeId, int updateRange, int updateInterval, boolean sendVelocityInfo)
    146    {
    147        ModLoaderHelper.buildEntityTracker(mod, entityClass, entityTypeId, updateRange, updateInterval, sendVelocityInfo);
    148    }
    149
    150    public static void addCommand(ICommand command)
    151    {
    152        ModLoaderHelper.addCommand(command);
    153    }
    154
    155    /**
    156     * Add a behaviour to the dispenser
    157     *
    158     * @param item
    159     * @param behavior
    160     */
    161    public static void addDispenserBehavior(Item item, IBehaviorDispenseItem behavior)
    162    {
    163        BlockDispenser.dispenseBehaviorRegistry.putObject(item, behavior);
    164    }
    165    /**
    166     * Add localization for the specified string
    167     *
    168     * @param key Key
    169     * @param value Value
    170     */
    171    public static void addLocalization(String key, String value)
    172    {
    173        addLocalization(key, "en_US", value);
    174    }
    175
    176    /**
    177     * Add localization for the specified string
    178     *
    179     * @param key Key
    180     * @param lang Language identifier
    181     * @param value Value
    182     */
    183    public static void addLocalization(String key, String lang, String value)
    184    {
    185        LanguageRegistry.instance().addStringLocalization(key, lang, value);
    186    }
    187
    188    /**
    189     * Name the specified minecraft object with the supplied name
    190     *
    191     * @param instance Item to name
    192     * @param name The name to give it
    193     */
    194    public static void addName(Object instance, String name)
    195    {
    196        addName(instance,"en_US",name);
    197    }
    198
    199    /**
    200     * Unimplemented on the server as it does not generate names
    201     *
    202     * @param instance Item to name
    203     * @param lang Languge identifier
    204     * @param name Name to give it
    205     */
    206    public static void addName(Object instance, String lang, String name)
    207    {
    208        LanguageRegistry.instance().addNameForObject(instance, lang, name);
    209    }
    210
    211    /**
    212     * Attempts to register a small image to be applied to a larger texture image,
    213     * typically how old ModLoader mods add custom Item/Block textures.
    214     *
    215     * Forge mods should use setTextureFile in Item/Block
    216     *
    217     * Will return the icon index it was applied to.
    218     *
    219     * Unimplemented on the server as it does not render textures
    220     *
    221     * @param fileToOverride The texture to apply the new image to
    222     * @param fileToAdd The new image
    223     * @return The 'icon index' in the main image that the new image will be applied to
    224     */
    225    @Deprecated
    226    @SideOnly(CLIENT)
    227    public static int addOverride(String fileToOverride, String fileToAdd)
    228    {
    229        return RenderingRegistry.addTextureOverride(fileToOverride, fileToAdd);
    230    }
    231
    232    /**
    233     * Attempts to register a small image to be applied to a larger texture image,
    234     * typically how old ModLoader mods add custom Item/Block textures.
    235     *
    236     * Forge mods should use setTextureFile in Item/Block
    237     *
    238     * Unimplemented on the server as it does not render textures
    239     *
    240     * @param path The texture to apply the new image to
    241     * @param overlayPath The new image
    242     * @param index Where on the texture to apply it
    243     */
    244    @SideOnly(CLIENT)
    245    public static void addOverride(String path, String overlayPath, int index)
    246    {
    247        RenderingRegistry.addTextureOverride(path, overlayPath, index);
    248    }
    249
    250    /**
    251     * Add a Shaped Recipe
    252     *
    253     * @param output The result
    254     * @param params The input
    255     */
    256    public static void addRecipe(ItemStack output, Object... params)
    257    {
    258        GameRegistry.addRecipe(output, params);
    259    }
    260
    261    /**
    262     * Add a shapeless recipe
    263     *
    264     * @param output The result
    265     * @param params The input
    266     */
    267    public static void addShapelessRecipe(ItemStack output, Object... params)
    268    {
    269        GameRegistry.addShapelessRecipe(output, params);
    270    }
    271
    272    /**
    273     * Add a new product to be smelted
    274     *
    275     * @param input
    276     * @param output
    277     */
    278    public static void addSmelting(int input, ItemStack output)
    279    {
    280        GameRegistry.addSmelting(input, output, 1.0f);
    281    }
    282
    283    /**
    284     * Add a new product to be smelted
    285     *
    286     * @param input
    287     * @param output
    288     */
    289    public static void addSmelting(int input, ItemStack output, float experience)
    290    {
    291        GameRegistry.addSmelting(input, output, experience);
    292    }
    293    /**
    294     * Add a mob to the spawn list
    295     *
    296     * @param entityClass
    297     * @param weightedProb
    298     * @param min
    299     * @param max
    300     * @param spawnList
    301     */
    302    public static void addSpawn(Class<? extends EntityLiving> entityClass, int weightedProb, int min, int max, EnumCreatureType spawnList)
    303    {
    304        EntityRegistry.addSpawn(entityClass, weightedProb, min, max, spawnList, WorldType.base12Biomes);
    305    }
    306
    307    /**
    308     * Add a mob to the spawn list
    309     *
    310     * @param entityClass
    311     * @param weightedProb
    312     * @param min
    313     * @param max
    314     * @param spawnList
    315     * @param biomes
    316     */
    317    public static void addSpawn(Class<? extends EntityLiving> entityClass, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeGenBase... biomes)
    318    {
    319        EntityRegistry.addSpawn(entityClass, weightedProb, min, max, spawnList, biomes);
    320    }
    321
    322    /**
    323     * Add a mob to the spawn list
    324     *
    325     * @param entityName
    326     * @param weightedProb
    327     * @param min
    328     * @param max
    329     * @param spawnList
    330     */
    331    public static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList)
    332    {
    333        EntityRegistry.addSpawn(entityName, weightedProb, min, max, spawnList, WorldType.base12Biomes);
    334    }
    335
    336    /**
    337     * Add a mob to the spawn list
    338     *
    339     * @param entityName
    340     * @param weightedProb
    341     * @param min
    342     * @param max
    343     * @param spawnList
    344     * @param biomes
    345     */
    346    public static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeGenBase... biomes)
    347    {
    348        EntityRegistry.addSpawn(entityName, weightedProb, min, max, spawnList, biomes);
    349    }
    350
    351    public static void addTrade(int profession, TradeEntry entry)
    352    {
    353        ModLoaderHelper.registerTrade(profession, entry);
    354    }
    355    /**
    356     * Send a packet from the client
    357     * @param packet
    358     */
    359    public static void clientSendPacket(Packet packet)
    360    {
    361        PacketDispatcher.sendPacketToServer(packet);
    362    }
    363
    364    /**
    365     * This method is a call in hook from modified external code. Implemented elsewhere.
    366     *
    367     * @param world
    368     * @param x
    369     * @param y
    370     * @param z
    371     * @param xVel
    372     * @param zVel
    373     * @param item
    374     * @return Always false, not implemented here
    375     */
    376    @Deprecated
    377    public static boolean dispenseEntity(World world, double x, double y, double z, int xVel, int zVel, ItemStack item)
    378    {
    379        return false;
    380    }
    381
    382    /**
    383     * Remove a container and drop all the items in it on the ground around
    384     *
    385     * @param world
    386     * @param x
    387     * @param y
    388     * @param z
    389     */
    390    public static void genericContainerRemoval(World world, int x, int y, int z)
    391    {
    392/*        TileEntity te = world.func_603_b(x, y, z);
    393
    394        if (!(te instanceof IInventory))
    395        {
    396            return;
    397        }
    398
    399        IInventory inv = (IInventory)te;
    400
    401        for (int l = 0; l < inv.func_469_c(); l++)
    402        {
    403            ItemStack itemstack = inv.func_468_c(l);
    404
    405            if (itemstack == null)
    406            {
    407                continue;
    408            }
    409
    410            float f = world.field_1037_n.nextFloat() * 0.8F + 0.1F;
    411            float f1 = world.field_1037_n.nextFloat() * 0.8F + 0.1F;
    412            float f2 = world.field_1037_n.nextFloat() * 0.8F + 0.1F;
    413
    414            while (itemstack.field_1615_a > 0)
    415            {
    416                int i1 = world.field_1037_n.nextInt(21) + 10;
    417
    418                if (i1 > itemstack.field_1615_a)
    419                {
    420                    i1 = itemstack.field_1615_a;
    421                }
    422
    423                itemstack.field_1615_a -= i1;
    424                EntityItem entityitem = new EntityItem(world, (float)te.field_823_f + f, (float)te.field_822_g + f1, (float)te.field_821_h + f2, new ItemStack(itemstack.field_1617_c, i1, itemstack.func_21181_i()));
    425                float f3 = 0.05F;
    426                entityitem.field_608_an = (float) world.field_1037_n.nextGaussian() * f3;
    427                entityitem.field_607_ao = (float) world.field_1037_n.nextGaussian() * f3 + 0.2F;
    428                entityitem.field_606_ap = (float) world.field_1037_n.nextGaussian() * f3;
    429
    430                if (itemstack.func_40710_n())
    431                {
    432                    entityitem.field_801_a.func_40706_d((NBTTagCompound) itemstack.func_40709_o().func_40195_b());
    433                }
    434
    435                world.func_674_a(entityitem);
    436            }
    437        }
    438*/    }
    439
    440    /**
    441     * Get a list of all BaseMod loaded into the system
    442     * {@link ModLoaderModContainer#findAll}
    443     *
    444     * @return A list containing all loaded ModLoader mods
    445     */
    446    public static List<BaseMod> getLoadedMods()
    447    {
    448        return ModLoaderModContainer.findAll(BaseMod.class);
    449    }
    450
    451    /**
    452     * Get a logger instance {@link FMLCommonHandler#getFMLLogger()}
    453     *
    454     * @return The current logger
    455     */
    456    public static Logger getLogger()
    457    {
    458        return FMLLog.getLogger();
    459    }
    460
    461    @SideOnly(CLIENT)
    462    public static Minecraft getMinecraftInstance()
    463    {
    464        return FMLClientHandler.instance().getClient();
    465    }
    466
    467    public static MinecraftServer getMinecraftServerInstance()
    468    {
    469        return FMLCommonHandler.instance().getMinecraftServerInstance();
    470    }
    471
    472    /**
    473     * Get a value from a field using reflection
    474     * {@link ObfuscationReflectionHelper#getPrivateValue(Class, Object, int)}
    475     *
    476     * @param instanceclass
    477     * @param instance
    478     * @param fieldindex
    479     * @return The value in the specified field.
    480     */
    481    public static <T, E> T getPrivateValue(Class<? super E> instanceclass, E instance, int fieldindex)
    482    {
    483        return ObfuscationReflectionHelper.getPrivateValue(instanceclass, instance, fieldindex);
    484    }
    485
    486    /**
    487     * Get a value from a field using reflection
    488     * {@link ObfuscationReflectionHelper#getPrivateValue(Class, Object, String[])}
    489     *
    490     * @param instanceclass
    491     * @param instance
    492     * @param field
    493     * @return The value in the specified field.
    494     */
    495    public static <T, E> T getPrivateValue(Class<? super E> instanceclass, E instance, String field)
    496    {
    497        return ObfuscationReflectionHelper.getPrivateValue(instanceclass, instance, field);
    498    }
    499
    500    /**
    501     * Stubbed method on the server to return a unique model id
    502     *
    503     */
    504    @SideOnly(CLIENT)
    505    public static int getUniqueBlockModelID(BaseMod mod, boolean inventoryRenderer)
    506    {
    507        return ModLoaderClientHelper.obtainBlockModelIdFor(mod, inventoryRenderer);
    508    }
    509
    510    /**
    511     * Get a new unique entity id
    512     * {@link EntityRegistry#findGlobalUniqueEntityId()}
    513     *
    514     * @return A unique entity ID
    515     */
    516    public static int getUniqueEntityId()
    517    {
    518        return EntityRegistry.findGlobalUniqueEntityId();
    519    }
    520
    521    @Deprecated
    522    @SideOnly(CLIENT)
    523    public static int getUniqueSpriteIndex(String path)
    524    {
    525        return -1;
    526    }
    527
    528    /**
    529     * To properly implement packet 250 protocol you should always check your
    530     * channel is active prior to sending the packet
    531     *
    532     * @param player
    533     * @param channel
    534     * @return If the channel is registered to the current connection.
    535     */
    536    public static boolean isChannelActive(EntityPlayer player, String channel)
    537    {
    538        return NetworkRegistry.instance().isChannelActive(channel, (Player)player);
    539    }
    540
    541    @SideOnly(CLIENT)
    542    public static boolean isGUIOpen(Class<? extends GuiScreen> gui)
    543    {
    544        return FMLClientHandler.instance().getClient().currentScreen != null && FMLClientHandler.instance().getClient().currentScreen.equals(gui);
    545    }
    546
    547    /**
    548     * Is the named mod loaded?
    549     * {@link Loader#isModLoaded(String)}
    550     *
    551     * @param modname
    552     * @return If the specified mod is loaded
    553     */
    554    public static boolean isModLoaded(String modname)
    555    {
    556        return Loader.isModLoaded(modname);
    557    }
    558
    559    /**
    560     * Implemented elsewhere
    561     */
    562    @Deprecated
    563    public static void loadConfig()
    564    {
    565    }
    566
    567    @SideOnly(CLIENT)
    568    public static BufferedImage loadImage(RenderEngine renderEngine, String path) throws Exception
    569    {
    570        return TextureFXManager.instance().loadImageFromTexturePack(renderEngine, path);
    571    }
    572
    573    /**
    574     * Call in from elsewhere. Unimplemented here.
    575     * @param player
    576     * @param item
    577     */
    578    @Deprecated
    579    public static void onItemPickup(EntityPlayer player, ItemStack item)
    580    {
    581    }
    582    /**
    583     * Call in from elsewhere. Unimplemented here.
    584     */
    585    @Deprecated
    586    @SideOnly(CLIENT)
    587    public static void onTick(float tick, Minecraft game)
    588    {
    589    }
    590
    591    @SideOnly(CLIENT)
    592    public static void openGUI(EntityPlayer player, GuiScreen gui)
    593    {
    594        FMLClientHandler.instance().displayGuiScreen(player, gui);
    595    }
    596
    597    @Deprecated
    598    public static void populateChunk(IChunkProvider generator, int chunkX, int chunkZ, World world)
    599    {
    600    }
    601
    602    /**
    603     * This method is a call in hook from modified external code. Implemented elsewhere.
    604     *
    605     * @param packet
    606     */
    607    @Deprecated
    608    public static void receivePacket(Packet250CustomPayload packet)
    609    {
    610    }
    611
    612    @Deprecated
    613    @SideOnly(CLIENT)
    614    public static KeyBinding[] registerAllKeys(KeyBinding[] keys)
    615    {
    616        return keys;
    617    }
    618
    619    @Deprecated
    620    @SideOnly(CLIENT)
    621    public static void registerAllTextureOverrides(RenderEngine cache)
    622    {
    623    }
    624
    625    /**
    626     * Register a new block
    627     *
    628     * @param block
    629     */
    630    public static void registerBlock(Block block)
    631    {
    632        GameRegistry.registerBlock(block);
    633    }
    634
    635    /**
    636     * Register a new block
    637     *
    638     * @param block
    639     * @param itemclass
    640     */
    641    public static void registerBlock(Block block, Class<? extends ItemBlock> itemclass)
    642    {
    643        GameRegistry.registerBlock(block, itemclass);
    644    }
    645
    646    public static void registerContainerID(BaseMod mod, int id)
    647    {
    648        ModLoaderHelper.buildGuiHelper(mod, id);
    649    }
    650    /**
    651     * Register a new entity ID
    652     *
    653     * @param entityClass
    654     * @param entityName
    655     * @param id
    656     */
    657    public static void registerEntityID(Class<? extends Entity> entityClass, String entityName, int id)
    658    {
    659        EntityRegistry.registerGlobalEntityID(entityClass, entityName, id);
    660    }
    661
    662    /**
    663     * Register a new entity ID
    664     *
    665     * @param entityClass
    666     * @param entityName
    667     * @param id
    668     * @param background
    669     * @param foreground
    670     */
    671    public static void registerEntityID(Class<? extends Entity> entityClass, String entityName, int id, int background, int foreground)
    672    {
    673        EntityRegistry.registerGlobalEntityID(entityClass, entityName, id, background, foreground);
    674    }
    675
    676    @SideOnly(CLIENT)
    677    public static void registerKey(BaseMod mod, KeyBinding keyHandler, boolean allowRepeat)
    678    {
    679        ModLoaderClientHelper.registerKeyBinding(mod, keyHandler, allowRepeat);
    680    }
    681
    682    /**
    683     * Register the mod for packets on this channel.
    684     * {@link NetworkRegistry#registerChannel(IPacketHandler, String)}
    685     *
    686     * @param mod
    687     * @param channel
    688     */
    689    public static void registerPacketChannel(BaseMod mod, String channel)
    690    {
    691        NetworkRegistry.instance().registerChannel(ModLoaderHelper.buildPacketHandlerFor(mod), channel);
    692    }
    693
    694    /**
    695     * Register a new tile entity class
    696     *
    697     * @param tileEntityClass
    698     * @param id
    699     */
    700    public static void registerTileEntity(Class<? extends TileEntity> tileEntityClass, String id)
    701    {
    702        GameRegistry.registerTileEntity(tileEntityClass, id);
    703    }
    704
    705    @SideOnly(CLIENT)
    706    public static void registerTileEntity(Class<? extends TileEntity> tileEntityClass, String id, TileEntitySpecialRenderer renderer)
    707    {
    708        ClientRegistry.registerTileEntity(tileEntityClass, id, renderer);
    709    }
    710
    711    /**
    712     * Remove a biome from the list of generated biomes
    713     *
    714     * @param biome
    715     */
    716    public static void removeBiome(BiomeGenBase biome)
    717    {
    718        GameRegistry.removeBiome(biome);
    719    }
    720
    721    /**
    722     * Remove a spawn
    723     *
    724     * @param entityClass
    725     * @param spawnList
    726     */
    727    public static void removeSpawn(Class<? extends EntityLiving> entityClass, EnumCreatureType spawnList)
    728    {
    729        EntityRegistry.removeSpawn(entityClass, spawnList, WorldType.base12Biomes);
    730    }
    731
    732    /**
    733     * Remove a spawn
    734     *
    735     * @param entityClass
    736     * @param spawnList
    737     * @param biomes
    738     */
    739    public static void removeSpawn(Class<? extends EntityLiving> entityClass, EnumCreatureType spawnList, BiomeGenBase... biomes)
    740    {
    741        EntityRegistry.removeSpawn(entityClass, spawnList, biomes);
    742    }
    743
    744    /**
    745     * Remove a spawn
    746     *
    747     * @param entityName
    748     * @param spawnList
    749     */
    750    public static void removeSpawn(String entityName, EnumCreatureType spawnList)
    751    {
    752        EntityRegistry.removeSpawn(entityName, spawnList, WorldType.base12Biomes);
    753    }
    754
    755    /**
    756     * Remove a spawn
    757     *
    758     * @param entityName
    759     * @param spawnList
    760     * @param biomes
    761     */
    762    public static void removeSpawn(String entityName, EnumCreatureType spawnList, BiomeGenBase... biomes)
    763    {
    764        EntityRegistry.removeSpawn(entityName, spawnList, biomes);
    765    }
    766
    767    @Deprecated
    768    @SideOnly(CLIENT)
    769    public static boolean renderBlockIsItemFull3D(int modelID)
    770    {
    771        return RenderingRegistry.instance().renderItemAsFull3DBlock(modelID);
    772    }
    773
    774    @Deprecated
    775    @SideOnly(CLIENT)
    776    public static void renderInvBlock(RenderBlocks renderer, Block block, int metadata, int modelID)
    777    {
    778        RenderingRegistry.instance().renderInventoryBlock(renderer, block, metadata, modelID);
    779    }
    780
    781    @Deprecated
    782    @SideOnly(CLIENT)
    783    public static boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelID)
    784    {
    785        return RenderingRegistry.instance().renderWorldBlock(renderer, world, x, y, z, block, modelID);
    786    }
    787
    788    /**
    789     * Configuration is handled elsewhere
    790     * {@link ModLoaderModContainer}
    791     */
    792    @Deprecated
    793    public static void saveConfig()
    794    {
    795    }
    796
    797    /**
    798     * Send a packet from client to server
    799     *
    800     * @param packet
    801     */
    802    public static void sendPacket(Packet packet) {
    803        PacketDispatcher.sendPacketToServer(packet);
    804    }
    805    /**
    806     * Send a chat message to the server
    807     *
    808     * @param text
    809     */
    810    @Deprecated
    811    public static void serverChat(String text)
    812    {
    813        //TODO
    814    }
    815
    816    @Deprecated
    817    @SideOnly(CLIENT)
    818    public static void serverLogin(NetClientHandler handler, Packet1Login loginPacket)
    819    {
    820        //TODO
    821    }
    822
    823    public static void serverSendPacket(NetServerHandler handler, Packet packet)
    824    {
    825        if (handler != null)
    826        {
    827            PacketDispatcher.sendPacketToPlayer(packet, (Player)handler.getPlayer());
    828        }
    829    }
    830    public static void serverOpenWindow(EntityPlayerMP player, Container container, int ID, int x, int y, int z)
    831    {
    832        ModLoaderHelper.openGui(ID, player, container, x, y, z);
    833    }
    834
    835    /**
    836     * Indicate that you want to receive ticks
    837     *
    838     * @param mod receiving the events
    839     * @param enable indicates whether you want to recieve them or not
    840     * @param useClock don't receive render subticks, just world ticks
    841     */
    842    public static void setInGameHook(BaseMod mod, boolean enable, boolean useClock)
    843    {
    844        ModLoaderHelper.updateStandardTicks(mod, enable, useClock);
    845    }
    846
    847
    848    public static void setInGUIHook(BaseMod mod, boolean enable, boolean useClock)
    849    {
    850        ModLoaderHelper.updateGUITicks(mod, enable, useClock);
    851    }
    852
    853    /**
    854     * Set a private field to a value using reflection
    855     * {@link ObfuscationReflectionHelper#setPrivateValue(Class, Object, int, Object)}
    856     *
    857     * @param instanceclass
    858     * @param instance
    859     * @param fieldindex
    860     * @param value
    861     */
    862    public static <T, E> void setPrivateValue(Class<? super T> instanceclass, T instance, int fieldindex, E value)
    863    {
    864        ObfuscationReflectionHelper.setPrivateValue(instanceclass, instance, value, fieldindex);
    865    }
    866
    867    /**
    868     * Set a private field to a value using reflection
    869     * {@link ObfuscationReflectionHelper#setPrivateValue(Class, Object, String, Object)}
    870     *
    871     * @param instanceclass
    872     * @param instance
    873     * @param field
    874     * @param value
    875     */
    876    public static <T, E> void setPrivateValue(Class<? super T> instanceclass, T instance, String field, E value)
    877    {
    878        ObfuscationReflectionHelper.setPrivateValue(instanceclass, instance, value, field);
    879    }
    880
    881    /**
    882     * This method is a call in hook from modified external code. Implemented elsewhere.
    883     *
    884     * @param player
    885     * @param item
    886     * @param matrix
    887     */
    888    @Deprecated
    889    public static void takenFromCrafting(EntityPlayer player, ItemStack item, IInventory matrix)
    890    {
    891    }
    892
    893    /**
    894     * This method is a call in hook from modified external code. Implemented elsewhere.
    895     *
    896     * @param player
    897     * @param item
    898     */
    899    @Deprecated
    900    public static void takenFromFurnace(EntityPlayer player, ItemStack item)
    901    {
    902    }
    903
    904    /**
    905     * Throw the offered exception. Likely will stop the game.
    906     *
    907     * @param message
    908     * @param e
    909     */
    910    public static void throwException(String message, Throwable e)
    911    {
    912        FMLCommonHandler.instance().raiseException(e, message, true);
    913    }
    914
    915    public static void throwException(Throwable e)
    916    {
    917        throwException("Exception in ModLoader", e);
    918    }
    919}