diff options
Diffstat (limited to 'java/darkknight/jewelrycraft/JewelrycraftMod.java')
| -rw-r--r-- | java/darkknight/jewelrycraft/JewelrycraftMod.java | 87 |
1 files changed, 61 insertions, 26 deletions
diff --git a/java/darkknight/jewelrycraft/JewelrycraftMod.java b/java/darkknight/jewelrycraft/JewelrycraftMod.java index a7c0746..ef8a0e3 100644 --- a/java/darkknight/jewelrycraft/JewelrycraftMod.java +++ b/java/darkknight/jewelrycraft/JewelrycraftMod.java @@ -3,7 +3,6 @@ * It's an awesome mod * I love me! :D */ - package darkknight.jewelrycraft; import java.io.File; @@ -11,12 +10,13 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.logging.Logger; - import net.minecraft.client.Minecraft; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.gen.structure.MapGenStructureIO; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.oredict.OreDictionary; @@ -24,25 +24,31 @@ import cpw.mods.fml.common.FMLCommonHandler; 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.Mod.Metadata; import cpw.mods.fml.common.ModMetadata; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.FMLServerStartingEvent; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; +import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.VillagerRegistry; import cpw.mods.fml.relauncher.Side; import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.commands.JewelrycraftCommands; import darkknight.jewelrycraft.config.ConfigHandler; -import darkknight.jewelrycraft.container.ContainerJewelryTab; import darkknight.jewelrycraft.container.GuiHandler; -import darkknight.jewelrycraft.container.JewelryInventory; +import darkknight.jewelrycraft.curses.CurseList; +import darkknight.jewelrycraft.damage.DamageSourceList; +import darkknight.jewelrycraft.effects.EffectsList; +import darkknight.jewelrycraft.entities.EntityHalfHeart; +import darkknight.jewelrycraft.entities.EntityHeart; import darkknight.jewelrycraft.events.BucketHandler; import darkknight.jewelrycraft.events.EntityEventHandler; import darkknight.jewelrycraft.events.KeyBindings; +import darkknight.jewelrycraft.events.PlayerRenderHandler; import darkknight.jewelrycraft.events.ScreenHandler; import darkknight.jewelrycraft.item.ItemList; import darkknight.jewelrycraft.lib.Reference; @@ -59,22 +65,16 @@ import darkknight.jewelrycraft.worldGen.village.ComponentJewelry; import darkknight.jewelrycraft.worldGen.village.JCTrades; import darkknight.jewelrycraft.worldGen.village.VillageJewelryHandler; -@Mod(modid = Reference.MODID, name = Reference.MODNAME, version = Reference.VERSION) +@Mod (modid = Reference.MODID, name = Reference.MODNAME, version = Reference.VERSION) public class JewelrycraftMod { - @Instance(Reference.MODID) + @Instance (Reference.MODID) public static JewelrycraftMod instance; - - @Metadata(Reference.MODID) - public static ModMetadata metadata; - - @SidedProxy(clientSide = "darkknight.jewelrycraft.client.ClientProxy", serverSide = "darkknight.jewelrycraft.CommonProxy") + @SidedProxy (clientSide = "darkknight.jewelrycraft.client.ClientProxy", serverSide = "darkknight.jewelrycraft.CommonProxy") public static CommonProxy proxy; - public static final Logger logger = Logger.getLogger("Jewelrycraft"); public static File dir; - public static CreativeTabs jewelrycraft = new CreativeTabs("JewelryCraft") - { + public static CreativeTabs jewelrycraft = new CreativeTabs("JewelryCraft"){ @Override public Item getTabIconItem() { @@ -85,11 +85,15 @@ public class JewelrycraftMod public static NBTTagCompound saveData = new NBTTagCompound(); public static NBTTagCompound clientData = new NBTTagCompound(); public static File liquidsConf; - public static SimpleNetworkWrapper netWrapper; public static boolean fancyRender; - public static JewelryInventory jewelry = new JewelryInventory(); + /** + * Pre initialization of mod stuff. + * + * @param e FMLPreInitializationEvent + * @throws IOException Signals that an I/O exception has occurred. + */ @EventHandler public void preInit(FMLPreInitializationEvent e) throws IOException { @@ -97,34 +101,34 @@ public class JewelrycraftMod BlockList.preInit(e); ItemList.preInit(e); CraftingRecipes.preInit(e); + CurseList.preInit(e); OreDictionary.registerOre("ingotShadow", new ItemStack(ItemList.shadowIngot)); OreDictionary.registerOre("oreShadow", new ItemStack(BlockList.shadowOre)); - VillagerRegistry.instance().registerVillagerId(3000); VillagerRegistry.instance().registerVillageTradeHandler(3000, new JCTrades()); VillagerRegistry.instance().registerVillageCreationHandler(new VillageJewelryHandler()); - try - { + try{ MapGenStructureIO.func_143031_a(ComponentJewelry.class, "Jewelrycraft:Jewelry"); } - catch (Throwable e2) - { + catch(Throwable e2){ logger.severe("Error registering Jewelrycraft Structures with Vanilla Minecraft: this is expected in versions earlier than 1.7.10"); } MinecraftForge.EVENT_BUS.register(new EntityEventHandler()); - if (FMLCommonHandler.instance().getSide() == Side.CLIENT) MinecraftForge.EVENT_BUS.register(new ScreenHandler(Minecraft.getMinecraft())); + if (FMLCommonHandler.instance().getSide() == Side.CLIENT) MinecraftForge.EVENT_BUS.register(new PlayerRenderHandler()); + ResourceLocation jeweleryTexture = new ResourceLocation("jewelrycraft", "textures/gui/curses.png"); + if (FMLCommonHandler.instance().getSide() == Side.CLIENT) MinecraftForge.EVENT_BUS.register(new ScreenHandler(Minecraft.getMinecraft(), jeweleryTexture)); MinecraftForge.EVENT_BUS.register(BucketHandler.INSTANCE); BucketHandler.INSTANCE.buckets.put(BlockList.moltenMetal, ItemList.bucket); ModMetadata metadata = e.getModMetadata(); - List<String> authorList = new ArrayList<String>(); + authorList.add("DarkKnight (or sor1n)"); authorList.add("bspkrs"); authorList.add("domi1819"); + dir = e.getModConfigurationDirectory(); proxy.registerRenderers(); - netWrapper = NetworkRegistry.INSTANCE.newSimpleChannel(Reference.MODID); netWrapper.registerMessage(PacketRequestLiquidData.class, PacketRequestLiquidData.class, 0, Side.SERVER); netWrapper.registerMessage(PacketSendLiquidData.class, PacketSendLiquidData.class, 1, Side.CLIENT); @@ -132,12 +136,29 @@ public class JewelrycraftMod netWrapper.registerMessage(PacketKeyPressEvent.class, PacketKeyPressEvent.class, 3, Side.SERVER); netWrapper.registerMessage(PacketRequestPlayerInfo.class, PacketRequestPlayerInfo.class, 4, Side.SERVER); netWrapper.registerMessage(PacketSendPlayerInfo.class, PacketSendPlayerInfo.class, 5, Side.CLIENT); - metadata.autogenerated = false; metadata.authorList = authorList; metadata.url = "https://github.com/sor1n/Jewelrycraft"; + + createEntity(EntityHeart.class, "Heart", 0x000000, 0xFF0000, true); + createEntity(EntityHalfHeart.class, "Half-Heart", 0x000000, 0xFF0000, true); + +// EntityRegistry.addSpawn(EntityMob.class, 5, 2, 3, EnumCreatureType.creature, BiomeGenBase.forest, BiomeGenBase.forestHills, BiomeGenBase.birchForest, BiomeGenBase.birchForestHills, BiomeGenBase.plains, BiomeGenBase.beach, BiomeGenBase.coldBeach, BiomeGenBase.frozenRiver); + } + + public void createEntity(Class<? extends Entity> entity, String entityName, int solidColor, int spotColor, boolean hasSpawnEgg) + { + int randomID = EntityRegistry.findGlobalUniqueEntityId(); + if(hasSpawnEgg) EntityRegistry.registerGlobalEntityID(entity, entityName, randomID, solidColor, spotColor); + else EntityRegistry.registerGlobalEntityID(entity, entityName, randomID); + EntityRegistry.registerModEntity(entity, entityName, randomID, this, 40, 3, true); } + /** + * Initializes the world generation and key bindings. + * + * @param e FMLInitializationEvent + */ @EventHandler public void init(FMLInitializationEvent e) { @@ -146,11 +167,25 @@ public class JewelrycraftMod new GuiHandler(); } + /** + * Post initialization of metals, modifiers and others. + * + * @param e FMLPostInitializationEvent + */ @EventHandler public void postInit(FMLPostInitializationEvent e) { JewelrycraftUtil.addMetals(); JewelrycraftUtil.addStuff(); JewelrycraftUtil.jamcrafters(); + EffectsList.postInit(e); + DamageSourceList.postInit(e); + } + + @Mod.EventHandler + public void serverLoad(FMLServerStartingEvent event) + { + event.registerServerCommand(new JewelrycraftCommands()); } + } |
