MinionCore logoMinionCore

Breakdowns and repairs

How upgraded minions can break down after an action, how the chance, repair price and repair items are worked out, and how players repair them.

Upgrades make a minion stronger, and breakdowns give that a running cost. After every action a minion has a small chance to break down. A broken minion stops working until someone pays to repair it. The more upgrades it holds, the higher the chance and the higher the repair price.

With the shipped config.yml, a minion with no upgrades never breaks down.

Settings

config.yml
breakdowns:
  enabled: true
  base-chance: 0.0
  chance-per-upgrade: 0.02
  repair-cost:
    money: 2500
  repair-cost-per-upgrade:
    money: 500
  repair-items:
    iron:
      enabled: false
      material: IRON_INGOT
      custom-model-data: 0
      name: ""
      itemsadder: ""
      mythicmobs: ""
      amount: 4
      amount-per-upgrade: 0
      display: ""
KeyShipped valueWhat it does
breakdowns.enabledtrueWhether minions can break down at all
breakdowns.base-chance0.0The chance, in percent, that any action breaks a minion before upgrades are counted
breakdowns.chance-per-upgrade0.02The chance, in percent, added for each counted upgrade
breakdowns.repair-costmoney: 2500What every repair costs, using currency ids from upgrades.yml
breakdowns.repair-cost-per-upgrademoney: 500What a repair costs on top for each counted upgrade
breakdowns.repair-itemsiron, switched offItems a repair takes from the player's inventory on top of repair-cost, see Repair items

Both costs can list more than one currency, the same way a level cost can. See Fuel and upgrades files. Each type can set its own price and items in its type file, see Repairs for each type.

Repair items

Each entry under breakdowns.repair-items is one item a repair asks for. The key is only a name for the entry. The player has to carry the items, and they are taken when the repair goes through.

KeyDefaultWhat it does
enabledtrueWhether this item is asked for. The shipped iron entry is false, so shipped repairs cost money only
materialnoneThe material the player has to carry
custom-model-data0Only count items with this custom model data. 0 ignores it
name""Only count items with this name, colours included, written like any other item name. Empty ignores it
itemsadder""Only count this ItemsAdder item. Empty ignores it
mythicmobs""Only count this MythicMobs item. Empty ignores it. Used before itemsadder when both are set
saved-itemnot setA whole item in the server's own item format. When set, only items exactly like it count
amount1How many are taken for one repair
amount-per-upgrade0How many more are taken for each counted upgrade. Level and reliability upgrades do not count
display""How the item is shown in repair prices, with %amount% for the number. Empty shows the number and the item's own name, such as 4 Iron Ingot

An entry with no usable material, itemsadder, mythicmobs or saved-item, or with both amount and amount-per-upgrade at 0, is skipped with a console warning.

A miner with 5 counted upgrades and an entry with amount: 2 and amount-per-upgrade: 1 needs 2 + 1 x 5 = 7 of that item.

Repairs for each type

Every type file except chunkloader.yml has a breakdowns section. Chunk loaders never break down, so theirs has none.

minions/miner.yml
breakdowns:
  repair-cost: DEFAULT
  repair-cost-per-upgrade: DEFAULT
  repair-items: DEFAULT
KeyWhat it does
repair-costDEFAULT uses breakdowns.repair-cost from config.yml. A section of currency ids sets this type's own base price
repair-cost-per-upgradeDEFAULT uses breakdowns.repair-cost-per-upgrade from config.yml. A section sets this type's own price per counted upgrade
repair-itemsDEFAULT uses breakdowns.repair-items from config.yml. A section of entries, written like the ones above, sets this type's own items

Each of the three is chosen on its own, so a type can keep the money price from config.yml and only change the items. An empty section, {}, means nothing for that part: repair-items: {} asks for no items on this type even when config.yml lists some, and repair-cost-per-upgrade: {} charges nothing extra for upgrades.

The chance of a breakdown is not set per type. It always comes from config.yml.

Worked example: a hunter repair that needs MythicMobs items

Hunters keep the money price from config.yml, and each repair also takes 2 of a MythicMobs item called SoulShard:

minions/hunter.yml
breakdowns:
  repair-cost: DEFAULT
  repair-cost-per-upgrade: DEFAULT
  repair-items:
    soul-shard:
      enabled: true
      material: PRISMARINE_SHARD
      mythicmobs: "SoulShard"
      amount: 2
      amount-per-upgrade: 0
      display: "<light_purple>%amount% Soul Shards"

A hunter with 3 counted upgrades now costs money: 4000 and 2 Soul Shards, shown together in %cost%. Only real SoulShard items count, a plain prismarine shard does not. If MythicMobs is not installed, the repair is refused with upgrade.currency-missing naming soul-shard. Set amount-per-upgrade: 1 to ask for one more shard for every counted upgrade, 5 in all for that hunter.

To switch breakdowns off, set enabled: false, or set both base-chance and chance-per-upgrade to 0.

Counted upgrades

Every upgrade item applied to the minion counts once, except LEVEL and RELIABILITY upgrades. An entry applied twice counts twice. So a miner with storage-1, storage-2, speed applied twice and one reliability upgrade has 4 counted upgrades.

The repair menu shows this number as %upgrades%.

The chance

After each action that finished, the minion rolls:

chance = (base-chance + chance-per-upgrade x counted upgrades) x (1 - reliability / 100)

