blob: 8ac1af5f385143e395a4658c7e1e28dba7f9581a [file] [log] [blame] [raw]
package li.cil.oc.integration.util
import java.lang.reflect.Method
import li.cil.oc.common.IMC
import li.cil.oc.util.BlockPosition
import net.minecraft.entity.player.EntityPlayer
import scala.collection.mutable
object Wrench {
private val wrenches = mutable.LinkedHashSet.empty[Method]
def add(wrench: Method): Unit = wrenches += wrench
def holdsApplicableWrench(player: EntityPlayer, position: BlockPosition): Boolean =
player.getCurrentEquippedItem != null && wrenches.exists(IMC.tryInvokeStatic(_, player, int2Integer(position.x), int2Integer(position.y), int2Integer(position.z), boolean2Boolean(false))(false))
def wrenchUsed(player: EntityPlayer, position: BlockPosition): Unit =
if (player.getCurrentEquippedItem != null) wrenches.foreach(IMC.tryInvokeStaticVoid(_, player, int2Integer(position.x), int2Integer(position.y), int2Integer(position.z), boolean2Boolean(true)))
}