Skip to content

Delivery Agreement

mortuusars edited this page May 20, 2024 · 31 revisions

Agreement is static, realized contract. If you need to randomly define deals - see Sealed Agreement


Basics

Agreements is an essential part of deliveries. They describe in full detail what items will be traded for what, how many deliveries there can be, and how many time you have for delivering all packages.

Structure

Agreement data is stored in NBT of a Delivery Agreement item. You can see example by using an in-game command
/wares give agreementExample
If you know java, I think it shouldn't be hard to understand how everything works from the code.
Relevant class: wares.data.agreement.Agreement

If not - here is the list of elements:

  • id - string - Used to detect specific agreements in quests, for example. Default: empty string
  • buyerName - component - Displayed with the message and on seal mouse over. Supports styling. Default: empty component
  • buyerAddress - component - Displayed with the message and on seal mouse over. Supports styling. Default: empty component
  • title - component - Displayed in the very center of an Agreement. Supports styling. Default: empty component
  • message - component - Displayed in the very center of an Agreement. Supports styling. Default: empty component
  • seal - string - Seal name that will be used. Default: "default"
  • requestedItems - list of Requested Item - Items that you'll need to deliver.
  • paymentItems - list of ItemStack - Items that you'll receive.
  • ordered - Total number of deliveries. 0 means infinite (cannot be completed). Default: 0
  • delivered - How many packages were delivered. When delivered reaches ordered - agreement is considered complete. Default: 0
  • experience - Points of experience that will be dropped when last package is delivered and agreement is completed. Default: 0
  • deliveryTime - Time in ticks for one delivery. Overrides value set in config. Default: 0 (Will use value from config)
  • expireTimestamp - Level time in ticks at which agreement will expire. By default it will never expire. Default: -1

All elements, except requestedItems and paymentItems, are optional.
If paymentItems is set to id:"minecraft:air" - Items will be consumed without payment. Otherwise, if requestedItems is set to id:"minecraft:air" - you'll be receiving items for free.

Example:

/give @s wares:delivery_agreement{title:'{"text":"A Great Deal"}',requestedItems:[{id:"minecraft:stick",Count:2}],paymentItems:[{id:"minecraft:emerald",Count:1}],ordered:10}


Requested Item

Requested Item is defined exactly like vanilla item stacks - but with several differences: you can set them to an item tag (in additon to item id), Count is not required for deserialization and they have additional field - 'TagMatching'.

TagMatching

To control how nbt tag of items are compared - you set TagMatching field to one of the following:

  • ignore - nbt tag does not matter
  • weak - item should have specified nbt tags (can have other)
  • strong - item nbt should be equal to the specified one (can not have other tags. only the ones specified)

This field is optional and by default it is set to 'weak'.

Examples:

...requestedItems:[{id:"minecraft:emerald"}]... - 1 Emerald
{id:"minecraft:emerald", Count: 4} - 4 Emeralds
{id:"minecraft:emerald", Count: 4, tag:{display:{Name:'{"translate":"item.minecraft.diamond"}'}}} - 4 "Diamonds"
{id:"#minecraft:logs", Count: 4} - 4 Logs of any kind - note the # symbol in a tag definition
{id:"minecraft:iron_pickaxe", Count: 1, tag:{"Damage":0}, TagMatching:"strong"} - accept only undamaged Iron Pickaxes.

For Sealed Delivery Agreement's requested see Sealed Requested Item.


expireTimestamp

Timestamp is relative to the world creation. It is possible that by the time player finds your agreement - it will already be expired.
If you want to create agreements that expire relative to the time player opens it at - use Sealed Delivery Agreement.