reliability is the total amount of the reliability upgrades on the minion. The chance is in percent and never goes above 100.

What counts as one action is the same as for fuel: a block mined, a crop harvested, a mob hit, a fish caught. A chunk collector only rolls when it moved at least one item. A minion that is waiting, full or has nothing to do never rolls. Chunk loaders never break down, whatever they hold. See Fuel.

Reliability upgrades

A RELIABILITY upgrade cuts the chance by its amount in percent. The shipped reliability entry cuts it by 25, can go on a minion twice for 50, and fits every type. It adds no fuel use (fuel-increase: 0). At 100 or more the minion never breaks down. See Upgrade kinds.

Worked example

A miner holds 5 counted upgrades and one reliability upgrade, with the shipped settings.

StepValue
Before reliability0.0 + 0.02 x 5 = 0.1 percent
After reliability0.1 x (1 - 25 / 100) = 0.075 percent per action
Repair price2500 + 500 x 5 = money: 5000

At a 2 second delay that is roughly one breakdown in every 1333 actions, or about once every 44 minutes of steady work.

When a minion breaks down

  1. MinionBreakEvent is fired. If another plugin cancels it, nothing happens.
  2. The minion is marked broken and its status becomes Broken, right click to repair (status.broken), in the menu and on the hologram. The shipped type files, except the chunk loader, also swap the whole hologram for their hologram.states.BROKEN lines, see Holograms and effects.
  3. It leaves the work queue and stops.
  4. The sounds.breakdown sound and particles.breakdown particle play where it stands. See Holograms and effects.
  5. The owner gets breakdown.broke with the type and the repair price, repair items included, if they are online.

The broken mark is saved with the minion in the database, so it stays broken after a restart.

Repairing

Right click a broken minion. Instead of the minion menu, players with the repair access get the repair menu. The owner and players with minioncore.admin.bypass always have it, and trusted players have it on every shipped type (trusted.repair: true). See Trust and access.

The repair menu is set up under repair in gui.yml:

ItemSlotWhat it does
info13An anvil showing the price as %cost%, repair items included, and the counted upgrades as %upgrades%
confirm11Pays and repairs
cancel15Closes the menu without paying

The menu has rows: 3 and takes the usual minion placeholders as well. When the repair is free, %cost% shows menu.none. See Menus.

One total price

%cost% is the whole price as one total. The base price and the price for the upgrades are added together per currency, so the worked example above shows one price of 5000 money, not 2500 and 2500 side by side. A price that mixes currencies shows each currency once, with its own total. Repair items are listed after the currencies, each with its full amount.

Two more placeholders show the parts on their own, in the repair menu and in breakdown.broke:

PlaceholderShowsIn the worked example
%cost%The full price5000 money
%base_cost%repair-cost, and the amount of each repair item2500 money
%upgrade_cost%repair-cost-per-upgrade times the counted upgrades, and each repair item's amount-per-upgrade times the counted upgrades2500 money

The shipped text only uses %cost%. Add the other two to the lore of repair.items.info in gui.yml, or to breakdown.broke in the language file, if players should see the split. A part that comes to nothing, such as %upgrade_cost% on a minion with no counted upgrades, shows menu.none.

Clicking Repair checks everything again before charging:

Refused whenMessage key
The player no longer has the repair accessaccess.not-yours or access.not-allowed
The minion is no longer brokenbreakdown.not-broken
A currency in the price does not exist or cannot work right now, or a repair item needs ItemsAdder or MythicMobs and that item is not available. The message names the currency id or the repair item's keyupgrade.currency-missing
The player cannot afford every part of the price, or does not carry enough of a repair itemupgrade.cannot-afford
Another plugin cancels MinionRepairEventnone
Taking the payment failed part way, so nothing is takenupgrade.payment-failed

Repair items are taken first, all from the same inventory, so one stack cannot count for two entries. Then the money and other currencies are taken. If that fails, the inventory goes back to exactly how it was, and the player sees upgrade.payment-failed.

After a repair the player hears sounds.repair and sees breakdown.repaired, the particles.repair particle plays at the minion, and it goes back to work straight away. A paused minion stays paused.

While a minion is broken

  • Right clicking always opens the repair menu, so the minion menu cannot be opened.
  • Players cannot pick it up by any path. Shift right click, /minion remove and the Pick up button all refuse with breakdown.broken-pickup.
  • Its storage keeps its items. Players cannot open its storage until it is repaired, but a paired chunk collector still pulls from it. A broken chunk collector takes nothing in.
  • Admin removal still works, so an admin can clear a broken minion away. It is still broken when it is placed again.
  • The admin menu opens a broken minion's own menu directly. See Admin tools.

Messages

KeyWhen it is sent
breakdown.brokeTo the owner when a minion breaks down. %type%, %cost%, %base_cost% and %upgrade_cost%
breakdown.repairedAfter a repair. %type%
breakdown.not-brokenWhen Repair is clicked on a minion that is no longer broken
breakdown.broken-pickupWhen a player tries to pick up a broken minion
status.brokenThe status text while broken

See Messages and language.

For developers

MinionBreakEvent is cancellable and getChance() returns the chance in percent that was rolled. MinionRepairEvent is cancellable, and getPlayer() is the player repairing, or null for a repair through the API. MinionCoreAPI#repair(UUID) repairs a broken minion for free. See Developer API.

On this page