Added world sensor card, closes #770.

This commit is contained in:
Florian Nücke 2015-01-03 15:08:56 +01:00
parent 93788aeab6
commit cc839cb326
14 changed files with 110 additions and 10 deletions

Binary file not shown.

Binary file not shown.

View File

@ -123,6 +123,7 @@ item.oc.UpgradeTank.name=Tank Upgrade
item.oc.UpgradeTankController.name=Tank Controller Upgrade
item.oc.UpgradeTractorBeam.name=Tractor Beam Upgrade
item.oc.WirelessNetworkCard.name=Wireless Network Card
item.oc.WorldSensorCard.name=World Sensor Card
# Entities
entity.oc.Drone.name=Drone
@ -302,6 +303,7 @@ oc:tooltip.UpgradeTank=This upgrade provides a tank for fluid storage to the rob
oc:tooltip.UpgradeTankController=This upgrade allows the robot more control in how it interacts with external tanks, and allows it to transfer fluids into and out of fluid tank items in its inventory.
oc:tooltip.UpgradeTractorBeam=Equips the robot with extremely advanced technology, nicknamed the "Item Magnet". Allows it to pick up items anywhere within 3 blocks of its location.
oc:tooltip.WirelessNetworkCard=Allows wireless sending of network messages in addition to normal ones. You can adjust the §fsignal strength§7 to control how far messages are sent. Higher signal strength results in higher energy consumption.
oc:tooltip.WorldSensorCard=Allows reading out information about the world, such as its gravity and whether it has a breathable atmosphere. Use results at own risk. The manufacturer takes no responsibility for bodily or material harm caused by decisions made upon the cards' outputs. We have lawyers. And money. Don't even try.
# NEI Usage Pages
item.oc.AbstractBusCard.usage=This card allows computers, servers and robots to interact with StargateTech2's abstract bus. When the card is installed, these blocks will connect to the abstract bus and a component becomes available to the machine that can be used to send messages across the abstract bus. Incoming abstract bus messages are converted to signals that are injected into the machine.

View File

