package com.tiedup.remake.cells; import java.util.*; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import org.jetbrains.annotations.Nullable; /** * Immutable result container returned by the flood-fill algorithm. * * Either a success (with geometry and detected features) or a failure (with an error translation key). */ public class FloodFillResult { private final boolean success; @Nullable private final String errorKey; // Geometry private final Set interior; private final Set walls; @Nullable private final Direction interiorFace; // Auto-detected features private final List beds; private final List petBeds; private final List anchors; private final List doors; private final List linkedRedstone; private FloodFillResult( boolean success, @Nullable String errorKey, Set interior, Set walls, @Nullable Direction interiorFace, List beds, List petBeds, List anchors, List doors, List linkedRedstone ) { this.success = success; this.errorKey = errorKey; this.interior = Collections.unmodifiableSet(interior); this.walls = Collections.unmodifiableSet(walls); this.interiorFace = interiorFace; this.beds = Collections.unmodifiableList(beds); this.petBeds = Collections.unmodifiableList(petBeds); this.anchors = Collections.unmodifiableList(anchors); this.doors = Collections.unmodifiableList(doors); this.linkedRedstone = Collections.unmodifiableList(linkedRedstone); } public static FloodFillResult success( Set interior, Set walls, Direction interiorFace, List beds, List petBeds, List anchors, List doors, List linkedRedstone ) { return new FloodFillResult( true, null, interior, walls, interiorFace, beds, petBeds, anchors, doors, linkedRedstone ); } public static FloodFillResult failure(String errorKey) { return new FloodFillResult( false, errorKey, Collections.emptySet(), Collections.emptySet(), null, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList() ); } // --- Getters --- public boolean isSuccess() { return success; } @Nullable public String getErrorKey() { return errorKey; } public Set getInterior() { return interior; } public Set getWalls() { return walls; } @Nullable public Direction getInteriorFace() { return interiorFace; } public List getBeds() { return beds; } public List getPetBeds() { return petBeds; } public List getAnchors() { return anchors; } public List getDoors() { return doors; } public List getLinkedRedstone() { return linkedRedstone; } }