Hello!
How can I set the direction of a block at a given location?
In another thread I’ve read that the direction can be set via the DirectionalData interface.
If I have
- instance of
org.spongepowered.api.world.Location<World>
and -
org.spongepowered.api.util.Direction
,
how can I set the direction of 1 to 2?
Using the code below or differently?
private fun setDirection(
loc: org.spongepowered.api.world.Location<World>,
direction: Direction) {
loc.offer(Keys.DIRECTION, direction)
}
Here’s the Bukkit analog of what I’m trying to achieve:
protected void setFacingDirection(final BlockFace face, final Block block) {
final BlockState state = block.getState();
final MaterialData materialData = state.getData();
if (materialData instanceof Directional) {
final Directional directional = (Directional) materialData;
directional.setFacingDirection(face);
state.update();
}
}
Thanks
Dmitri Pisarenko