mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-15 18:30:27 -04:00
add recrafting option to link 2 link cards
also, clean up the net_splitter.getSides() return, it should use the exact same index values you need to use in setSides. added getChannel() on link cards. Link cards of the same channel are linked in the same network. Also inventory controllers can read this as the `linkChannel` from the item closes #2400
This commit is contained in:
parent
6182fde957
commit
4731cb1b01
@ -210,6 +210,7 @@ object Recipes {
|
||||
val robot = api.Items.get(Constants.BlockName.Robot)
|
||||
val switch = api.Items.get(Constants.BlockName.Switch)
|
||||
val tablet = api.Items.get(Constants.ItemName.Tablet)
|
||||
val linkedCard = api.Items.get(Constants.ItemName.LinkedCard)
|
||||
|
||||
// Navigation upgrade recrafting.
|
||||
GameRegistry.addRecipe(new ExtendedShapelessOreRecipe(
|
||||
@ -342,6 +343,12 @@ object Recipes {
|
||||
if (Settings.get.lootRecrafting) {
|
||||
GameRegistry.addRecipe(new LootDiskCyclingRecipe())
|
||||
}
|
||||
|
||||
// link card copying via crafting.
|
||||
GameRegistry.addRecipe(new ExtendedShapelessOreRecipe(
|
||||
linkedCard.createItemStack(2),
|
||||
linkedCard.createItemStack(1), linkedCard.createItemStack(1)))
|
||||
|
||||
}
|
||||
catch {
|
||||
case e: Throwable => OpenComputers.log.error("Error parsing recipes, you may not be able to craft any items from this mod!", e)
|
||||
|
@ -15,6 +15,7 @@ import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
|
||||
import scala.collection.convert.WrapAsJava._
|
||||
import scala.collection.mutable
|
||||
|
||||
class NetSplitter extends traits.Environment with traits.OpenSides with traits.RedstoneAware with api.network.SidedEnvironment with DeviceInfo {
|
||||
private lazy val deviceInfo: util.Map[String, String] = Map(
|
||||
@ -112,12 +113,12 @@ class NetSplitter extends traits.Environment with traits.OpenSides with traits.R
|
||||
}
|
||||
|
||||
// component api
|
||||
def currentStatus(): Array[Boolean] = {
|
||||
val openSidesCopy = Array.fill(ForgeDirection.VALID_DIRECTIONS.length)(false)
|
||||
def currentStatus(): mutable.Map[Int, Boolean] = {
|
||||
val openSides = mutable.Map[Int, Boolean]()
|
||||
for (side <- ForgeDirection.VALID_DIRECTIONS) {
|
||||
openSidesCopy(side.ordinal()) = isSideOpen(side)
|
||||
openSides += side.ordinal() -> isSideOpen(side)
|
||||
}
|
||||
openSidesCopy
|
||||
openSides
|
||||
}
|
||||
|
||||
def setSide(side: ForgeDirection, state: Boolean): Boolean = {
|
||||
|
@ -0,0 +1,23 @@
|
||||
package li.cil.oc.integration.opencomputers
|
||||
|
||||
import java.util
|
||||
|
||||
import li.cil.oc.Constants
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.detail.ItemInfo
|
||||
import li.cil.oc.api.driver.Converter
|
||||
import li.cil.oc.server.component
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
import scala.collection.convert.WrapAsScala._
|
||||
|
||||
object ConverterLinkedCard extends Converter {
|
||||
lazy val linkedCard: ItemInfo = api.Items.get(Constants.ItemName.LinkedCard)
|
||||
|
||||
override def convert(value: scala.Any, output: util.Map[AnyRef, AnyRef]): Unit = value match {
|
||||
case stack: ItemStack if api.Items.get(stack) == linkedCard =>
|
||||
val card = new component.LinkedCard()
|
||||
output += "linkChannel" -> card.tunnel
|
||||
case _ => // Ignore.
|
||||
}
|
||||
}
|
@ -117,6 +117,7 @@ object ModOpenComputers extends ModProxy {
|
||||
MinecraftForge.EVENT_BUS.register(li.cil.oc.server.ComponentTracker)
|
||||
|
||||
api.Driver.add(ConverterNanomachines)
|
||||
api.Driver.add(ConverterLinkedCard)
|
||||
|
||||
api.Driver.add(DriverAPU)
|
||||
api.Driver.add(DriverComponentBus)
|
||||
|
@ -26,7 +26,7 @@ class LinkedCard extends prefab.ManagedEnvironment with QuantumNetwork.QuantumNo
|
||||
withConnector().
|
||||
create()
|
||||
|
||||
var tunnel = "creative"
|
||||
var tunnel: String = "creative"
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
@ -57,7 +57,7 @@ class LinkedCard extends prefab.ManagedEnvironment with QuantumNetwork.QuantumNo
|
||||
else result(Unit, "not enough energy")
|
||||
}
|
||||
|
||||
@Callback(direct = true, doc = """function():number -- Gets the maximum packet size (config setting).""")
|
||||
@Callback(direct = true, doc = "function():number -- Gets the maximum packet size (config setting).")
|
||||
def maxPacketSize(context: Context, args: Arguments): Array[AnyRef] = result(Settings.get.maxNetworkPacketSize)
|
||||
|
||||
def receivePacket(packet: Packet) {
|
||||
@ -65,6 +65,11 @@ class LinkedCard extends prefab.ManagedEnvironment with QuantumNetwork.QuantumNo
|
||||
node.sendToReachable("computer.signal", Seq("modem_message", packet.source, Int.box(packet.port), Double.box(distance)) ++ packet.data: _*)
|
||||
}
|
||||
|
||||
@Callback(direct = true, doc = "function():string -- Gets this link card's shared channel address")
|
||||
def getChannel(context: Context, args: Arguments): Array[AnyRef] = {
|
||||
result(this.tunnel)
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
override def onConnect(node: Node) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user