@ -111,11 +111,6 @@ luaBios {
type: shapeless
input: ["oc:eeprom", book]
}
abstractBusCard {
input: [[{block="StargateTech2:block.busCable"}, {item="StargateTech2:naquadah", subID=3}, ""]
["", "oc:materialCard", ""]]
}
graphicsCard1 {
input: [["oc:circuitChip1", "oc:materialALU", "oc:ram1"]
["", "oc:materialCard", ""]]
@ -155,6 +150,15 @@ linkedCard {
output: 2 # Note: all resulting cards are linked to each other.
}
abstractBusCard {
input: [[{block="StargateTech2:block.busCable"}, {item="StargateTech2:naquadah", subID=3}, ""]
["", "oc:materialCard", ""]]
}
worldSensorCard {
input: [[{item="GalacticraftCore:item.sensorLens"}, "oc:circuitChip2", ""]
["", "oc:materialCard", ""]]
}
angelUpgrade {
input: [[ingotIron, enderPearl, ingotIron]
["oc:circuitChip1", pistonStickyBase, "oc:circuitChip1"]

Binary file not shown.

After

Width:  |  Height:  |  Size: 505 B

View File

@ -317,5 +317,11 @@ object Items extends ItemAPI {
Recipes.addMultiItem(new item.MicrocontrollerCase(multi, Tier.Two), "microcontrollerCase2", "oc:microcontrollerCase2")
Recipes.addMultiItem(new item.DroneCase(multi, Tier.Two), "droneCase2", "oc:droneCase2")
registerItem(new item.Present(multi), "present")
// Always create, to avoid shifting IDs.
val worldSensorCard = new item.WorldSensorCard(multi)
if (Mods.Galacticraft.isAvailable) {
Recipes.addMultiItem(worldSensorCard, "worldSensorCard", "oc:worldSensorCard")
}
}
}

View File

@ -0,0 +1,7 @@
package li.cil.oc.common.item
import li.cil.oc.integration.Mods
class WorldSensorCard(val parent: Delegator) extends Delegate with ItemTier {
showInItemList = Mods.Galacticraft.isAvailable
}

View File

@ -7,6 +7,7 @@ import li.cil.oc.api.network
import li.cil.oc.api.network.ManagedEnvironment
import li.cil.oc.common.asm.Injectable
import li.cil.oc.integration.Mods
import li.cil.oc.integration.stargatetech2.AbstractBusCard
import li.cil.oc.integration.util.StargateTech2
import li.cil.oc.server.component
import li.cil.oc.server.{PacketSender => ServerPacketSender}
@ -28,7 +29,7 @@ trait AbstractBusAware extends TileEntity with network.Environment {
if (isAbstractBusAvailable) {
if (isServer) {
installedComponents.collect {
case abstractBus: component.AbstractBusCard => abstractBus.busInterface
case abstractBus: AbstractBusCard => abstractBus.busInterface
}.toArray
}
else fakeInterface.map(_.asInstanceOf[IBusInterface])

View File

@ -82,6 +82,7 @@ object Mods {
tryInit(integration.enderstorage.ModEnderStorage)
tryInit(integration.forestry.ModForestry)
tryInit(integration.fmp.ModForgeMultipart)
tryInit(integration.gc.ModGalacticraft)
tryInit(integration.gregtech.ModGregtech)
tryInit(integration.ic2.ModIndustrialCraft2)
tryInit(integration.mfr.ModMineFactoryReloaded)

View File

@ -0,0 +1,23 @@
package li.cil.oc.integration.gc
import li.cil.oc.api
import li.cil.oc.api.driver.EnvironmentAware
import li.cil.oc.api.driver.EnvironmentHost
import li.cil.oc.api.driver.item.HostAware
import li.cil.oc.common.Slot
import li.cil.oc.integration.Mods
import li.cil.oc.integration.opencomputers.Item
import net.minecraft.item.ItemStack
object DriverWorldSensorCard extends Item with HostAware with EnvironmentAware {
override def worksWith(stack: ItemStack) =
isOneOf(stack, api.Items.get("worldSensorCard"))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (Mods.Galacticraft.isAvailable) new WorldSensorCard(host)
else null
override def slot(stack: ItemStack) = Slot.Card
override def providedEnvironment(stack: ItemStack) = classOf[WorldSensorCard]
}

View File

@ -0,0 +1,13 @@
package li.cil.oc.integration.gc
import li.cil.oc.api
import li.cil.oc.integration.ModProxy
import li.cil.oc.integration.Mods
object ModGalacticraft extends ModProxy {
override def getMod = Mods.Galacticraft
override def initialize() {
api.Driver.add(DriverWorldSensorCard)
}
}

View File

@ -0,0 +1,43 @@
package li.cil.oc.integration.gc
import li.cil.oc.api.Network
import li.cil.oc.api.driver.EnvironmentHost
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.Visibility
import li.cil.oc.api.prefab
import li.cil.oc.server.component.result
import micdoodle8.mods.galacticraft.api.world.IAtmosphericGas
import micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider
class WorldSensorCard(val host: EnvironmentHost) extends prefab.ManagedEnvironment {
override val node = Network.newNode(this, Visibility.Neighbors).
withComponent("world_sensor").
withConnector().
create()
@Callback(doc = """function():number -- Get the gravity of the world the device is currently in.""")
def getGravity(context: Context, args: Arguments): Array[AnyRef] =
withProvider(provider => result(provider.getGravity))(result(1f))
@Callback(doc = """function():boolean -- Get whether the world the device is currently in has a breathable atmosphere.""")
def hasBreathableAtmosphere(context: Context, args: Arguments): Array[AnyRef] =
withProvider(provider => result(provider.hasBreathableAtmosphere))(result(true))
@Callback(doc = """function(gas:string):boolean -- Get whether the world the device is currently in has the specified gas (e.g. oxygen or nitrogen).""")
def isGasPresent(context: Context, args: Arguments): Array[AnyRef] =
withProvider(provider => {
val gas = IAtmosphericGas.valueOf(args.checkString(0).toUpperCase)
result(provider.isGasPresent(gas))
})(result(true))
@Callback(doc = """function():number -- Get the wind level in the world the device is currently in.""")
def getWindLevel(context: Context, args: Arguments): Array[AnyRef] =
withProvider(provider => result(provider.getWindLevel))(result(1f))
private def withProvider(f: IGalacticraftWorldProvider => Array[AnyRef])(default: Array[AnyRef] = null) = host.world.provider match {
case provider: IGalacticraftWorldProvider => f(provider)
case _ => default
}
}

View File

@ -1,4 +1,4 @@
package li.cil.oc.server.component
package li.cil.oc.integration.stargatetech2
import li.cil.oc.Settings
import li.cil.oc.api.Network
@ -7,6 +7,7 @@ import li.cil.oc.api.machine.Callback
import li.cil.oc.api.machine.Context
import li.cil.oc.api.network._
import li.cil.oc.api.prefab
import li.cil.oc.server.component.result
import lordfokas.stargatetech2.api.StargateTechAPI
import lordfokas.stargatetech2.api.bus._
import net.minecraft.nbt.NBTTagCompound

View File

@ -7,7 +7,6 @@ import li.cil.oc.api.driver.item.HostAware
import li.cil.oc.common.Slot
import li.cil.oc.integration.Mods
import li.cil.oc.integration.opencomputers.Item
import li.cil.oc.server.component
import lordfokas.stargatetech2.api.bus.IBusDevice
import net.minecraft.item.ItemStack
@ -19,12 +18,12 @@ object DriverAbstractBusCard extends Item with HostAware with EnvironmentAware {
worksWith(stack) && (isComputer(host) || isRobot(host) || isServer(host) || isMicrocontroller(host))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) = if (Mods.StargateTech2.isAvailable) host match {
case device: IBusDevice => new component.AbstractBusCard(device)
case device: IBusDevice => new AbstractBusCard(device)
case _ => null
}
else null
override def slot(stack: ItemStack) = Slot.Card
override def providedEnvironment(stack: ItemStack) = classOf[component.AbstractBusCard]
override def providedEnvironment(stack: ItemStack) = classOf[AbstractBusCard]
}