Democre

my mod's root package object

May 4th, 2013
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 1.62 KB | None | 0 0
  1. package at.codezilla
  2.  
  3.  
  4. /**
  5. Created by Democre on 5/3/13
  6.   */
  7. package object scamod {
  8.   //string constants replacing Pahimar's reference class idea
  9.   final val MOD_ID = "ScaMod"
  10.   final val MOD_NAME = "Scala Mod"
  11.   final val VERSION = "0.0.1"
  12.  
  13.  
  14.   //import and shortening some names just cause I can
  15.  
  16.   import cpw.mods.fml.common.event._
  17.   type FMLPreInitEvent = FMLPreInitializationEvent
  18.   type FMLInitEvent = FMLInitializationEvent
  19.   type FMLPostInitEvent = FMLPostInitializationEvent
  20.  
  21.   //implicit Block to ItemStack and Item to ItemStack
  22.   import net.minecraft.block.Block
  23.   import net.minecraft.item.Item
  24.   import net.minecraft.item.ItemStack
  25.  
  26.   implicit def block2ItemStack(value: Block) = new ItemStack(value)
  27.   implicit def blockAndQuantity2ItemStack(value: (Block, Int)) = new ItemStack(value._1, value._2)
  28.   implicit def blockAndQuantityAndDamage2ItemStack(value: (Block, Int, Int)) = new ItemStack(value._1, value._2, value._3)
  29.  
  30.   implicit def item2ItemStack(value: Item) = new ItemStack(value)
  31.   implicit def itemAndQuantity2ItemStack(value: (Item, Int)) = new ItemStack(value._1, value._2)
  32.   implicit def itemAndQuantityAndDamage2ItemStack(value: (Item, Int, Int)) = new ItemStack(value._1, value._2, value._3)
  33.  
  34.   //ItemStack factory to exercise the implicits
  35.   object IS {
  36.     def apply (value: ItemStack) = value
  37.     def apply (obj: Block, quantity: Int) = IS((obj, quantity))
  38.     def apply (obj: Block, quantity: Int, dam: Int) = IS((obj, quantity, dam))
  39.     def apply (obj: Item, quantity: Int) = IS((obj, quantity))
  40.     def apply (obj: Item, quantity: Int, dam: Int) = IS((obj, quantity, dam))
  41.   }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment