From a50b237734a3914bd218d0daf2964a4d7db04de7 Mon Sep 17 00:00:00 2001 From: payonel Date: Sun, 23 Jun 2019 01:02:51 -0700 Subject: [PATCH 1/4] vt100 Hf position defaults to 1 --- .../loot/openos/lib/core/full_vt.lua | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/resources/assets/opencomputers/loot/openos/lib/core/full_vt.lua b/src/main/resources/assets/opencomputers/loot/openos/lib/core/full_vt.lua index ee4b4f494..6e95d685a 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/lib/core/full_vt.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/lib/core/full_vt.lua @@ -35,8 +35,16 @@ end -- [Line;ColumnH Move cursor to screen location v,h -- [Line;Columnf ^ same -rules[{"%[", "%d+", ";", "%d+", "[Hf]"}] = function(window, _, y, _, x) - set_cursor(window, tonumber(x), tonumber(y)) +-- [;H Move cursor to upper left corner +-- [;f ^ same +rules[{"%[", "%d*", ";", "%d*", "[Hf]"}] = function(window, _, y, _, x) + set_cursor(window, tonumber(x) or 1, tonumber(y) or 1) +end + +-- [H move cursor to upper left corner +-- [f ^ same +rules[{"%[[Hf]"}] = function(window) + set_cursor(window, 1, 1) end -- [K clear line from cursor right @@ -63,14 +71,6 @@ rules[{"%[", "[012]?", "J"}] = function(window, _, n) window.gpu.fill(1 + window.dx, y + window.dy, window.width, rep, " ") end --- [H move cursor to upper left corner --- [;H ^ same --- [f ^ same --- [;f ^ same -rules[{"%[;?", "[Hf]"}] = function(window) - set_cursor(window, 1, 1) -end - -- [6n get the cursor position [ EscLine;ColumnR Response: cursor is at v,h ] rules[{"%[", "6", "n"}] = function(window) -- this solution puts the response on stdin, but it isn't echo'd From 9a1923f7f47e8d6882a505503f21a2e3067479e7 Mon Sep 17 00:00:00 2001 From: payonel Date: Sun, 14 Jul 2019 14:11:15 -0700 Subject: [PATCH 2/4] check tostring result for print closes #3125 --- .../resources/assets/opencomputers/loot/openos/boot/00_base.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/assets/opencomputers/loot/openos/boot/00_base.lua b/src/main/resources/assets/opencomputers/loot/openos/boot/00_base.lua index 7bd7b3aba..475af463c 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/boot/00_base.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/boot/00_base.lua @@ -34,7 +34,7 @@ function print(...) local stdout = io.stdout local pre = "" for i = 1, args.n do - stdout:write(pre, tostring(args[i])) + stdout:write(pre, assert(tostring(args[i]), "'tostring' must return a string to 'print'")) pre = "\t" end stdout:write("\n") From 838de82df9ed4d3f6b4d52ce7a62a35982fe3c3c Mon Sep 17 00:00:00 2001 From: payonel Date: Mon, 15 Jul 2019 02:11:37 -0700 Subject: [PATCH 3/4] woops, meant to grab only 1 return from assert --- .../resources/assets/opencomputers/loot/openos/boot/00_base.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/assets/opencomputers/loot/openos/boot/00_base.lua b/src/main/resources/assets/opencomputers/loot/openos/boot/00_base.lua index 475af463c..0709614b4 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/boot/00_base.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/boot/00_base.lua @@ -34,7 +34,7 @@ function print(...) local stdout = io.stdout local pre = "" for i = 1, args.n do - stdout:write(pre, assert(tostring(args[i]), "'tostring' must return a string to 'print'")) + stdout:write(pre, (assert(tostring(args[i]), "'tostring' must return a string to 'print'"))) pre = "\t" end stdout:write("\n") From f846726b4615d5243537131e8f2e986953992976 Mon Sep 17 00:00:00 2001 From: repo_alt Date: Sun, 21 Jul 2019 22:06:26 +0300 Subject: [PATCH 4/4] Added IC2 crop breeding integration. Updated IC2 API version reference (old api is deprecated) --- build.gradle | 4 + build.properties | 2 +- .../integration/ic2/ConverterBaseSeed.scala | 23 ++++ .../li/cil/oc/integration/ic2/DriverCrop.java | 107 ++++++++++++++++++ .../ic2/EventHandlerIndustrialCraft2.scala | 27 ++++- .../integration/ic2/ModIndustrialCraft2.scala | 2 + 6 files changed, 163 insertions(+), 2 deletions(-) create mode 100644 src/main/scala/li/cil/oc/integration/ic2/ConverterBaseSeed.scala create mode 100644 src/main/scala/li/cil/oc/integration/ic2/DriverCrop.java diff --git a/build.gradle b/build.gradle index 257789d86..933c42e03 100644 --- a/build.gradle +++ b/build.gradle @@ -77,6 +77,10 @@ repositories { name = "mightypirates" url = "https://maven.cil.li/" } + maven { + name = "ic2" + url = "http://maven.ic2.player.to/" + } } configurations { diff --git a/build.properties b/build.properties index e9d4b2e25..f8281faae 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 000000000..5d490e6e6 --- /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 000000000..6a67b595d --- /dev/null +++ b/src/main/scala/li/cil/oc/integration/ic2/DriverCrop.java @@ -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 { + 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 { + 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 5155af63a..991ecf01d 100644 --- a/src/main/scala/li/cil/oc/integration/ic2/EventHandlerIndustrialCraft2.scala +++ b/src/main/scala/li/cil/oc/integration/ic2/EventHandlerIndustrialCraft2.scala @@ -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 { 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 e26766f1b..a33931336 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) } }