Skip to content

Sealed Delivery Agreement

mortuusars edited this page May 20, 2024 · 20 revisions

Sealed Agreement allows to randomize some of the elements of an agreement. When opened - it is finalized to the regular Delivery Agreement.

Structure

Agreement data is stored in NBT of a Sealed Delivery Agreement item. You can see example by using an in-game command /wares give sealedAgreementExample
Relevant class: wares.data.agreement.SealedAgreement

  • id - string - Transfered as is.
  • buyerName - either [Component] or [List of WeightedComponent].
  • buyerAddress - either [Component] or [List of WeightedComponent].
  • title - either [Component] or [List of WeightedComponent].
  • message - either [Component] or [List of WeightedComponent].
  • seal - string - Transfered as is.
  • sealTooltip - component - Text shown on seal mouse over. Not transfered.
  • backsideMessage - component - Text shown on the back of a letter (In the inspect screen). Not transfered.
  • requested - either [LootTable path] or [List of Sealed Requested Items] - Gets the list of items from a loot table or just transfers as is if list is provided.
  • payment - either [LootTable path] or [List of ItemStack] - Gets the list of items from a loot table or just transfers as is if list is provided.
  • ordered - [Integer] or [Stepped Int] - Finalized to a number.
  • experience - [Integer] or [Stepped Int] - Finalized to a number.
  • deliveryTime - [Integer] or [Stepped Int] - Finalized to a number.
  • expiresInSeconds - [Integer] or [Stepped Int] - Finalized to a number.

Note:

expiresInSeconds - Is relative to when the player opens the Sealed Agreement. When opened - this time is multiplied by 20 (ticks) and combined with current game time to create an expireTimestamp for the Agreement.

As with the regular Agreement - all elements except requested and payment are optional and will have their default values if omitted.

Example:

/give @s wares:sealed_delivery_agreement{title:'{"text":"A Great Deal"}',requested:[{id:"minecraft:stick",Count:{min:4,max:16,step:4}}],payment:[{id:"minecraft:emerald",Count:1}],ordered:10}


Stepped Int

Simple integer provider that allows snapping to nearest step value.

When sealed agreement is finalized into a regular agreement - value from a SteppedInt will be chosen at random (within min-max bounds) and rounded up to a step, but not larger than a max value.


Given the SteppedInt [min = 2, max = 14, step = 4]

  • if random value chosen to be 9 - it will be rounded to 12 as it is the next "step" from 8.
  • if random value chosen to be 13 - it will be rounded to 16 as it is the next "step" from 12. BUT it is then clamped to the max value and we get 14 as the result.

Possible values for the example above would be: [4, 8, 12, 14].

Example json

{
  "min": 2,
  "max": 14,
  "step": 4
}

step is optional. If omitted - it is defaulted to 1.


Sealed Requested Item

Sealed Requested Item is mostly the same as Requested Item but with one small difference - Count can also be defined as a Stepped Int in addition to a regular number.

Examples:

{id:"minecraft:emerald", Count:{min:4,max:16,step:4}} - 4/8/12/16 Emeralds

For regular Delivery Agreement's requestedItems see Requested Item.