SDKRecipes
Transfer items
Deposit blocks and withdraw food from a container.
Set the chest coordinates in the program. The bot must be near a loaded, accessible container. The scoped handle closes the menu when the program leaves the scope, including when a transfer fails.
import { Effect, Stream } from "effect";
import { SoulFire } from "@soulfiremc/sdk";
function env(name: string): string {
const value = process.env[name];
if (!value) throw new Error(`Set ${name} before running this recipe`);
return value;
}
const program = Effect.scoped(
Effect.gen(function* () {
const soulfire = yield* SoulFire.connect({
baseUrl: env("SOULFIRE_URL"),
token: env("SOULFIRE_TOKEN"),
});
const bot = soulfire
.instance(env("SOULFIRE_INSTANCE_ID"))
.bot(env("SOULFIRE_BOT_ID"));
yield* bot.start();
yield* bot.waitForOnline();
const chestPosition = {
dimension: "minecraft:overworld",
x: 10,
y: 64,
z: 10,
};
const chest = yield* bot.inventory.openScoped(chestPosition);
yield* chest.deposit({ itemIds: ["minecraft:cobblestone"] }, 64);
yield* chest.withdraw({ tags: ["minecraft:foods"] }, 16);
}),
);
await Effect.runPromise(program);Each transfer checks the source count and destination space before clicking slots. See inventory and containers for snapshots, revision handling, and item selection.
How is this page?
Last updated on
