From c7ebcca083f439730c672c69b0116ed04dc2c752 Mon Sep 17 00:00:00 2001 From: repo_alt Date: Sun, 5 Dec 2021 17:29:45 +0300 Subject: [PATCH 1/4] Railcraft anchors driver API: "getFuel():int -- Get remaining anchor time in ticks." "getOwner():string -- Get the anchor owner name." "getType():string -- Get the anchor type." "getFuelSlotContents():table -- Get the anchor input slot contents." "isDisabled():boolean -- If the anchor is disabled with redstone." https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/8994 --- .../integration/railcraft/DriverAnchor.scala | 44 +++++++++++++++++++ .../integration/railcraft/ModRailcraft.scala | 1 + 2 files changed, 45 insertions(+) create mode 100644 src/main/scala/li/cil/oc/integration/railcraft/DriverAnchor.scala diff --git a/src/main/scala/li/cil/oc/integration/railcraft/DriverAnchor.scala b/src/main/scala/li/cil/oc/integration/railcraft/DriverAnchor.scala new file mode 100644 index 000000000..d51745cb5 --- /dev/null +++ b/src/main/scala/li/cil/oc/integration/railcraft/DriverAnchor.scala @@ -0,0 +1,44 @@ +package li.cil.oc.integration.railcraft + + +import li.cil.oc.api.driver.NamedBlock +import li.cil.oc.api.machine.{Arguments, Callback, Context} +import li.cil.oc.api.network.ManagedEnvironment +import li.cil.oc.api.prefab.DriverSidedTileEntity +import li.cil.oc.integration.ManagedTileEntityEnvironment +import li.cil.oc.util.ResultWrapper.result +import mods.railcraft.common.blocks.machine.alpha.{EnumMachineAlpha, TileAnchorWorld} +import net.minecraft.world.World +import net.minecraftforge.common.util.ForgeDirection + +object DriverAnchor extends DriverSidedTileEntity { + def getTileEntityClass: Class[_] = classOf[TileAnchorWorld] + + def createEnvironment(world: World, x: Int, y: Int, z: Int, side: ForgeDirection): ManagedEnvironment = + new Environment(world.getTileEntity(x, y, z).asInstanceOf[TileAnchorWorld]) + + final class Environment(val tile: TileAnchorWorld) extends ManagedTileEntityEnvironment[TileAnchorWorld](tile, "anchor") with NamedBlock { + override def preferredName = "anchor" + override def priority = 5 + + @Callback(doc = "function():int -- Get remaining anchor time in ticks.") + def getFuel(context: Context, args: Arguments): Array[AnyRef] = result(tile.getAnchorFuel) + + @Callback(doc = "function():string -- Get the anchor owner name.") + def getOwner(context: Context, args: Arguments): Array[AnyRef] = result(tile.getOwner.getName) + + @Callback(doc = "function():string -- Get the anchor type.") + def getType(context: Context, args: Arguments): Array[AnyRef] = tile.getMachineType match { + case EnumMachineAlpha.WORLD_ANCHOR => result("world") + case EnumMachineAlpha.ADMIN_ANCHOR => result("admin") + case EnumMachineAlpha.PERSONAL_ANCHOR => result("personal") + case _ => result("passive") + } + + @Callback(doc = "function():table -- Get the anchor input slot contents.") + def getFuelSlotContents(context: Context, args: Arguments): Array[AnyRef] = result(tile.getStackInSlot(0)) + + @Callback(doc = "function():boolean -- If the anchor is disabled with redstone.") + def isDisabled(context: Context, args: Arguments): Array[AnyRef] = result(tile.isPowered) + } +} diff --git a/src/main/scala/li/cil/oc/integration/railcraft/ModRailcraft.scala b/src/main/scala/li/cil/oc/integration/railcraft/ModRailcraft.scala index 2d0dbd216..51040a1fc 100644 --- a/src/main/scala/li/cil/oc/integration/railcraft/ModRailcraft.scala +++ b/src/main/scala/li/cil/oc/integration/railcraft/ModRailcraft.scala @@ -14,5 +14,6 @@ object ModRailcraft extends ModProxy { Driver.add(new DriverBoilerFirebox) Driver.add(new DriverSteamTurbine) + Driver.add(DriverAnchor) } } \ No newline at end of file From 418792b29ada7173ee0febe6ca022255fccdca78 Mon Sep 17 00:00:00 2001 From: Adrian Siekierka Date: Sun, 4 Jun 2023 14:16:50 +0200 Subject: [PATCH 2/4] update changelog, minor tweaks to anchor driver --- changelog.md | 1 + .../integration/railcraft/DriverAnchor.scala | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/changelog.md b/changelog.md index 53f78e6c0..2c5054256 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,7 @@ * [#3533] Added support for observing the contents of fluid container items. * [#3620] Fixed OC 1.8.0+ regression involving API arguments and numbers. * [#3013] Fixed rare server-side deadlock when sending disk activity update packets. +* Added Railcraft anchor driver. * Added Spanish translation. * Fixed bugs in internal wcwidth() implementation and updated it to cover Unicode 12. * Fixed server->client synchronization for some types of GPU bitblt operations. diff --git a/src/main/scala/li/cil/oc/integration/railcraft/DriverAnchor.scala b/src/main/scala/li/cil/oc/integration/railcraft/DriverAnchor.scala index d51745cb5..ee54d7cb5 100644 --- a/src/main/scala/li/cil/oc/integration/railcraft/DriverAnchor.scala +++ b/src/main/scala/li/cil/oc/integration/railcraft/DriverAnchor.scala @@ -11,6 +11,8 @@ import mods.railcraft.common.blocks.machine.alpha.{EnumMachineAlpha, TileAnchorW import net.minecraft.world.World import net.minecraftforge.common.util.ForgeDirection +import java.util.Objects + object DriverAnchor extends DriverSidedTileEntity { def getTileEntityClass: Class[_] = classOf[TileAnchorWorld] @@ -21,24 +23,29 @@ object DriverAnchor extends DriverSidedTileEntity { override def preferredName = "anchor" override def priority = 5 - @Callback(doc = "function():int -- Get remaining anchor time in ticks.") + @Callback(doc = "function():int -- Get the remaining anchor time, in ticks.") def getFuel(context: Context, args: Arguments): Array[AnyRef] = result(tile.getAnchorFuel) - @Callback(doc = "function():string -- Get the anchor owner name.") - def getOwner(context: Context, args: Arguments): Array[AnyRef] = result(tile.getOwner.getName) + @Callback(doc = "function():string -- Get the anchor owner name.") + def getOwner(context: Context, args: Arguments): Array[AnyRef] = + if (tile.getOwner == null || tile.getOwner.getName == null || Objects.equals(tile.getOwner.getName, "[Railcraft]")) + result() + else + result(tile.getOwner.getName) @Callback(doc = "function():string -- Get the anchor type.") def getType(context: Context, args: Arguments): Array[AnyRef] = tile.getMachineType match { case EnumMachineAlpha.WORLD_ANCHOR => result("world") case EnumMachineAlpha.ADMIN_ANCHOR => result("admin") case EnumMachineAlpha.PERSONAL_ANCHOR => result("personal") - case _ => result("passive") + case EnumMachineAlpha.PASSIVE_ANCHOR => result("passive") + case _ => result("missing") } - @Callback(doc = "function():table -- Get the anchor input slot contents.") + @Callback(doc = "function():table -- Get the anchor fuel slot's contents.") def getFuelSlotContents(context: Context, args: Arguments): Array[AnyRef] = result(tile.getStackInSlot(0)) - @Callback(doc = "function():boolean -- If the anchor is disabled with redstone.") + @Callback(doc = "function():boolean -- If the anchor is disabled (powered by redstone).") def isDisabled(context: Context, args: Arguments): Array[AnyRef] = result(tile.isPowered) } } From 3916eedc7ac28759f946025bb6af230d30d2394f Mon Sep 17 00:00:00 2001 From: Adrian Siekierka Date: Sun, 4 Jun 2023 14:19:54 +0200 Subject: [PATCH 3/4] fix Database upgrade documentation not showing in NEI usage --- changelog.md | 1 + .../li/cil/oc/integration/opencomputers/ModOpenComputers.scala | 1 + 2 files changed, 2 insertions(+) diff --git a/changelog.md b/changelog.md index 2c5054256..8076344ab 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,7 @@ * Added Railcraft anchor driver. * Added Spanish translation. * Fixed bugs in internal wcwidth() implementation and updated it to cover Unicode 12. +* [1.7.10] Fixed the Database upgrade's documentation not showing up in NEI. * Fixed server->client synchronization for some types of GPU bitblt operations. * Fixed string.gmatch not supporting the "init" argument on Lua 5.4. * Tweaks to server->client networking code: diff --git a/src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala b/src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala index a0a27e823..c95d95be4 100644 --- a/src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala +++ b/src/main/scala/li/cil/oc/integration/opencomputers/ModOpenComputers.scala @@ -190,6 +190,7 @@ object ModOpenComputers extends ModProxy { api.Driver.add(DriverUpgradeChunkloader.Provider) api.Driver.add(DriverUpgradeCrafting.Provider) + api.Driver.add(DriverUpgradeDatabase.Provider) api.Driver.add(DriverUpgradeExperience.Provider) api.Driver.add(DriverUpgradeGenerator.Provider) api.Driver.add(DriverUpgradeInventoryController.Provider) From 94f6405c4756d5a9786aaacddbca05c48112cd2a Mon Sep 17 00:00:00 2001 From: Adrian Siekierka Date: Sun, 4 Jun 2023 15:07:47 +0200 Subject: [PATCH 4/4] update changelog --- changelog.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 8076344ab..cb7354d84 100644 --- a/changelog.md +++ b/changelog.md @@ -1,10 +1,14 @@ -## Fixes/improvements +## New features * [#3533] Added support for observing the contents of fluid container items. +* [1.12.2] Ported some CoFH Core, Ender IO and Railcraft drivers and wrench support. +* Added Railcraft Anchor/Worldspike driver (repo-alt). +* Added Spanish translation (sanmofe). + +## Fixes/improvements + * [#3620] Fixed OC 1.8.0+ regression involving API arguments and numbers. * [#3013] Fixed rare server-side deadlock when sending disk activity update packets. -* Added Railcraft anchor driver. -* Added Spanish translation. * Fixed bugs in internal wcwidth() implementation and updated it to cover Unicode 12. * [1.7.10] Fixed the Database upgrade's documentation not showing up in NEI. * Fixed server->client synchronization for some types of GPU bitblt operations.