mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-12 08:50:04 -04:00
agri craft not 100% working
This commit is contained in:
parent
cd3b6119b3
commit
f4044db8a0
@ -152,6 +152,10 @@ repositories {
|
||||
name 'BloodMagic'
|
||||
artifactPattern "http://addons-origin.cursecdn.com/files/${config.bloodmagic.cf}/[module]-${config.minecraft.version}-[revision].[ext]"
|
||||
}
|
||||
ivy {
|
||||
name 'AgriCraft'
|
||||
artifactPattern "http://addons-origin.cursecdn.com/files/${config.agricraft.cf}/[module]-${config.minecraft.version}-[revision].[ext]"
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
@ -191,6 +195,7 @@ dependencies {
|
||||
provided name: 'EnderIO', version: config.eio.version, ext: 'jar'
|
||||
provided name: 'Railcraft', version: config.rc.version, ext: 'jar'
|
||||
provided name: 'BloodMagic', version: config.bloodmagic.version, ext: 'jar'
|
||||
provided name: 'AgriCraft', version: config.agricraft.version, ext: 'jar'
|
||||
|
||||
compile 'com.google.code.findbugs:jsr305:1.3.9' // Annotations used by google libs.
|
||||
|
||||
|
@ -5,6 +5,8 @@ oc.version=1.5.13
|
||||
oc.subversion=dev
|
||||
|
||||
ae2.version=rv2-beta-26
|
||||
agricraft.cf=2229/714
|
||||
agricraft.version=1.3.1
|
||||
bc.version=7.0.8
|
||||
bloodmagic.cf=2223/203
|
||||
bloodmagic.version=1.3.0a-1
|
||||
|
@ -146,6 +146,7 @@ object Constants {
|
||||
final val TexturePicker = "texturePicker"
|
||||
final val TractorBeamUpgrade = "tractorBeamUpgrade"
|
||||
final val Transistor = "transistor"
|
||||
final val FarmingUpgrade = "farmingUpgrade"
|
||||
final val UpgradeContainerTier1 = "upgradeContainer1"
|
||||
final val UpgradeContainerTier2 = "upgradeContainer2"
|
||||
final val UpgradeContainerTier3 = "upgradeContainer3"
|
||||
|
@ -14,8 +14,7 @@ import li.cil.oc.common.Loot
|
||||
import li.cil.oc.common.Tier
|
||||
import li.cil.oc.common.block.SimpleBlock
|
||||
import li.cil.oc.common.item
|
||||
import li.cil.oc.common.item.Delegator
|
||||
import li.cil.oc.common.item.UpgradeLeash
|
||||
import li.cil.oc.common.item.{UpgradeFarming, Delegator, UpgradeLeash}
|
||||
import li.cil.oc.common.item.data.DroneData
|
||||
import li.cil.oc.common.item.data.HoverBootsData
|
||||
import li.cil.oc.common.item.data.MicrocontrollerData
|
||||
@ -538,5 +537,9 @@ object Items extends ItemAPI {
|
||||
|
||||
// 1.5.12
|
||||
registerItem(new item.APU(multi, Tier.Three), Constants.ItemName.APUCreative)
|
||||
|
||||
//???
|
||||
registerItem(new UpgradeFarming(multi),Constants.ItemName.FarmingUpgrade)
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,5 @@
|
||||
package li.cil.oc.common.item
|
||||
|
||||
class UpgradeFarming (val parent: Delegator) extends traits.Delegate with traits.ItemTier{
|
||||
|
||||
}
|
@ -19,6 +19,7 @@ object Mods {
|
||||
|
||||
def All = knownMods.clone()
|
||||
|
||||
val AgriCraft = new SimpleMod(IDs.AgriCraft)
|
||||
val AppliedEnergistics2 = new SimpleMod(IDs.AppliedEnergistics2, version = "@[rv1,)", providesPower = true)
|
||||
val BattleGear2 = new SimpleMod(IDs.BattleGear2)
|
||||
val BloodMagic = new SimpleMod(IDs.BloodMagic)
|
||||
@ -79,6 +80,7 @@ object Mods {
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
val Proxies = Array(
|
||||
integration.agricraft.ModAgriCraft,
|
||||
integration.appeng.ModAppEng,
|
||||
integration.bloodmagic.ModBloodMagic,
|
||||
integration.bluepower.ModBluePower,
|
||||
@ -147,6 +149,7 @@ object Mods {
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
object IDs {
|
||||
final val AgriCraft = "AgriCraft"
|
||||
final val AppliedEnergistics2 = "appliedenergistics2"
|
||||
final val BattleGear2 = "battlegear2"
|
||||
final val BloodMagic = "AWWayofTime"
|
||||
@ -168,7 +171,8 @@ object Mods {
|
||||
final val Factorization = "factorization"
|
||||
final val Forestry = "Forestry"
|
||||
final val ForgeMultipart = "ForgeMultipart"
|
||||
final val DeepStorageUnit = "MineFactoryReloaded|DeepStorageUnit" // Doesn't really exist.
|
||||
final val DeepStorageUnit = "MineFactoryReloaded|DeepStorageUnit"
|
||||
// Doesn't really exist.
|
||||
final val Galacticraft = "Galacticraft API"
|
||||
final val GregTech = "gregtech"
|
||||
final val IndustrialCraft2 = "IC2"
|
||||
|
@ -0,0 +1,38 @@
|
||||
package li.cil.oc.integration.agricraft
|
||||
|
||||
import com.InfinityRaider.AgriCraft.blocks.BlockCrop
|
||||
import li.cil.oc.integration.util.Crop
|
||||
import li.cil.oc.integration.util.Crop.CropProvider
|
||||
import li.cil.oc.integration.{Mods, Mod, ModProxy}
|
||||
import li.cil.oc.server.component._
|
||||
import li.cil.oc.util.BlockPosition
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.item.Item
|
||||
|
||||
object ModAgriCraft extends ModProxy with CropProvider {
|
||||
override def getMod: Mod = Mods.AgriCraft
|
||||
|
||||
override def initialize(): Unit = {
|
||||
Crop.addProvider(this)
|
||||
}
|
||||
|
||||
override def getInformation(pos: BlockPosition): Array[AnyRef] = {
|
||||
val world = pos.world.get
|
||||
val target = world.getBlock(pos.x,pos.y,pos.z)
|
||||
target match {
|
||||
case crop:BlockCrop=>{
|
||||
val meta = world.getBlockMetadata(pos.x, pos.y, pos.z)
|
||||
val value = meta * 100 / 2
|
||||
result(Item.itemRegistry.getNameForObject(crop.getSeed))
|
||||
}
|
||||
case _=>result(Unit,"not a thing")
|
||||
}
|
||||
}
|
||||
|
||||
override def isValidFor(block: Block): Boolean = {
|
||||
block match {
|
||||
case _: BlockCrop => true
|
||||
case _ => false
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package li.cil.oc.integration.opencomputers
|
||||
|
||||
import li.cil.oc.api.driver.item.HostAware
|
||||
import li.cil.oc.api.driver.{EnvironmentAware, EnvironmentHost}
|
||||
import li.cil.oc.api.internal.Robot
|
||||
import li.cil.oc.common.{Slot, Tier}
|
||||
import li.cil.oc.server.component
|
||||
import li.cil.oc.{Constants, api}
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
object DriverUpgradeFarming extends Item with HostAware with EnvironmentAware {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack,
|
||||
api.Items.get(Constants.ItemName.FarmingUpgrade))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
|
||||
host match {
|
||||
case robot: EnvironmentHost with Robot => new component.UpgradeFarming(robot)
|
||||
case _ => null
|
||||
}
|
||||
|
||||
override def slot(stack: ItemStack) = Slot.Upgrade
|
||||
|
||||
override def tier(stack: ItemStack) = Tier.One
|
||||
|
||||
override def providedEnvironment(stack: ItemStack) = classOf[component.UpgradeFarming]
|
||||
}
|
@ -119,6 +119,7 @@ object ModOpenComputers extends ModProxy {
|
||||
api.Driver.add(DriverUpgradeCrafting)
|
||||
api.Driver.add(DriverUpgradeDatabase)
|
||||
api.Driver.add(DriverUpgradeExperience)
|
||||
api.Driver.add(DriverUpgradeFarming)
|
||||
api.Driver.add(DriverUpgradeGenerator)
|
||||
api.Driver.add(DriverUpgradeHover)
|
||||
api.Driver.add(DriverUpgradeInventory)
|
||||
|
26
src/main/scala/li/cil/oc/integration/util/Crop.scala
Normal file
26
src/main/scala/li/cil/oc/integration/util/Crop.scala
Normal file
@ -0,0 +1,26 @@
|
||||
package li.cil.oc.integration.util
|
||||
|
||||
import li.cil.oc.util.BlockPosition
|
||||
import net.minecraft.block.Block
|
||||
|
||||
import scala.collection.mutable
|
||||
|
||||
object Crop {
|
||||
|
||||
|
||||
val providers = mutable.Buffer.empty[CropProvider]
|
||||
|
||||
def addProvider(provider: CropProvider): Unit = providers += provider
|
||||
|
||||
def getProviderForBlock(block: Block): Option[CropProvider] = {
|
||||
providers.find(_.isValidFor(block))
|
||||
}
|
||||
|
||||
trait CropProvider {
|
||||
def getInformation(pos: BlockPosition): Array[AnyRef]
|
||||
|
||||
def isValidFor(block: Block): Boolean
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -4,14 +4,18 @@ import li.cil.oc.Settings
|
||||
import li.cil.oc.api.Driver
|
||||
import li.cil.oc.integration.ModProxy
|
||||
import li.cil.oc.integration.Mods
|
||||
import li.cil.oc.integration.util.BundledRedstone
|
||||
import li.cil.oc.integration.util.{Crop, BundledRedstone}
|
||||
import li.cil.oc.integration.util.BundledRedstone.RedstoneProvider
|
||||
import li.cil.oc.integration.util.Crop.CropProvider
|
||||
import li.cil.oc.server.component._
|
||||
import li.cil.oc.util.BlockPosition
|
||||
import li.cil.oc.util.ExtendedWorld._
|
||||
import net.minecraft.init.Blocks
|
||||
import net.minecraft.block._
|
||||
import net.minecraft.init.{Items, Blocks}
|
||||
import net.minecraft.item.Item
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
|
||||
object ModVanilla extends ModProxy with RedstoneProvider {
|
||||
object ModVanilla extends ModProxy with RedstoneProvider with CropProvider {
|
||||
def getMod = Mods.Minecraft
|
||||
|
||||
def initialize() {
|
||||
@ -44,6 +48,7 @@ object ModVanilla extends ModProxy with RedstoneProvider {
|
||||
RecipeHandler.init()
|
||||
|
||||
BundledRedstone.addProvider(this)
|
||||
Crop.addProvider(this)
|
||||
}
|
||||
|
||||
override def computeInput(pos: BlockPosition, side: ForgeDirection): Int = {
|
||||
@ -53,4 +58,57 @@ object ModVanilla extends ModProxy with RedstoneProvider {
|
||||
}
|
||||
|
||||
override def computeBundledInput(pos: BlockPosition, side: ForgeDirection): Array[Int] = null
|
||||
|
||||
override def getInformation(pos: BlockPosition): Array[AnyRef] = {
|
||||
val world = pos.world.get
|
||||
val target = world.getBlock(pos.x, pos.y, pos.z)
|
||||
target match {
|
||||
case crop: BlockBush => {
|
||||
val meta = world.getBlockMetadata(pos.x, pos.y, pos.z)
|
||||
var name = crop.getLocalizedName
|
||||
var modifier = 7
|
||||
crop match {
|
||||
|
||||
case Blocks.wheat => {
|
||||
name = Item.itemRegistry.getNameForObject(Items.wheat)
|
||||
}
|
||||
case Blocks.melon_stem => {
|
||||
//Localize this?
|
||||
name = "Melon stem"
|
||||
}
|
||||
case Blocks.pumpkin_stem => {
|
||||
name = "Pumpkin stem"
|
||||
}
|
||||
case Blocks.nether_wart => {
|
||||
modifier = 3
|
||||
}
|
||||
case _ =>
|
||||
}
|
||||
result(name, meta * 100 / modifier)
|
||||
}
|
||||
case cocoa: BlockCocoa => {
|
||||
val meta = world.getBlockMetadata(pos.x, pos.y, pos.z)
|
||||
val value = meta * 100 / 2
|
||||
|
||||
result(cocoa.getLocalizedName, Math.min(value, 100))
|
||||
}
|
||||
case _: BlockMelon | _: BlockPumpkin => {
|
||||
result(target.getLocalizedName, 100)
|
||||
}
|
||||
case _: BlockCactus | _: BlockReed => {
|
||||
val meta = world.getBlockMetadata(pos.x, pos.y, pos.z)
|
||||
result(target.getLocalizedName, meta)
|
||||
}
|
||||
case _ => result(Unit, "Not a crop")
|
||||
}
|
||||
}
|
||||
|
||||
override def isValidFor(block: Block): Boolean = {
|
||||
block match {
|
||||
//has to be specified for crops otherwise overriding blocks of other mods might not get their own Provider
|
||||
case _: BlockStem | Blocks.wheat | Blocks.carrots | Blocks.potatoes | _: BlockCocoa | _: BlockMelon | _: BlockPumpkin | _: BlockCactus | _: BlockReed => true
|
||||
case _ => false
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
package li.cil.oc.server.component
|
||||
|
||||
import li.cil.oc.api.driver.EnvironmentHost
|
||||
import li.cil.oc.api.machine.{Callback, Arguments, Context}
|
||||
import li.cil.oc.api.network.Visibility
|
||||
import li.cil.oc.api.{Network, prefab, internal}
|
||||
import li.cil.oc.integration.util.Crop
|
||||
import li.cil.oc.integration.util.Crop.CropProvider
|
||||
import li.cil.oc.util.BlockPosition
|
||||
import net.minecraft.block._
|
||||
import net.minecraft.init.{Items, Blocks}
|
||||
import net.minecraft.item.Item
|
||||
import net.minecraftforge.common.IPlantable
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
|
||||
class UpgradeFarming(val host: EnvironmentHost with internal.Robot) extends prefab.ManagedEnvironment {
|
||||
override val node = Network.newNode(this, Visibility.Network).
|
||||
withComponent("farming").
|
||||
create()
|
||||
|
||||
@Callback(doc = """function([count:number]):boolean -- checks the ripeness of the seed.""")
|
||||
def check(context: Context, args: Arguments): Array[AnyRef] = {
|
||||
val hostPos = BlockPosition(host)
|
||||
val targetPos = hostPos.offset(ForgeDirection.DOWN)
|
||||
val target = host.world.getBlock(targetPos.x, targetPos.y, targetPos.z)
|
||||
Crop.getProviderForBlock(target) match {
|
||||
case Some(provider) => provider.getInformation(BlockPosition(targetPos.x, targetPos.y, targetPos.z, host.world))
|
||||
case _ => result(Unit, "Not a crop")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user