mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
Add value types for settings (BlockSpec, NoiseStyle, StyledRange, Range, BlockPosition, Object as any JSON), host-built noise through PackResources.noise(), and VanillaStructureHook for the platform's own structures
This commit is contained in:
1 parent
ef4b640867
commit
84969c74bd
28 files changed
+1012
-39
No files matched your search
@@ -0,0 +1,13 @@
|
||||
package com.volmit.vanilla;
|
||||
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.resource.PackResources;
|
||||
|
||||
/** The world a {@link VanillaStructureHook} decides for. Valid only while the hook runs. */
|
||||
public interface VanillaStructureContext {
|
||||
/** The resources of the world's pack, module resource kinds included. */
|
||||
PackResources resources();
|
||||
|
||||
/** The module settings the world's dimension declares: its own, and every region and biome it can reach. */
|
||||
PackSettings settings();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.volmit.vanilla;
|
||||
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
/** A module's say over the platform's own structures. Modules register it with
|
||||
* {@link com.volmit.FeatureRegistry#registerVanillaStructureHook}; the host asks every hook of the pack before the
|
||||
* platform starts one of its structures in a world, and when it locates one.
|
||||
*
|
||||
* <p>The host asks once per world, structure and pack snapshot and keeps the answer, so a hook decides from the
|
||||
* pack (its settings and resources) and never from where a start would be. Rules of several modules combine with
|
||||
* {@link VanillaStructureRule#and}: any module may block the platform's starts.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface VanillaStructureHook {
|
||||
/** What this module wants for the platform structure {@code structure}, such as {@code minecraft:village_plains},
|
||||
* in the world {@code context} describes. {@link VanillaStructureRule#GENERATE} when the module has no part in it.
|
||||
*/
|
||||
VanillaStructureRule rule(ResourceId structure, VanillaStructureContext context);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.volmit.vanilla;
|
||||
|
||||
/** What a module wants for one of the platform's own structures, the ones Minecraft, data packs and mods register
|
||||
* (such as {@code minecraft:village_plains}), in a world: whether the platform may start it where it would on its
|
||||
* own, and whether the module places it itself.
|
||||
*/
|
||||
public enum VanillaStructureRule {
|
||||
/** The platform generates the structure where it would; the module has no part in it. */
|
||||
GENERATE,
|
||||
/** The platform generates the structure where it would, and the module also places it, where it chooses. */
|
||||
ALSO_PLACE,
|
||||
/** The module places the structure instead of the platform: the platform's own starts of it are blocked. */
|
||||
REPLACE,
|
||||
/** The platform's own starts of the structure are blocked, and the module does not place it either. */
|
||||
BLOCK;
|
||||
|
||||
/** Whether the platform's own starts of the structure are blocked. */
|
||||
public boolean blocksPlatform() {
|
||||
return this == REPLACE || this == BLOCK;
|
||||
}
|
||||
|
||||
/** Whether the module places the structure itself, so the host locates it through the module. */
|
||||
public boolean placedByModule() {
|
||||
return this == ALSO_PLACE || this == REPLACE;
|
||||
}
|
||||
|
||||
/** What two modules' rules for one structure mean together: the platform's starts are blocked when either
|
||||
* blocks them, and the structure is placed by a module when either places it. The order does not matter.
|
||||
*/
|
||||
public VanillaStructureRule and(VanillaStructureRule other) {
|
||||
return of(blocksPlatform() || other.blocksPlatform(), placedByModule() || other.placedByModule());
|
||||
}
|
||||
|
||||
private static VanillaStructureRule of(boolean blocksPlatform, boolean placedByModule) {
|
||||
if (blocksPlatform) {
|
||||
return placedByModule ? REPLACE : BLOCK;
|
||||
}
|
||||
return placedByModule ? ALSO_PLACE : GENERATE;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user