mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-05-09 15:29:16 +00:00
Add block.getRelative() funcs and docs (#3)
This commit is contained in:
parent
ebc1d4c640
commit
b97fe888d1
|
|
@ -121,4 +121,46 @@ public class Block
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue