MerchantJS

This mod is an addon for KubeJS, expanding its functionality in the trading system.

Редакция NLZONE · 2 мин чтения · 1 просмотр
MerchantJS
Скачать MerchantJS1.20.1 – 1.20.6 · с официальной страницы: modrinth.com
Перейти к загрузке

Что это

This mod is an addon for KubeJS, expanding its functionality in the trading system.

  • Тип: мод
  • Загрузчик: forge
  • Версии Minecraft: 1.20.1 – 1.20.6
  • Скачиваний на Modrinth: 35 093

Подробно

This mod is an addon for KubeJS, expanding its functionality in the trading system.

This mod allows you to initiate trades anywhere — trade with pigs, with End Stone, with Enchanted Golden Apples, or even out of thin air!

javascript // serverscripts ItemEvents.entityInteracted(event => { // Check if the interacted entity is a pig if (event.getTarget().type === "minecraft:pig") { // Create a complete trade offer let offer0 = MerchantJSUtils.createMerchantOffer({ buy: Item.of("minecraft:potato").toNBT(), buyB: Item.of("minecraft:bread").toNBT(), sell: Item.of("minecraft:stone").toNBT(), uses: 0, maxUses: 50, xp: 5, priceMultiplier: 0, demand: 0 }); // Create a simple trade offer let offer1 = MerchantJSUtils.createMerchantOffer({ buy: Item.of("minecraft:beef").toNBT(), sell: Item.of("minecraft:egg").toNBT() }); // Open a custom trading GUI with the given player, title, and offers MerchantJSUtils.openMerchant( event.player, Component.translatable("Little Piggy’s Cartoon House"), [offer0, offer1] ); } });

The above example lets players trade with pigs, with a fully customizable trading GUI!

And if you need deeper customization — read on.

Let’s first explain the meaning of each parameter:

javascript let offer0 = MerchantJSUtils.createMerchantOffer({ buy: Item.of("minecraft:potato").toNBT(), // Input item A (required) buyB: Item.of("minecraft:bread").toNBT(), // Input item B (optional, defaults to empty) sell: Item.of("minecraft:stone").toNBT(), // Output item (required) uses: 0, // Number of times used (optional, default 0) maxUses: 50, // Maximum uses (optional, default 99) xp: 5, // Experience reward (optional, default 0) priceMultiplier: 0, // Price fluctuation multiplier (optional, default 0) demand: 0 // Initial demand value (optional, default 0) });

Setting maxUses to 0 will make the trade appear unavailable.

Now combine it with this event for dynamic trade control:

javascript // clientscripts MerchantEvents.switchTrade(event => { if (event.titleKey == "Little Piggy’s Cartoon House") { // Check if it’s the pig’s trading window (works with vanilla ones too!) if (event.getOffer().getMaxUses() == 0) { Client.player.tell("This trade is locked..."); } } });

Как установить

Скачайте файл на официальной странице ниже и положите его в папку mods (для модов) или plugins (для плагинов) вашего сервера или клиента. Для модов нужен совместимый загрузчик. Версия должна совпадать с версией Minecraft.

Текст подготовлен автоматически из описания на Modrinth и ждёт проверки редакцией.

Редакция NLZONE

Пишем о серверах, модах и играх, в которые играем сами. Нашли ошибку — напишите нам, исправим.

Комментарии 0

Комментарии к этому материалу отключены.

Читайте также