mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 16:54:04 +00:00
Move structure placement and jigsaw into the built-in modules jar
iris:structure places and locates structures and owns the structure commands; iris:jigsaw owns the model, the assembler, the importers, the studio and the jigsaw commands. Both load from the jar, and the studio now lives with its tool world: it is created by the first jigsaw command and closes with the world. The host's structure host, model module, assemblies seam and studio host are gone. A datapack's structures are imported through the new DatapackStructureImport service.
This commit is contained in:
1 parent
ba8429952a
commit
543e8c615e
235 files changed
+1199
-1006
No files matched your search
@@ -69,6 +69,13 @@ public interface PackResources {
|
||||
return ResourceId.ofPackKey(packId().namespace(), key);
|
||||
}
|
||||
|
||||
/** The providers of {@code service} that the pack's modules registered, in module id order, so a module that holds only the
|
||||
* resources, such as a locator listing structures, can ask the modules that own the kinds. Empty by default.
|
||||
*/
|
||||
default <S> List<S> services(Class<S> service) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
/** {@link #find} for a resource that must exist: a missing one throws NoSuchElementException naming kind and id. */
|
||||
default <T> T require(ResourceKind<T> kind, ResourceId id) {
|
||||
return find(kind, id).orElseThrow(() -> new NoSuchElementException("Missing " + kind.id() + " resource: " + id));
|
||||
|
||||
@@ -117,6 +117,15 @@ public final class Argument<T> {
|
||||
});
|
||||
}
|
||||
|
||||
/** One word that {@code reader} turns into the value, for a value only the command's module can check, such as a resource
|
||||
* of a kind its module's neighbour registers. {@code reader} fails with an IllegalArgumentException that says why; the
|
||||
* argument completes nothing until {@link #suggesting} gives it candidates.
|
||||
*/
|
||||
public static <T> Argument<T> reading(String name, Reader<T> reader) {
|
||||
Objects.requireNonNull(reader, "reader");
|
||||
return of(name, false, reader::read, (partial, context) -> List.of());
|
||||
}
|
||||
|
||||
/** An id registered in the platform's {@code registry}, such as {@link Reference#STRUCTURE}; completes
|
||||
* {@link PlatformRegistries#ids}. Written as the platform writes it, {@code minecraft:village_plains}, or without the
|
||||
* {@code minecraft:} namespace.
|
||||
@@ -244,6 +253,12 @@ public final class Argument<T> {
|
||||
return registry.name().toLowerCase(Locale.ROOT).replace('_', ' ');
|
||||
}
|
||||
|
||||
/** Turns the word a sender typed into the argument's value. */
|
||||
@FunctionalInterface
|
||||
public interface Reader<T> {
|
||||
T read(String text, CommandContext context);
|
||||
}
|
||||
|
||||
private interface Parser<T> {
|
||||
T parse(String text, CommandContext context);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.volmit.tooling;
|
||||
|
||||
import com.volmit.resource.ResourceId;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/** What {@link DatapackStructureImport#importAll} did.
|
||||
*
|
||||
* @param total the sources it tried
|
||||
* @param imported the sources it imported
|
||||
* @param skipped the sources it left as they were
|
||||
* @param failed the sources it could not import
|
||||
* @param importedBundles the bundle each fully imported source ended up as, by bundle name
|
||||
* @param retryRequired whether a failure may pass when the import runs again, as opposed to the source being invalid
|
||||
*/
|
||||
public record DatapackImportReport(int total, int imported, int skipped, int failed, Map<String, ResourceId> importedBundles,
|
||||
boolean retryRequired) {
|
||||
public DatapackImportReport {
|
||||
Objects.requireNonNull(importedBundles, "importedBundles");
|
||||
importedBundles = java.util.Collections.unmodifiableMap(new TreeMap<>(importedBundles));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.volmit.tooling;
|
||||
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.service.Providers;
|
||||
import com.volmit.service.Service;
|
||||
import java.util.Collection;
|
||||
|
||||
/** Turns the structures and templates a datapack brought into editable resources of the pack, once the host installed the
|
||||
* datapack. A module that owns a kind of structure provides it; the host asks the pack's first provider and, when the pack has
|
||||
* none, leaves the datapack's structures pending. Re-importing a source replaces what an earlier import made of it.
|
||||
*/
|
||||
@Service(Providers.FIRST)
|
||||
public interface DatapackStructureImport {
|
||||
/** Imports {@code structures} (ids of the platform's registered structures) and {@code templates} (ids of its structure
|
||||
* templates) into {@code pack}, reporting progress to {@code sender}. A source that fails does not stop the others.
|
||||
*/
|
||||
DatapackImportReport importAll(ToolPack pack, PlatformStructures platform, Sender sender,
|
||||
Collection<ResourceId> structures, Collection<ResourceId> templates);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.volmit.tooling.world;
|
||||
|
||||
/** A host refused to open a tool world for a reason its message tells the user and the pack's author can fix, such as a pack
|
||||
* with blocking errors. {@link ToolWorlds#open} completes with it; it is not a fault, so a tool reports the message and logs no
|
||||
* stack trace.
|
||||
*/
|
||||
public final class ToolWorldDenied extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ToolWorldDenied(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -14,8 +14,10 @@ public interface ToolWorlds {
|
||||
/**
|
||||
* Opens a world whose chunks come only from {@code spec.painter()}. The future completes, on a host thread, when
|
||||
* players can enter the world. It fails with {@link IllegalStateException} when a tool world of that name is open
|
||||
* already, and with the cause when the platform cannot create the world; a failed open leaves no world behind.
|
||||
* The host closes every tool world it still has open when it shuts down.
|
||||
* already, with {@link ToolWorldDenied} when the host refuses the pack a world (its message says why), and with the
|
||||
* cause when the platform cannot create the world; a failed open leaves no world behind.
|
||||
* The host closes every tool world it still has open when it shuts down: it hears {@link ToolWorldListener#closing}
|
||||
* of each and waits for it before {@link ToolWorldListener#closed}.
|
||||
*
|
||||
* <p>A tool world has no natural mob spawning, weather, daylight cycle, portals, vanilla structures or features.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user