mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-05-21 20:23:51 +00:00
blockstate, more block events, command preprocess event.
This commit is contained in:
parent
21b5accc69
commit
18a673bd46
34 changed files with 1359 additions and 58 deletions
|
|
@ -0,0 +1,46 @@
|
|||
namespace Minecraft.Server.FourKit.Event.Block;
|
||||
|
||||
using Minecraft.Server.FourKit.Block;
|
||||
|
||||
/// <summary>
|
||||
/// Called when a piston extends.
|
||||
/// </summary>
|
||||
public class BlockPistonExtendEvent : BlockPistonEvent
|
||||
{
|
||||
private readonly int _length;
|
||||
|
||||
internal BlockPistonExtendEvent(Block block, int length, BlockFace direction)
|
||||
: base(block, direction)
|
||||
{
|
||||
_length = length;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the amount of blocks which will be moved while extending.
|
||||
/// </summary>
|
||||
/// <returns>The amount of moving blocks.</returns>
|
||||
public int getLength() => _length;
|
||||
|
||||
/// <summary>
|
||||
/// Get an immutable list of the blocks which will be moved by the extending.
|
||||
/// </summary>
|
||||
/// <returns>Immutable list of the moved blocks.</returns>
|
||||
public List<Block> getBlocks()
|
||||
{
|
||||
var blocks = new List<Block>();
|
||||
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();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue