namespace Minecraft.Server.FourKit.Event.Block;
using Minecraft.Server.FourKit.Block;
///
/// Called when a piston extends.
///
public class BlockPistonExtendEvent : BlockPistonEvent
{
private readonly int _length;
internal BlockPistonExtendEvent(Block block, int length, BlockFace direction)
: base(block, direction)
{
_length = length;
}
///
/// Get the amount of blocks which will be moved while extending.
///
/// The amount of moving blocks.
public int getLength() => _length;
///
/// Get an immutable list of the blocks which will be moved by the extending.
///
/// Immutable list of the moved blocks.
public List getBlocks()
{
var blocks = new List();
var world = getBlock().getWorld();
int x = getBlock().getX();
int y = getBlock().getY();
int z = getBlock().getZ();
var dir = getDirection();
for (int i = 0; i < _length; i++)
{
x += dir.getModX();
y += dir.getModY();
z += dir.getModZ();
blocks.Add(new Block(world, x, y, z));
}
return blocks.AsReadOnly().ToList();
}
}