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.
This commit is contained in:
piexel committed 2026-11-06 01:18:48 +01:00
1 parent d2ce5f4a05
commit f70b8a8abc
2 files changed
+77 -1

No files matched your search

@@ -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
@@ -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 <https://www.gnu.org/licenses/>.
*/
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<SceneEntry> entries(PackWorld world) {
return world.resources().ids(PackResources.OBJECTS).stream()
.map(id -> entryOf(id.path()))
.toList();
}
@Override
public Optional<GeneratedObject> 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);
}
}