if (length > 0) {
BlockFace facing = this.getFacing(block);
MoveReaction reac;
//the previous material
BlockMaterial prevMat = VanillaMaterials.PISTON_EXTENSION;
short prevData = (short) (block.getBlockData() & 0x7);
Block previous = block.translate(facing);
if (this.isSticky()) {
prevData |= 0x8;
}
//temporary values to use while swapping
BlockMaterial nextMat;
short nextData;
Block next; // = block.translate(facing);
for (int i = 0; i < length; i++) {
//prepare the next material
nextMat = previous.getMaterial();
nextData = previous.getBlockData();
next = previous.translate(facing);
reac = this.getReaction(previous);
if (reac == MoveReaction.BREAK) {
//break block
nextMat.getSubMaterial(nextData).destroy(previous, toCause(block));
previous.setMaterial(prevMat, prevData);
break;
} else if (reac == MoveReaction.ALLOW) {
//transfer data over and continue
previous.setMaterial(prevMat, prevData);