From f70b8a8abc67ce355ffa37e36d86a3feff3c992a Mon Sep 17 00:00:00 2001 From: piexel Date: Fri, 6 Nov 2026 01:18:48 +0100 Subject: [PATCH] Show the pack's objects in the studio iris:objects registers the Objects scene view: every object of the pack, listed under the folders of its file, one scene each. --- .../mantle/components/ObjectModule.java | 5 +- .../modules/objects/PackObjectScenes.java | 73 +++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 src/main/java/art/arcane/iris/modules/objects/PackObjectScenes.java diff --git a/src/main/java/art/arcane/iris/engine/mantle/components/ObjectModule.java b/src/main/java/art/arcane/iris/engine/mantle/components/ObjectModule.java index ba70f3bc5..81cbcecfa 100644 --- a/src/main/java/art/arcane/iris/engine/mantle/components/ObjectModule.java +++ b/src/main/java/art/arcane/iris/engine/mantle/components/ObjectModule.java @@ -24,6 +24,7 @@ import art.arcane.iris.builtin.objects.ObjectSettings; 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.TreeGrowthSettings; import art.arcane.iris.builtin.objects.UpperObjectsForceSettings; import art.arcane.iris.builtin.objects.UpperObjectsSettings; @@ -45,7 +46,8 @@ import com.volmit.world.PackWorld; * procedural objects they place ({@link ProceduralObjectCatalog}) built ahead of generation ({@link #warmUp}). Its * 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, and grows the trees of saplings ({@link TreeGrowing}). + * object search and studio tools, grows the trees of saplings ({@link TreeGrowing}), and shows the pack's objects in + * the studio ({@link PackObjectScenes}). */ public final class ObjectModule implements IrisModule, ModuleLifecycle { private static final String VERSION = "built-in"; @@ -69,6 +71,7 @@ public final class ObjectModule implements IrisModule, ModuleLifecycle { registry.registerResourceKind(ProceduralObjectCatalog.DEFINITIONS); registry.registerPlacementType(ObjectPlacement.class, ObjectPlacement.jsonFields()); registry.registerLifecycle(this); + setup.tooling().registerSceneView(new PackObjectScenes()); } @Override diff --git a/src/main/java/art/arcane/iris/modules/objects/PackObjectScenes.java b/src/main/java/art/arcane/iris/modules/objects/PackObjectScenes.java new file mode 100644 index 000000000..a6a2c18b2 --- /dev/null +++ b/src/main/java/art/arcane/iris/modules/objects/PackObjectScenes.java @@ -0,0 +1,73 @@ +/* + * 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 . + */ + +package art.arcane.iris.modules.objects; + +import com.volmit.object.GeneratedObject; +import com.volmit.object.PlaceableObject; +import com.volmit.resource.PackResources; +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 Objects view: every object in the pack, one scene each, listed under the folders of its file. */ +public final class PackObjectScenes implements SceneView { + private static final ResourceId ID = ResourceId.parse("iris:objects"); + private static final char FOLDER_SEPARATOR = '/'; + + @Override + public ResourceId id() { + return ID; + } + + @Override + public String label() { + return "Objects"; + } + + @Override + public String description() { + return "Every object in the pack in 3D, with the blocks it is made of"; + } + + @Override + public List entries(PackWorld world) { + return world.resources().ids(PackResources.OBJECTS).stream() + .map(id -> entryOf(id.path())) + .toList(); + } + + @Override + public Optional scene(PackWorld world, String key, int variant) { + if (variant != 0) { + return Optional.empty(); + } + PackResources resources = world.resources(); + return resources.objects().object(resources.idOf(key)).map(PlaceableObject::geometry); + } + + private static SceneEntry entryOf(String key) { + int lastSeparator = key.lastIndexOf(FOLDER_SEPARATOR); + String folder = lastSeparator < 0 ? "" : key.substring(0, lastSeparator); + return new SceneEntry(key, key.substring(lastSeparator + 1), folder, 1); + } +}