MightyPirates / OpenComputers

Home of the OpenComputers mod for Minecraft.
https://oc.cil.li
Other
1.6k stars 434 forks source link

Trading Upgrade #829

Closed AtomSponge closed 8 years ago

AtomSponge commented 9 years ago

An upgrade for Robots and/or Drones, which comes with two tiers:

  1. Allows Robots/Drones to view all offers of a Villager
  2. An extended version of the first tier, which additionally allows trading with the Villager (providing that the Robot/Drone has an Inventory Upgrade installed)

Basic idea by @ZeekDaGeek, I just thought of the different tiers

Sbotkin commented 9 years ago

I think your version first tier is pretty pointless. How about making it view and trade, but only second tier?

fnuecke commented 9 years ago

I admit I also don't see a use-case for the T1 version, but the general idea is interesting. Making it T2 sounds about right to me.

ZeekDaGeek commented 9 years ago

Possibly for balance. If you would prefer people on your server to find a good villager, leech it and bring it to a user for trading, which would require a users involvement and interaction then disable T2 upgrade.

Also it's a pretty powerful upgrade for just 1 point on drone.

Otherwise only ever craft the T2 upgrade and pretend the T1 doesn't exist.

fnuecke commented 9 years ago

I think it'd be fine to have this as T2, considering it kind of balances itself a bit by the fact that to actually find a villager on its own it'd need a second upgrade (like Computronics' radar).

Inari-Whitebear commented 9 years ago

Hm, wondering how this would work. Would it just be e.g. trading component

and operating on the closest villager in a small range?

fnuecke commented 9 years ago

My idea would have been something along these lines:

The methods on the userdata objects would fail once the respective villager is out of range or the trade becomes invalid.

Inari-Whitebear commented 9 years ago

Hm, yeah, makes sense ^^ Will take a shot at it~

fnuecke commented 9 years ago

Cool! If you have any questions, lemme know.

ZeekDaGeek commented 9 years ago

trade.trade(int slot1, int slot2) may be required. Villager trades sometimes involve 2 different items in order to complete, such as emeralds and book resulting in an enchanted book.

fnuecke commented 9 years ago

Ohh, right, I completely forgot they have two input slots. Hrm, in that case getInput() would return a tuple, I guess (i.e. local in1, in2 = trade.getInput()), and trade... maybe the agent's inventory could automatically be searched for matching items? I'm not sure if, say, the OreDictionary applies when trading, so that the additional control via specifying the slots is needed?

Inari-Whitebear commented 8 years ago

I went with the automatic way. The only issue with that I found is that if the trader wants for example a diamond sword and gives you an enchanted one back (usually you still have to give something as a second item) and you want to do that multiple times. Minecraft Villagers don't care if the diamond sword you hand them is already enchanted... so depending on inventory layout it could happen that you trade in an already enchanted one for an enchanted one.... 3 ways to go about that I guess:

fnuecke commented 8 years ago

I adjusted that check to take into account NBT now, i.e. it must be an exact match. Makes sense for trades potentially added by mods, using mod items with NBT in them, anyway, I think.