blob: 18862635cba9bc30d1f576106689c6e0e9d6b271 [file] [log] [blame] [raw]
package li.cil.oc.common.item
import java.util
import cpw.mods.fml.relauncher.Side
import cpw.mods.fml.relauncher.SideOnly
import li.cil.oc.client.KeyBindings
import li.cil.oc.common.entity
import li.cil.oc.integration.util.NEI
import li.cil.oc.util.BlockPosition
import li.cil.oc.util.ItemUtils
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
class Drone(val parent: Delegator) extends Delegate {
NEI.hide(this)
override protected def tooltipExtended(stack: ItemStack, tooltip: util.List[String]): Unit = {
if (KeyBindings.showExtendedTooltips) {
val info = new ItemUtils.MicrocontrollerData(stack)
for (component <- info.components) {
tooltip.add("- " + component.getDisplayName)
}
}
}
override def onItemUse(stack: ItemStack, player: EntityPlayer, position: BlockPosition, side: Int, hitX: Float, hitY: Float, hitZ: Float) = {
val world = position.world.get
if (!world.isRemote) {
val drone = new entity.Drone(world)
drone.initializeAfterPlacement(stack, player, position.offset(hitX * 1.1f, hitY * 1.1f, hitZ * 1.1f))
world.spawnEntityInWorld(drone)
}
stack.stackSize -= 1
true
}
// We no item (rendering using model only).
@SideOnly(Side.CLIENT)
override def registerIcons(iconRegister: IconRegister) {}
}