Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BlockPlacerCallback #2564

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,35 @@ public interface Feature extends DefaultedRegistryValue {
DataView toContainer();

/**
* Places the feature at given position and world
*
* @param world The world
* @param pos The position
*
* @return true when the feature was successfully placed
*/
boolean place(ServerWorld world, Vector3i pos);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a reason why this couldn't remain, if a callback can be optionally an overloaded method.

* Functional interface to handle block placement during feature generation.
*/
@FunctionalInterface
interface BlockPlacerCallback {
/**
* Called when a block is being placed during feature generation.
* @param location The location of the block being placed
* @param block The block being placed
* @return True to allow the block placement, false to skip the block.
*/
boolean onBlockPlace(ServerLocation location, Block block);
}

/**
* Places the feature at given location
*
* @param location The location
*
* @return true when the feature was successfully placed
*/
boolean place(ServerLocation location);
/**
* Places the feature at the given position in the world, using the provided callback for block placement.
* @param world The world where the feature will be placed
* @param pos The position where the feature will be placed
* @param callback The callback for handling block placement.
* @return true if the feature was successfully placed
*/
boolean place(ServerWorld world, Vector3i pos, BlockPlacerCallback callback);


/**
* Places the feature at the given location, using the provided callback for block placement.
* @param location The location where the feature will be placed
* @param callback The callback for handling block placement.
* @return true if the feature was successfully placed
*/
boolean place(ServerLocation location, BlockPlacerCallback callback);

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,37 @@
public interface Structure extends DefaultedRegistryValue {

/**
* Places the structure at given position and world
*
* @param world The world
* @param pos The position
*
* @return true when the feature was successfully placed
*/
boolean place(ServerWorld world, Vector3i pos);
* Functional interface to handle block placement during structure generation.
*/
@FunctionalInterface
interface BlockPlacerCallback {
/**
* Called when a block is being placed during structure generation.
* @param location The location of the block being placed
* @param block The block being placed
* @return True to allow the block placement, false to skip the block.
*/
boolean onBlockPlace(ServerLocation location, Block block);
}


/**
* Places the structure at given location
*
* @param location The location
*
* @return true when the feature was successfully placed
*/
boolean place(ServerLocation location);
* Places the structure at given position and world using a callback for each block placed.
* @param world The world
* @param pos The position
* @param callback The callback for handling block placement.
* @return true if the structure was successfully placed
*/
boolean place(ServerWorld world, Vector3i pos, BlockPlacerCallback callback);


/**
* Places the structure at given location using a callback for each block placed.
* @param location The location
* @param callback The callback for handling block placement.
* @return true if the structure was successfully placed
*/
boolean place(ServerLocation location, BlockPlacerCallback callback);

/**
* Returns the biomes the structure is allowed in.
Expand Down
Loading