mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-25 22:14:09 -04:00
Added IC2 crop breeding integration.
Updated IC2 API version reference (old api is deprecated)
This commit is contained in:
parent
d82e06f83f
commit
f846726b46
@ -77,6 +77,10 @@ repositories {
|
||||
name = "mightypirates"
|
||||
url = "https://maven.cil.li/"
|
||||
}
|
||||
maven {
|
||||
name = "ic2"
|
||||
url = "http://maven.ic2.player.to/"
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
|
@ -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
|
||||
|
@ -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")
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
107
src/main/scala/li/cil/oc/integration/ic2/DriverCrop.java
Normal file
107
src/main/scala/li/cil/oc/integration/ic2/DriverCrop.java
Normal file
@ -0,0 +1,107 @@
|
||||
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) {
|
||||
ICropTile tile = (ICropTile) world.getTileEntity(x, y, z);
|
||||
if (tile.getScanLevel() < 4)
|
||||
return new DriverCrop.DummyEnvironment((ICropTile) world.getTileEntity(x, y, z));
|
||||
else
|
||||
return new DriverCrop.Environment((ICropTile) world.getTileEntity(x, y, z));
|
||||
}
|
||||
public static final class DummyEnvironment extends ManagedTileEntityEnvironment<ICropTile> {
|
||||
public DummyEnvironment(final ICropTile tileEntity) {
|
||||
super(tileEntity, "crop");
|
||||
}
|
||||
|
||||
@Callback
|
||||
public Object[] getScanLevel(final Context context, final Arguments args) {
|
||||
return new Object[]{tileEntity.getScanLevel()};
|
||||
}
|
||||
}
|
||||
public static final class Environment extends ManagedTileEntityEnvironment<ICropTile> {
|
||||
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)};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +1,41 @@
|
||||
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
|
||||
val tile = world.getTileEntity(e.x, e.y, e.z) match {
|
||||
case crop : ICropTile => {
|
||||
val cc = crop.getCrop
|
||||
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: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 {
|
||||
|
@ -34,5 +34,7 @@ object ModIndustrialCraft2 extends ModProxy {
|
||||
Driver.add(new DriverReactorChamber)
|
||||
|
||||
Driver.add(new ConverterElectricItem)
|
||||
Driver.add(new ConverterBaseSeed)
|
||||
Driver.add(new DriverCrop)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user