2012-04-25 03:17:23 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (c) 2012 cpw.
|
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
* are made available under the terms of the GNU Public License v3.0
|
|
|
|
* which accompanies this distribution, and is available at
|
|
|
|
* http://www.gnu.org/licenses/gpl.html
|
2012-06-26 22:12:36 +02:00
|
|
|
*
|
2012-04-25 03:17:23 +02:00
|
|
|
* Contributors:
|
|
|
|
* cpw - initial API and implementation
|
|
|
|
******************************************************************************/
|
2012-06-26 22:12:36 +02:00
|
|
|
package cpw.mods.ironchest;
|
2012-01-26 23:37:39 +01:00
|
|
|
|
|
|
|
import java.io.File;
|
2012-02-06 14:43:43 +01:00
|
|
|
import java.lang.reflect.Method;
|
2012-01-26 23:37:39 +01:00
|
|
|
|
2012-06-26 22:27:50 +02:00
|
|
|
import cpw.mods.fml.common.ModContainer;
|
|
|
|
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
|
|
|
|
|
2012-06-26 22:12:36 +02:00
|
|
|
import net.minecraft.src.ModLoader;
|
|
|
|
import net.minecraft.src.SidedProxy;
|
2012-01-29 22:12:06 +01:00
|
|
|
import net.minecraft.src.forge.Configuration;
|
|
|
|
import net.minecraft.src.forge.MinecraftForge;
|
2012-03-29 06:31:46 +02:00
|
|
|
import net.minecraft.src.forge.NetworkMod;
|
2012-07-12 07:54:11 +02:00
|
|
|
import net.minecraft.src.forge.adaptors.EntityLivingHandlerAdaptor;
|
2012-01-26 23:37:39 +01:00
|
|
|
|
2012-03-29 06:31:46 +02:00
|
|
|
public class mod_IronChest extends NetworkMod {
|
2012-01-26 23:37:39 +01:00
|
|
|
|
2012-03-29 06:31:46 +02:00
|
|
|
public static BlockIronChest ironChestBlock;
|
2012-06-03 06:21:20 +02:00
|
|
|
@SidedProxy(clientSide="cpw.mods.ironchest.client.ClientProxy", serverSide="cpw.mods.ironchest.server.ServerProxy")
|
2012-03-29 06:31:46 +02:00
|
|
|
public static IProxy proxy;
|
|
|
|
public static mod_IronChest instance;
|
2012-07-08 20:28:25 +02:00
|
|
|
public static boolean CACHE_RENDER = true;
|
2012-07-12 07:54:11 +02:00
|
|
|
public static boolean OCELOTS_SITONCHESTS = true;
|
2012-01-26 23:37:39 +01:00
|
|
|
|
2012-03-29 06:31:46 +02:00
|
|
|
@Override
|
|
|
|
public String getVersion() {
|
|
|
|
return Version.version();
|
|
|
|
}
|
2012-01-26 23:37:39 +01:00
|
|
|
|
2012-03-29 06:31:46 +02:00
|
|
|
@Override
|
|
|
|
public void load() {
|
2012-07-07 18:21:22 +02:00
|
|
|
MinecraftForge.versionDetect("IronChest", 3, 3, 8);
|
2012-06-26 22:27:50 +02:00
|
|
|
ModContainer fml=ModLoaderModContainer.findContainerFor(this);
|
|
|
|
if (fml.getMetadata()!=null) {
|
|
|
|
fml.getMetadata().version=Version.fullVersionString();
|
|
|
|
}
|
2012-03-29 06:31:46 +02:00
|
|
|
instance = this;
|
|
|
|
File cfgFile = new File(proxy.getMinecraftDir(), "config/IronChest.cfg");
|
|
|
|
Configuration cfg = new Configuration(cfgFile);
|
|
|
|
try {
|
|
|
|
cfg.load();
|
2012-07-07 18:21:22 +02:00
|
|
|
int bId = cfg.getOrCreateBlockIdProperty("ironChests", 181).getInt(181);
|
2012-03-29 06:31:46 +02:00
|
|
|
ironChestBlock = new BlockIronChest(bId);
|
2012-07-07 18:21:22 +02:00
|
|
|
ChestChangerType.buildItems(cfg, 29501);
|
2012-07-08 20:28:25 +02:00
|
|
|
CACHE_RENDER = cfg.getOrCreateBooleanProperty("cacheRenderingInformation", Configuration.CATEGORY_GENERAL, true).getBoolean(true);
|
2012-07-12 07:54:11 +02:00
|
|
|
OCELOTS_SITONCHESTS = cfg.getOrCreateBooleanProperty("ocelotsSitOnChests", Configuration.CATEGORY_GENERAL, true).getBoolean(true);
|
2012-03-29 06:31:46 +02:00
|
|
|
} catch (Exception e) {
|
|
|
|
ModLoader.getLogger().severe("IronChest was unable to load it's configuration successfully");
|
|
|
|
e.printStackTrace(System.err);
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
} finally {
|
|
|
|
cfg.save();
|
|
|
|
}
|
2012-01-27 05:50:52 +01:00
|
|
|
|
2012-03-29 06:31:46 +02:00
|
|
|
ModLoader.registerBlock(ironChestBlock, ItemIronChest.class);
|
|
|
|
proxy.registerTranslations();
|
|
|
|
proxy.registerTileEntities();
|
2012-06-26 22:12:36 +02:00
|
|
|
IronChestType.generateTieredRecipes(ironChestBlock);
|
|
|
|
ChestChangerType.generateRecipes();
|
2012-01-27 22:05:42 +01:00
|
|
|
|
2012-03-29 06:31:46 +02:00
|
|
|
MinecraftForge.setGuiHandler(this, proxy);
|
|
|
|
MinecraftForge.registerConnectionHandler(new PacketHandler());
|
|
|
|
proxy.registerRenderInformation();
|
2012-07-12 07:54:11 +02:00
|
|
|
MinecraftForge.registerEntityLivingHandler(new OcelotsSitOnChestsHandler());
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
2012-01-26 23:37:39 +01:00
|
|
|
|
2012-03-29 06:31:46 +02:00
|
|
|
@Override
|
|
|
|
public void modsLoaded() {
|
|
|
|
try {
|
|
|
|
Class<?> equivexmaps = Class.forName("ee.EEMaps");
|
|
|
|
Method addEMC = equivexmaps.getMethod("addEMC", int.class, int.class, int.class);
|
|
|
|
Method addMeta = equivexmaps.getMethod("addMeta", int.class, int.class);
|
2012-06-26 22:12:36 +02:00
|
|
|
int[] chestEMCValues = new int[]
|
|
|
|
{
|
|
|
|
8 * 8 + 256 * 8, /* iron chest */
|
|
|
|
8 * 8 + 256 * 8 + 2048 * 8, /* gold chest */
|
|
|
|
2 * 8192 + 8 * 8 + 256 * 8 + 2048 * 8 + 6, /* diamond chest */
|
|
|
|
85 * 8 + 8 * 8, /* copper chest */
|
|
|
|
85 * 8 + 8 * 8 + 512 * 8, /* silver chest */
|
|
|
|
2 * 8192 + 8 * 8 + 256 * 8 + 2048 * 8 + 6 + 8 /* crystal chest */
|
|
|
|
};
|
2012-03-29 06:31:46 +02:00
|
|
|
for (IronChestType icType : IronChestType.values()) {
|
2012-07-08 20:28:25 +02:00
|
|
|
if (icType.ordinal()>=chestEMCValues.length)
|
|
|
|
break;
|
2012-03-29 06:31:46 +02:00
|
|
|
addEMC.invoke(null, ironChestBlock.blockID, icType.ordinal(), chestEMCValues[icType.ordinal()]);
|
|
|
|
}
|
|
|
|
addMeta.invoke(null, ironChestBlock.blockID, IronChestType.values().length - 1);
|
|
|
|
ModLoader.getLogger().fine("mod_IronChest registered chests with Equivalent Exchange");
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ModLoader.getLogger().fine("mod_IronChest unable to load Equivalent Exchange integration");
|
|
|
|
}
|
|
|
|
}
|
2012-01-29 22:12:06 +01:00
|
|
|
|
2012-03-29 06:31:46 +02:00
|
|
|
@Override
|
|
|
|
public boolean clientSideRequired() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean serverSideRequired() {
|
2012-04-08 16:23:56 +02:00
|
|
|
return false;
|
2012-03-29 06:31:46 +02:00
|
|
|
}
|
2012-01-26 23:37:39 +01:00
|
|
|
}
|