Water objects need flat water

- Single-piece structures stay forced but keep the river and pond exclusion
- Water-flagged objects skip footprints on dams, cascades, waterfalls or water at another head
- The provisional guard runs before any bore and throws an engine failure
- Saplings stay when a tree override is rejected or the terrain is still being planned
- Object paste reports a retry when the terrain is still being planned
- Tests cover structures over rivers, flat water, lava, bore ordering, explicit Y and saplings
This commit is contained in:
Brian Neumann-Fopiano committed 2026-11-02 05:19:02 -05:00
1 parent 2d52cc409e
commit 65d06ae83c
37 files changed
+777 -242

No files matched your search

@@ -562,15 +562,7 @@ public class IrisStructureComponent extends IrisMantleComponent {
boolean supportNonOccluding) {
IrisObject object = p.getObject();
String objectKey = object.getLoadKey();
IrisObjectPlacement config = structure.createLootPlacement(objectKey);
config.setMode(mode);
config.setRotation(p.getRotation());
if (!structure.getEdit().isEmpty()) {
config.setEdit(structure.getEdit());
}
if (mode != ObjectPlaceMode.STRUCTURE_PIECE && mode != ObjectPlaceMode.FLOATING) {
config.setForcePlace(true);
}
IrisObjectPlacement config = piecePlacement(structure, p, mode);
int placeY = (y == -1) ? -1 : y - getEngineMantle().getEngine().getMinHeight();
String marker = structurePlacementMarker(structure, p, objectKey);
return object.place(p.getX(), placeY, p.getZ(), writer, config, rng, (position, state) -> {
@@ -583,6 +575,20 @@ public class IrisStructureComponent extends IrisMantleComponent {
}, null, getData());
}
static IrisObjectPlacement piecePlacement(IrisStructure structure, PlacedStructurePiece piece, ObjectPlaceMode mode) {
IrisObjectPlacement config = structure.createLootPlacement(piece.getObject().getLoadKey());
config.setMode(mode);
config.setRotation(piece.getRotation());
if (!structure.getEdit().isEmpty()) {
config.setEdit(structure.getEdit());
}
if (mode != ObjectPlaceMode.STRUCTURE_PIECE && mode != ObjectPlaceMode.FLOATING) {
config.setForcePlace(true);
config.setForcedByStructure(true);
}
return config;
}
static boolean shouldWriteStructureMarker(NativeBlockState state) {
return state != null && state.isStorageChest();
}
@@ -1,5 +1,6 @@
package art.arcane.iris.generation.runtime;
import art.arcane.iris.generation.stream.ProvisionalAnswerException;
import art.arcane.iris.world.history.SavedBiomeUnavailableException;
import art.arcane.volmlib.util.mantle.MantleClosedException;
@@ -25,6 +26,7 @@ public final class GenerationFailures {
public static boolean isEngineFailure(Throwable failure) {
return isShutdownFailure(failure) || hasCause(failure, (Throwable cause) -> cause instanceof Error
|| cause instanceof WrongEngineBroException
|| cause instanceof ProvisionalAnswerException
|| cause instanceof SavedBiomeUnavailableException unavailable && unavailable.isLoading()
|| cause instanceof TimeoutException);
}
@@ -0,0 +1,7 @@
package art.arcane.iris.generation.stream;
public final class ProvisionalAnswerException extends IllegalStateException {
public ProvisionalAnswerException(String message) {
super(message);
}
}
@@ -382,6 +382,10 @@ public final class BukkitCommandMessagesExtended {
"iris.bukkit.commandobject.placed",
C.IRIS + "Placed " + "{object}"
);
public static final TextKey COMMAND_OBJECT_PASTE_WAITS_FOR_TERRAIN_PLAN = TextKey.of(
"iris.bukkit.commandobject.paste_waits_for_terrain_plan",
C.YELLOW + "The terrain at " + "{x}" + " " + "{y}" + " " + "{z}" + " is still being planned. Nothing was pasted; run the paste again in a moment."
);
public static final TextKey COMMAND_OBJECT_YOU_NEED_HOLD_YOUR_WAND = TextKey.of(
"iris.bukkit.commandobject.you_need_hold_your_wand",
C.YELLOW + "You need to hold your wand!"
@@ -899,6 +903,7 @@ public final class BukkitCommandMessagesExtended {
COMMAND_OBJECT_GIVEN_NEW_WAND_OBJECTS_IOB,
COMMAND_OBJECT_UPDATED_WAND_OBJECTS_IOB_2,
COMMAND_OBJECT_PLACED,
COMMAND_OBJECT_PASTE_WAITS_FOR_TERRAIN_PLAN,
COMMAND_OBJECT_YOU_NEED_HOLD_YOUR_WAND,
COMMAND_OBJECT_FILE_ALREADY_EXISTS_SET_OVERWRITE_TRUE_OVERWRITE_IT,
COMMAND_OBJECT_FAILED_SAVE_OBJECT_BECAUSE_IOEXCEPTION,
@@ -201,6 +201,7 @@ public class IrisObjectPlacement {
@Description("Ignore any placement restrictions for this object")
@SerializedName(value = "forcePlace", alternate = {"force"})
private boolean forcePlace = false;
private transient boolean forcedByStructure = false;
private transient AtomicCache<TableCache> cache = new AtomicCache<>();
private transient AtomicCache<CompatStatus> compatCache = new AtomicCache<>();
@Getter(AccessLevel.NONE)
@@ -9,6 +9,8 @@ import art.arcane.iris.pack.loading.IrisData;
import art.arcane.iris.generation.runtime.IrisComplex;
import art.arcane.iris.generation.runtime.Engine;
import art.arcane.iris.generation.geometry.IrisBlockVector;
import art.arcane.iris.generation.hydrology.raster.WaterRole;
import art.arcane.volmlib.util.stream.ProceduralStream;
import java.util.Arrays;
import java.util.List;
@@ -60,6 +62,21 @@ public final class IrisSurfaceSupport {
return stencil.anyColumnIntersectsHydrology(engine.getComplex(), x, z);
}
public static boolean intersectsUnevenWater(IObjectPlacer placer, int x, int z,
IrisObjectTranslate translate, IrisObjectRotation rotation,
int spinX, int spinY, int spinZ,
List<IrisBlockVector> supportOffsets) {
Engine engine = placer.getEngine();
if (engine == null || engine.getComplex() == null) {
return false;
}
Stencil stencil = STENCIL.get();
if (!stencil.build(supportOffsets, translate, rotation, spinX, spinY, spinZ, 0)) {
return true;
}
return stencil.anyColumnIntersectsUnevenWater(engine.getComplex(), x, z);
}
private static IrisBlockVector transform(IrisBlockVector offset, IrisObjectTranslate translate,
IrisObjectRotation rotation, int spinX, int spinY, int spinZ) {
IrisBlockVector transformed = offset.clone();
@@ -228,6 +245,44 @@ public final class IrisSurfaceSupport {
return false;
}
private boolean anyColumnIntersectsUnevenWater(IrisComplex complex, int x, int z) {
ProceduralStream<WaterRole> roles = complex.getWaterRoleStream();
ProceduralStream<Double> heads = complex.getWaterHeadStream();
boolean anchorKnown = false;
long anchorHead = 0L;
for (int stencilX = 0; stencilX < width; stencilX++) {
for (int stencilZ = 0; stencilZ < depth; stencilZ++) {
if (!cells[(stencilX * depth) + stencilZ]) {
continue;
}
int columnX = x + minX + stencilX;
int columnZ = z + minZ + stencilZ;
WaterRole role = roles.get(columnX, columnZ);
if (breaksFlatWater(role)) {
return true;
}
if (!role.wet()) {
continue;
}
if (!anchorKnown) {
anchorHead = Math.round(heads.getDouble(x, z));
anchorKnown = true;
}
if (Math.round(heads.getDouble(columnX, columnZ)) != anchorHead) {
return true;
}
}
}
return false;
}
private static boolean breaksFlatWater(WaterRole role) {
return switch (role) {
case DAM, CASCADE, WATERFALL -> true;
case NONE, CHANNEL, BANK, SHORE, POND, POND_SHORE, MOUTH, INLET -> false;
};
}
private boolean isColumnUnsupported(IObjectPlacer placer, IrisData data, int x, int z,
int stencilX, int stencilZ, int minSolidDepth,
IrisPaintSurfaceProjection projection) {
@@ -1,5 +1,6 @@
package art.arcane.iris.structure.object;
import art.arcane.iris.generation.stream.ProvisionalAnswerException;
import art.arcane.iris.generation.stream.ProvisionalSampling;
import java.util.List;
@@ -17,10 +18,11 @@ public final class PlacementLifecycle {
public PlacementState execute(PlacementContext context) {
PlacementState state = new PlacementState(context);
long revision = ProvisionalSampling.revision();
for (PlacementStage<Void> stage : PlacementStage.BEFORE_PASS) {
for (PlacementStage<Void> stage : PlacementStage.DECISION) {
run(stage, context, state, null);
}
requireFinalAnswers(context, revision);
run(PlacementStage.BEFORE_BLOCKS, context, state, null);
if (state.isRejected()) {
return state;
}
@@ -51,7 +53,7 @@ public final class PlacementLifecycle {
return;
}
String key = context.self.getLoadKey();
throw new IllegalStateException("Object " + (key == null ? "<no loadKey>" : key) + " at " + context.x + "," + context.z
throw new ProvisionalAnswerException("Object " + (key == null ? "<no loadKey>" : key) + " at " + context.x + "," + context.z
+ " read a provisional terrain or water answer; automatic placements are only made from final terrain.");
}
}
@@ -15,14 +15,9 @@ final class PlacementModuleSurfaceSupport implements PlacementModule {
public void install(PlacementLifecycleBuilder lifecycle) {
lifecycle.add(CHECK, PlacementStage.VALIDATE, (context, state, ignored) -> {
IrisObjectPlacement config = state.config;
if (context.yv < 0 && !config.isForcePlace() && !config.isUnderwater() && !config.isOnwater()
&& config.getCarvingSupport().supportsSurface()
&& config.getMode() != ObjectPlaceMode.FLOATING && config.getMode() != ObjectPlaceMode.STRUCTURE_PIECE
&& (state.paintProjection != null
? IrisSurfaceSupport.intersectsHydrology(context.placer, context.x, context.z, null, null, 0, 0, 0, state.paintSupport)
: IrisSurfaceSupport.intersectsHydrology(context.placer, context.x, context.z, config.getTranslate(),
config.getRotation(), state.spinX, state.spinY, state.spinZ, context.self.getSurfaceSupportOffsets()))) {
state.reject("hydrology-support");
String hydrologyRejection = hydrologyRejection(context, state);
if (hydrologyRejection != null) {
state.reject(hydrologyRejection);
return;
}
boolean rawStructurePiece = config.getMode() == ObjectPlaceMode.STRUCTURE_PIECE;
@@ -59,6 +54,31 @@ final class PlacementModuleSurfaceSupport implements PlacementModule {
};
}
private static String hydrologyRejection(PlacementContext context, PlacementState state) {
IrisObjectPlacement config = state.config;
if (context.yv >= 0 || !config.getCarvingSupport().supportsSurface()
|| config.getMode() == ObjectPlaceMode.FLOATING || config.getMode() == ObjectPlaceMode.STRUCTURE_PIECE) {
return null;
}
boolean painted = state.paintProjection != null;
if (entersWater(config)) {
return (painted
? IrisSurfaceSupport.intersectsUnevenWater(context.placer, context.x, context.z, null, null, 0, 0, 0, state.paintSupport)
: IrisSurfaceSupport.intersectsUnevenWater(context.placer, context.x, context.z, config.getTranslate(),
config.getRotation(), state.spinX, state.spinY, state.spinZ, context.self.getSurfaceSupportOffsets()))
? "uneven-water" : null;
}
return (painted
? IrisSurfaceSupport.intersectsHydrology(context.placer, context.x, context.z, null, null, 0, 0, 0, state.paintSupport)
: IrisSurfaceSupport.intersectsHydrology(context.placer, context.x, context.z, config.getTranslate(),
config.getRotation(), state.spinX, state.spinY, state.spinZ, context.self.getSurfaceSupportOffsets()))
? "hydrology-support" : null;
}
private static boolean entersWater(IrisObjectPlacement config) {
return config.isUnderwater() || config.isOnwater() || config.isForcePlace() && !config.isForcedByStructure();
}
private static void warnImplausibleBedrockPlacement(IrisObject self, IObjectPlacer placer, IrisObjectPlacement config, int x, int y, int z) {
String key = self.getLoadKey();
String fingerprint = (key == null ? "<null>" : key) + "|" + config.getMode();
@@ -20,7 +20,7 @@ public final class PlacementStage<C> {
public static final PlacementStage<Void> AFTER_BLOCKS = new PlacementStage<>("after-blocks", 6);
static final List<PlacementStage<?>> ALL = List.of(PREPARE, HEIGHT, VALIDATE, BEFORE_BLOCKS,
BLOCK_WRITTEN, BLOCKS, AFTER_BLOCKS);
static final List<PlacementStage<Void>> BEFORE_PASS = List.of(PREPARE, HEIGHT, VALIDATE, BEFORE_BLOCKS);
static final List<PlacementStage<Void>> DECISION = List.of(PREPARE, HEIGHT, VALIDATE);
private final String name;
final int order;
@@ -27,6 +27,7 @@ import art.arcane.iris.world.IrisToolbelt;
import art.arcane.iris.generation.runtime.Engine;
import art.arcane.iris.generation.runtime.EngineLifecycleTasks;
import art.arcane.iris.generation.decoration.tree.TreeBlockMaterial;
import art.arcane.iris.generation.stream.ProvisionalAnswerException;
import art.arcane.iris.structure.object.IObjectPlacer;
import art.arcane.iris.generation.biome.IrisBiome;
import art.arcane.iris.generation.terrain.IrisDimension;
@@ -158,7 +159,6 @@ public class TreeSVC implements IrisService {
return;
}
saplingPlane.forEach(block -> block.setType(Material.AIR));
IrisObject object = placement.scaleObject(RNG.r,
worldAccess.getData().getObjectLoader().load(pool.getRandom(RNG.r)), dimension);
@@ -257,17 +257,28 @@ public class TreeSVC implements IrisService {
}
};
object.place(
saplingPlane.getCenter().getBlockX(),
(saplingPlane.getCenter().getBlockY() + object.getH() / 2),
saplingPlane.getCenter().getBlockZ(),
placer,
placement,
RNG.r,
Objects.requireNonNull(worldAccess).getData()
);
try {
object.place(
saplingPlane.getCenter().getBlockX(),
(saplingPlane.getCenter().getBlockY() + object.getH() / 2),
saplingPlane.getCenter().getBlockZ(),
placer,
placement,
RNG.r,
Objects.requireNonNull(worldAccess).getData()
);
} catch (ProvisionalAnswerException provisional) {
IrisLogging.debug("Sapling growth at " + event.getLocation() + " waits for the terrain plan: " + provisional.getMessage());
event.setCancelled(true);
return;
}
event.setCancelled(true);
if (blockStateList.isEmpty()) {
IrisLogging.debug("Tree placement " + object.getLoadKey() + " placed nothing at " + event.getLocation() + "; the sapling stays");
return;
}
saplingPlane.forEach(block -> block.setType(Material.AIR));
Runnable growTask = () -> {
@@ -597,6 +597,7 @@ updated_wand_objects_iob = "Zauberstab für objects/{value}.iob aktualisiert "
given_new_wand_objects_iob = "Neuen Zauberstab für objects/{value}.iob erhalten "
updated_wand_objects_iob_2 = "Zauberstab für objects/{value}.iob aktualisiert "
placed = "§a{object} platziert"
paste_waits_for_terrain_plan = "§eDas Gelände bei {x} {y} {z} wird noch geplant. Es wurde nichts eingefügt; führe das Einfügen gleich erneut aus."
you_need_hold_your_wand = "§eDu musst deinen Zauberstab halten!"
file_already_exists_set_overwrite_true_overwrite_it = "§cFile existiert bereits. Setze overwrite=true, um es zu überschreiben."
failed_save_object_because_ioexception = "§cDas Objekt konnte wegen einer IOException nicht gespeichert werden: {value}"
@@ -941,6 +942,7 @@ unknown_empty_object = "Unbekanntes oder leeres Objekt: {key}"
console_must_specify_coordinates_iris_object_paste_at_x_y = "Die Konsole muss Koordinaten angeben: /iris object paste at <x> <y> <z> [rotate <degrees>] {key}"
you_are_not_looking_at_block_within_blocks = "Du blickst auf keinen Block innerhalb von {value} Blöcken."
paste_failed_partial_changes_recorded_undo = "Einfügen fehlgeschlagen: {value} (Teiländerungen wurden zum Rückgängigmachen aufgezeichnet)"
paste_waits_for_terrain_plan = "Das Gelände bei {value} {value2} {value3} wird noch geplant. Es wurde nichts eingefügt; führe das Einfügen gleich erneut aus."
placed_at_rot_write_s_non_air = "{key} bei {value} {value2} {value3} mit rot={rotation} platziert ({value4} Schreibvorgänge, {value5} Nicht-Luft-Blöcke{tileNote})"
this_command_can_only_be_used_by_players = "Dieser Befehl kann nur von Spielern verwendet werden."
hold_your_iris_wand_iris_wand_2 = "Halte deinen Iris-Zauberstab. (/iris wand)"
@@ -597,6 +597,7 @@ updated_wand_objects_iob = "Varita actualizada para objects/{value}.iob "
given_new_wand_objects_iob = "Se entregó una varita nueva para objects/{value}.iob "
updated_wand_objects_iob_2 = "Varita actualizada para objects/{value}.iob "
placed = "§aSe colocó {object}"
paste_waits_for_terrain_plan = "§eEl terreno en {x} {y} {z} todavía se está planificando. No se pegó nada; vuelve a ejecutar el pegado en un momento."
you_need_hold_your_wand = "§e¡Debes sostener tu varita!"
file_already_exists_set_overwrite_true_overwrite_it = "§cEl archivo ya existe. Usa overwrite=true para sobrescribirlo."
failed_save_object_because_ioexception = "§cNo se pudo guardar el objeto debido a una IOException: {value}"
@@ -941,6 +942,7 @@ unknown_empty_object = "Objeto desconocido o vacío: {key}"
console_must_specify_coordinates_iris_object_paste_at_x_y = "La consola debe indicar coordenadas: /iris object paste at <x> <y> <z> [rotate <degrees>] {key}"
you_are_not_looking_at_block_within_blocks = "No estás mirando un bloque a menos de {value} bloques."
paste_failed_partial_changes_recorded_undo = "El pegado falló: {value} (se registraron los cambios parciales para deshacerlos)"
paste_waits_for_terrain_plan = "El terreno en {value} {value2} {value3} todavía se está planificando. No se pegó nada; vuelve a ejecutar el pegado en un momento."
placed_at_rot_write_s_non_air = "Se colocó {key} en {value} {value2} {value3} rot={rotation} ({value4} escritura(s), {value5} sin aire{tileNote})"
this_command_can_only_be_used_by_players = "Este comando solo puede ser utilizado por jugadores."
hold_your_iris_wand_iris_wand_2 = "Sostén tu varita de Iris. (/iris wand)"
@@ -602,6 +602,7 @@ updated_wand_objects_iob = "Päivitetty sauva objects/{value}.iob "
given_new_wand_objects_iob = "Uusi sauva objects/{value}.iob "
updated_wand_objects_iob_2 = "Päivitetty sauva objects/{value}.iob "
placed = "§aPaikka {object}"
paste_waits_for_terrain_plan = "§eMaastoa kohdassa {x} {y} {z} suunnitellaan vielä. Mitään ei liitetty; suorita liittäminen uudelleen hetken kuluttua."
you_need_hold_your_wand = "§ePitele sauvaasi!"
file_already_exists_set_overwrite_true_overwrite_it = "§cTiedosto on jo olemassa. Aseta ylikirjoitus=tosi korvataksesi sen."
failed_save_object_because_ioexception = "§cKohdetta ei voitu tallentaa, koska IOException: {value}"
@@ -946,6 +947,7 @@ unknown_empty_object = "Tuntematon tai tyhjä objekti: {key}"
console_must_specify_coordinates_iris_object_paste_at_x_y = "Konsolissa on ilmoitettava koordinaatit: /iris object paste at <x> <y> <z> [rotate <degrees>] {key}"
you_are_not_looking_at_block_within_blocks = "Et katso kortteliakaan sisälläsi. {value} Palikat."
paste_failed_partial_changes_recorded_undo = "Liittäminen epäonnistui: {value} (osittaiset muutokset tallennettiin kumoamista varten)"
paste_waits_for_terrain_plan = "Maastoa kohdassa {value} {value2} {value3} suunnitellaan vielä. Mitään ei liitetty; suorita liittäminen uudelleen hetken kuluttua."
placed_at_rot_write_s_non_air = "Paikka {key} klo {value} {value2} {value3} mätä ={rotation} ({value4} kirjoita(s), {value5} muu kuin ilma{tileNote})"
this_command_can_only_be_used_by_players = "Vain pelaajat voivat käyttää tätä komentoa."
hold_your_iris_wand_iris_wand_2 = "Pidä kiinni. Iris Sauva. (/iris wand)"
@@ -597,6 +597,7 @@ updated_wand_objects_iob = "Baguette mise à jour pour objects/{value}.iob "
given_new_wand_objects_iob = "Nouvelle baguette donnée pour objects/{value}.iob "
updated_wand_objects_iob_2 = "Baguette mise à jour pour objects/{value}.iob "
placed = "§a{object} a été placé"
paste_waits_for_terrain_plan = "§eLe terrain en {x} {y} {z} est encore en cours de planification. Rien n'a été collé ; relancez le collage dans un instant."
you_need_hold_your_wand = "§eVous devez tenir votre baguette !"
file_already_exists_set_overwrite_true_overwrite_it = "§cLe fichier existe déjà. Utilisez overwrite=true pour l'écraser."
failed_save_object_because_ioexception = "§cImpossible d'enregistrer l'objet à cause d'une IOException : {value}"
@@ -941,6 +942,7 @@ unknown_empty_object = "Objet inconnu ou vide : {key}"
console_must_specify_coordinates_iris_object_paste_at_x_y = "La console doit indiquer des coordonnées : /iris object paste at <x> <y> <z> [rotate <degrees>] {key}"
you_are_not_looking_at_block_within_blocks = "Vous ne regardez pas de bloc à moins de {value} blocs."
paste_failed_partial_changes_recorded_undo = "Échec du collage : {value} (les modifications partielles ont été enregistrées pour pouvoir les annuler)"
paste_waits_for_terrain_plan = "Le terrain en {value} {value2} {value3} est encore en cours de planification. Rien n'a été collé ; relancez le collage dans un instant."
placed_at_rot_write_s_non_air = "{key} placé en {value} {value2} {value3} rot={rotation} ({value4} écriture(s), {value5} hors air{tileNote})"
this_command_can_only_be_used_by_players = "Cette commande ne peut être utilisée que par les joueurs."
hold_your_iris_wand_iris_wand_2 = "Tenez votre baguette Iris. (/iris wand)"
@@ -602,6 +602,7 @@ updated_wand_objects_iob = "עקבו אחרי objects/{value}.iob "
given_new_wand_objects_iob = "עקבו אחרי objects/{value}.iob"
updated_wand_objects_iob_2 = "עקבו אחרי objects/{value}.iob "
placed = "§aמקום {object}"
paste_waits_for_terrain_plan = "§eהשטח ב-{x} {y} {z} עדיין בתכנון. דבר לא הודבק; הרץ את ההדבקה שוב בעוד רגע."
you_need_hold_your_wand = "§eאתה צריך להחזיק את השרביט שלך!"
file_already_exists_set_overwrite_true_overwrite_it = "§cהקובץ כבר קיים. הגדר overwrite=נכון לכתוב אותו."
failed_save_object_because_ioexception = "§cנכשל להציל את האובייקט בגלל IOException: {value}"
@@ -946,6 +947,7 @@ unknown_empty_object = "אובייקט לא ידוע או ריק: {key}"
console_must_specify_coordinates_iris_object_paste_at_x_y = "הקונסולה חייבת לציין קואורדינטות: /iris object paste at <x> <y> <z> [rotate <degrees>] {key}"
you_are_not_looking_at_block_within_blocks = "אתה לא מסתכל על בלוק בתוך {value} בלוקים"
paste_failed_partial_changes_recorded_undo = "ההדבקה נכשלה: {value} (שינויים חלקיים נרשמו לביטול)"
paste_waits_for_terrain_plan = "השטח ב-{value} {value2} {value3} עדיין בתכנון. דבר לא הודבק; הרץ את ההדבקה שוב בעוד רגע."
placed_at_rot_write_s_non_air = "מקום {key} ב {value} {value2} {value3} רוט ={rotation} ({value4} לכתוב (s) {value5} לא אוויר{tileNote})"
this_command_can_only_be_used_by_players = "רק שחקנים יכולים להשתמש בפקודה זו."
hold_your_iris_wand_iris_wand_2 = "החזיקו את Iris שרביט (/iris wand)"
@@ -597,6 +597,7 @@ updated_wand_objects_iob = "Bacchetta aggiornata per objects/{value}.iob "
given_new_wand_objects_iob = "Nuova bacchetta fornita per objects/{value}.iob "
updated_wand_objects_iob_2 = "Bacchetta aggiornata per objects/{value}.iob "
placed = "§a{object} posizionato"
paste_waits_for_terrain_plan = "§eIl terreno in {x} {y} {z} è ancora in fase di pianificazione. Non è stato incollato nulla; esegui di nuovo l'incolla tra un momento."
you_need_hold_your_wand = "§eDevi tenere la bacchetta!"
file_already_exists_set_overwrite_true_overwrite_it = "§cIl file esiste già. Impostare overwrite=true per sovrascrivere."
failed_save_object_because_ioexception = "§cImpossibile salvare l'oggetto a causa di una IOException: {value}"
@@ -941,6 +942,7 @@ unknown_empty_object = "Oggetto sconosciuto o vuoto: {key}"
console_must_specify_coordinates_iris_object_paste_at_x_y = "La console deve specificare le coordinate: /iris object paste at <x> <y> <z> [rotate <degrees>] {key}"
you_are_not_looking_at_block_within_blocks = "Non stai guardando un blocco all'interno {value} blocchi."
paste_failed_partial_changes_recorded_undo = "Incollamento non riuscito: {value} (modifiche parziali registrate per l'annullamento)"
paste_waits_for_terrain_plan = "Il terreno in {value} {value2} {value3} è ancora in fase di pianificazione. Non è stato incollato nulla; esegui di nuovo l'incolla tra un momento."
placed_at_rot_write_s_non_air = "Posizionato {key} in {value} {value2} {value3} con rot={rotation} ({value4} scritture, {value5} blocchi non vuoti{tileNote})"
this_command_can_only_be_used_by_players = "Questo comando può essere usato solo dai giocatori."
hold_your_iris_wand_iris_wand_2 = "Impugna la bacchetta Iris. (/iris wand)"
@@ -600,6 +600,7 @@ updated_wand_objects_iob = "objects/{value}.iob 用に杖を更新しました "
given_new_wand_objects_iob = "objects/{value}.iob 用の新しい杖を渡しました "
updated_wand_objects_iob_2 = "objects/{value}.iob 用に杖を更新しました "
placed = "§a{object} を配置しました"
paste_waits_for_terrain_plan = "§e{x} {y} {z} の地形はまだ計画中です。何も貼り付けていません。少し待ってからもう一度貼り付けてください。"
you_need_hold_your_wand = "§e杖を手に持つ必要があります!"
file_already_exists_set_overwrite_true_overwrite_it = "§cファイルはすでに存在します。上書きするには overwrite=true を設定してください。"
failed_save_object_because_ioexception = "§cIOException によりオブジェクトを保存できませんでした: {value}"
@@ -944,6 +945,7 @@ unknown_empty_object = "不明または空のオブジェクト: {key}"
console_must_specify_coordinates_iris_object_paste_at_x_y = "コンソールは座標を指定しなければなりません: /iris object paste at <x> <y> <z> [rotate <degrees>] {key}"
you_are_not_looking_at_block_within_blocks = "{value} ブロック以内のブロックを見ていません。"
paste_failed_partial_changes_recorded_undo = "貼り付けに失敗しました: {value}(途中までの変更は元に戻せるよう記録されました)"
paste_waits_for_terrain_plan = "{value} {value2} {value3} の地形はまだ計画中です。何も貼り付けていません。少し待ってからもう一度貼り付けてください。"
placed_at_rot_write_s_non_air = "{key} を {value} {value2} {value3} に配置しました。rot={rotation}(書き込み {value4}、空気以外 {value5}{tileNote})"
this_command_can_only_be_used_by_players = "このコマンドはプレイヤーのみ使用できます。"
hold_your_iris_wand_iris_wand_2 = "Iris の杖を手に持ってください。(/iris wand)"
@@ -600,6 +600,7 @@ updated_wand_objects_iob = "지팡이 업데이트 objects/{value}.iob "
given_new_wand_objects_iob = "새로운 지팡이를 objects/{value}.iob "
updated_wand_objects_iob_2 = "지팡이 업데이트 objects/{value}.iob "
placed = "§a{object} 배치 완료"
paste_waits_for_terrain_plan = "§e{x} {y} {z}의 지형은 아직 계획 중입니다. 아무것도 붙여넣지 않았습니다. 잠시 후 다시 붙여넣기를 실행하세요."
you_need_hold_your_wand = "§e당신은 당신의 지팡이를 붙들 필요가 있습니다!"
file_already_exists_set_overwrite_true_overwrite_it = "§c파일이 이미 존재합니다. overwrite=true를 설정한다."
failed_save_object_because_ioexception = "§c객체를 저장하기 위해 실패 IOException: {value}"
@@ -944,6 +945,7 @@ unknown_empty_object = "알려진 또는 빈 객체: {key}"
console_must_specify_coordinates_iris_object_paste_at_x_y = "콘솔은 좌표를 지정해야 합니다: /iris object paste at <x> <y> <z> [rotate <degrees>] {key}"
you_are_not_looking_at_block_within_blocks = "블록을 찾고 있지 않습니다. {value} 블록."
paste_failed_partial_changes_recorded_undo = "붙여넣기 실패: {value} (불행의 변화)"
paste_waits_for_terrain_plan = "{value} {value2} {value3}의 지형은 아직 계획 중입니다. 아무것도 붙여넣지 않았습니다. 잠시 후 다시 붙여넣기를 실행하세요."
placed_at_rot_write_s_non_air = "{key}을(를) {value} {value2} {value3}에 배치했습니다. rot={rotation} (쓰기 {value4}회, 비공기 {value5}개{tileNote})"
this_command_can_only_be_used_by_players = "이 명령어는 플레이어만 사용할 수 있습니다."
hold_your_iris_wand_iris_wand_2 = "Iris 지팡이를 손에 드세요. (/iris wand)"
@@ -602,6 +602,7 @@ updated_wand_objects_iob = "Atnaujinta lazdelė objects/{value}.iob "
given_new_wand_objects_iob = "Atsižvelgiant į naują lazdelę objects/{value}.iob "
updated_wand_objects_iob_2 = "Atnaujinta lazdelė objects/{value}.iob "
placed = "§aPateikta {object}"
paste_waits_for_terrain_plan = "§eReljefas ties {x} {y} {z} dar planuojamas. Nieko neįklijuota; po akimirkos įklijuokite dar kartą."
you_need_hold_your_wand = "§eLaikyk lazdelę!"
file_already_exists_set_overwrite_true_overwrite_it = "§cFailas jau egzistuoja. Nustatyti perrašyti = teisinga jį perrašyti."
failed_save_object_because_ioexception = "§cNepavyko įrašyti objekto dėl IOException: {value}"
@@ -946,6 +947,7 @@ unknown_empty_object = "Nežinomas arba tuščias objektas: {key}"
console_must_specify_coordinates_iris_object_paste_at_x_y = "Konsolė turi nurodyti koordinates: /iris object paste at <x> <y> <z> [rotate <degrees>] {key}"
you_are_not_looking_at_block_within_blocks = "Tu nežiūri į bloką viduje {value} blokus."
paste_failed_partial_changes_recorded_undo = "Įklijuoti nepavyko: {value} (daliniai pakeitimai įrašyti atšaukimui)"
paste_waits_for_terrain_plan = "Reljefas ties {value} {value2} {value3} dar planuojamas. Nieko neįklijuota; po akimirkos įklijuokite dar kartą."
placed_at_rot_write_s_non_air = "Pateikta {key} : {value} {value2} {value3} puvinio ={rotation} ({value4} rašymas (-ai), {value5} ne oras{tileNote})"
this_command_can_only_be_used_by_players = "Šią komandą gali naudoti tik žaidėjai."
hold_your_iris_wand_iris_wand_2 = "Laikykite Iris lazdelės. (/iris wand)"
@@ -597,6 +597,7 @@ updated_wand_objects_iob = "Bijgewerkte toverstok voor objects/{value}.iob "
given_new_wand_objects_iob = "Gegeven nieuwe toverstok voor objects/{value}.iob "
updated_wand_objects_iob_2 = "Bijgewerkte toverstok voor objects/{value}.iob "
placed = "§aGeplaatst {object}"
paste_waits_for_terrain_plan = "§eHet terrein bij {x} {y} {z} wordt nog gepland. Er is niets geplakt; voer het plakken zo meteen opnieuw uit."
you_need_hold_your_wand = "§eJe moet je staf vasthouden!"
file_already_exists_set_overwrite_true_overwrite_it = "§cBestand bestaat al. Zet overwrite=true om het te overschrijven."
failed_save_object_because_ioexception = "§cOpslaan van object is mislukt vanwege een IOException: {value}"
@@ -941,6 +942,7 @@ unknown_empty_object = "Onbekend of leeg object: {key}"
console_must_specify_coordinates_iris_object_paste_at_x_y = "Console moet coördinaten specificeren: /iris object paste at <x> <y> <z> [rotate <degrees>] {key}"
you_are_not_looking_at_block_within_blocks = "U kijkt niet naar een blok binnen {value} blokken."
paste_failed_partial_changes_recorded_undo = "Plakken mislukt: {value} (gedeeltelijke wijzigingen vastgelegd om ongedaan te maken)"
paste_waits_for_terrain_plan = "Het terrein bij {value} {value2} {value3} wordt nog gepland. Er is niets geplakt; voer het plakken zo meteen opnieuw uit."
placed_at_rot_write_s_non_air = "Geplaatst {key} op {value} {value2} {value3} rot ={rotation} ({value4} schrijven(s), {value5} niet-lucht{tileNote})"
this_command_can_only_be_used_by_players = "Deze opdracht kan alleen door spelers worden gebruikt."
hold_your_iris_wand_iris_wand_2 = "Wacht even. Iris Toverstok. (/iris wand)"
@@ -602,6 +602,7 @@ updated_wand_objects_iob = "Aktualizacja różdżki objects/{value}.iob "
given_new_wand_objects_iob = "W przypadku nowej różdżki objects/{value}.iob "
updated_wand_objects_iob_2 = "Aktualizacja różdżki objects/{value}.iob "
placed = "§aUmieszczone {object}"
paste_waits_for_terrain_plan = "§eTeren w {x} {y} {z} jest nadal planowany. Nic nie wklejono; uruchom wklejanie ponownie za chwilę."
you_need_hold_your_wand = "§eMusisz trzymać różdżkę!"
file_already_exists_set_overwrite_true_overwrite_it = "§cPlik już istnieje. Ustaw nadpisanie = true, aby nadpisać."
failed_save_object_because_ioexception = "§cNie udało się zapisać obiektu z powodu IOException: {value}"
@@ -946,6 +947,7 @@ unknown_empty_object = "Nieznany lub pusty obiekt: {key}"
console_must_specify_coordinates_iris_object_paste_at_x_y = "Konsola musi określać współrzędne: /iris object paste at <x> <y> <z> [rotate <degrees>] {key}"
you_are_not_looking_at_block_within_blocks = "Nie patrzysz na blok wewnątrz {value} bloki."
paste_failed_partial_changes_recorded_undo = "Wklejanie nie powiodło się: {value} (częściowe zmiany zapisano do cofnięcia)"
paste_waits_for_terrain_plan = "Teren w {value} {value2} {value3} jest nadal planowany. Nic nie wklejono; uruchom wklejanie ponownie za chwilę."
placed_at_rot_write_s_non_air = "Umieszczone {key} w {value} {value2} {value3} rot ={rotation} ({value4} zapis (y), {value5} non- air{tileNote})"
this_command_can_only_be_used_by_players = "Tego polecenia mogą używać tylko gracze."
hold_your_iris_wand_iris_wand_2 = "Trzymaj się. Iris różdżka. (/iris wand)"
@@ -597,6 +597,7 @@ updated_wand_objects_iob = "Varinha actualizada para objects/{value}.iob "
given_new_wand_objects_iob = "Dada a nova varinha para objects/{value}.iob "
updated_wand_objects_iob_2 = "Varinha actualizada para objects/{value}.iob "
placed = "§aColocado {object}"
paste_waits_for_terrain_plan = "§eO terreno em {x} {y} {z} ainda está a ser planeado. Nada foi colado; volte a executar a colagem daqui a pouco."
you_need_hold_your_wand = "§eTens de segurar a varinha!"
file_already_exists_set_overwrite_true_overwrite_it = "§cO ficheiro já existe. Definir sobrescrever=verdadeiro para sobrescrevê-lo."
failed_save_object_because_ioexception = "§cFalha ao salvar o objeto por causa de uma IOException: {value}"
@@ -941,6 +942,7 @@ unknown_empty_object = "Objeto desconhecido ou vazio: {key}"
console_must_specify_coordinates_iris_object_paste_at_x_y = "O console deve especificar as coordenadas: /iris object paste at <x> <y> <z> [rotate <degrees>] {key}"
you_are_not_looking_at_block_within_blocks = "Você não está olhando para um bloco dentro {value} Blocos."
paste_failed_partial_changes_recorded_undo = "Falha ao colar: {value} (alterações parciais registadas para desfazer)"
paste_waits_for_terrain_plan = "O terreno em {value} {value2} {value3} ainda está a ser planeado. Nada foi colado; volte a executar a colagem daqui a pouco."
placed_at_rot_write_s_non_air = "Colocado {key} em {value} {value2} {value3} rot ={rotation} ({value4} escrever( s) {value5} não-ar{tileNote})"
this_command_can_only_be_used_by_players = "Este comando só pode ser utilizado por jogadores."
hold_your_iris_wand_iris_wand_2 = "Segura-te. Iris Varinha. (/iris wand)"
@@ -602,6 +602,7 @@ updated_wand_objects_iob = "Обновленная палочка для objects
given_new_wand_objects_iob = "Новая палочка для objects/{value}.iob "
updated_wand_objects_iob_2 = "Обновленная палочка для objects/{value}.iob "
placed = "§aразмещенный {object}"
paste_waits_for_terrain_plan = "§eРельеф в точке {x} {y} {z} ещё планируется. Ничего не вставлено; повторите вставку через мгновение."
you_need_hold_your_wand = "§eТы должен держать свою палочку!"
file_already_exists_set_overwrite_true_overwrite_it = "§cФайл уже существует. Настройте overwrite=true, чтобы переписать его."
failed_save_object_because_ioexception = "§cНе удалось спасти объект из-за IOException: {value}"
@@ -946,6 +947,7 @@ unknown_empty_object = "Неизвестный или пустой объект:
console_must_specify_coordinates_iris_object_paste_at_x_y = "Консоль должна указывать координаты: /iris object paste at <x> <y> <z> [rotate <degrees>] {key}"
you_are_not_looking_at_block_within_blocks = "Вы не смотрите на блок внутри {value} блоки."
paste_failed_partial_changes_recorded_undo = "Вставка не удалась: {value} (частичные изменения записаны для отмены)"
paste_waits_for_terrain_plan = "Рельеф в точке {value} {value2} {value3} ещё планируется. Ничего не вставлено; повторите вставку через мгновение."
placed_at_rot_write_s_non_air = "размещенный {key} в {value} {value2} {value3} ротация{rotation} ({value4} Пишите(а), {value5} невоздушный{tileNote})"
this_command_can_only_be_used_by_players = "Эту команду могут использовать только игроки."
hold_your_iris_wand_iris_wand_2 = "Держи. Iris палочка. (/iris wand)"
@@ -602,6 +602,7 @@ updated_wand_objects_iob = "Güncelleme için asa için objects/{value}.iob "
given_new_wand_objects_iob = "Yeni asa için objects/{value}.iob "
updated_wand_objects_iob_2 = "Güncelleme için asa için objects/{value}.iob "
placed = "§ayerleştirildi Place {object}"
paste_waits_for_terrain_plan = "§e{x} {y} {z} konumundaki arazi hâlâ planlanıyor. Hiçbir şey yapıştırılmadı; yapıştırmayı birazdan yeniden çalıştırın."
you_need_hold_your_wand = "§easa'ınızı tutmanız gerekir!"
file_already_exists_set_overwrite_true_overwrite_it = "§cDosya zaten var. Bunu yazmak için son derece doğru bir şekilde ayarlayın."
failed_save_object_because_ioexception = "§cBir nesneyi kurtarmak için başarısız oldu çünkü bir IOException: {value}"
@@ -946,6 +947,7 @@ unknown_empty_object = "Bilinmeyen veya boş nesne: {key}"
console_must_specify_coordinates_iris_object_paste_at_x_y = "Konsol koordinatları belirtmelidir: /iris object paste at <x> <y> <z> [rotate <degrees>] {key}"
you_are_not_looking_at_block_within_blocks = "İçinde bir blok aramıyorsunuz {value} Bloklar."
paste_failed_partial_changes_recorded_undo = "Yapıştırma başarısız oldu: {value} (kısmi değişiklikler geri alma için kaydedildi)"
paste_waits_for_terrain_plan = "{value} {value2} {value3} konumundaki arazi hâlâ planlanıyor. Hiçbir şey yapıştırılmadı; yapıştırmayı birazdan yeniden çalıştırın."
placed_at_rot_write_s_non_air = "{key}, {value} {value2} {value3} konumuna rot={rotation} ile yerleştirildi ({value4} yazma, {value5} hava olmayan{tileNote})"
this_command_can_only_be_used_by_players = "Bu komutu yalnızca oyuncular kullanabilir."
hold_your_iris_wand_iris_wand_2 = "tut Iris b. (/iris wand)"
@@ -600,6 +600,7 @@ updated_wand_objects_iob = "Name objects/{value}.iob "
given_new_wand_objects_iob = "Đưa cây đũa mới cho objects/{value}.iob "
updated_wand_objects_iob_2 = "Name objects/{value}.iob "
placed = "§aĐã đặt {object}"
paste_waits_for_terrain_plan = "§eĐịa hình tại {x} {y} {z} vẫn đang được lập kế hoạch. Chưa dán gì cả; hãy chạy lại lệnh dán sau giây lát."
you_need_hold_your_wand = "§eAnh cần phải giữ đũa phép!"
file_already_exists_set_overwrite_true_overwrite_it = "§cTập tin đã có. Đặt ghi đè bằng chân dung để ghi đè lên nó."
failed_save_object_because_ioexception = "§cLỗi lưu đối tượng vì một IOException: {value}"
@@ -944,6 +945,7 @@ unknown_empty_object = "Đối tượng không rõ hay rỗng: {key}"
console_must_specify_coordinates_iris_object_paste_at_x_y = "Cần phải xác định tọa độ: /iris object paste at <x> <y> <z> [rotate <degrees>] {key}"
you_are_not_looking_at_block_within_blocks = "Bạn không nhìn vào một khối trong {value} tòa nhà."
paste_failed_partial_changes_recorded_undo = "Dán thất bại: {value} (các thay đổi một phần đã được ghi lại để hoàn tác)"
paste_waits_for_terrain_plan = "Địa hình tại {value} {value2} {value3} vẫn đang được lập kế hoạch. Chưa dán gì cả; hãy chạy lại lệnh dán sau giây lát."
placed_at_rot_write_s_non_air = "Đã đặt {key} vào {value} {value2} {value3} thối ={rotation} ({value4} ghi(s), {value5} không phải không gian{tileNote})"
this_command_can_only_be_used_by_players = "Chỉ người chơi mới có thể sử dụng lệnh này."
hold_your_iris_wand_iris_wand_2 = "Giữ lấy Iris đũa phép. (/iris wand)"
@@ -600,6 +600,7 @@ updated_wand_objects_iob = "更新的魔杖 objects/{value}.iob "
given_new_wand_objects_iob = "给新魔杖 objects/{value}.iob "
updated_wand_objects_iob_2 = "更新的魔杖 objects/{value}.iob "
placed = "§a已放置 {object}"
paste_waits_for_terrain_plan = "§e{x} {y} {z} 处的地形仍在规划中。未粘贴任何内容;请稍后再次执行粘贴。"
you_need_hold_your_wand = "§e你得拿着你的魔杖!"
file_already_exists_set_overwrite_true_overwrite_it = "§c文件已经存在 。 设置覆盖=真以覆盖它."
failed_save_object_because_ioexception = "§c由于保存对象失败 IOException: {value}"
@@ -944,6 +945,7 @@ unknown_empty_object = "未知或空对象 : {key}"
console_must_specify_coordinates_iris_object_paste_at_x_y = "控制台必须指定坐标 : /iris object paste at <x> <y> <z> [rotate <degrees>] {key}"
you_are_not_looking_at_block_within_blocks = "你不看一个街区里面 {value} 块。"
paste_failed_partial_changes_recorded_undo = "粘贴失败 : {value} (部分更改记录为撤销)"
paste_waits_for_terrain_plan = "{value} {value2} {value3} 处的地形仍在规划中。未粘贴任何内容;请稍后再次执行粘贴。"
placed_at_rot_write_s_non_air = "已放置 {key} 时间 {value} {value2} {value3} 腐烂={rotation} ({value4} 写入(s) {value5} 非空调{tileNote})"
this_command_can_only_be_used_by_players = "此命令只能由玩家使用。"
hold_your_iris_wand_iris_wand_2 = "拿着 Iris 魔杖 魔棍 (/iris wand)"
@@ -600,6 +600,7 @@ updated_wand_objects_iob = "更新的魔杖 objects/{value}.iob "
given_new_wand_objects_iob = "給新魔杖 objects/{value}.iob "
updated_wand_objects_iob_2 = "更新的魔杖 objects/{value}.iob "
placed = "§a已放置 {object}"
paste_waits_for_terrain_plan = "§e{x} {y} {z} 處的地形仍在規劃中。未貼上任何內容;請稍後再次執行貼上。"
you_need_hold_your_wand = "§e你得拿著你的魔杖!"
file_already_exists_set_overwrite_true_overwrite_it = "§c檔案已經存在 。 設定覆蓋=真以覆蓋它."
failed_save_object_because_ioexception = "§c由於儲存物件失敗 IOException: {value}"
@@ -944,6 +945,7 @@ unknown_empty_object = "未知或空物件 : {key}"
console_must_specify_coordinates_iris_object_paste_at_x_y = "控制檯必須指定座標 : /iris object paste at <x> <y> <z> [rotate <degrees>] {key}"
you_are_not_looking_at_block_within_blocks = "你不看一個街區裡面 {value} 塊。"
paste_failed_partial_changes_recorded_undo = "貼上失敗 : {value} (部分更改記錄為撤銷)"
paste_waits_for_terrain_plan = "{value} {value2} {value3} 處的地形仍在規劃中。未貼上任何內容;請稍後再次執行貼上。"
placed_at_rot_write_s_non_air = "已放置 {key} 時間 {value} {value2} {value3} 腐爛={rotation} ({value4} 寫入(s) {value5} 非空調{tileNote})"
this_command_can_only_be_used_by_players = "此命令只能由玩家使用。"
hold_your_iris_wand_iris_wand_2 = "拿著 Iris 魔杖 魔棍 (/iris wand)"
@@ -0,0 +1,51 @@
package art.arcane.iris.generation.mantle;
import art.arcane.iris.generation.hydrology.raster.WaterRole;
import art.arcane.iris.structure.object.HydrologyWaterFixture;
import art.arcane.iris.structure.object.IrisObject;
import art.arcane.iris.structure.object.IrisObjectPlacement;
import art.arcane.iris.structure.object.IrisObjectRotation;
import art.arcane.iris.structure.object.ObjectPlaceMode;
import art.arcane.iris.structure.placement.IrisStructure;
import art.arcane.iris.structure.placement.PlacedStructurePiece;
import art.arcane.iris.testsupport.PlatformBinding;
import art.arcane.volmlib.util.math.RNG;
import org.junit.Rule;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class IrisStructureComponentWaterTest {
@Rule
public final PlatformBinding platform = PlatformBinding.mockPlatform();
private final HydrologyWaterFixture world = new HydrologyWaterFixture();
@Test
public void forcedSinglePieceStructureStaysOutOfRiverWater() {
world.water(WaterRole.CHANNEL, 9, 13);
HydrologyWaterFixture.Placer placer = world.placer();
IrisObject object = HydrologyWaterFixture.raft();
IrisObjectPlacement config = IrisStructureComponent.piecePlacement(new IrisStructure(), piece(object), ObjectPlaceMode.CENTER_HEIGHT);
assertTrue(config.isForcePlace());
assertEquals(-1, object.place(0, -1, 0, placer, config, new RNG(7L), world.data()));
assertTrue(placer.writes().isEmpty());
}
@Test
public void forcedSinglePieceStructureStillPlacesOnDryLand() {
HydrologyWaterFixture.Placer placer = world.placer();
IrisObject object = HydrologyWaterFixture.raft();
IrisObjectPlacement config = IrisStructureComponent.piecePlacement(new IrisStructure(), piece(object), ObjectPlaceMode.CENTER_HEIGHT);
assertTrue(object.place(0, -1, 0, placer, config, new RNG(7L), world.data()) >= 0);
assertFalse(placer.writes().isEmpty());
}
private static PlacedStructurePiece piece(IrisObject object) {
return new PlacedStructurePiece(null, object, 0, 0, 0, IrisObjectRotation.of(0, 0, 0), -1, 0, -1, 1, 2, 1);
}
}
@@ -1,5 +1,6 @@
package art.arcane.iris.generation.runtime;
import art.arcane.iris.generation.stream.ProvisionalAnswerException;
import art.arcane.iris.world.history.SavedBiomeUnavailableException;
import art.arcane.volmlib.util.mantle.MantleClosedException;
import org.junit.Test;
@@ -24,6 +25,7 @@ public class GenerationFailuresTest {
assertTrue(GenerationFailures.isEngineFailure(new SavedBiomeUnavailableException("loading", true)));
assertTrue(GenerationFailures.isEngineFailure(new GenerationSessionException("sealed", true)));
assertTrue(GenerationFailures.isEngineFailure(new OutOfMemoryError()));
assertTrue(GenerationFailures.isEngineFailure(new ProvisionalAnswerException("water not planned")));
assertTrue(GenerationFailures.isEngineFailure(new CompletionException(
new IllegalStateException("placement failed", new GenerationClosedException("router closed")))));
}
@@ -3,6 +3,7 @@ package art.arcane.iris.structure.nativegen;
import art.arcane.volmlib.nativelib.terrain.structure.NativeStructureVolume;
import art.arcane.iris.generation.block.TileData;
import art.arcane.iris.generation.hydrology.raster.WaterRole;
import art.arcane.iris.generation.terrain.IrisDimension;
import art.arcane.iris.structure.object.IObjectPlacer;
import art.arcane.iris.structure.object.IrisObject;
@@ -30,6 +31,7 @@ import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyDouble;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
@@ -52,8 +54,12 @@ public class NativeStructureObjectVetoTest {
log = state("minecraft:oak_log", true);
@SuppressWarnings("unchecked")
ProceduralStream<Double> heightStream = mock(ProceduralStream.class);
@SuppressWarnings("unchecked")
ProceduralStream<WaterRole> roles = mock(ProceduralStream.class);
when(roles.get(anyDouble(), anyDouble())).thenReturn(WaterRole.NONE);
IrisComplex complex = mock(IrisComplex.class);
when(complex.getHeightStream()).thenReturn(heightStream);
when(complex.getWaterRoleStream()).thenReturn(roles);
engine = mock(Engine.class);
when(engine.getHeight()).thenReturn(256);
when(engine.getHeight(anyInt(), anyInt())).thenReturn(SURFACE_Y);
@@ -0,0 +1,248 @@
package art.arcane.iris.structure.object;
import art.arcane.iris.generation.block.TileData;
import art.arcane.iris.generation.hydrology.raster.WaterRole;
import art.arcane.iris.generation.runtime.Engine;
import art.arcane.iris.generation.runtime.IrisComplex;
import art.arcane.iris.generation.stream.ProvisionalSampling;
import art.arcane.iris.generation.terrain.IrisDimension;
import art.arcane.iris.pack.loading.IrisData;
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
import art.arcane.volmlib.util.stream.ProceduralStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.mockito.ArgumentMatchers.anyDouble;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public final class HydrologyWaterFixture {
public static final int LAND_ABOVE_SEA = 17;
public static final int WATER_RADIUS = 8;
private final Map<Long, Column> columns = new HashMap<>();
private final IrisData data;
private final Engine engine;
private final IrisComplex complex;
private final int seaLevel;
private Column water;
private boolean provisional;
public HydrologyWaterFixture() {
IrisDimension dimension = new IrisDimension();
seaLevel = dimension.getFluidHeight();
@SuppressWarnings("unchecked")
ProceduralStream<Double> heads = mock(ProceduralStream.class);
when(heads.get(anyDouble(), anyDouble())).thenAnswer(invocation -> (double) headAt(block(invocation.getArgument(0)), block(invocation.getArgument(1))));
when(heads.getDouble(anyDouble(), anyDouble())).thenAnswer(invocation -> (double) headAt(block(invocation.getArgument(0)), block(invocation.getArgument(1))));
@SuppressWarnings("unchecked")
ProceduralStream<WaterRole> roles = mock(ProceduralStream.class);
when(roles.get(anyDouble(), anyDouble())).thenAnswer(invocation -> roleAt(block(invocation.getArgument(0)), block(invocation.getArgument(1))));
complex = mock(IrisComplex.class);
when(complex.getWaterHeadStream()).thenReturn(heads);
when(complex.getWaterRoleStream()).thenReturn(roles);
when(complex.hasWaterOrShore(anyInt(), anyInt())).thenAnswer(invocation -> waterOrShore(roleAt(invocation.getArgument(0), invocation.getArgument(1))));
engine = mock(Engine.class);
when(engine.getHeight()).thenReturn(256);
when(engine.getComplex()).thenReturn(complex);
when(engine.getDimension()).thenReturn(dimension);
data = mock(IrisData.class);
when(data.getEngine()).thenReturn(engine);
}
public IrisData data() {
return data;
}
public IrisComplex complex() {
return complex;
}
public int seaLevel() {
return seaLevel;
}
public void water(WaterRole role, int floorAboveSea, int headAboveSea) {
water = new Column(role, seaLevel + floorAboveSea, seaLevel + headAboveSea);
}
public void column(int x, int z, WaterRole role, int floorAboveSea, int headAboveSea) {
columns.put(key(x, z), new Column(role, seaLevel + floorAboveSea, seaLevel + headAboveSea));
}
public void provisional() {
provisional = true;
}
public int floorAt(int x, int z) {
return columnAt(x, z).floor();
}
public int headAt(int x, int z) {
Column column = columnAt(x, z);
return column.role().wet() ? column.head() : seaLevel;
}
public Placer placer() {
return new Placer();
}
public static IrisObject pillar() {
IrisObject object = new IrisObject(3, 3, 3);
object.setUnsigned(1, 0, 1, solid());
object.setUnsigned(1, 1, 1, solid());
return object;
}
public static IrisObject raft() {
IrisObject object = new IrisObject(3, 3, 3);
for (int x = 0; x < 3; x++) {
for (int z = 0; z < 3; z++) {
object.setUnsigned(x, 0, z, solid());
}
}
object.setUnsigned(1, 1, 1, solid());
return object;
}
private static NativeBlockState solid() {
NativeBlockState solid = mock(NativeBlockState.class);
when(solid.isSolid()).thenReturn(true);
when(solid.key()).thenReturn("minecraft:stone");
when(solid.materialKey()).thenReturn("minecraft:stone");
return solid;
}
private WaterRole roleAt(int x, int z) {
return columnAt(x, z).role();
}
private Column columnAt(int x, int z) {
if (provisional) {
ProvisionalSampling.mark();
}
Column override = columns.get(key(x, z));
if (override != null) {
return override;
}
if (water != null && Math.abs(x) <= WATER_RADIUS && Math.abs(z) <= WATER_RADIUS) {
return water;
}
return new Column(WaterRole.NONE, seaLevel + LAND_ABOVE_SEA, seaLevel);
}
private static boolean waterOrShore(WaterRole role) {
return switch (role) {
case CHANNEL, POND, MOUTH, CASCADE, WATERFALL, INLET, SHORE, POND_SHORE, DAM -> true;
case NONE, BANK -> false;
};
}
private static int block(Object coordinate) {
return (int) Math.floor(((Number) coordinate).doubleValue());
}
private static long key(int x, int z) {
return ((long) x << 32) ^ (z & 0xffffffffL);
}
private record Column(WaterRole role, int floor, int head) {
}
public final class Placer implements IObjectPlacer {
private final List<Integer> writes = new ArrayList<>();
public List<Integer> writes() {
return writes;
}
public int lowestWrite() {
int lowest = Integer.MAX_VALUE;
for (int y : writes) {
lowest = Math.min(lowest, y);
}
return lowest;
}
public int highestWrite() {
int highest = Integer.MIN_VALUE;
for (int y : writes) {
highest = Math.max(highest, y);
}
return highest;
}
@Override
public int getHighest(int x, int z, IrisData data) {
return getHighest(x, z, data, false);
}
@Override
public int getHighest(int x, int z, IrisData data, boolean ignoreFluid) {
int floor = floorAt(x, z);
return ignoreFluid ? floor : Math.max(floor, getFluidHeight(x, z));
}
@Override
public void set(int x, int y, int z, NativeBlockState state) {
writes.add(y);
}
@Override
public NativeBlockState get(int x, int y, int z) {
return null;
}
@Override
public boolean isPreventingDecay() {
return false;
}
@Override
public boolean isCarved(int x, int y, int z) {
return false;
}
@Override
public boolean isSolid(int x, int y, int z) {
return false;
}
@Override
public boolean isUnderwater(int x, int z) {
return getHighest(x, z, data, true) < getFluidHeight(x, z);
}
@Override
public int getFluidHeight() {
return seaLevel;
}
@Override
public boolean isDebugSmartBore() {
return false;
}
@Override
public void setTile(int x, int y, int z, TileData tile) {
}
@Override
public <T> void setData(int x, int y, int z, T value) {
}
@Override
public <T> T getData(int x, int y, int z, Class<T> type) {
return null;
}
@Override
public Engine getEngine() {
return engine;
}
}
}
@@ -1,5 +1,6 @@
package art.arcane.iris.structure.object;
import art.arcane.iris.generation.hydrology.raster.WaterRole;
import art.arcane.iris.generation.block.BlockDataMergeSupport;
import art.arcane.iris.generation.block.IrisBlockData;
import art.arcane.iris.generation.block.TileData;
@@ -110,8 +111,11 @@ public class ObjectPlacementGoldenTest {
ProceduralStream<NativeBlockState> rock = mock(ProceduralStream.class, withSettings().stubOnly());
when(rock.get(anyDouble(), anyDouble())).thenAnswer(invocation -> state("minecraft:stone"));
ProceduralStream<WaterRole> roles = mock(ProceduralStream.class, withSettings().stubOnly());
when(roles.get(anyDouble(), anyDouble())).thenReturn(WaterRole.NONE);
IrisComplex complex = mock(IrisComplex.class, withSettings().stubOnly());
when(complex.getRockStream()).thenReturn(rock);
when(complex.getWaterRoleStream()).thenReturn(roles);
IrisDimension dimension = mock(IrisDimension.class, withSettings().stubOnly());
engine = mock(Engine.class, withSettings().stubOnly());
when(engine.getHeight()).thenReturn(256);
@@ -1,27 +1,19 @@
package art.arcane.iris.structure.object;
import art.arcane.iris.generation.block.TileData;
import art.arcane.iris.generation.runtime.Engine;
import art.arcane.iris.generation.runtime.IrisComplex;
import art.arcane.iris.generation.stream.ProvisionalSampling;
import art.arcane.iris.generation.terrain.IrisDimension;
import art.arcane.iris.pack.loading.IrisData;
import art.arcane.iris.generation.hydrology.raster.WaterRole;
import art.arcane.iris.generation.stream.ProvisionalAnswerException;
import art.arcane.iris.testsupport.PlatformBinding;
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
import art.arcane.volmlib.util.math.RNG;
import art.arcane.volmlib.util.stream.ProceduralStream;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyDouble;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -30,125 +22,133 @@ public class PlacementModuleSurfaceSupportTest {
@Rule
public final PlatformBinding platform = PlatformBinding.mockPlatform();
private static final int LAND_ABOVE_SEA = 17;
private static final int WATER_RADIUS = 8;
private IrisData data;
private Engine engine;
private IrisComplex complex;
private int dimensionFluidHeight;
private int waterFloor;
private int waterHead;
private boolean provisionalWater;
@Before
public void bindEngine() {
IrisDimension dimension = new IrisDimension();
dimensionFluidHeight = dimension.getFluidHeight();
@SuppressWarnings("unchecked")
ProceduralStream<Double> waterHeads = mock(ProceduralStream.class);
when(waterHeads.get(anyDouble(), anyDouble())).thenAnswer(invocation -> {
if (provisionalWater) {
ProvisionalSampling.mark();
}
return (double) headAt((int) Math.floor((double) invocation.getArgument(0)), (int) Math.floor((double) invocation.getArgument(1)));
});
complex = mock(IrisComplex.class);
when(complex.getWaterHeadStream()).thenReturn(waterHeads);
when(complex.hasWaterOrShore(anyInt(), anyInt())).thenAnswer(invocation -> {
if (provisionalWater) {
ProvisionalSampling.mark();
}
return isWater(invocation.getArgument(0), invocation.getArgument(1));
});
engine = mock(Engine.class);
when(engine.getHeight()).thenReturn(256);
when(engine.getComplex()).thenReturn(complex);
when(engine.getDimension()).thenReturn(dimension);
data = mock(IrisData.class);
when(data.getEngine()).thenReturn(engine);
}
private final HydrologyWaterFixture world = new HydrologyWaterFixture();
@Test
public void underwaterObjectsPlaceInPonds() {
water(7, 13);
WaterPlacer placer = new WaterPlacer();
IrisObjectPlacement placement = placement();
placement.setUnderwater(true);
world.water(WaterRole.POND, 7, 13);
HydrologyWaterFixture.Placer placer = world.placer();
assertTrue(place(placer, placement) >= 0);
assertTrue(place(HydrologyWaterFixture.pillar(), placer, underwater()) >= 0);
assertFalse(placer.writes().isEmpty());
assertEquals(waterFloor, placer.lowestWrite());
assertTrue(placer.highestWrite() < waterHead);
assertEquals(world.floorAt(0, 0), placer.lowestWrite());
assertTrue(placer.highestWrite() < world.headAt(0, 0));
}
@Test
public void underwaterObjectsNeedWaterAboveTheirBase() {
water(12, 13);
WaterPlacer placer = new WaterPlacer();
IrisObjectPlacement placement = placement();
placement.setUnderwater(true);
public void underwaterObjectsSkipWaterTooShallowForTheirResolvedY() {
world.water(WaterRole.POND, 9, 13);
HydrologyWaterFixture.Placer deep = world.placer();
assertTrue(place(HydrologyWaterFixture.pillar(), deep, underwater()) >= 0);
assertEquals(-1, place(placer, placement));
assertTrue(placer.writes().isEmpty());
world.water(WaterRole.POND, 10, 13);
HydrologyWaterFixture.Placer shallow = world.placer();
assertEquals(-1, place(HydrologyWaterFixture.pillar(), shallow, underwater()));
assertTrue(shallow.writes().isEmpty());
}
@Test
public void underwaterObjectsTreatLavaPondsLikeLavaSeas() {
NativeBlockState lava = mock(NativeBlockState.class);
when(lava.key()).thenReturn("minecraft:lava");
when(world.complex().resolveWaterFluid(anyInt(), anyInt())).thenReturn(lava);
world.water(WaterRole.POND, 7, 13);
HydrologyWaterFixture.Placer placer = world.placer();
assertTrue(place(HydrologyWaterFixture.pillar(), placer, underwater()) >= 0);
assertEquals(world.floorAt(0, 0), placer.lowestWrite());
}
@Test
public void onwaterObjectsFloatOnRivers() {
water(9, 13);
WaterPlacer placer = new WaterPlacer();
IrisObjectPlacement placement = placement();
placement.setOnwater(true);
world.water(WaterRole.CHANNEL, 9, 13);
HydrologyWaterFixture.Placer placer = world.placer();
assertTrue(place(placer, placement) >= 0);
assertEquals(waterHead, placer.lowestWrite());
assertTrue(place(HydrologyWaterFixture.pillar(), placer, onwater()) >= 0);
assertEquals(world.headAt(0, 0), placer.lowestWrite());
}
@Test
public void onwaterObjectsSkipDryColumns() {
WaterPlacer placer = new WaterPlacer();
IrisObjectPlacement placement = placement();
placement.setOnwater(true);
HydrologyWaterFixture.Placer placer = world.placer();
assertEquals(-1, place(placer, placement));
assertEquals(-1, place(HydrologyWaterFixture.pillar(), placer, onwater()));
assertTrue(placer.writes().isEmpty());
}
@Test
public void forcePlaceObjectsPlaceInRiverWater() {
water(9, 13);
WaterPlacer placer = new WaterPlacer();
IrisObjectPlacement placement = placement();
placement.setForcePlace(true);
world.water(WaterRole.CHANNEL, 9, 13);
HydrologyWaterFixture.Placer placer = world.placer();
assertTrue(place(placer, placement) >= 0);
assertEquals(waterHead, placer.lowestWrite());
assertTrue(place(HydrologyWaterFixture.pillar(), placer, forced()) >= 0);
assertEquals(world.headAt(0, 0), placer.lowestWrite());
}
@Test
public void landObjectsStayOutOfRiverWater() {
water(9, 13);
WaterPlacer placer = new WaterPlacer();
world.water(WaterRole.CHANNEL, 9, 13);
HydrologyWaterFixture.Placer placer = world.placer();
assertEquals(-1, place(placer, placement()));
assertEquals(-1, place(HydrologyWaterFixture.pillar(), placer, placement()));
assertTrue(placer.writes().isEmpty());
}
@Test
public void flatPondsTakeWideWaterObjects() {
world.water(WaterRole.POND, 5, 13);
for (IrisObjectPlacement placement : List.of(underwater(), onwater(), forced())) {
HydrologyWaterFixture.Placer placer = world.placer();
assertTrue(place(HydrologyWaterFixture.raft(), placer, placement) >= 0);
assertFalse(placer.writes().isEmpty());
}
}
@Test
public void onwaterObjectsSkipCascadeSteps() {
world.water(WaterRole.CHANNEL, 9, 13);
world.column(1, 0, WaterRole.CASCADE, 8, 11);
HydrologyWaterFixture.Placer placer = world.placer();
assertEquals(-1, place(HydrologyWaterFixture.raft(), placer, onwater()));
assertTrue(placer.writes().isEmpty());
}
@Test
public void underwaterObjectsSkipDamWalls() {
world.water(WaterRole.POND, 5, 13);
world.column(1, 0, WaterRole.DAM, 14, 0);
HydrologyWaterFixture.Placer placer = world.placer();
assertEquals(-1, place(HydrologyWaterFixture.raft(), placer, underwater()));
assertTrue(placer.writes().isEmpty());
}
@Test
public void waterObjectsSkipWaterAtAnotherHead() {
world.water(WaterRole.CHANNEL, 9, 13);
world.column(1, 0, WaterRole.CHANNEL, 8, 12);
for (IrisObjectPlacement placement : List.of(underwater(), onwater(), forced())) {
HydrologyWaterFixture.Placer placer = world.placer();
assertEquals(-1, place(HydrologyWaterFixture.raft(), placer, placement));
assertTrue(placer.writes().isEmpty());
}
}
@Test
public void waterObjectsNeverPlaceOnProvisionalHydrology() {
water(7, 13);
provisionalWater = true;
IrisObjectPlacement underwater = placement();
underwater.setUnderwater(true);
IrisObjectPlacement onwater = placement();
onwater.setOnwater(true);
IrisObjectPlacement forced = placement();
forced.setForcePlace(true);
world.water(WaterRole.POND, 7, 13);
world.provisional();
for (IrisObjectPlacement placement : List.of(underwater, onwater, forced)) {
WaterPlacer placer = new WaterPlacer();
for (IrisObjectPlacement placement : List.of(underwater(), onwater(), forced())) {
HydrologyWaterFixture.Placer placer = world.placer();
IllegalStateException error = assertThrows(IllegalStateException.class, () -> place(placer, placement));
ProvisionalAnswerException error = assertThrows(ProvisionalAnswerException.class,
() -> place(HydrologyWaterFixture.pillar(), placer, placement));
assertTrue(error.getMessage().contains("provisional"));
assertTrue(placer.writes().isEmpty());
@@ -157,34 +157,36 @@ public class PlacementModuleSurfaceSupportTest {
@Test
public void landObjectsNeverPlaceOnProvisionalHydrology() {
provisionalWater = true;
WaterPlacer placer = new WaterPlacer();
world.provisional();
HydrologyWaterFixture.Placer placer = world.placer();
IllegalStateException error = assertThrows(IllegalStateException.class, () -> place(placer, placement()));
assertTrue(error.getMessage().contains("provisional"));
assertThrows(ProvisionalAnswerException.class, () -> place(HydrologyWaterFixture.pillar(), placer, placement()));
assertTrue(placer.writes().isEmpty());
}
private void water(int floorAboveSea, int headAboveSea) {
waterFloor = dimensionFluidHeight + floorAboveSea;
waterHead = dimensionFluidHeight + headAboveSea;
@Test
public void provisionalAnswersStopABoreBeforeItClearsAir() {
world.provisional();
HydrologyWaterFixture.Placer placer = world.placer();
IrisObjectPlacement placement = placement();
placement.setBore(true);
assertThrows(ProvisionalAnswerException.class, () -> place(HydrologyWaterFixture.pillar(), placer, placement));
assertTrue(placer.writes().isEmpty());
}
private boolean isWater(int x, int z) {
return waterHead > waterFloor && Math.abs(x) <= WATER_RADIUS && Math.abs(z) <= WATER_RADIUS;
@Test
public void explicitPlacementsIgnoreProvisionalAnswers() {
world.provisional();
HydrologyWaterFixture.Placer placer = world.placer();
int surface = world.floorAt(0, 0);
assertTrue(HydrologyWaterFixture.pillar().place(0, surface + 1, 0, placer, placement(), new RNG(1234L), world.data()) >= 0);
assertFalse(placer.writes().isEmpty());
}
private int headAt(int x, int z) {
return isWater(x, z) ? waterHead : dimensionFluidHeight;
}
private int floorAt(int x, int z) {
return isWater(x, z) ? waterFloor : dimensionFluidHeight + LAND_ABOVE_SEA;
}
private int place(WaterPlacer placer, IrisObjectPlacement placement) {
return object().place(0, -1, 0, placer, placement, new RNG(1234L), data);
private int place(IrisObject object, HydrologyWaterFixture.Placer placer, IrisObjectPlacement placement) {
return object.place(0, -1, 0, placer, placement, new RNG(1234L), world.data());
}
private static IrisObjectPlacement placement() {
@@ -193,107 +195,21 @@ public class PlacementModuleSurfaceSupportTest {
return placement;
}
private static IrisObject object() {
NativeBlockState solid = mock(NativeBlockState.class);
when(solid.isSolid()).thenReturn(true);
when(solid.key()).thenReturn("minecraft:stone");
when(solid.materialKey()).thenReturn("minecraft:stone");
IrisObject object = new IrisObject(3, 3, 3);
object.setUnsigned(1, 0, 1, solid);
object.setUnsigned(1, 1, 1, solid);
return object;
private static IrisObjectPlacement underwater() {
IrisObjectPlacement placement = placement();
placement.setUnderwater(true);
return placement;
}
private final class WaterPlacer implements IObjectPlacer {
private final List<Integer> writes = new ArrayList<>();
private static IrisObjectPlacement onwater() {
IrisObjectPlacement placement = placement();
placement.setOnwater(true);
return placement;
}
private List<Integer> writes() {
return writes;
}
private int lowestWrite() {
int lowest = Integer.MAX_VALUE;
for (int y : writes) {
lowest = Math.min(lowest, y);
}
return lowest;
}
private int highestWrite() {
int highest = Integer.MIN_VALUE;
for (int y : writes) {
highest = Math.max(highest, y);
}
return highest;
}
@Override
public int getHighest(int x, int z, IrisData data) {
return getHighest(x, z, data, false);
}
@Override
public int getHighest(int x, int z, IrisData data, boolean ignoreFluid) {
int floor = floorAt(x, z);
return ignoreFluid ? floor : Math.max(floor, getFluidHeight(x, z));
}
@Override
public void set(int x, int y, int z, NativeBlockState state) {
writes.add(y);
}
@Override
public NativeBlockState get(int x, int y, int z) {
return null;
}
@Override
public boolean isPreventingDecay() {
return false;
}
@Override
public boolean isCarved(int x, int y, int z) {
return false;
}
@Override
public boolean isSolid(int x, int y, int z) {
return false;
}
@Override
public boolean isUnderwater(int x, int z) {
return getHighest(x, z, data, true) < getFluidHeight(x, z);
}
@Override
public int getFluidHeight() {
return dimensionFluidHeight;
}
@Override
public boolean isDebugSmartBore() {
return false;
}
@Override
public void setTile(int x, int y, int z, TileData tile) {
}
@Override
public <T> void setData(int x, int y, int z, T value) {
}
@Override
public <T> T getData(int x, int y, int z, Class<T> type) {
return null;
}
@Override
public Engine getEngine() {
return engine;
}
private static IrisObjectPlacement forced() {
IrisObjectPlacement placement = placement();
placement.setForcePlace(true);
return placement;
}
}
@@ -0,0 +1,147 @@
package art.arcane.iris.world.tree;
import art.arcane.iris.generation.biome.IrisBiome;
import art.arcane.iris.generation.decoration.tree.IrisTree;
import art.arcane.iris.generation.decoration.tree.IrisTreeSize;
import art.arcane.iris.generation.runtime.Engine;
import art.arcane.iris.generation.runtime.EngineTarget;
import art.arcane.iris.generation.runtime.GenerationSessionManager;
import art.arcane.iris.generation.runtime.IrisComplex;
import art.arcane.iris.generation.stream.ProvisionalSampling;
import art.arcane.iris.generation.terrain.IrisDimension;
import art.arcane.iris.pack.validation.PackCompatReport;
import art.arcane.iris.pack.loading.IrisData;
import art.arcane.iris.pack.loading.ResourceLoader;
import art.arcane.iris.platform.generation.PlatformChunkGenerator;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.structure.object.HydrologyWaterFixture;
import art.arcane.iris.structure.object.IrisObject;
import art.arcane.iris.structure.object.IrisObjectPlacement;
import art.arcane.iris.testsupport.PlatformBinding;
import art.arcane.iris.world.IrisToolbelt;
import art.arcane.iris.world.IrisWorld;
import art.arcane.volmlib.util.collection.KList;
import art.arcane.volmlib.util.data.Cuboid;
import org.bukkit.Location;
import org.bukkit.TreeType;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.event.world.StructureGrowEvent;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.MockedStatic;
import java.util.List;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public class TreeSVCSaplingTest {
private static final int SAPLING_Y = -20;
@Rule
public final PlatformBinding platform = PlatformBinding.mockPlatform();
@Test
public void provisionalTerrainCancelsGrowthAndKeepsTheSapling() {
Fixture fixture = new Fixture(true);
StructureGrowEvent event = fixture.event();
fixture.grow(event);
assertTrue(event.isCancelled());
verify(fixture.saplings, never()).forEach(any());
}
@Test
public void rejectedTreeKeepsTheSapling() {
Fixture fixture = new Fixture(false);
StructureGrowEvent event = fixture.event();
fixture.grow(event);
assertTrue(event.isCancelled());
verify(fixture.saplings, never()).forEach(any());
}
private static final class Fixture {
private final Engine engine = mock(Engine.class);
private final World world = mock(World.class);
private final PlatformChunkGenerator generator = mock(PlatformChunkGenerator.class);
private final TreeSVC service = spy(new TreeSVC());
private final Cuboid saplings = mock(Cuboid.class);
private Fixture(boolean provisionalWater) {
IrisDimension dimension = new IrisDimension();
dimension.getTreeSettings().setEnabled(true);
IrisComplex complex = mock(IrisComplex.class);
when(complex.hasWaterOrShore(anyInt(), anyInt())).thenAnswer(invocation -> {
if (provisionalWater) {
ProvisionalSampling.mark();
}
return false;
});
when(engine.getGenerationSessions()).thenReturn(new GenerationSessionManager(true));
when(engine.getDimension()).thenReturn(dimension);
when(engine.getComplex()).thenReturn(complex);
when(engine.getBiome(8, SAPLING_Y, 8)).thenReturn(biome());
EngineTarget target = mock(EngineTarget.class);
when(target.getWorld()).thenReturn(mock(IrisWorld.class));
@SuppressWarnings("unchecked")
ResourceLoader<IrisObject> objects = mock(ResourceLoader.class);
IrisObject tree = HydrologyWaterFixture.pillar();
when(objects.load(anyString())).thenReturn(tree);
IrisData data = mock(IrisData.class);
when(data.getObjectLoader()).thenReturn(objects);
when(data.getCompatReport()).thenReturn(mock(PackCompatReport.class));
when(generator.getEngine()).thenReturn(engine);
when(generator.getTarget()).thenReturn(target);
when(generator.getData()).thenReturn(data);
Block block = mock(Block.class);
BlockData blockData = mock(BlockData.class);
when(world.getBlockAt(anyInt(), anyInt(), anyInt())).thenReturn(block);
when(world.getBlockAt(any(Location.class))).thenReturn(block);
when(block.getBlockData()).thenReturn(blockData);
when(blockData.clone()).thenReturn(blockData);
when(saplings.getCenter()).thenReturn(new Location(world, 8, SAPLING_Y, 8));
doReturn(saplings).when(service).getSaplings(any(), any(), any());
}
private static IrisBiome biome() {
IrisTree tree = new IrisTree();
tree.getTreeTypes().add(TreeType.TREE.name());
tree.getSizes().add(new IrisTreeSize());
IrisObjectPlacement placement = new IrisObjectPlacement();
placement.getPlace().add("trees/oak");
placement.getTrees().add(tree);
IrisBiome biome = new IrisBiome();
biome.getObjects().add(placement);
return biome;
}
private StructureGrowEvent event() {
return new StructureGrowEvent(new Location(world, 8, SAPLING_Y, 8), TreeType.TREE, false, null, List.of());
}
private void grow(StructureGrowEvent event) {
try (MockedStatic<IrisToolbelt> toolbelt = mockStatic(IrisToolbelt.class);
MockedStatic<IrisLogging> logging = mockStatic(IrisLogging.class)) {
toolbelt.when(() -> IrisToolbelt.isIrisWorld(world)).thenReturn(true);
toolbelt.when(() -> IrisToolbelt.access(world)).thenReturn(generator);
service.on(event);
}
}
}
}