Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions Minecraft.Server.FourKit/Block/Block.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,46 @@ public bool breakNaturally()
return NativeBridge.BreakBlock(_world.getDimensionId(), _x, _y, _z) != 0;
return false;
}

/// <summary>
/// Gets the block at the given offsets
/// </summary>
/// <param name="modX">X offset</param>
/// <param name="modY">Y offset</param>
/// <param name="modZ">Z offset</param>
/// <returns>Block at the given offsets</returns>
public Block getRelative(int modX, int modY, int modZ)
{
return getWorld().getBlockAt(getX() + modX, getY() + modY, getZ() + modZ);
}

/// <summary>
/// Gets the block at the given face
/// <para>This method is equal to getRelative(face, 1)</para>
/// </summary>
/// <param name="face">BlockFace to get relative to</param>
/// <returns>Block at the given face</returns>
public Block getRelative(BlockFace face)
{
return getRelative(face, 1);
}

/// <summary>
/// Gets the block at the given distance of the given face
/// <para>For example, the following method places water at 100,102,100; two
/// blocks above 100,100,100.</para>
/// <code>
/// Block block = world.getBlockAt(100, 100, 100);
/// Block shower = block.getRelative(BlockFace.UP, 2);
/// shower.setType(Material.WATER);
/// </code>
/// </summary>
/// <param name="face">BlockFace to get relative to</param>
/// <param name="distance">Distance to get relative to</param>
/// <returns>Block at the given distance of the given face</returns>
public Block getRelative(BlockFace face, int distance)
{
return getRelative(face.getModX() * distance, face.getModY() * distance, face.getModZ() * distance);
}

}