Moveable Entity Block Module >=1.21.1 API redesigned in 26.1
The package dev.anvilcraft.lib.v2.piston solves the issue of vanilla pistons being unable to push blocks with block entities. Through a set of Mixins and interfaces, it allows blocks to carry custom NBT data during movement and write the data back to the block entity at the destination when the piston stops.
Document Index
| Document | Content |
|---|---|
| Core Interfaces | IMoveableEntityBlock, IPistonMovingBlockEntityExtension |
| Mixin and Usage | Mixin modification points, complete usage example |
Overview
In vanilla, a piston pushing a block with a block entity has no effect. This module injects into the piston movement logic:
- Before movement -- Calls
clearDatato extract block entity data - During movement -- Data is temporarily stored in
PistonMovingBlockEntity - After movement -- Calls
setDatato write data back to the block entity at the new position
The entire process is transparent to the server and requires no modification to the vanilla piston core logic.
Notes
- All data transfer occurs server-side; the client does not retain additional data
clearDatashould return only the custom data that needs to be preserved, not serialize the entire block entityIMoveableEntityBlockextendsEntityBlock; if your block is already aBaseEntityBlocksubclass, you only need to additionally implement this interface- Mixin priority is
priority = 943; may need adjustment if conflicting with other piston-modifying mods