2014-04-21 19:13:15 +01:00
|
|
|
package info.jbcs.minecraft.chisel;
|
|
|
|
|
|
2014-06-27 18:07:23 -07:00
|
|
|
import cpw.mods.fml.client.event.ConfigChangedEvent;
|
2014-09-09 18:57:43 +02:00
|
|
|
import cpw.mods.fml.common.FMLCommonHandler;
|
2014-09-09 19:02:20 +02:00
|
|
|
import cpw.mods.fml.common.FMLLog;
|
2014-09-09 18:57:43 +02:00
|
|
|
import cpw.mods.fml.common.Mod;
|
2014-05-31 20:29:35 +01:00
|
|
|
import cpw.mods.fml.common.Mod.EventHandler;
|
|
|
|
|
import cpw.mods.fml.common.Mod.Instance;
|
2014-09-09 18:57:43 +02:00
|
|
|
import cpw.mods.fml.common.SidedProxy;
|
2014-08-08 09:06:15 -04:00
|
|
|
import cpw.mods.fml.common.event.*;
|
2014-05-31 20:29:35 +01:00
|
|
|
import cpw.mods.fml.common.event.FMLMissingMappingsEvent.MissingMapping;
|
2014-06-27 18:07:23 -07:00
|
|
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
2014-05-31 20:29:35 +01:00
|
|
|
import cpw.mods.fml.common.network.IGuiHandler;
|
|
|
|
|
import cpw.mods.fml.common.network.NetworkRegistry;
|
|
|
|
|
import cpw.mods.fml.common.registry.EntityRegistry;
|
|
|
|
|
import cpw.mods.fml.common.registry.GameRegistry;
|
|
|
|
|
import cpw.mods.fml.common.registry.GameRegistry.Type;
|
2014-04-21 19:13:15 +01:00
|
|
|
import info.jbcs.minecraft.chisel.carving.Carving;
|
2014-05-31 20:29:35 +01:00
|
|
|
import info.jbcs.minecraft.chisel.client.gui.GuiChisel;
|
2014-04-21 19:13:15 +01:00
|
|
|
import info.jbcs.minecraft.chisel.entity.EntityBallOMoss;
|
|
|
|
|
import info.jbcs.minecraft.chisel.entity.EntityCloudInABottle;
|
2014-04-22 16:46:39 +01:00
|
|
|
import info.jbcs.minecraft.chisel.entity.EntitySmashingRock;
|
2014-04-21 19:13:15 +01:00
|
|
|
import info.jbcs.minecraft.chisel.inventory.ContainerChisel;
|
|
|
|
|
import info.jbcs.minecraft.chisel.inventory.InventoryChiselSelection;
|
|
|
|
|
import info.jbcs.minecraft.chisel.item.ItemBallOMoss;
|
|
|
|
|
import info.jbcs.minecraft.chisel.item.ItemChisel;
|
|
|
|
|
import info.jbcs.minecraft.chisel.item.ItemCloudInABottle;
|
2014-04-22 16:46:39 +01:00
|
|
|
import info.jbcs.minecraft.chisel.item.ItemSmashingRock;
|
2014-09-15 11:36:29 +01:00
|
|
|
import info.jbcs.minecraft.chisel.world.GeneratorLimestone;
|
|
|
|
|
import info.jbcs.minecraft.chisel.world.GeneratorMarble;
|
2014-09-06 11:46:36 +01:00
|
|
|
import info.jbcs.minecraft.utilities.General;
|
2014-08-31 13:37:01 +02:00
|
|
|
import net.minecraft.block.Block;
|
2014-04-21 19:13:15 +01:00
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
2014-05-31 20:29:35 +01:00
|
|
|
import net.minecraftforge.common.config.Configuration;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
2014-04-21 19:13:15 +01:00
|
|
|
|
|
|
|
|
|
2014-08-08 09:06:15 -04:00
|
|
|
@Mod(modid = Chisel.MOD_ID, name = Chisel.MOD_NAME, version = "@MOD_VERSION@", guiFactory = "info.jbcs.minecraft.chisel.client.gui.GuiFactory"/*, dependencies = "after:ForgeMicroblock;"*/)
|
2014-04-21 19:13:15 +01:00
|
|
|
public class Chisel
|
|
|
|
|
{
|
2014-07-26 09:17:49 +01:00
|
|
|
public static final String MOD_ID = "chisel";
|
|
|
|
|
public static final String MOD_NAME = "Chisel";
|
|
|
|
|
|
2014-04-21 19:13:15 +01:00
|
|
|
public static ItemChisel chisel;
|
2014-05-23 22:44:19 +01:00
|
|
|
// public static ItemChisel needle;
|
2014-04-21 19:13:15 +01:00
|
|
|
public static ItemCloudInABottle itemCloudInABottle;
|
|
|
|
|
public static ItemBallOMoss itemBallOMoss;
|
2014-04-22 16:46:39 +01:00
|
|
|
public static ItemSmashingRock smashingRock;
|
2014-04-21 19:13:15 +01:00
|
|
|
|
|
|
|
|
public static CreativeTabs tabChisel;
|
|
|
|
|
|
2014-06-09 21:32:33 +01:00
|
|
|
public static boolean multipartLoaded = false;
|
|
|
|
|
|
2014-04-21 19:13:15 +01:00
|
|
|
public static final StepSoundEx soundHolystoneFootstep = new StepSoundEx("chisel:holystone", "chisel:holystone", "chisel:holystone", 1.0f);
|
|
|
|
|
public static final StepSoundEx soundTempleFootstep = new StepSoundEx("dig.stone", "chisel:temple-footstep", "dig.stone", 1.0f);
|
|
|
|
|
public static final StepSoundEx soundMetalFootstep = new StepSoundEx("chisel:metal", "chisel:metal", "chisel:metal", 1.0f);
|
|
|
|
|
|
|
|
|
|
public static int RenderEldritchId;
|
|
|
|
|
public static int RenderCTMId;
|
|
|
|
|
public static int RenderCarpetId;
|
|
|
|
|
|
2014-08-08 09:06:15 -04:00
|
|
|
@Instance(MOD_ID)
|
2014-04-21 19:13:15 +01:00
|
|
|
public static Chisel instance;
|
|
|
|
|
|
|
|
|
|
@SidedProxy(clientSide = "info.jbcs.minecraft.chisel.ClientProxy", serverSide = "info.jbcs.minecraft.chisel.CommonProxy")
|
|
|
|
|
public static CommonProxy proxy;
|
|
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
|
public void missingMapping(FMLMissingMappingsEvent event)
|
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
{
|
2014-06-23 20:19:11 -07:00
|
|
|
m.warn();//(Action.WARN);
|
2014-04-21 19:13:15 +01:00
|
|
|
}
|
2014-09-06 11:46:36 +01:00
|
|
|
|
|
|
|
|
// Fix mapping of snakestoneSand, snakestoneStone, limestoneStairs, marbleStairs when loading an old (1.5.4) save
|
2014-09-15 11:27:15 +01:00
|
|
|
else if(m.type == Type.BLOCK)
|
2014-09-06 11:46:36 +01:00
|
|
|
{
|
|
|
|
|
Block block = null;
|
|
|
|
|
|
2014-09-15 11:27:15 +01:00
|
|
|
if(General.cleanTags(m.name).equals("sandSnakestone"))
|
2014-09-06 11:46:36 +01:00
|
|
|
block = GameRegistry.findBlock(Chisel.MOD_ID, "tile.snakestoneSand");
|
2014-09-15 11:27:15 +01:00
|
|
|
else if(General.cleanTags(m.name).equals("snakestone"))
|
2014-09-06 11:46:36 +01:00
|
|
|
block = GameRegistry.findBlock(Chisel.MOD_ID, "tile.snakestoneStone");
|
|
|
|
|
else
|
|
|
|
|
block = GameRegistry.findBlock(Chisel.MOD_ID, General.cleanTags(m.name));
|
|
|
|
|
|
2014-09-15 11:27:15 +01:00
|
|
|
if(block != null)
|
2014-09-06 11:46:36 +01:00
|
|
|
{
|
|
|
|
|
m.remap(block);
|
|
|
|
|
FMLLog.getLogger().info("Remapping block " + m.name + " to " + General.getName(block));
|
2014-09-15 11:27:15 +01:00
|
|
|
} else
|
2014-09-06 11:46:36 +01:00
|
|
|
FMLLog.getLogger().warn("Block " + m.name + " could not get remapped.");
|
2014-09-15 11:27:15 +01:00
|
|
|
} else if(m.type == Type.ITEM)
|
2014-09-06 11:46:36 +01:00
|
|
|
{
|
|
|
|
|
Item item = null;
|
|
|
|
|
|
2014-09-15 11:27:15 +01:00
|
|
|
if(General.cleanTags(m.name).equals("sandSnakestone"))
|
2014-09-06 11:46:36 +01:00
|
|
|
item = GameRegistry.findItem(Chisel.MOD_ID, "tile.snakestoneSand");
|
2014-09-15 11:27:15 +01:00
|
|
|
else if(General.cleanTags(m.name).equals("snakestone"))
|
2014-09-06 11:46:36 +01:00
|
|
|
item = GameRegistry.findItem(Chisel.MOD_ID, "tile.snakestoneStone");
|
|
|
|
|
else
|
|
|
|
|
item = GameRegistry.findItem(Chisel.MOD_ID, General.cleanTags(m.name));
|
|
|
|
|
|
2014-09-15 11:27:15 +01:00
|
|
|
if(item != null)
|
2014-09-06 11:46:36 +01:00
|
|
|
{
|
|
|
|
|
m.remap(item);
|
|
|
|
|
FMLLog.getLogger().info("Remapping item " + m.name + " to " + General.getName(item));
|
|
|
|
|
|
2014-09-15 11:27:15 +01:00
|
|
|
} else
|
2014-09-06 11:46:36 +01:00
|
|
|
FMLLog.getLogger().warn("Item " + m.name + " could not get remapped.");
|
|
|
|
|
}
|
2014-04-21 19:13:15 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
|
public void preInit(FMLPreInitializationEvent event)
|
|
|
|
|
{
|
|
|
|
|
File configFile = event.getSuggestedConfigurationFile();
|
2014-07-17 22:05:29 +01:00
|
|
|
Configurations.configExists = configFile.exists();
|
|
|
|
|
Configurations.config = new Configuration(configFile);
|
|
|
|
|
Configurations.config.load();
|
|
|
|
|
Configurations.refreshConfig();
|
2014-04-21 19:13:15 +01:00
|
|
|
|
2014-04-23 15:09:02 +01:00
|
|
|
tabChisel = new CreativeTabs("tabChisel")
|
|
|
|
|
{
|
|
|
|
|
@Override
|
|
|
|
|
public Item getTabIconItem()
|
|
|
|
|
{
|
|
|
|
|
return chisel;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2014-04-21 19:13:15 +01:00
|
|
|
chisel = (ItemChisel) new ItemChisel(Carving.chisel).setTextureName("chisel:chisel").setCreativeTab(CreativeTabs.tabTools);
|
|
|
|
|
GameRegistry.registerItem(chisel, "chisel");
|
|
|
|
|
|
2014-07-26 09:17:49 +01:00
|
|
|
if(Configurations.featureEnabled("cloud"))
|
2014-04-21 19:13:15 +01:00
|
|
|
{
|
|
|
|
|
itemCloudInABottle = (ItemCloudInABottle) new ItemCloudInABottle().setTextureName("Chisel:cloudinabottle").setCreativeTab(CreativeTabs.tabTools);
|
|
|
|
|
EntityRegistry.registerModEntity(EntityCloudInABottle.class, "CloudInABottle", 1, this, 40, 1, true);
|
|
|
|
|
GameRegistry.registerItem(itemCloudInABottle, "chisel.cloudinabottle");
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-26 09:17:49 +01:00
|
|
|
if(Configurations.featureEnabled("ballOfMoss"))
|
2014-04-21 19:13:15 +01:00
|
|
|
{
|
|
|
|
|
itemBallOMoss = (ItemBallOMoss) new ItemBallOMoss().setTextureName("Chisel:ballomoss").setCreativeTab(CreativeTabs.tabTools);
|
|
|
|
|
EntityRegistry.registerModEntity(EntityBallOMoss.class, "BallOMoss", 2, this, 40, 1, true);
|
|
|
|
|
GameRegistry.registerItem(itemBallOMoss, "ballomoss");
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-26 09:17:49 +01:00
|
|
|
if(Configurations.featureEnabled("smashingRock"))
|
2014-04-22 16:46:39 +01:00
|
|
|
{
|
|
|
|
|
smashingRock = (ItemSmashingRock) new ItemSmashingRock().setTextureName("Chisel:smashingrock").setCreativeTab(CreativeTabs.tabTools);
|
|
|
|
|
EntityRegistry.registerModEntity(EntitySmashingRock.class, "SmashingRock", 2, this, 40, 1, true);
|
|
|
|
|
GameRegistry.registerItem(smashingRock, "smashingrock");
|
|
|
|
|
}
|
2014-04-21 19:13:15 +01:00
|
|
|
ChiselBlocks.load();
|
|
|
|
|
proxy.preInit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
|
public void init(FMLInitializationEvent event)
|
|
|
|
|
{
|
|
|
|
|
Crafting.init();
|
|
|
|
|
|
|
|
|
|
NetworkRegistry.INSTANCE.registerGuiHandler(this, new IGuiHandler()
|
|
|
|
|
{
|
|
|
|
|
@Override
|
|
|
|
|
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
|
|
|
|
{
|
|
|
|
|
return new ContainerChisel(player.inventory, new InventoryChiselSelection(null));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
|
|
|
|
{
|
|
|
|
|
return new GuiChisel(player.inventory, new InventoryChiselSelection(null));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
2014-09-15 11:36:29 +01:00
|
|
|
GameRegistry.registerWorldGenerator(new GeneratorMarble(ChiselBlocks.blockMarble, 32, Configurations.marbleAmount), 1000);
|
|
|
|
|
GameRegistry.registerWorldGenerator(new GeneratorLimestone(ChiselBlocks.blockLimestone, 32, Configurations.limestoneAmount), 1000);
|
2014-04-21 19:13:15 +01:00
|
|
|
|
|
|
|
|
proxy.init();
|
|
|
|
|
MinecraftForge.EVENT_BUS.register(this);
|
2014-09-15 11:14:40 +01:00
|
|
|
MinecraftForge.EVENT_BUS.register(new ChiselLeftClick());
|
2014-06-27 18:07:23 -07:00
|
|
|
FMLCommonHandler.instance().bus().register(instance);
|
2014-08-08 09:06:15 -04:00
|
|
|
|
|
|
|
|
FMLInterModComms.sendMessage("Waila", "register", "info.jbcs.minecraft.chisel.Waila.register");
|
2014-04-21 19:13:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
|
public void postInit(FMLPostInitializationEvent event)
|
|
|
|
|
{
|
2014-08-13 16:58:37 +01:00
|
|
|
Compatibility.init(event);
|
2014-04-21 19:13:15 +01:00
|
|
|
}
|
2014-06-27 18:07:23 -07:00
|
|
|
|
2014-07-17 22:05:29 +01:00
|
|
|
|
2014-06-27 18:07:23 -07:00
|
|
|
@SubscribeEvent
|
2014-06-30 20:43:30 +01:00
|
|
|
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event)
|
|
|
|
|
{
|
|
|
|
|
if(event.modID.equals("chisel"))
|
|
|
|
|
{
|
2014-07-17 22:05:29 +01:00
|
|
|
Configurations.refreshConfig();
|
2014-06-27 18:07:23 -07:00
|
|
|
}
|
|
|
|
|
}
|
2014-08-31 13:37:01 +02:00
|
|
|
|
2014-04-21 19:13:15 +01:00
|
|
|
}
|