Skip to content

Gateway

Dylan Brose edited this page Aug 30, 2026 · 5 revisions

Gateway storage

A block is a Gateway when block.hasTag("xxdmogxx_dns:gateway").

stock, list, deposit, withdraw, and craftStart take at = that Gateway on a live data network. A Drive, cable, Terminal, or Machine Interface returns err: "no_gateway". Below is an example of getting the stock of typeId in the network from a gateway the player is looking at.

import type { Block } from "@minecraft/server";

function coordsOf(block: Block) {
  const { x, y, z } = block.location;
  return { d: block.dimension.id, x, y, z };
}

const hit = player.getBlockFromViewDirection({ maxDistance: 8 })?.block;
if (hit?.hasTag("xxdmogxx_dns:gateway")) {
  const at = coordsOf(hit);
  const stock = await dns.stock(at, typeId);
}

At most 64 items per deposit or withdraw.

Simple vs unique

Simple stacks are normal items (dirt, ingots, …). Unique stacks have extra data — custom name, enchantments, durability, and similar. list returns one snapshot per unique identity.

  • stock → n = simple count, u = unique count
  • list adds items[]: { snap, n } per unique identity
  • withdraw without a snap takes simple first (one ItemStack). If simple is empty, it takes the first unique identity of that typeId
  • withdraw with a snap from list takes only that unique

The client captures and restores ItemStack NBT.

const stock = await dns.stock(at, "minecraft:dirt"); // n = simple, u = unique
const listed = await dns.list(at, "minecraft:diamond_sword");
await dns.deposit(at, dirtStack); // optional third arg n = amount (default stack.amount)
const simple = await dns.withdraw(at, "minecraft:dirt", 8);
const unique = await dns.withdraw(at, "minecraft:diamond_sword", 1, listed.items[0].snap);

Inventory is yours

deposit does not remove items from the player or a container. Check reply?.ok and reply.n (it can be less than you asked if the network is full), then remove that many yourself.

withdraw returns a real ItemStack (NBT restored) or undefined. Put that stack into a slot. undefined also means not ready, timeout, n outside 1–64, or restore failed.

Clone this wiki locally