From 9c97d5cd5580130ed8e6c149f3e55b3188254a94 Mon Sep 17 00:00:00 2001 From: effery Date: Tue, 24 Mar 2026 17:13:56 +1300 Subject: [PATCH] Add block.getRelative() funcs and docs --- Minecraft.Server.FourKit/Block/Block.cs | 42 +++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/Minecraft.Server.FourKit/Block/Block.cs b/Minecraft.Server.FourKit/Block/Block.cs index 022b9b616..1a31081a5 100644 --- a/Minecraft.Server.FourKit/Block/Block.cs +++ b/Minecraft.Server.FourKit/Block/Block.cs @@ -121,4 +121,46 @@ public bool breakNaturally() return NativeBridge.BreakBlock(_world.getDimensionId(), _x, _y, _z) != 0; return false; } + + /// + /// Gets the block at the given offsets + /// + /// X offset + /// Y offset + /// Z offset + /// Block at the given offsets + public Block getRelative(int modX, int modY, int modZ) + { + return getWorld().getBlockAt(getX() + modX, getY() + modY, getZ() + modZ); + } + + /// + /// Gets the block at the given face + /// This method is equal to getRelative(face, 1) + /// + /// BlockFace to get relative to + /// Block at the given face + public Block getRelative(BlockFace face) + { + return getRelative(face, 1); + } + + /// + /// Gets the block at the given distance of the given face + /// For example, the following method places water at 100,102,100; two + /// blocks above 100,100,100. + /// + /// Block block = world.getBlockAt(100, 100, 100); + /// Block shower = block.getRelative(BlockFace.UP, 2); + /// shower.setType(Material.WATER); + /// + /// + /// BlockFace to get relative to + /// Distance to get relative to + /// Block at the given distance of the given face + public Block getRelative(BlockFace face, int distance) + { + return getRelative(face.getModX() * distance, face.getModY() * distance, face.getModZ() * distance); + } + }