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 } from "effect";
import { SoulFire, itemSelector } 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.connect();
const chestPosition = {
dimension: "minecraft:overworld",
x: 10,
y: 64,
z: 10,
};
const chest = yield* bot.inventory.openScoped(chestPosition);
yield* chest.deposit(itemSelector("cobblestone"), 64);
yield* chest.withdraw(itemSelector("#foods"), 16);
}),
);
await Effect.runPromise(program);TypeScript uses openScoped to tie the menu to the scope. Python open registers the same cleanup in the current scope.
Each transfer checks the source count and destination space before clicking slots. See inventory and containers for snapshots, revision handling, and item selection.
Last updated on
Was this page helpful?
