Skip to content

Trading Upgrade #1595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/resources/application.conf
Original file line number Diff line number Diff line change
@@ -1317,6 +1317,10 @@ opencomputers {
# such as the redstone card and redstone I/O block. Lowering this can
# have very negative impact on server TPS, so beware.
redstoneDelay: 0.1

# The maximum range between the drone/robot and a villager for a trade to
# be performed by the trading upgrade
tradingRange: 8.0
}

# Settings for mod integration (the mod previously known as OpenComponents).
1 change: 1 addition & 0 deletions src/main/resources/assets/opencomputers/lang/de_DE.lang
Original file line number Diff line number Diff line change
@@ -145,6 +145,7 @@ item.oc.UpgradeSolarGenerator.name=Solargenerator-Upgrade
item.oc.UpgradeTank.name=Tank-Upgrade
item.oc.UpgradeTankController.name=Tankbedienungs-Upgrade
item.oc.UpgradeTractorBeam.name=Traktorstrahl-Upgrade
item.oc.UpgradeTrading.name=Handels-Upgrade
item.oc.WirelessNetworkCard.name=Drahtlosnetzwerkkarte
item.oc.WorldSensorCard.name=Weltsensorkarte
item.oc.wrench.name=Schraubenziehschlüssel
1 change: 1 addition & 0 deletions src/main/resources/assets/opencomputers/lang/en_US.lang
Original file line number Diff line number Diff line change
@@ -150,6 +150,7 @@ item.oc.UpgradeSolarGenerator.name=Solar Generator Upgrade
item.oc.UpgradeTank.name=Tank Upgrade
item.oc.UpgradeTankController.name=Tank Controller Upgrade
item.oc.UpgradeTractorBeam.name=Tractor Beam Upgrade
item.oc.UpgradeTrading.name=Trading Upgrade
item.oc.WirelessNetworkCard.name=Wireless Network Card
item.oc.WorldSensorCard.name=World Sensor Card
item.oc.wrench.name=Scrench
Original file line number Diff line number Diff line change
@@ -367,6 +367,12 @@ upgradeContainer3 {
[ingotGold, "oc:materialCircuitBoardPrinted", ingotGold]]
}

upgradeTrading {
input: [[ingotGold, chest, ingotGold]
[emerald, "oc:circuitChip2", emerald]
[dropper, "oc:materialCircuitBoardPrinted", craftingPiston]]
}

# Note: iron ingot and nugget recipes are *only* registered if no other mod
# already provides the same functionality.
nuggetIron {
Original file line number Diff line number Diff line change
@@ -182,6 +182,12 @@ solarGeneratorUpgrade {
["oc:circuitChip3", "oc:generatorUpgrade", "oc:circuitChip3"]]
}

upgradeTrading {
input: [["oc:circuitChip2", chest, "oc:circuitChip2"]
[emerald, "oc:circuitChip2", emerald]
[dropper, "oc:materialCircuitBoardPrinted", craftingPiston]]
}

