mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Show every procedural object variant in the studio
iris:objects registers the Procedural scene view: each procedural definition with as many variants as it asks for, baked the way the world bakes them.
This commit is contained in:
1 parent
f70b8a8abc
commit
cb3859b40f
3 files changed
+86
-1
No files matched your search
@@ -25,6 +25,7 @@ import art.arcane.iris.engine.procedural.ProceduralObjectCatalog;
|
||||
import art.arcane.iris.builtin.objects.RequireSurfaceSupportSettings;
|
||||
import art.arcane.iris.builtin.objects.SurfaceSupportBufferSettings;
|
||||
import art.arcane.iris.modules.objects.PackObjectScenes;
|
||||
import art.arcane.iris.modules.objects.ProceduralObjectScenes;
|
||||
import art.arcane.iris.modules.objects.TreeGrowthSettings;
|
||||
import art.arcane.iris.builtin.objects.UpperObjectsForceSettings;
|
||||
import art.arcane.iris.builtin.objects.UpperObjectsSettings;
|
||||
@@ -47,7 +48,7 @@ import com.volmit.world.PackWorld;
|
||||
* reach is the pack's largest object placement. It tells
|
||||
* Iris which objects a chunk would get and which biomes and regions place an object ({@link ObjectLocating}), for the
|
||||
* object search and studio tools, grows the trees of saplings ({@link TreeGrowing}), and shows the pack's objects in
|
||||
* the studio ({@link PackObjectScenes}).
|
||||
* the studio with every variant of its procedural objects ({@link PackObjectScenes}, {@link ProceduralObjectScenes}).
|
||||
*/
|
||||
public final class ObjectModule implements IrisModule, ModuleLifecycle {
|
||||
private static final String VERSION = "built-in";
|
||||
@@ -72,6 +73,7 @@ public final class ObjectModule implements IrisModule, ModuleLifecycle {
|
||||
registry.registerPlacementType(ObjectPlacement.class, ObjectPlacement.jsonFields());
|
||||
registry.registerLifecycle(this);
|
||||
setup.tooling().registerSceneView(new PackObjectScenes());
|
||||
setup.tooling().registerSceneView(new ProceduralObjectScenes());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -66,6 +66,11 @@ public abstract class ProceduralVariants {
|
||||
return key() + ProceduralObjectCatalog.VARIANT_SEPARATOR + index;
|
||||
}
|
||||
|
||||
/** How many variants the definition asks for, known without baking; a variant may still bake no blocks. */
|
||||
public int variantCount() {
|
||||
return variantCount;
|
||||
}
|
||||
|
||||
/** Every variant, baked on first use. */
|
||||
public List<PlaceableObject> variants() {
|
||||
List<PlaceableObject> known = baked;
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.modules.objects;
|
||||
|
||||
import art.arcane.iris.engine.procedural.ProceduralObjectCatalog;
|
||||
import art.arcane.iris.engine.procedural.ProceduralVariants;
|
||||
import com.volmit.object.GeneratedObject;
|
||||
import com.volmit.object.PlaceableObject;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.tooling.SceneEntry;
|
||||
import com.volmit.tooling.SceneView;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* The studio's Procedural view: every procedural object of the pack with each of its variants, baked as the world
|
||||
* bakes them, so what the studio shows is what generation places.
|
||||
*/
|
||||
public final class ProceduralObjectScenes implements SceneView {
|
||||
private static final ResourceId ID = ResourceId.parse("iris:objects/procedural");
|
||||
private static final char FOLDER_SEPARATOR = '/';
|
||||
|
||||
@Override
|
||||
public ResourceId id() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String label() {
|
||||
return "Procedural";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return "Trees, rock formations and more that Iris generates from settings, every variant in 3D";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SceneEntry> entries(PackWorld world) {
|
||||
ProceduralObjectCatalog catalog = ProceduralObjectCatalog.of(world);
|
||||
return world.resources().ids(ProceduralObjectCatalog.DEFINITIONS).stream()
|
||||
.flatMap(id -> catalog.variants(ProceduralObjectCatalog.KEY_PREFIX + id.path()).stream())
|
||||
.map(ProceduralObjectScenes::entryOf)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<GeneratedObject> scene(PackWorld world, String key, int variant) {
|
||||
return ProceduralObjectCatalog.of(world).variants(ProceduralObjectCatalog.KEY_PREFIX + key)
|
||||
.flatMap(variants -> variants.variant(variant))
|
||||
.map(PlaceableObject::geometry);
|
||||
}
|
||||
|
||||
private static SceneEntry entryOf(ProceduralVariants variants) {
|
||||
String path = variants.path();
|
||||
int lastSeparator = path.lastIndexOf(FOLDER_SEPARATOR);
|
||||
String folder = lastSeparator < 0 ? "" : path.substring(0, lastSeparator);
|
||||
return new SceneEntry(path, path.substring(lastSeparator + 1), folder, variants.variantCount());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user