resonant-induction/src/resonantinduction/ResonantInduction.java

330 lines
15 KiB
Java
Raw Normal View History

2013-08-02 02:17:42 +02:00
package resonantinduction;
2013-08-25 11:15:00 +02:00
import ic2.api.item.Items;
2013-08-02 02:24:57 +02:00
import java.io.File;
2013-08-02 02:38:42 +02:00
import java.util.Arrays;
import java.util.Map;
2013-08-02 02:38:42 +02:00
import java.util.logging.Logger;
2013-08-02 02:24:57 +02:00
2013-08-02 02:29:44 +02:00
import net.minecraft.block.Block;
2013-08-02 05:07:56 +02:00
import net.minecraft.item.Item;
2013-08-02 04:03:44 +02:00
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
2013-08-02 02:24:57 +02:00
import net.minecraftforge.common.Configuration;
2013-08-24 14:00:33 +02:00
import net.minecraftforge.common.MinecraftForge;
2013-09-21 17:34:05 +02:00
import net.minecraftforge.oredict.OreDictionary;
2013-08-02 05:07:56 +02:00
import net.minecraftforge.oredict.ShapedOreRecipe;
2013-08-25 11:15:00 +02:00
import net.minecraftforge.oredict.ShapelessOreRecipe;
import org.modstats.ModstatInfo;
import org.modstats.Modstats;
2013-08-04 04:14:47 +02:00
import resonantinduction.battery.BlockBattery;
2013-08-04 04:23:06 +02:00
import resonantinduction.battery.ItemCapacitor;
2013-08-25 11:15:00 +02:00
import resonantinduction.battery.ItemInfiniteCapacitor;
2013-08-04 04:14:47 +02:00
import resonantinduction.battery.TileEntityBattery;
2013-08-03 04:18:03 +02:00
import resonantinduction.contractor.BlockEMContractor;
2013-08-03 19:41:37 +02:00
import resonantinduction.contractor.ItemBlockContractor;
2013-08-03 04:18:03 +02:00
import resonantinduction.contractor.TileEntityEMContractor;
2013-08-04 16:20:45 +02:00
import resonantinduction.entangler.ItemLinker;
import resonantinduction.entangler.ItemQuantumEntangler;
2013-08-04 01:19:20 +02:00
import resonantinduction.multimeter.BlockMultimeter;
import resonantinduction.multimeter.ItemBlockMultimeter;
2013-08-24 14:00:33 +02:00
import resonantinduction.multimeter.MultimeterEventHandler;
2013-08-04 01:43:10 +02:00
import resonantinduction.multimeter.TileEntityMultimeter;
2013-08-02 02:57:56 +02:00
import resonantinduction.tesla.BlockTesla;
import resonantinduction.tesla.TileEntityTesla;
2013-08-07 01:03:29 +02:00
import resonantinduction.wire.BlockWire;
2013-08-23 14:49:01 +02:00
import resonantinduction.wire.EnumWireMaterial;
2013-08-07 01:24:24 +02:00
import resonantinduction.wire.ItemBlockWire;
2013-08-12 14:47:42 +02:00
import resonantinduction.wire.TileEntityTickWire;
2013-08-07 01:46:08 +02:00
import resonantinduction.wire.TileEntityWire;
2013-09-17 05:21:00 +02:00
import resonantinduction.wire.multipart.ItemPartWire;
import universalelectricity.core.item.IItemElectric;
2013-08-23 14:49:01 +02:00
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.TranslationHelper;
2013-08-12 14:47:42 +02:00
import basiccomponents.api.BasicRegistry;
import calclavia.lib.UniversalRecipes;
2013-08-02 02:38:42 +02:00
import cpw.mods.fml.common.FMLLog;
2013-08-02 02:24:57 +02:00
import cpw.mods.fml.common.Loader;
2013-08-02 02:17:42 +02:00
import cpw.mods.fml.common.Mod;
2013-08-02 02:29:44 +02:00
import cpw.mods.fml.common.Mod.EventHandler;
2013-08-02 02:20:14 +02:00
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.ObfuscationReflectionHelper;
2013-08-02 02:48:07 +02:00
import cpw.mods.fml.common.SidedProxy;
2013-08-02 02:29:44 +02:00
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
2013-08-02 02:38:42 +02:00
import cpw.mods.fml.common.network.NetworkMod;
2013-08-04 01:43:10 +02:00
import cpw.mods.fml.common.network.NetworkRegistry;
2013-08-02 02:57:56 +02:00
import cpw.mods.fml.common.registry.GameRegistry;
2013-08-02 02:17:42 +02:00
/**
* @author Calclavia
*
*/
@Mod(modid = ResonantInduction.ID, name = ResonantInduction.NAME, version = ResonantInduction.VERSION)
2013-08-02 02:38:42 +02:00
@NetworkMod(channels = ResonantInduction.CHANNEL, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
2013-08-06 23:58:17 +02:00
@ModstatInfo(prefix = "resonantin")
2013-08-02 02:17:42 +02:00
public class ResonantInduction
{
2013-08-02 02:24:57 +02:00
/**
* Mod Information
*/
2013-08-02 03:08:46 +02:00
public static final String ID = "resonantinduction";
2013-08-02 02:17:42 +02:00
public static final String NAME = "Resonant Induction";
2013-08-05 21:53:54 +02:00
public static final String CHANNEL = "RESIND";
2013-08-02 02:17:42 +02:00
public static final String MAJOR_VERSION = "@MAJOR@";
public static final String MINOR_VERSION = "@MINOR@";
public static final String REVISION_VERSION = "@REVIS@";
public static final String BUILD_VERSION = "@BUILD@";
public static final String VERSION = MAJOR_VERSION + "." + MINOR_VERSION + "." + REVISION_VERSION;
2013-08-02 02:20:14 +02:00
@Instance(ID)
public static ResonantInduction INSTANCE;
2013-08-02 02:20:14 +02:00
2013-08-02 02:48:07 +02:00
@SidedProxy(clientSide = ID + ".ClientProxy", serverSide = ID + ".CommonProxy")
public static CommonProxy proxy;
2013-08-02 02:20:14 +02:00
@Mod.Metadata(ID)
public static ModMetadata metadata;
2013-08-02 02:24:57 +02:00
2013-08-02 02:38:42 +02:00
public static final Logger LOGGER = Logger.getLogger(NAME);
2013-08-02 02:24:57 +02:00
/**
* Directory Information
*/
public static final String DOMAIN = "resonantinduction";
public static final String PREFIX = DOMAIN + ":";
public static final String DIRECTORY = "/assets/" + DOMAIN + "/";
public static final String TEXTURE_DIRECTORY = "textures/";
2013-08-04 01:43:10 +02:00
public static final String GUI_DIRECTORY = TEXTURE_DIRECTORY + "gui/";
2013-08-02 03:15:02 +02:00
public static final String BLOCK_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "blocks/";
public static final String ITEM_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "items/";
public static final String MODEL_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "models/";
2013-08-07 23:59:02 +02:00
public static final String MODEL_DIRECTORY = DIRECTORY + "models/";
2013-08-02 02:24:57 +02:00
2013-08-02 04:19:01 +02:00
public static final String LANGUAGE_DIRECTORY = DIRECTORY + "languages/";
public static final String[] LANGUAGES = new String[] { "en_US", "de_DE" };
2013-08-02 02:24:57 +02:00
/**
* Settings
*/
public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), NAME + ".cfg"));
2013-08-12 14:04:48 +02:00
public static float FURNACE_WATTAGE = 1;
2013-08-04 01:11:50 +02:00
public static boolean SOUND_FXS = true;
2013-08-02 02:24:57 +02:00
2013-08-02 02:29:44 +02:00
/** Block ID by Jyzarc */
private static final int BLOCK_ID_PREFIX = 3200;
/** Item ID by Horfius */
private static final int ITEM_ID_PREFIX = 20150;
2013-08-05 23:20:08 +02:00
public static int MAX_CONTRACTOR_DISTANCE = 200;
2013-08-02 02:29:44 +02:00
private static int NEXT_BLOCK_ID = BLOCK_ID_PREFIX;
private static int NEXT_ITEM_ID = ITEM_ID_PREFIX;
public static int getNextBlockID()
{
return NEXT_BLOCK_ID++;
}
public static int getNextItemID()
{
return NEXT_ITEM_ID++;
}
2013-08-02 15:03:12 +02:00
// Items
public static Item itemQuantumEntangler;
2013-08-04 04:23:06 +02:00
public static Item itemCapacitor;
2013-08-25 11:15:00 +02:00
public static Item itemInfiniteCapacitor;
2013-08-04 16:20:45 +02:00
public static Item itemLinker;
2013-09-17 05:21:00 +02:00
public static Item itemPartWire;
2013-08-02 02:29:44 +02:00
2013-08-02 15:03:12 +02:00
// Blocks
2013-08-02 02:29:44 +02:00
public static Block blockTesla;
2013-08-04 01:19:20 +02:00
public static Block blockMultimeter;
2013-08-03 04:18:03 +02:00
public static Block blockEMContractor;
2013-08-04 04:14:47 +02:00
public static Block blockBattery;
2013-08-07 01:03:29 +02:00
public static Block blockWire;
2013-09-21 05:20:39 +02:00
public static Block blockAdvancedFurnaceIdle, blockAdvancedFurnaceBurning;
public static final Vector3[] DYE_COLORS = new Vector3[] { new Vector3(), new Vector3(1, 0, 0), new Vector3(0, 0.608, 0.232), new Vector3(0.588, 0.294, 0), new Vector3(0, 0, 1), new Vector3(0.5, 0, 05), new Vector3(0, 1, 1), new Vector3(0.8, 0.8, 0.8), new Vector3(0.3, 0.3, 0.3), new Vector3(1, 0.412, 0.706), new Vector3(0.616, 1, 0), new Vector3(1, 1, 0), new Vector3(0.46f, 0.932, 1), new Vector3(0.5, 0.2, 0.5), new Vector3(0.7, 0.5, 0.1), new Vector3(1, 1, 1) };
2013-08-02 02:29:44 +02:00
@EventHandler
public void preInit(FMLPreInitializationEvent evt)
{
2013-08-02 02:38:42 +02:00
LOGGER.setParent(FMLLog.getLogger());
2013-08-04 03:38:12 +02:00
NetworkRegistry.instance().registerGuiHandler(this, ResonantInduction.proxy);
2013-08-06 23:58:17 +02:00
Modstats.instance().getReporter().registerMod(this);
2013-08-24 14:00:33 +02:00
MinecraftForge.EVENT_BUS.register(new MultimeterEventHandler());
2013-08-02 02:48:07 +02:00
CONFIGURATION.load();
2013-08-02 15:03:12 +02:00
2013-08-02 15:06:32 +02:00
// Config
2013-08-12 14:04:48 +02:00
FURNACE_WATTAGE = (float) CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Furnace Wattage Per Tick", FURNACE_WATTAGE).getDouble(FURNACE_WATTAGE);
2013-08-04 01:11:50 +02:00
SOUND_FXS = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Tesla Sound FXs", SOUND_FXS).getBoolean(SOUND_FXS);
2013-08-05 23:20:08 +02:00
MAX_CONTRACTOR_DISTANCE = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Max EM Contractor Path", MAX_CONTRACTOR_DISTANCE).getInt(MAX_CONTRACTOR_DISTANCE);
2013-08-04 03:38:12 +02:00
TileEntityEMContractor.ACCELERATION = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Contractor Item Acceleration", TileEntityEMContractor.ACCELERATION).getDouble(TileEntityEMContractor.ACCELERATION);
TileEntityEMContractor.MAX_REACH = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Contractor Max Item Reach", TileEntityEMContractor.MAX_REACH).getInt(TileEntityEMContractor.MAX_REACH);
TileEntityEMContractor.MAX_SPEED = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Contractor Max Item Speed", TileEntityEMContractor.MAX_SPEED).getDouble(TileEntityEMContractor.MAX_SPEED);
TileEntityEMContractor.PUSH_DELAY = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Contractor Item Push Delay", TileEntityEMContractor.PUSH_DELAY).getInt(TileEntityEMContractor.PUSH_DELAY);
2013-08-04 01:19:20 +02:00
2013-08-02 15:06:32 +02:00
// Items
itemQuantumEntangler = new ItemQuantumEntangler(getNextItemID());
2013-08-04 04:23:06 +02:00
itemCapacitor = new ItemCapacitor(getNextItemID());
2013-08-04 16:20:45 +02:00
itemLinker = new ItemLinker(getNextItemID());
2013-08-25 11:15:00 +02:00
itemInfiniteCapacitor = new ItemInfiniteCapacitor(getNextItemID());
2013-08-04 04:23:06 +02:00
2013-09-17 05:21:00 +02:00
itemPartWire = new ItemPartWire(getNextItemID());
2013-08-04 04:23:06 +02:00
2013-08-02 15:06:32 +02:00
// Blocks
2013-08-02 02:48:07 +02:00
blockTesla = new BlockTesla(getNextBlockID());
2013-08-04 01:19:20 +02:00
blockMultimeter = new BlockMultimeter(getNextBlockID());
2013-08-04 01:43:10 +02:00
blockEMContractor = new BlockEMContractor(getNextBlockID());
2013-08-04 04:14:47 +02:00
blockBattery = new BlockBattery(getNextBlockID());
2013-08-07 01:03:29 +02:00
blockWire = new BlockWire(getNextBlockID());
2013-09-21 05:20:39 +02:00
blockAdvancedFurnaceIdle = new BlockAdvancedFurnace(getNextBlockID(), false);
blockAdvancedFurnaceBurning = new BlockAdvancedFurnace(getNextBlockID(), true);
2013-08-04 01:43:10 +02:00
CONFIGURATION.save();
2013-08-04 01:19:20 +02:00
2013-08-07 01:24:24 +02:00
GameRegistry.registerItem(itemQuantumEntangler, itemQuantumEntangler.getUnlocalizedName());
GameRegistry.registerItem(itemCapacitor, itemCapacitor.getUnlocalizedName());
2013-08-25 11:15:00 +02:00
GameRegistry.registerItem(itemInfiniteCapacitor, itemInfiniteCapacitor.getUnlocalizedName());
2013-08-07 01:24:24 +02:00
GameRegistry.registerItem(itemLinker, itemLinker.getUnlocalizedName());
2013-08-07 01:46:08 +02:00
2013-08-02 02:57:56 +02:00
GameRegistry.registerBlock(blockTesla, blockTesla.getUnlocalizedName());
GameRegistry.registerBlock(blockMultimeter, ItemBlockMultimeter.class, blockMultimeter.getUnlocalizedName());
2013-08-03 19:41:37 +02:00
GameRegistry.registerBlock(blockEMContractor, ItemBlockContractor.class, blockEMContractor.getUnlocalizedName());
2013-08-04 04:14:47 +02:00
GameRegistry.registerBlock(blockBattery, blockBattery.getUnlocalizedName());
2013-08-07 01:24:24 +02:00
GameRegistry.registerBlock(blockWire, ItemBlockWire.class, blockWire.getUnlocalizedName());
2013-08-02 15:03:12 +02:00
2013-08-02 15:06:32 +02:00
// Tiles
2013-08-02 02:57:56 +02:00
GameRegistry.registerTileEntity(TileEntityTesla.class, blockTesla.getUnlocalizedName());
2013-08-04 01:43:10 +02:00
GameRegistry.registerTileEntity(TileEntityMultimeter.class, blockMultimeter.getUnlocalizedName());
2013-08-03 04:18:03 +02:00
GameRegistry.registerTileEntity(TileEntityEMContractor.class, blockEMContractor.getUnlocalizedName());
2013-08-04 04:14:47 +02:00
GameRegistry.registerTileEntity(TileEntityBattery.class, blockBattery.getUnlocalizedName());
2013-08-07 01:46:08 +02:00
GameRegistry.registerTileEntity(TileEntityWire.class, blockWire.getUnlocalizedName());
2013-08-12 14:47:42 +02:00
GameRegistry.registerTileEntity(TileEntityTickWire.class, blockWire.getUnlocalizedName() + "2");
2013-08-04 16:20:45 +02:00
ResonantInduction.proxy.registerRenderers();
2013-08-02 04:03:44 +02:00
2013-08-05 19:36:31 +02:00
TabRI.ITEMSTACK = new ItemStack(blockBattery);
2013-09-21 17:34:05 +02:00
OreDictionary.registerOre("copperWire", new ItemStack(blockWire));
2013-08-12 13:05:59 +02:00
// Basic Components
BasicRegistry.register("itemIngotSteel");
BasicRegistry.register("itemPlateSteel");
BasicRegistry.register("itemIngotBronze");
2013-08-02 02:29:44 +02:00
}
@EventHandler
public void init(FMLInitializationEvent evt)
{
LOGGER.fine("Languages Loaded:" + TranslationHelper.loadLanguages(LANGUAGE_DIRECTORY, LANGUAGES));
2013-08-02 02:38:42 +02:00
metadata.modId = ID;
metadata.name = NAME;
metadata.description = "Resonant Induction is a Minecraft mod focusing on the manipulation of electricity and wireless technology. Ever wanted blazing electrical shocks flying off your evil lairs? You've came to the right place!";
2013-08-05 18:33:09 +02:00
metadata.url = "http://universalelectricity.com/resonant-induction";
2013-08-07 01:24:24 +02:00
metadata.logoFile = "/ri_logo.png";
2013-08-02 02:38:42 +02:00
metadata.version = VERSION + BUILD_VERSION;
metadata.authorList = Arrays.asList(new String[] { "Calclavia", "Aidancbrady" });
2013-08-05 18:33:09 +02:00
metadata.credits = "Thanks to Archadia for the awesome assets!";
2013-08-07 01:24:24 +02:00
metadata.autogenerated = false;
2013-09-17 05:21:00 +02:00
new MultipartRI().init();
2013-08-02 02:29:44 +02:00
}
@EventHandler
2013-08-03 08:55:44 +02:00
public void postInit(FMLPostInitializationEvent evt)
2013-08-02 02:29:44 +02:00
{
2013-08-02 05:07:56 +02:00
/**
* Recipes
*/
2013-08-05 21:34:34 +02:00
ItemStack emptyCapacitor = new ItemStack(itemCapacitor);
((IItemElectric) itemCapacitor).setElectricity(emptyCapacitor, 0);
2013-08-05 21:34:34 +02:00
2013-08-23 14:49:01 +02:00
final ItemStack defaultWire = new ItemStack(blockWire, 1, EnumWireMaterial.IRON.ordinal());
2013-08-12 13:05:59 +02:00
2013-08-05 05:50:59 +02:00
/** Capacitor **/
2013-08-12 13:05:59 +02:00
GameRegistry.addRecipe(new ShapedOreRecipe(emptyCapacitor, "RRR", "RIR", "RRR", 'R', Item.redstone, 'I', UniversalRecipes.PRIMARY_METAL));
2013-08-02 02:29:44 +02:00
2013-08-05 05:50:59 +02:00
/** Linker **/
2013-08-12 13:05:59 +02:00
GameRegistry.addRecipe(new ShapedOreRecipe(itemLinker, " E ", "GCG", " E ", 'E', Item.eyeOfEnder, 'C', emptyCapacitor, 'G', UniversalRecipes.SECONDARY_METAL));
2013-08-05 05:50:59 +02:00
/** Quantum Entangler **/
2013-08-12 13:05:59 +02:00
GameRegistry.addRecipe(new ShapedOreRecipe(itemQuantumEntangler, "EEE", "ILI", "EEE", 'E', Item.eyeOfEnder, 'L', itemLinker, 'I', UniversalRecipes.PRIMARY_METAL));
2013-08-05 05:50:59 +02:00
/** Tesla - by Jyzarc */
2013-08-12 13:05:59 +02:00
GameRegistry.addRecipe(new ShapedOreRecipe(blockTesla, "WEW", " C ", " I ", 'W', defaultWire, 'E', Item.eyeOfEnder, 'C', emptyCapacitor, 'I', UniversalRecipes.PRIMARY_PLATE));
2013-08-05 05:50:59 +02:00
/** Multimeter */
2013-08-12 13:05:59 +02:00
GameRegistry.addRecipe(new ShapedOreRecipe(blockMultimeter, "WWW", "ICI", 'W', defaultWire, 'C', emptyCapacitor, 'I', UniversalRecipes.PRIMARY_METAL));
2013-08-05 05:50:59 +02:00
/** Multimeter */
2013-08-12 13:05:59 +02:00
GameRegistry.addRecipe(new ShapedOreRecipe(blockBattery, "III", "IRI", "III", 'R', Block.blockRedstone, 'I', UniversalRecipes.PRIMARY_METAL));
2013-08-05 05:50:59 +02:00
/** EM Contractor */
2013-08-12 13:05:59 +02:00
GameRegistry.addRecipe(new ShapedOreRecipe(blockEMContractor, " I ", "GCG", "WWW", 'W', UniversalRecipes.PRIMARY_METAL, 'C', emptyCapacitor, 'G', UniversalRecipes.SECONDARY_METAL, 'I', UniversalRecipes.PRIMARY_METAL));
2013-08-07 05:34:06 +02:00
/** Wires **/
2013-08-25 11:31:27 +02:00
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 3, EnumWireMaterial.COPPER.ordinal()), "MMM", 'M', "ingotCopper"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 3, EnumWireMaterial.TIN.ordinal()), "MMM", 'M', "ingotTin"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 3, EnumWireMaterial.IRON.ordinal()), "MMM", 'M', Item.ingotIron));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 3, EnumWireMaterial.ALUMINUM.ordinal()), "MMM", 'M', "ingotAluminum"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 3, EnumWireMaterial.SILVER.ordinal()), "MMM", 'M', "ingotSilver"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockWire, 3, EnumWireMaterial.SUPERCONDUCTOR.ordinal()), "MMM", 'M', "ingotSuperconductor"));
2013-08-07 05:34:06 +02:00
2013-08-25 11:15:00 +02:00
/** Wire Compatiblity **/
if (Loader.isModLoaded("IC2"))
{
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(blockWire, 1, EnumWireMaterial.COPPER.ordinal()), Items.getItem("copperCableItem")));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(blockWire, 1, EnumWireMaterial.TIN.ordinal()), Items.getItem("tinCableItem")));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(blockWire, 1, EnumWireMaterial.IRON.ordinal()), Items.getItem("ironCableItem")));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(blockWire, 2, EnumWireMaterial.SUPERCONDUCTOR.ordinal()), Items.getItem("glassFiberCableItem")));
}
if (Loader.isModLoaded("Mekanism"))
{
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(blockWire, 1, EnumWireMaterial.COPPER.ordinal()), "universalCable"));
}
/** Inject new furnace tile class */
replaceTileEntity(TileEntityFurnace.class, TileEntityAdvancedFurnace.class);
}
public static void replaceTileEntity(Class<? extends TileEntity> findTile, Class<? extends TileEntity> replaceTile)
{
try
{
Map<String, Class> nameToClassMap = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_" + "70326_a", "nameToClassMap", "a");
Map<Class, String> classToNameMap = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_" + "70326_b", "classToNameMap", "b");
String findTileID = classToNameMap.get(findTile);
if (findTileID != null)
{
nameToClassMap.put(findTileID, replaceTile);
classToNameMap.put(replaceTile, findTileID);
classToNameMap.remove(findTile);
2013-09-21 05:20:39 +02:00
LOGGER.fine("Replaced TileEntity: " + findTile);
}
else
{
LOGGER.severe("Failed to replace TileEntity: " + findTile);
}
}
catch (Exception e)
{
LOGGER.severe("Failed to replace TileEntity: " + findTile);
e.printStackTrace();
}
2013-08-02 02:29:44 +02:00
}
2013-08-02 02:17:42 +02:00
}