Skip to content

Transfer

These types move energy, items, and fluid between blocks and stacks, and let other mods use a mod’s own storage. They replace Forge’s capabilities and Fabric’s transfer and energy lookups, which differ between the loaders and count fluid in different units.

Type Summary Status Since Side Thread
EnergyAccess Energy storage, from Transfer#energy or a mod’s own EnergyBuffer. Experimental 2.10.0 server server
EnergyBuffer A mod’s energy storage. Experimental 2.10.0 server server
FluidAccess Fluid storage, from Transfer#fluids or a mod’s own FluidTank. Experimental 2.10.0 server server
FluidAmount An amount of a fluid, in millibuckets (1000 to a bucket). Experimental 2.10.0 both any
FluidTank A mod’s tank of one fluid. Experimental 2.10.0 server server
ItemAccess Item storage, from Transfer#items or a mod’s own ItemSlots. Experimental 2.10.0 server server
ItemSlots A mod’s item slots. Experimental 2.10.0 both any
Transfer Energy, item, and fluid storage on blocks and stacks. Experimental 2.10.0 server server

BatteryBoxBlockEntity keeps its energy in an EnergyBuffer field, energy. With BATTERY_BOX, its block entity type from the mod’s Registrar, in the mod’s initializer:

Let other mods fill and drain a battery box
Transfer.exposeEnergy(BATTERY_BOX, (box, side) -> box.energy);

Experimental · Since 2.10.0 · Side: server · Thread: server

Transfer finds another block’s storage on the face that touches it. In a generator’s block entity, with energy its EnergyBuffer and FACING the side it pushes to, in its server tick:

Push energy into the block in front every half second
// Spread over ticks: each generator pushes on its own tick of ten.
if ((level.getGameTime() + worldPosition.asLong()) % 10 != 0) return;
Direction facing = getBlockState().getValue(FACING);
EnergyAccess target = Transfer.energy(level, worldPosition.relative(facing), facing.getOpposite());
if (target != null) energy.extract(target.insert(energy.extract(1_000, true), false), false);
  • Each find makes a new view of the storage, so a machine that moves something often finds it only as often as it moves.