nuggetIron {
type: shapeless
input: ingotIron
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/main/scala/li/cil/oc/Constants.scala
Original file line number Diff line number Diff line change
@@ -154,6 +154,7 @@ object Constants {
final val TerminalServer = "terminalServer"
final val TexturePicker = "texturePicker"
final val TractorBeamUpgrade = "tractorBeamUpgrade"
final val TradingUpgrade = "upgradeTrading"
final val Transistor = "transistor"
final val UpgradeContainerTier1 = "upgradeContainer1"
final val UpgradeContainerTier2 = "upgradeContainer2"
1 change: 1 addition & 0 deletions src/main/scala/li/cil/oc/Settings.scala
Original file line number Diff line number Diff line change
@@ -342,6 +342,7 @@ class Settings(val config: Config) {
val dataCardTimeout = config.getDouble("misc.dataCardTimeout") max 0
val serverRackSwitchTier = (config.getInt("misc.serverRackSwitchTier") - 1) max Tier.None min Tier.Three
val redstoneDelay = config.getDouble("misc.redstoneDelay") max 0
val tradingRange = config.getDouble("misc.tradingRange") max 0

// ----------------------------------------------------------------------- //
// nanomachines
2 changes: 2 additions & 0 deletions src/main/scala/li/cil/oc/common/init/Items.scala
Original file line number Diff line number Diff line change
@@ -533,6 +533,8 @@ object Items extends ItemAPI {
Recipes.addSubItem(new item.TerminalServer(multi), Constants.ItemName.TerminalServer, "oc:terminalServer")
Recipes.addSubItem(new item.DiskDriveMountable(multi), Constants.ItemName.DiskDriveMountable, "oc:diskDriveMountable")

Recipes.addSubItem(new item.UpgradeTrading(multi), Constants.ItemName.TradingUpgrade, "oc:upgradeTrading")

// Register aliases.
for ((k, v) <- aliases) {
descriptors.getOrElseUpdate(k, descriptors(v))
3 changes: 3 additions & 0 deletions src/main/scala/li/cil/oc/common/item/UpgradeTrading.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package li.cil.oc.common.item

class UpgradeTrading(val parent: Delegator) extends traits.Delegate with traits.ItemTier
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package li.cil.oc.integration.opencomputers

import li.cil.oc.api
import li.cil.oc.Constants
import li.cil.oc.api.driver.EnvironmentProvider
import li.cil.oc.api.network.EnvironmentHost
import li.cil.oc.api.driver.item.HostAware
import li.cil.oc.common.{Tier, Slot}
import li.cil.oc.server.component.UpgradeTrading
import net.minecraft.item.ItemStack
import li.cil.oc.common.entity.Drone
import li.cil.oc.common.tileentity.Robot
import li.cil.oc.server.component

object DriverUpgradeTrading extends Item with HostAware {
override def worksWith(stack: ItemStack) = isOneOf(stack,
api.Items.get(Constants.ItemName.TradingUpgrade))

override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
else host match {
case host: EnvironmentHost with Robot => new UpgradeTrading(host)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say the with Robot and with Drone here should go, since that will be handled via the blacklist (otherwise addon robots, should they be created, could not use this driver otherwise). I'll make the adjustment so you don't have to rebase again, if that's allright.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I think when I wrote that part I was still under the impression that createEnvironment or worksWith decide the Blacklist, somehow didn't occur to me to change it <.<

case host: EnvironmentHost with Drone => new UpgradeTrading(host)
case _ => null
}

override def slot(stack: ItemStack) = Slot.Upgrade

override def tier(stack: ItemStack) = Tier.Two

object Provider extends EnvironmentProvider {
override def getEnvironment(stack: ItemStack): Class[_] =
if (worksWith(stack))
classOf[component.UpgradeTrading]
else null
}
}
Original file line number Diff line number Diff line change
@@ -146,6 +146,7 @@ object ModOpenComputers extends ModProxy {
api.Driver.add(DriverUpgradeTank)
api.Driver.add(DriverUpgradeTankController)
api.Driver.add(DriverUpgradeTractorBeam)
api.Driver.add(DriverUpgradeTrading)

api.Driver.add(DriverAPU.Provider)
api.Driver.add(DriverDataCard.Provider)
@@ -200,7 +201,8 @@ object ModOpenComputers extends ModProxy {
Constants.ItemName.SolarGeneratorUpgrade,
Constants.ItemName.TankUpgrade,
Constants.ItemName.TractorBeamUpgrade,
Constants.ItemName.LeashUpgrade)
Constants.ItemName.LeashUpgrade,
Constants.ItemName.TradingUpgrade)
blacklistHost(classOf[internal.Drone],
Constants.BlockName.Keyboard,
Constants.BlockName.ScreenTier1,
@@ -240,7 +242,8 @@ object ModOpenComputers extends ModProxy {
Constants.ItemName.TankUpgrade,
Constants.ItemName.TankControllerUpgrade,
Constants.ItemName.TractorBeamUpgrade,
Constants.ItemName.LeashUpgrade)
Constants.ItemName.LeashUpgrade,
Constants.ItemName.TradingUpgrade)
blacklistHost(classOf[internal.Robot],
Constants.BlockName.Transposer,
Constants.ItemName.LeashUpgrade)
@@ -263,7 +266,8 @@ object ModOpenComputers extends ModProxy {
Constants.ItemName.InventoryControllerUpgrade,
Constants.ItemName.TankUpgrade,
Constants.ItemName.TankControllerUpgrade,
Constants.ItemName.LeashUpgrade)
Constants.ItemName.LeashUpgrade,
Constants.ItemName.TradingUpgrade)

if (!WirelessRedstone.isAvailable) {
blacklistHost(classOf[internal.Drone], Constants.ItemName.RedstoneCardTier2)
Loading