diff --git a/build.gradle b/build.gradle index e810eee5b5..93d970e293 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ buildscript { } maven { url = "https://jitpack.io" - } + } } dependencies { classpath 'com.github.CDAGaming:ForgeGradle:1c670759c5' @@ -78,6 +78,10 @@ repositories { name = "mightypirates" url = "https://maven.cil.li/" } + maven { + name = "ic2, forestry" + url = "http://maven.ic2.player.to/" + } // These are necessary because some parts of the maven repo is weirdly structured, this needs to be fixed. ivy { name 'weird maven repos' diff --git a/build.properties b/build.properties index cd7736ec69..0af969e56e 100644 --- a/build.properties +++ b/build.properties @@ -25,7 +25,7 @@ forestry.version=4.1.0.44 gc.build=3 gc.version=3.0.7 gt.version=5.04.06 -ic2.version=2.2.654-experimental +ic2.version=2.2.828-experimental igwmod.version=1.1.3-18 mekanism.build=5 mekanism.version=7.1.2 diff --git a/src/main/scala/li/cil/oc/integration/ic2/ConverterBaseSeed.scala b/src/main/scala/li/cil/oc/integration/ic2/ConverterBaseSeed.scala new file mode 100644 index 0000000000..5d490e6e63 --- /dev/null +++ b/src/main/scala/li/cil/oc/integration/ic2/ConverterBaseSeed.scala @@ -0,0 +1,23 @@ +package li.cil.oc.integration.ic2 + +import ic2.api.crops.BaseSeed +import ic2.api.crops.Crops +import li.cil.oc.api.driver.Converter +import net.minecraft.item.ItemStack +import java.util +import scala.collection.convert.WrapAsScala._ + +class ConverterBaseSeed extends Converter { + override def convert(value: Any, output: util.Map[AnyRef, AnyRef]): Unit = if (value.isInstanceOf[ItemStack]) { + val stack = value.asInstanceOf[ItemStack] + val cc = Crops.instance.getCropCard(stack) + if (cc != null && stack.getTagCompound().getByte("scan") == 4) { + output += "crop" -> Map("name" -> cc.name, + "tier" -> cc.tier, + "growth" -> stack.getTagCompound().getByte("growth"), + "gain" -> stack.getTagCompound().getByte("gain"), + "resistance" -> stack.getTagCompound().getByte("resistance") + ) + } + } +} \ No newline at end of file diff --git a/src/main/scala/li/cil/oc/integration/ic2/DriverCrop.java b/src/main/scala/li/cil/oc/integration/ic2/DriverCrop.java new file mode 100644 index 0000000000..6be69a5dc6 --- /dev/null +++ b/src/main/scala/li/cil/oc/integration/ic2/DriverCrop.java @@ -0,0 +1,93 @@ +package li.cil.oc.integration.ic2; + +import li.cil.oc.api.machine.Arguments; +import li.cil.oc.api.machine.Callback; +import li.cil.oc.api.machine.Context; +import li.cil.oc.api.network.ManagedEnvironment; +import li.cil.oc.api.prefab.DriverSidedTileEntity; +import ic2.api.crops.ICropTile; +import li.cil.oc.integration.ManagedTileEntityEnvironment; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public final class DriverCrop extends DriverSidedTileEntity { + @Override + public Class getTileEntityClass() { + return ICropTile.class; + } + + @Override + public ManagedEnvironment createEnvironment(World world, int x, int y, int z, ForgeDirection side) { + return new DriverCrop.Environment((ICropTile) world.getTileEntity(x, y, z)); + } + public static final class Environment extends ManagedTileEntityEnvironment { + public Environment(final ICropTile tileEntity) { + super(tileEntity, "crop"); + } + + @Callback + public Object[] getSize(final Context context, final Arguments args) { + return new Object[]{tileEntity.getSize()}; + } + @Callback + public Object[] getGrowth(final Context context, final Arguments args) { + return new Object[]{tileEntity.getGrowth()}; + } + @Callback + public Object[] getGain(final Context context, final Arguments args) { + return new Object[]{tileEntity.getGain()}; + } + @Callback + public Object[] getResistance(final Context context, final Arguments args) { + return new Object[]{tileEntity.getResistance()}; + } + @Callback + public Object[] getNutrientStorage(final Context context, final Arguments args) { + return new Object[]{tileEntity.getNutrientStorage()}; + } + @Callback + public Object[] getHydrationStorage(final Context context, final Arguments args) { + return new Object[]{tileEntity.getHydrationStorage()}; + } + @Callback + public Object[] getWeedExStorage(final Context context, final Arguments args) { + return new Object[]{tileEntity.getWeedExStorage()}; + } + @Callback + public Object[] getHumidity(final Context context, final Arguments args) { + return new Object[]{tileEntity.getHumidity()}; + } + @Callback + public Object[] getNutrients(final Context context, final Arguments args) { + return new Object[]{tileEntity.getNutrients()}; + } + @Callback + public Object[] getAirQuality(final Context context, final Arguments args) { + return new Object[]{tileEntity.getAirQuality()}; + } + @Callback + public Object[] getName(final Context context, final Arguments args) { + return new Object[]{tileEntity.getCrop().name()}; + } + @Callback + public Object[] getRootsLength(final Context context, final Arguments args) { + return new Object[]{tileEntity.getCrop().getrootslength(tileEntity)}; + } + @Callback + public Object[] getTier(final Context context, final Arguments args) { + return new Object[]{tileEntity.getCrop().tier()}; + } + @Callback + public Object[] maxSize(final Context context, final Arguments args) { + return new Object[]{tileEntity.getCrop().maxSize()}; + } + @Callback + public Object[] canGrow(final Context context, final Arguments args) { + return new Object[]{tileEntity.getCrop().canGrow(tileEntity)}; + } + @Callback + public Object[] getOptimalHavestSize(final Context context, final Arguments args) { + return new Object[]{tileEntity.getCrop().getOptimalHavestSize(tileEntity)}; + } + } +} diff --git a/src/main/scala/li/cil/oc/integration/ic2/EventHandlerIndustrialCraft2.scala b/src/main/scala/li/cil/oc/integration/ic2/EventHandlerIndustrialCraft2.scala index 5155af63aa..f794d90f86 100644 --- a/src/main/scala/li/cil/oc/integration/ic2/EventHandlerIndustrialCraft2.scala +++ b/src/main/scala/li/cil/oc/integration/ic2/EventHandlerIndustrialCraft2.scala @@ -1,26 +1,54 @@ package li.cil.oc.integration.ic2 import cpw.mods.fml.common.eventhandler.SubscribeEvent +import ic2.api.crops.ICropTile import ic2.api.item.ElectricItem import ic2.api.item.IElectricItem import ic2.api.item.ISpecialElectricItem import ic2.core.item.tool.ItemToolWrench -import li.cil.oc.api.event.RobotUsedToolEvent +import li.cil.oc.api.event.{GeolyzerEvent, RobotUsedToolEvent} import li.cil.oc.integration.util.Power import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.ItemStack +import scala.collection.convert.WrapAsScala._ object EventHandlerIndustrialCraft2 { + @SubscribeEvent + def onGeolyzerAnalyze(e: GeolyzerEvent.Analyze) { + val world = e.host.world + world.getTileEntity(e.x, e.y, e.z) match { + case crop: ICropTile => + crop.setScanLevel(4) + val cc = crop.getCrop + if (cc != null) { + e.data += "crop:name" -> cc.name() + e.data += "crop:tier" -> Int.box(cc.tier) + e.data += "crop:size" -> Int.box(crop.getSize) + e.data += "crop:maxSize" -> Int.box(cc.maxSize) + e.data += "crop:growth" -> Int.box(crop.getGrowth) + e.data += "crop:gain" -> Int.box(crop.getGain) + e.data += "crop:resistance" -> Int.box(crop.getResistance) + e.data += "crop:fertilizer" -> Int.box(crop.getNutrientStorage) + e.data += "crop:hydration" -> Int.box(crop.getHydrationStorage) + e.data += "crop:weedex" -> Int.box(crop.getWeedExStorage) + e.data += "crop:humidity" -> Int.box(crop.getHumidity) + e.data += "crop:nutrients" -> Int.box(crop.getNutrients) + e.data += "crop:air" -> Int.box(crop.getAirQuality) + e.data += "crop:roots" -> Int.box(cc.getrootslength(crop)) + } + case _ => None + } + } @SubscribeEvent def onRobotApplyDamageRate(e: RobotUsedToolEvent.ApplyDamageRate) { val optManagerBefore = e.toolBeforeUse.getItem match { case item: ISpecialElectricItem => Option(item.getManager(e.toolBeforeUse)) - case item: IElectricItem => Option(ElectricItem.manager) + case _: IElectricItem => Option(ElectricItem.manager) case _ => None } val optManagerAfter = e.toolAfterUse.getItem match { case item: ISpecialElectricItem => Option(item.getManager(e.toolAfterUse)) - case item: IElectricItem => Option(ElectricItem.manager) + case _: IElectricItem => Option(ElectricItem.manager) case _ => None } (optManagerBefore, optManagerAfter) match { @@ -69,7 +97,7 @@ object EventHandlerIndustrialCraft2 { def charge(stack: ItemStack, amount: Double, simulate: Boolean): Double = { (stack.getItem match { case item: ISpecialElectricItem => Option(item.getManager(stack)) - case item: IElectricItem => Option(ElectricItem.manager) + case _: IElectricItem => Option(ElectricItem.manager) case _ => None }) match { case Some(manager) => amount - Power.fromEU(manager.charge(stack, Power.toEU(amount), Int.MaxValue, true, false)) diff --git a/src/main/scala/li/cil/oc/integration/ic2/ModIndustrialCraft2.scala b/src/main/scala/li/cil/oc/integration/ic2/ModIndustrialCraft2.scala index e26766f1bc..a339313362 100644 --- a/src/main/scala/li/cil/oc/integration/ic2/ModIndustrialCraft2.scala +++ b/src/main/scala/li/cil/oc/integration/ic2/ModIndustrialCraft2.scala @@ -34,5 +34,7 @@ object ModIndustrialCraft2 extends ModProxy { Driver.add(new DriverReactorChamber) Driver.add(new ConverterElectricItem) + Driver.add(new ConverterBaseSeed) + Driver.add(new DriverCrop) } }