2014-12-15 00:11:48 +00:00
|
|
|
package com.cricketcraft.chisel;
|
2014-12-14 20:05:39 +00:00
|
|
|
|
2015-01-11 20:59:16 +00:00
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
|
|
|
|
import net.minecraftforge.common.config.Configuration;
|
|
|
|
|
|
|
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
|
|
2015-04-24 17:05:12 -04:00
|
|
|
import com.cricketcraft.chisel.api.ChiselAPIProps;
|
2015-05-29 15:52:03 -04:00
|
|
|
import com.cricketcraft.chisel.api.Statistics;
|
2015-04-24 17:05:12 -04:00
|
|
|
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
2014-12-15 00:11:48 +00:00
|
|
|
import com.cricketcraft.chisel.block.BlockCarvable;
|
2015-04-26 20:33:39 -04:00
|
|
|
import com.cricketcraft.chisel.carving.Carving;
|
2014-12-15 00:11:48 +00:00
|
|
|
import com.cricketcraft.chisel.compat.Compatibility;
|
2015-02-06 21:47:17 -05:00
|
|
|
import com.cricketcraft.chisel.compat.IMCHandler;
|
2015-04-06 01:16:14 -04:00
|
|
|
import com.cricketcraft.chisel.compat.fmp.FMPCompat;
|
2015-01-08 05:46:10 -05:00
|
|
|
import com.cricketcraft.chisel.config.Configurations;
|
2015-04-26 02:30:39 -04:00
|
|
|
import com.cricketcraft.chisel.entity.EntityChiselSnowman;
|
2015-01-08 05:46:10 -05:00
|
|
|
import com.cricketcraft.chisel.init.ChiselBlocks;
|
|
|
|
|
import com.cricketcraft.chisel.init.ChiselTabs;
|
2015-04-24 17:05:12 -04:00
|
|
|
import com.cricketcraft.chisel.item.ItemCarvable;
|
2015-01-09 01:50:32 -05:00
|
|
|
import com.cricketcraft.chisel.item.chisel.ChiselController;
|
2015-01-13 01:45:52 -05:00
|
|
|
import com.cricketcraft.chisel.network.ChiselGuiHandler;
|
2015-01-11 17:21:53 -05:00
|
|
|
import com.cricketcraft.chisel.network.PacketHandler;
|
2014-12-15 00:11:48 +00:00
|
|
|
import com.cricketcraft.chisel.proxy.CommonProxy;
|
|
|
|
|
import com.cricketcraft.chisel.utils.General;
|
2015-01-05 19:15:35 -05:00
|
|
|
import com.cricketcraft.chisel.world.GeneratorChisel;
|
2015-01-09 01:50:32 -05:00
|
|
|
|
2014-12-14 20:05:39 +00:00
|
|
|
import cpw.mods.fml.client.event.ConfigChangedEvent;
|
|
|
|
|
import cpw.mods.fml.common.FMLCommonHandler;
|
|
|
|
|
import cpw.mods.fml.common.FMLLog;
|
2015-04-06 01:16:14 -04:00
|
|
|
import cpw.mods.fml.common.Loader;
|
2014-12-14 20:05:39 +00:00
|
|
|
import cpw.mods.fml.common.Mod;
|
|
|
|
|
import cpw.mods.fml.common.Mod.EventHandler;
|
|
|
|
|
import cpw.mods.fml.common.Mod.Instance;
|
|
|
|
|
import cpw.mods.fml.common.SidedProxy;
|
2015-01-11 20:59:16 +00:00
|
|
|
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
|
|
|
|
import cpw.mods.fml.common.event.FMLInterModComms;
|
2015-02-19 19:11:16 -05:00
|
|
|
import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent;
|
2015-02-06 21:47:17 -05:00
|
|
|
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
2015-01-11 20:59:16 +00:00
|
|
|
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
|
2014-12-14 20:05:39 +00:00
|
|
|
import cpw.mods.fml.common.event.FMLMissingMappingsEvent.MissingMapping;
|
2015-01-11 20:59:16 +00:00
|
|
|
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
|
|
|
|
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
2014-12-14 20:05:39 +00:00
|
|
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|
|
|
|
import cpw.mods.fml.common.network.NetworkRegistry;
|
2015-04-26 02:30:39 -04:00
|
|
|
import cpw.mods.fml.common.registry.EntityRegistry;
|
2014-12-14 20:05:39 +00:00
|
|
|
import cpw.mods.fml.common.registry.GameRegistry;
|
|
|
|
|
import cpw.mods.fml.common.registry.GameRegistry.Type;
|
2015-01-08 19:32:20 -05:00
|
|
|
|
2015-06-22 14:21:22 -04:00
|
|
|
@Mod(modid = Chisel.MOD_ID, name = Chisel.MOD_NAME, version = Chisel.VERSION, guiFactory = "com.cricketcraft.chisel.client.gui.GuiFactory", dependencies = "after:EE3;after:ForgeMultipart;after:Thaumcraft;after:Railcraft;after:AWWayofTime;after:TwilightForest")
|
2015-01-07 19:50:18 -05:00
|
|
|
public class Chisel {
|
|
|
|
|
|
|
|
|
|
public static final String MOD_ID = "chisel";
|
|
|
|
|
public static final BlockCarvable.SoundType soundTempleFootstep = new BlockCarvable.SoundType("dig.stone", MOD_ID + ":step.templeblock", 1.0f, 1.0f);
|
|
|
|
|
public static final String MOD_NAME = "Chisel 2";
|
2015-01-11 23:30:10 -05:00
|
|
|
public static final String VERSION = "@VERSION@";
|
2015-01-07 19:50:18 -05:00
|
|
|
public static final BlockCarvable.SoundType soundHolystoneFootstep = new BlockCarvable.SoundType("holystone", 1.0f, 1.0f);
|
|
|
|
|
public static final BlockCarvable.SoundType soundMetalFootstep = new BlockCarvable.SoundType("metal", 1.0f, 1.0f);
|
|
|
|
|
public static boolean multipartLoaded = false;
|
2015-01-08 01:59:50 -05:00
|
|
|
public static int renderEldritchId;
|
|
|
|
|
public static int renderAutoChiselId;
|
2015-01-08 18:34:47 -05:00
|
|
|
public static int renderGlowId;
|
2015-01-11 20:56:07 +00:00
|
|
|
public static int renderLayeredId;
|
2015-01-11 21:32:37 +00:00
|
|
|
public static int roadLineId;
|
2015-01-11 20:15:06 +00:00
|
|
|
|
2015-01-12 23:52:53 -05:00
|
|
|
public static final Logger logger = LogManager.getLogger(MOD_NAME);
|
2015-01-07 19:50:18 -05:00
|
|
|
|
|
|
|
|
@Instance(MOD_ID)
|
|
|
|
|
public static Chisel instance;
|
2015-04-24 17:05:12 -04:00
|
|
|
|
|
|
|
|
public Chisel() {
|
|
|
|
|
ChiselAPIProps.MOD_ID = MOD_ID;
|
|
|
|
|
CarvableHelper.itemCarvableClass = ItemCarvable.class;
|
2015-04-26 20:33:39 -04:00
|
|
|
Carving.construct();
|
2015-04-24 17:05:12 -04:00
|
|
|
}
|
2015-01-07 19:50:18 -05:00
|
|
|
|
|
|
|
|
@SidedProxy(clientSide = "com.cricketcraft.chisel.proxy.ClientProxy", serverSide = "com.cricketcraft.chisel.proxy.CommonProxy")
|
|
|
|
|
public static CommonProxy proxy;
|
|
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
|
public void missingMapping(FMLMissingMappingsEvent event) {
|
|
|
|
|
BlockNameConversion.init();
|
|
|
|
|
|
|
|
|
|
for (MissingMapping m : event.get()) {
|
|
|
|
|
// This bug was introduced along with Chisel 1.5.2, and was fixed in
|
|
|
|
|
// 1.5.3.
|
|
|
|
|
// Ice Stairs were called null.0-7 instead of other names, and
|
|
|
|
|
// Marble/Limestone stairs did not exist.
|
|
|
|
|
// This fixes the bug.
|
|
|
|
|
if (m.name.startsWith("null.") && m.name.length() == 6 && m.type == Type.BLOCK) {
|
|
|
|
|
m.warn();// (Action.WARN);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Fix mapping of snakestoneSand, snakestoneStone, limestoneStairs,
|
|
|
|
|
// marbleStairs when loading an old (1.5.4) save
|
|
|
|
|
else if (m.type == Type.BLOCK) {
|
|
|
|
|
final Block block = BlockNameConversion.findBlock(m.name);
|
|
|
|
|
|
|
|
|
|
if (block != null) {
|
|
|
|
|
m.remap(block);
|
|
|
|
|
FMLLog.getLogger().info("Remapping block " + m.name + " to " + General.getName(block));
|
|
|
|
|
} else
|
|
|
|
|
FMLLog.getLogger().warn("Block " + m.name + " could not get remapped.");
|
|
|
|
|
} else if (m.type == Type.ITEM) {
|
|
|
|
|
final Item item = BlockNameConversion.findItem(m.name);
|
|
|
|
|
|
|
|
|
|
if (item != null) {
|
|
|
|
|
m.remap(item);
|
|
|
|
|
FMLLog.getLogger().info("Remapping item " + m.name + " to " + General.getName(item));
|
|
|
|
|
|
|
|
|
|
} else
|
|
|
|
|
FMLLog.getLogger().warn("Item " + m.name + " could not get remapped.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
|
public void preInit(FMLPreInitializationEvent event) {
|
2015-01-13 01:45:52 -05:00
|
|
|
|
2015-01-07 19:50:18 -05:00
|
|
|
File configFile = event.getSuggestedConfigurationFile();
|
|
|
|
|
Configurations.configExists = configFile.exists();
|
|
|
|
|
Configurations.config = new Configuration(configFile);
|
|
|
|
|
Configurations.config.load();
|
|
|
|
|
Configurations.refreshConfig();
|
|
|
|
|
|
2015-01-08 15:27:15 -05:00
|
|
|
ChiselTabs.preInit();
|
2015-01-08 05:46:10 -05:00
|
|
|
Features.preInit();
|
2015-05-29 14:17:50 -04:00
|
|
|
Statistics.init();
|
2015-01-07 19:50:18 -05:00
|
|
|
PacketHandler.init();
|
2015-01-09 01:50:32 -05:00
|
|
|
ChiselController.INSTANCE.preInit();
|
2015-04-06 01:16:14 -04:00
|
|
|
if (Loader.isModLoaded("ForgeMultipart")) {
|
|
|
|
|
new FMPCompat().init();
|
|
|
|
|
}
|
2015-01-07 19:50:18 -05:00
|
|
|
proxy.preInit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
|
public void init(FMLInitializationEvent event) {
|
2015-01-08 05:46:10 -05:00
|
|
|
Features.init();
|
2015-01-07 19:50:18 -05:00
|
|
|
|
2015-01-13 01:45:52 -05:00
|
|
|
NetworkRegistry.INSTANCE.registerGuiHandler(this, new ChiselGuiHandler());
|
2015-01-07 19:50:18 -05:00
|
|
|
|
2015-01-24 22:03:30 -05:00
|
|
|
addWorldgen(Features.MARBLE, ChiselBlocks.marble, Configurations.marbleAmount);
|
|
|
|
|
addWorldgen(Features.LIMESTONE, ChiselBlocks.limestone, Configurations.limestoneAmount);
|
|
|
|
|
addWorldgen(Features.ANDESITE, ChiselBlocks.andesite, Configurations.andesiteAmount, 40, 100, 0.5);
|
|
|
|
|
addWorldgen(Features.GRANITE, ChiselBlocks.granite, Configurations.graniteAmount, 40, 100, 0.5);
|
|
|
|
|
addWorldgen(Features.DIORITE, ChiselBlocks.diorite, Configurations.dioriteAmount, 40, 100, 0.5);
|
|
|
|
|
GameRegistry.registerWorldGenerator(GeneratorChisel.INSTANCE, 1000);
|
2015-01-07 19:50:18 -05:00
|
|
|
|
2015-03-08 16:48:05 -04:00
|
|
|
EntityRegistry.registerModEntity(EntityChiselSnowman.class, "snowman", 0, this, 80, 1, true);
|
|
|
|
|
|
2015-01-07 19:50:18 -05:00
|
|
|
proxy.init();
|
|
|
|
|
MinecraftForge.EVENT_BUS.register(this);
|
|
|
|
|
FMLCommonHandler.instance().bus().register(instance);
|
|
|
|
|
|
2015-01-15 04:40:31 -05:00
|
|
|
FMLInterModComms.sendMessage("Waila", "register", "com.cricketcraft.chisel.compat.WailaCompat.register");
|
2015-01-07 19:50:18 -05:00
|
|
|
}
|
|
|
|
|
|
2015-01-24 22:03:30 -05:00
|
|
|
private void addWorldgen(Features feature, Block block, double... data) {
|
2015-01-08 16:31:13 -05:00
|
|
|
if (feature.enabled()) {
|
2015-01-24 22:03:30 -05:00
|
|
|
if (data.length == 1) {
|
|
|
|
|
GeneratorChisel.INSTANCE.addFeature(block, 32, (int) data[0]);
|
|
|
|
|
} else if (data.length > 1 && data.length < 4) {
|
|
|
|
|
GeneratorChisel.INSTANCE.addFeature(block, 32, (int) data[0], (int) data[1], (int) data[2]);
|
|
|
|
|
} else if (data.length == 4) {
|
|
|
|
|
GeneratorChisel.INSTANCE.addFeature(block, 32, (int) data[0], (int) data[1], (int) data[2], data[3]);
|
|
|
|
|
}
|
2015-01-08 16:31:13 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-07 19:50:18 -05:00
|
|
|
@EventHandler
|
|
|
|
|
public void postInit(FMLPostInitializationEvent event) {
|
2015-01-08 15:27:15 -05:00
|
|
|
ChiselTabs.postInit();
|
2015-01-07 19:50:18 -05:00
|
|
|
Compatibility.init(event);
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-06 21:47:17 -05:00
|
|
|
@EventHandler
|
|
|
|
|
public void onIMC(IMCEvent event) {
|
|
|
|
|
for (IMCMessage msg : event.getMessages()) {
|
|
|
|
|
IMCHandler.INSTANCE.handleMessage(msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-07 19:50:18 -05:00
|
|
|
@SubscribeEvent
|
|
|
|
|
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
|
|
|
|
|
if (event.modID.equals("chisel")) {
|
|
|
|
|
Configurations.refreshConfig();
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-04-21 19:13:15 +01:00
|
|
|
}
|