From 309f97b44307f03a91681485c309f77ad8647b85 Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Mon, 19 Jul 2021 04:22:03 -0400 Subject: [PATCH] Pregen method api --- .../core/pregenerator/PregeneratorMethod.java | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/main/java/com/volmit/iris/core/pregenerator/PregeneratorMethod.java diff --git a/src/main/java/com/volmit/iris/core/pregenerator/PregeneratorMethod.java b/src/main/java/com/volmit/iris/core/pregenerator/PregeneratorMethod.java new file mode 100644 index 000000000..9bad0e05a --- /dev/null +++ b/src/main/java/com/volmit/iris/core/pregenerator/PregeneratorMethod.java @@ -0,0 +1,72 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.core.pregenerator; + +/** + * Represents something that is capable of generating in chunks or regions, or both + */ +public interface PregeneratorMethod { + /** + * This is called before any generate methods are called. Setup your generator here + */ + void init(); + + /** + * This is called after the pregenerator is done. Save your work and stop threads + */ + void close(); + + /** + * This is called every X amount of chunks or regions. Save work, + * but no need to save all of it. At the end, close() will still be called. + */ + void save(); + + /** + * Return true if regions can be generated + * @return true if they can be + * @param x the x region + * @param z the z region + */ + boolean supportsRegions(int x, int z); + + /** + * Return the name of the method being used + * @return the name + * @param x the x region + * @param z the z region + */ + String getMethod(int x, int z); + + /** + * Called to generate a region. Execute sync, if multicore internally, wait + * for the task to complete + * @param x the x + * @param z the z + * @param listener signal chunks generating & generated. Parallel capable. + */ + void generateRegion(int x, int z, PregenListener listener); + + /** + * Called to generate a chunk. You can go async so long as save will wait on the threads to finish + * @param x the x + * @param z the z + */ + void generateChunk(int x, int z); +}