Skip to content

Regions: CuboidRegion

PXAV edited this page Mar 20, 2021 · 2 revisions

What is a CuboidRegion?

A cuboid region is a region of blocks in a cuboid shape, which can look like this:

An example of a rectangular cuboid region

You always have eight corners in total, two of which are considered as minPos and maxPos. When creating a cuboid region, you always have to define those points. They should be opposite of each other, in this case, A (for minPos) and D (for maxPos) would be a good example.

Kelp can then automatically interpolate the other corners and create a cuboid shape out of it.

Some code examples

This example might be familiar to you from the Gladiator kit of HG games. It spawns a glass cube up in the sky and lets two players fight against each other in there, before they are teleported on the ground again.

CuboidRegion region = CuboidRegion.create(pos1, pos2);
region.getSurfaceBlocks().forEach(block -> block.setMaterial(KelpMaterial.GLASS));
player1.teleport(region.getCenter().clone().addX(5));
player2.teleport(region.getCenter().clone().subtractX(5));
Clone this wiki locally