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