Mod that adds a GUI for buying and selling items. | Mod que agrega una GUI para compra y venta de artículos.
EN
ItemMarket adds a simple, fast in‑game market GUI where players can buy and sell items using a built‑in coin balance saved per-world. Prices are fully configurable via easy JSON files, and the mod exposes a small Java/Fabric API so other mods can read/write player balances and listen to market transactions.
Credits: Developed by TNTStudios — Website: TNTStudios.space — Socials: @TNTStudiosn
EN
ItemMarketAPI) to get/add/remove coinsMarketTransactionCallback) when a transaction succeedsEN
If you only install it on the server, players won’t have the GUI/keybind and won’t be able to use the market.
EN
.jar into:mods/mods/EN
EN
EN
EN
PersistentState, per world.itemmarket_economyItemMarket reads prices from:
config/ItemMarket/compra/
config/ItemMarket/venta/
EN
compra/ = BUY prices (player pays coins to get items)venta/ = SELL prices (player receives coins to sell items)EN
Each .json filename must be a number, and that number is the price.
Examples:
config/ItemMarket/compra/100.json → buy price = 100 coinsconfig/ItemMarket/venta/25.json → sell price = 25 coinsIf the filename is not purely numeric, it will be skipped.
Important: price 0 is valid as a filename (
0.json) but will not work in-game because transactions requireprice > 0. Use 1+.
EN
Each file is a JSON array of item IDs (strings):
[
"minecraft:diamond",
"minecraft:emerald",
"minecraft:iron_ingot"
]
EN
Create:
config/ItemMarket/compra/250.json
[
"minecraft:diamond",
"minecraft:netherite_ingot"
]
Result:
EN
Create:
config/ItemMarket/venta/50.json
[
"minecraft:iron_ingot",
"minecraft:gold_ingot"
]
Result:
EN
Each item can only have one price in memory (maps overwrite by item). If you put the same item in multiple price files, whichever file is loaded last will win — file ordering may depend on the OS, so don’t rely on it. Keep your lists unique per folder.
EN
EN
Yes. Prices are loaded at startup by MarketConfig.init(). There is no built-in live reload command yet, so you should:
ItemMarket provides a Java API intended for other Fabric mods.
EN
This is not an HTTP/REST API. You “connect” by adding ItemMarket as a dependency and calling its classes.
Class: com.TNTStudios.itemmarket.api.ItemMarketAPI
Methods:
getBalance(ServerPlayerEntity player) -> longaddBalance(ServerPlayerEntity player, long amount) -> longremoveBalance(ServerPlayerEntity player, long amount) -> booleanEN (Example: Give coins on player join)
import com.TNTStudios.itemmarket.api.ItemMarketAPI;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
public class MyMod {
public static void init() {
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
var player = handler.getPlayer();
// Give 100 coins on first join (simple example)
ItemMarketAPI.addBalance(player, 100);
});
}
}
Notes (EN)
addBalance() and removeBalance() will also trigger a UI sync by opening/updating the market screen if the player has it open (via MarketNetwork.openMarketForPlayer).removeBalance() returns false when the player doesn’t have enough funds.Interface: com.TNTStudios.itemmarket.api.MarketTransactionCallback
Called only when a transaction succeeds.
Signature:
void onTransaction(ServerPlayerEntity player, Item item, int count, long totalPrice, boolean isBuy);
EN (Example: Log every transaction)
import com.TNTStudios.itemmarket.api.MarketTransactionCallback;
public class MyMod {
public static void init() {
MarketTransactionCallback.EVENT.register((player, item, count, totalPrice, isBuy) -> {
String type = isBuy ? "BUY" : "SELL";
System.out.println("[MyMod] " + player.getName().getString() +
" " + type + " " + count + "x " + item.getName().getString() +
" for " + totalPrice + " coins");
});
}
}
EN
buy/sell, item id, sellAll flag)EN
The server is authoritative, so clients cannot “fake” prices or balances via packets.
EN
Market doesn’t open (pressing M does nothing)
Items show but can’t buy/sell
100.json)Some items missing
EN
ES
ItemMarket agrega un mercado simple y rápido con GUI dentro del juego para que los jugadores puedan comprar y vender ítems usando un balance de monedas guardado por mundo. Los precios se configuran con archivos JSON muy fáciles, y el mod incluye una API Java/Fabric para que otros mods puedan leer/escribir balances y escuchar transacciones.
Créditos: Desarrollado por TNTStudios — Sitio web: TNTStudios.space — Redes: @TNTStudiosn
ES
ItemMarketAPI) para consultar/sumar/restar monedasMarketTransactionCallback) cuando una transacción es exitosaES
Si lo instalas solo en el servidor, los jugadores no tendrán la GUI/tecla y no podrán usar el mercado.
ES
.jar de ItemMarket en:mods/mods/ES
ES
ES
ES
PersistentState, por mundo.itemmarket_economyItemMarket lee precios desde:
config/ItemMarket/compra/
config/ItemMarket/venta/
ES
compra/ = precios de COMPRA (pagas monedas para obtener ítems)venta/ = precios de VENTA (recibes monedas al vender)ES
Cada .json debe llamarse con un número, y ese número es el precio.
Ejemplos:
config/ItemMarket/compra/100.json → precio de compra = 100 monedasconfig/ItemMarket/venta/25.json → precio de venta = 25 monedasSi el nombre no es 100% numérico, se ignora.
Importante:
0.jsonexiste, pero no funcionará en juego porque las transacciones requierenprice > 0. Usa 1+.
ES
Cada archivo es un arreglo JSON de IDs de ítems (strings):
[
"minecraft:diamond",
"minecraft:emerald",
"minecraft:iron_ingot"
]
ES
Crear:
config/ItemMarket/compra/250.json
[
"minecraft:diamond",
"minecraft:netherite_ingot"
]
Resultado:
ES
Crear:
config/ItemMarket/venta/50.json
[
"minecraft:iron_ingot",
"minecraft:gold_ingot"
]
Resultado:
ES
Cada ítem solo puede tener un precio en memoria (los mapas sobreescriben por ítem). Si repites un ítem en varios archivos, “gana” el último que se cargue — el orden puede variar por sistema operativo. Mejor no repetir ítems.
ES
ES
Sí. Los precios se cargan al iniciar con MarketConfig.init(). No hay recarga en vivo por comando (todavía), así que:
ItemMarket incluye una API Java para otros mods Fabric.
ES
Esto no es una API HTTP/REST. Te “conectas” agregando ItemMarket como dependencia y llamando sus clases.
Clase: com.TNTStudios.itemmarket.api.ItemMarketAPI
Métodos:
getBalance(ServerPlayerEntity player) -> longaddBalance(ServerPlayerEntity player, long amount) -> longremoveBalance(ServerPlayerEntity player, long amount) -> booleanES (Ejemplo: dar monedas al entrar)
import com.TNTStudios.itemmarket.api.ItemMarketAPI;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
public class MiMod {
public static void init() {
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
var player = handler.getPlayer();
ItemMarketAPI.addBalance(player, 100);
});
}
}
Notas (ES)
addBalance() y removeBalance() también sincronizan la UI abriendo/actualizando la pantalla del mercado cuando corresponde.removeBalance() devuelve false si no hay fondos suficientes.Interfaz: com.TNTStudios.itemmarket.api.MarketTransactionCallback
Se llama solo si la transacción fue exitosa.
Firma:
void onTransaction(ServerPlayerEntity player, Item item, int count, long totalPrice, boolean isBuy);
ES (Ejemplo: registrar transacciones en consola)
import com.TNTStudios.itemmarket.api.MarketTransactionCallback;
public class MiMod {
public static void init() {
MarketTransactionCallback.EVENT.register((player, item, count, totalPrice, isBuy) -> {
String tipo = isBuy ? "COMPRA" : "VENTA";
System.out.println("[MiMod] " + player.getName().getString() +
" " + tipo + " " + count + "x " + item.getName().getString() +
" por " + totalPrice + " monedas");
});
}
}
ES
comprar/vender, id del ítem, sellAll)ES
El servidor manda, así que el cliente no puede falsificar precios o balances.
ES
No abre el mercado (M no hace nada)
Se ven ítems pero no deja comprar/vender
100.json)Faltan algunos ítems
ES