mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Type platform keys and fold pack references into @Ref(kind)
Batch 6, findings 41 and 42. - Platform keys travel as ResourceId: enchantments, attributes, sounds, particles, potions, loot tables, sapling species, marker tags, upper dimension ids and jigsaw start pools. ResourceId.ofPlatformKey normalises a key a pack wrote. - Item and entity types are a ContentKey (Registered id, or Provided provider and name) instead of strings and a special-type flag. - ItemDrop groups into Look, Wear and PlatformExtras; colours are an RGB int and DyeColor, attribute operations an enum. - EntitySpec groups into Appearance, Behaviour, Company, Drops and Arrival, and carries host extensions instead of Iris-only fields. - @Ref(kind = Type.class) replaces @ResourceRef and the PACK_* references; expressions and image maps become the host kinds EXPRESSIONS and IMAGE_MAPS.
This commit is contained in:
1 parent
05f621d82d
commit
6b24e6f150
31 files changed
+620
-295
No files matched your search
@@ -2,12 +2,21 @@ package com.volmit.config;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/** Says what an option's text names, such as {@code @Ref(Reference.BLOCK) String block}. Allowed on
|
||||
* {@code String} and {@link com.volmit.resource.ResourceId} options and on lists, sets and arrays of
|
||||
* them, where it applies to every element. Anywhere else it fails the pack load.
|
||||
/** Says what an option's text names: an entry of a platform registry, {@code @Ref(Reference.BLOCK) String block}, or
|
||||
* a resource of the pack by its key, {@code @Ref(kind = LootTable.class) String table}, where {@code kind} is the type
|
||||
* of a {@link com.volmit.resource.ResourceKind}: a host kind, the constants of
|
||||
* {@link com.volmit.resource.PackResources}, or a kind some module of the pack registers. Studio then offers the
|
||||
* registry's entries or the pack's keys of that kind. Give exactly one of the two. Allowed on {@code String} and
|
||||
* {@link com.volmit.resource.ResourceId} options and on lists, sets and arrays of them, where it applies to every
|
||||
* element; a {@code ResourceId} option naming a pack resource holds the id the pack gives the key it writes.
|
||||
* Anything else fails the pack load.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface Ref {
|
||||
Reference value();
|
||||
/** The platform registry the text names; give one, or none when {@link #kind} is given. */
|
||||
Reference[] value() default {};
|
||||
|
||||
/** The type of the resource kind the text names by key; {@code void.class}, the default, when {@link #value} is given. */
|
||||
Class<?> kind() default void.class;
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.volmit.config;
|
||||
|
||||
/** What a text option names, so studio can offer the matching completion list. Platform kinds name
|
||||
* entries of the server's registries, such as {@code minecraft:stone}, including those that data
|
||||
* packs and mods add. Pack kinds name resources of the pack being edited. The set is closed: every
|
||||
* kind is one the Iris host can list.
|
||||
/** The platform registry a text option names, so studio can offer the matching completion list: entries of the
|
||||
* server's registries, such as {@code minecraft:stone}, including those that data packs and mods add, and the host's
|
||||
* own noise generators. Resources of the pack are named by their kind instead, {@code @Ref(kind = ...)}. The set is
|
||||
* closed: every registry is one the Iris host can list.
|
||||
*/
|
||||
public enum Reference {
|
||||
/** A block type, such as {@code minecraft:stone}. {@link com.volmit.block.BlockState} options are block references without {@link Ref}. */
|
||||
@@ -29,20 +29,8 @@ public enum Reference {
|
||||
ENCHANTMENT,
|
||||
/** A loot table of the platform, such as {@code minecraft:chests/simple_dungeon}; not a loot table of the pack. */
|
||||
LOOT_TABLE,
|
||||
/** A mob of another plugin or content provider, such as {@code mythicmobs:skeleton_king}. */
|
||||
/** A mob of another plugin or content provider, such as {@code mythicmobs:SkeletonKing}; see {@link com.volmit.resource.ContentKey.Provided}. */
|
||||
SPECIAL_ENTITY,
|
||||
/** A biome of the pack. */
|
||||
PACK_BIOME,
|
||||
/** A region of the pack. */
|
||||
PACK_REGION,
|
||||
/** An object of the pack. */
|
||||
PACK_OBJECT,
|
||||
/** One of the host's noise styles, such as {@code SIMPLEX}; see {@link com.volmit.noise.NoiseStyle}. */
|
||||
NOISE_STYLE,
|
||||
/** An expression of the pack. */
|
||||
PACK_EXPRESSION,
|
||||
/** An image map of the pack. */
|
||||
PACK_IMAGE_MAP,
|
||||
/** A jigsaw structure of the pack. */
|
||||
PACK_STRUCTURE
|
||||
NOISE_STYLE
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.volmit.config;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/** Says that an option names a resource of the module resource kind read into {@code value}, by its key in the
|
||||
* pack, such as {@code @ResourceRef(Pool.class) String startPool = "castle/start"}. Studio then offers the keys
|
||||
* of that kind's files. Allowed on {@code String} options and lists, sets and arrays of them; the class must be
|
||||
* the type of a resource kind some module of the pack registers. Anywhere else it fails the pack load.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface ResourceRef {
|
||||
Class<?> value();
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.volmit.entity;
|
||||
|
||||
import com.volmit.item.ItemAttribute;
|
||||
import com.volmit.item.ItemDrop;
|
||||
import com.volmit.resource.ContentKey;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -9,57 +10,63 @@ import java.util.Optional;
|
||||
|
||||
/**
|
||||
* An entity a module decided to spawn, with every random choice made: the host creates it on the platform and applies
|
||||
* what is set. Names are as authored in the pack, with {@code &} colour codes.
|
||||
* what is set. A part the entity cannot have, such as equipment on an item frame, is left out. A host may leave a
|
||||
* {@link ContentKey.Provided} mob as its provider set it up.
|
||||
*
|
||||
* @param type the entity type's key, such as {@code minecraft:zombie}; ignored when {@code specialType} is set
|
||||
* @param specialType a mob of another plugin, written {@code PluginName:MobName}; empty for an entity of the platform
|
||||
* @param reason the platform's spawn reason by name; empty for a natural spawn
|
||||
* @param customName the name shown above the entity; empty for none
|
||||
* @param flags the settings that every entity kind understands
|
||||
* @param equipment what the entity wears and holds
|
||||
* @param passengers entities that ride this one
|
||||
* @param attributes attribute modifiers to apply
|
||||
* @param lootTables the pack's loot tables the entity drops, instead of the platform's drops, when it dies
|
||||
* @param lootShuffleSeed seeds how the drops of {@code lootTables} are shuffled
|
||||
* @param leashHolder the entity that holds this one on a leash; empty for none
|
||||
* @param spawnEffect an effect to show when the entity appears; empty for none
|
||||
* @param riseOutOfGround whether the entity slowly climbs out of the ground when players are near
|
||||
* @param pandaMainGene for pandas the main gene by name; empty to leave it to the platform
|
||||
* @param pandaHiddenGene for pandas the hidden gene by name; empty to leave it to the platform
|
||||
* @param applySettingsToSpecial whether the settings also apply to a mob of another plugin
|
||||
* @param commands console commands to run where the entity appears
|
||||
* @param type what the entity is: an entity type, such as {@code minecraft:zombie}, or a mob of a provider
|
||||
* @param appearance how it looks
|
||||
* @param behaviour how it acts
|
||||
* @param equipment what it wears and holds
|
||||
* @param attributes attribute modifiers to apply
|
||||
* @param company the entities that come with it
|
||||
* @param drops what it drops when it dies
|
||||
* @param arrival what happens where it appears
|
||||
* @param extensions values for a particular host, which other hosts ignore; see {@link #extension}
|
||||
*/
|
||||
public record EntitySpec(Optional<String> type, Optional<String> specialType, Optional<String> reason, Optional<String> customName,
|
||||
Flags flags, Equipment equipment, List<EntitySpec> passengers, List<ItemAttribute> attributes,
|
||||
List<ResourceId> lootTables, long lootShuffleSeed, Optional<EntitySpec> leashHolder,
|
||||
Optional<SpawnEffect> spawnEffect, boolean riseOutOfGround, Optional<String> pandaMainGene,
|
||||
Optional<String> pandaHiddenGene, boolean applySettingsToSpecial, List<Command> commands) {
|
||||
public record EntitySpec(ContentKey type, Appearance appearance, Behaviour behaviour, Equipment equipment,
|
||||
List<ItemAttribute> attributes, Company company, Drops drops, Arrival arrival, List<Object> extensions) {
|
||||
public EntitySpec {
|
||||
Objects.requireNonNull(type, "type");
|
||||
Objects.requireNonNull(specialType, "specialType");
|
||||
Objects.requireNonNull(reason, "reason");
|
||||
Objects.requireNonNull(customName, "customName");
|
||||
Objects.requireNonNull(flags, "flags");
|
||||
Objects.requireNonNull(appearance, "appearance");
|
||||
Objects.requireNonNull(behaviour, "behaviour");
|
||||
Objects.requireNonNull(equipment, "equipment");
|
||||
passengers = List.copyOf(passengers);
|
||||
attributes = List.copyOf(attributes);
|
||||
lootTables = List.copyOf(lootTables);
|
||||
Objects.requireNonNull(leashHolder, "leashHolder");
|
||||
Objects.requireNonNull(spawnEffect, "spawnEffect");
|
||||
Objects.requireNonNull(pandaMainGene, "pandaMainGene");
|
||||
Objects.requireNonNull(pandaHiddenGene, "pandaHiddenGene");
|
||||
commands = List.copyOf(commands);
|
||||
Objects.requireNonNull(company, "company");
|
||||
Objects.requireNonNull(drops, "drops");
|
||||
Objects.requireNonNull(arrival, "arrival");
|
||||
extensions = List.copyOf(extensions);
|
||||
}
|
||||
|
||||
/** Whether the entity is a mob of another plugin. */
|
||||
public boolean isSpecial() {
|
||||
return specialType.isPresent();
|
||||
/** The extension of type {@code type} the module added for its host; empty when it added none. */
|
||||
public <T> Optional<T> extension(Class<T> type) {
|
||||
return extensions.stream().filter(type::isInstance).map(type::cast).findFirst();
|
||||
}
|
||||
|
||||
/** What an entity can be set to be, whatever its kind; the host applies the ones its kind has. */
|
||||
public record Flags(boolean customNameVisible, boolean aware, boolean ai, boolean glowing, boolean gravity,
|
||||
boolean invulnerable, boolean silent, boolean pickupItems, boolean removable,
|
||||
boolean keepEntity, boolean baby) {
|
||||
/**
|
||||
* How the entity looks.
|
||||
*
|
||||
* @param customName the name shown above the entity, as authored in the pack with {@code &} colour codes; empty for none
|
||||
* @param nameVisible whether the name shows even when nobody looks at the entity
|
||||
*/
|
||||
public record Appearance(Optional<String> customName, boolean nameVisible, boolean glowing, boolean baby) {
|
||||
public static final Appearance PLAIN = new Appearance(Optional.empty(), false, false, false);
|
||||
|
||||
public Appearance {
|
||||
Objects.requireNonNull(customName, "customName");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* How the entity acts; the host applies what the entity's kind has.
|
||||
*
|
||||
* @param aware whether a mob notices its surroundings
|
||||
* @param ai whether a mob follows its goals
|
||||
* @param removable whether the entity despawns when far from players
|
||||
* @param keepEntity whether the entity is never culled
|
||||
*/
|
||||
public record Behaviour(boolean aware, boolean ai, boolean gravity, boolean invulnerable, boolean silent,
|
||||
boolean pickupItems, boolean removable, boolean keepEntity) {
|
||||
public static final Behaviour NATURAL = new Behaviour(true, true, true, false, false, false, false, false);
|
||||
}
|
||||
|
||||
/** The items an entity wears and holds; empty for an empty slot. */
|
||||
@@ -79,18 +86,88 @@ public record EntitySpec(Optional<String> type, Optional<String> specialType, Op
|
||||
}
|
||||
|
||||
/**
|
||||
* Sound and particles shown around an entity that appears. Offsets and the randomness of the particle motion are
|
||||
* as in an effect of the pack; the host makes the random choices.
|
||||
* The entities that come with this one.
|
||||
*
|
||||
* @param sound the platform's sound key; empty for no sound
|
||||
* @param particle the platform's particle key; empty for no particles
|
||||
* @param passengers entities that ride this one
|
||||
* @param leashHolder the entity that holds this one on a leash; empty for none
|
||||
*/
|
||||
public record SpawnEffect(Optional<String> sound, int soundDistance, double minPitch, double maxPitch, double volume,
|
||||
Optional<String> particle, int particleOffset, int particleCount, double altX, double altY,
|
||||
double altZ, boolean randomAltX, boolean randomAltY, boolean randomAltZ, double extra) {
|
||||
public record Company(List<EntitySpec> passengers, Optional<EntitySpec> leashHolder) {
|
||||
public static final Company NONE = new Company(List.of(), Optional.empty());
|
||||
|
||||
public Company {
|
||||
passengers = List.copyOf(passengers);
|
||||
Objects.requireNonNull(leashHolder, "leashHolder");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* What the entity drops when it dies.
|
||||
*
|
||||
* @param lootTables the pack's loot tables it drops instead of the platform's drops; none keeps the platform's
|
||||
* @param shuffleSeed seeds how the drops of {@code lootTables} are shuffled
|
||||
*/
|
||||
public record Drops(List<ResourceId> lootTables, long shuffleSeed) {
|
||||
public static final Drops PLATFORM = new Drops(List.of(), 0L);
|
||||
|
||||
public Drops {
|
||||
lootTables = List.copyOf(lootTables);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* What happens where the entity appears.
|
||||
*
|
||||
* @param effect an effect to show; empty for none
|
||||
* @param commands console commands to run
|
||||
*/
|
||||
public record Arrival(Optional<SpawnEffect> effect, List<Command> commands) {
|
||||
public static final Arrival QUIET = new Arrival(Optional.empty(), List.of());
|
||||
|
||||
public Arrival {
|
||||
Objects.requireNonNull(effect, "effect");
|
||||
commands = List.copyOf(commands);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sound and particles shown around an entity that appears. The host makes the random choices: where in range the
|
||||
* sound plays, its pitch, and the particles' random motion.
|
||||
*/
|
||||
public record SpawnEffect(Optional<Sound> sound, Optional<Burst> particles) {
|
||||
public SpawnEffect {
|
||||
Objects.requireNonNull(sound, "sound");
|
||||
Objects.requireNonNull(particle, "particle");
|
||||
Objects.requireNonNull(particles, "particles");
|
||||
}
|
||||
|
||||
/**
|
||||
* A sound played near the entity, at a pitch between {@code minPitch} and {@code maxPitch}.
|
||||
*
|
||||
* @param key the sound, such as {@code minecraft:entity.zombie.ambient}
|
||||
* @param distance how many blocks from the entity, at most, along each axis it seems to come from
|
||||
*/
|
||||
public record Sound(ResourceId key, int distance, double minPitch, double maxPitch, double volume) {
|
||||
public Sound {
|
||||
Objects.requireNonNull(key, "key");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Particles shown around the entity.
|
||||
*
|
||||
* @param key the particle, such as {@code minecraft:smoke}
|
||||
* @param offset how many blocks up, at most, they appear
|
||||
* @param count how many particles; none makes {@code motion} their motion
|
||||
* @param extra an extra value some particles take; 0 for none
|
||||
*/
|
||||
public record Burst(ResourceId key, int offset, int count, Motion motion, double extra) {
|
||||
public Burst {
|
||||
Objects.requireNonNull(key, "key");
|
||||
Objects.requireNonNull(motion, "motion");
|
||||
}
|
||||
}
|
||||
|
||||
/** How far the particles spread or move along each axis; a random axis takes a random amount between minus and plus its value. */
|
||||
public record Motion(double x, double y, double z, boolean randomX, boolean randomY, boolean randomZ) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.volmit.item;
|
||||
|
||||
/** The sixteen dye colours, which colour items such as shulker boxes, banners and beds. */
|
||||
public enum DyeColor {
|
||||
WHITE,
|
||||
ORANGE,
|
||||
MAGENTA,
|
||||
LIGHT_BLUE,
|
||||
YELLOW,
|
||||
LIME,
|
||||
PINK,
|
||||
GRAY,
|
||||
LIGHT_GRAY,
|
||||
CYAN,
|
||||
PURPLE,
|
||||
BLUE,
|
||||
BROWN,
|
||||
GREEN,
|
||||
RED,
|
||||
BLACK
|
||||
}
|
||||
@@ -1,18 +1,28 @@
|
||||
package com.volmit.item;
|
||||
|
||||
import com.volmit.resource.ResourceId;
|
||||
import java.util.Objects;
|
||||
|
||||
/** An attribute modifier of an {@link ItemDrop} or an entity, with the amount the module decided. The host creates a
|
||||
* modifier under an id it makes unique from {@code name}, for every equipment slot.
|
||||
*
|
||||
* @param attribute the platform attribute's key, such as {@code max_health} or {@code minecraft:armor}
|
||||
* @param attribute the attribute, such as {@code minecraft:max_health}
|
||||
* @param name identifies the modifier among those of one item or entity; not shown to players
|
||||
* @param operation {@code ADD_NUMBER}, {@code ADD_SCALAR} or {@code MULTIPLY_SCALAR_1}
|
||||
*/
|
||||
public record ItemAttribute(String attribute, String name, String operation, double amount) {
|
||||
public record ItemAttribute(ResourceId attribute, String name, Operation operation, double amount) {
|
||||
public ItemAttribute {
|
||||
Objects.requireNonNull(attribute, "attribute");
|
||||
Objects.requireNonNull(name, "name");
|
||||
Objects.requireNonNull(operation, "operation");
|
||||
}
|
||||
|
||||
/** How the amount changes the attribute's value, as the platform's attribute modifiers do. */
|
||||
public enum Operation {
|
||||
/** Adds the amount to the base value. */
|
||||
ADD_VALUE,
|
||||
/** Adds the base value times the amount. */
|
||||
ADD_MULTIPLIED_BASE,
|
||||
/** Multiplies the value, after the other modifiers, by one plus the amount. */
|
||||
ADD_MULTIPLIED_TOTAL
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.volmit.item;
|
||||
|
||||
import com.volmit.resource.ContentKey;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -11,48 +12,86 @@ import java.util.OptionalInt;
|
||||
|
||||
/**
|
||||
* One stack of items a module decided to give: what a loot entry, a block's drops or an entity's equipment turned into
|
||||
* after the module made every random choice. The host creates the stack on the platform. Names and lore are as authored
|
||||
* in the pack, with {@code &} colour codes; the host translates and wraps them.
|
||||
* after the module made every random choice. The host creates the stack on the platform; a part the item cannot have,
|
||||
* such as a leather colour on a sword, is left out.
|
||||
*
|
||||
* @param item the item's key as the pack wrote it, see {@link ItemRegistry}
|
||||
* @param amount how many, at least 1
|
||||
* @param displayName the item's name; empty keeps the platform's
|
||||
* @param lore lines of text under the name
|
||||
* @param enchantments applied in order
|
||||
* @param attributes attribute modifiers applied in order
|
||||
* @param unbreakable whether the item never breaks
|
||||
* @param flags platform item flags to set, by name; names the platform lacks are ignored
|
||||
* @param customModel custom model number; empty for none
|
||||
* @param damage the fraction of the item's durability already used, 0 to 1; empty leaves it undamaged
|
||||
* @param leatherColor colour of leather armour as {@code #rrggbb}; empty for none
|
||||
* @param dyeColor dye colour name; empty for none
|
||||
* @param customNbt custom data the platform stores on the item, or an empty map
|
||||
* @param source where the item came from, present only when the host asked for it to be shown (debug loot)
|
||||
* @param item what the item is
|
||||
* @param amount how many, at least 1
|
||||
* @param look its name, lore and colours
|
||||
* @param enchantments applied in order
|
||||
* @param attributes attribute modifiers applied in order
|
||||
* @param wear how worn it is
|
||||
* @param extras what only some platforms understand
|
||||
* @param source where the item came from, present only when the host asked for it to be shown (debug loot)
|
||||
*/
|
||||
public record ItemDrop(String item, int amount, Optional<String> displayName, List<String> lore, List<ItemEnchantment> enchantments,
|
||||
List<ItemAttribute> attributes, boolean unbreakable, List<String> flags, OptionalInt customModel,
|
||||
OptionalDouble damage, Optional<String> leatherColor, Optional<String> dyeColor, Map<String, Object> customNbt,
|
||||
Optional<Source> source) {
|
||||
public record ItemDrop(ContentKey item, int amount, Look look, List<ItemEnchantment> enchantments,
|
||||
List<ItemAttribute> attributes, Wear wear, PlatformExtras extras, Optional<Source> source) {
|
||||
public ItemDrop {
|
||||
Objects.requireNonNull(item, "item");
|
||||
if (amount < 1) throw new IllegalArgumentException("Item amount must be at least 1: " + amount);
|
||||
Objects.requireNonNull(displayName, "displayName");
|
||||
lore = List.copyOf(lore);
|
||||
Objects.requireNonNull(look, "look");
|
||||
enchantments = List.copyOf(enchantments);
|
||||
attributes = List.copyOf(attributes);
|
||||
flags = List.copyOf(flags);
|
||||
Objects.requireNonNull(customModel, "customModel");
|
||||
Objects.requireNonNull(damage, "damage");
|
||||
Objects.requireNonNull(leatherColor, "leatherColor");
|
||||
Objects.requireNonNull(dyeColor, "dyeColor");
|
||||
customNbt = Collections.unmodifiableMap(new LinkedHashMap<>(customNbt));
|
||||
Objects.requireNonNull(wear, "wear");
|
||||
Objects.requireNonNull(extras, "extras");
|
||||
Objects.requireNonNull(source, "source");
|
||||
}
|
||||
|
||||
/** {@code amount} items of kind {@code item} and nothing else. */
|
||||
public static ItemDrop of(String item, int amount) {
|
||||
return new ItemDrop(item, amount, Optional.empty(), List.of(), List.of(), List.of(), false, List.of(), OptionalInt.empty(),
|
||||
OptionalDouble.empty(), Optional.empty(), Optional.empty(), Map.of(), Optional.empty());
|
||||
public static ItemDrop of(ContentKey item, int amount) {
|
||||
return new ItemDrop(item, amount, Look.PLAIN, List.of(), List.of(), Wear.NEW, PlatformExtras.NONE, Optional.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
* How the item looks. Names and lore are as authored in the pack, with {@code &} colour codes; the host translates
|
||||
* and wraps them.
|
||||
*
|
||||
* @param displayName the item's name; empty keeps the platform's
|
||||
* @param lore lines of text under the name
|
||||
* @param customModel custom model number; empty for none
|
||||
* @param leatherColor colour of leather armour as {@code 0xRRGGBB}; empty for none
|
||||
* @param dyeColor the dye colour of an item that takes one; empty for none
|
||||
*/
|
||||
public record Look(Optional<String> displayName, List<String> lore, OptionalInt customModel, OptionalInt leatherColor,
|
||||
Optional<DyeColor> dyeColor) {
|
||||
public static final Look PLAIN = new Look(Optional.empty(), List.of(), OptionalInt.empty(), OptionalInt.empty(), Optional.empty());
|
||||
|
||||
public Look {
|
||||
Objects.requireNonNull(displayName, "displayName");
|
||||
lore = List.copyOf(lore);
|
||||
Objects.requireNonNull(customModel, "customModel");
|
||||
Objects.requireNonNull(leatherColor, "leatherColor");
|
||||
Objects.requireNonNull(dyeColor, "dyeColor");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* How worn the item is.
|
||||
*
|
||||
* @param unbreakable whether the item never breaks
|
||||
* @param damage the fraction of the item's durability already used, 0 to 1; empty leaves it undamaged
|
||||
*/
|
||||
public record Wear(boolean unbreakable, OptionalDouble damage) {
|
||||
public static final Wear NEW = new Wear(false, OptionalDouble.empty());
|
||||
|
||||
public Wear {
|
||||
Objects.requireNonNull(damage, "damage");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* What only some platforms understand; a platform without them ignores them.
|
||||
*
|
||||
* @param flags the platform's item flags to set, by name; names the platform lacks are ignored
|
||||
* @param customNbt custom data the platform stores on the item, or an empty map
|
||||
*/
|
||||
public record PlatformExtras(List<String> flags, Map<String, Object> customNbt) {
|
||||
public static final PlatformExtras NONE = new PlatformExtras(List.of(), Map.of());
|
||||
|
||||
public PlatformExtras {
|
||||
flags = List.copyOf(flags);
|
||||
customNbt = Collections.unmodifiableMap(new LinkedHashMap<>(customNbt));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.volmit.item;
|
||||
|
||||
import com.volmit.resource.ResourceId;
|
||||
import java.util.Objects;
|
||||
|
||||
/** An enchantment of an {@link ItemDrop}, named by the key the platform's registry knows ({@code sharpness},
|
||||
* {@code mymod:vorpal}) with the level the module decided.
|
||||
/** An enchantment of an {@link ItemDrop}, such as {@code minecraft:sharpness} or {@code mymod:vorpal}, with the level
|
||||
* the module decided.
|
||||
*/
|
||||
public record ItemEnchantment(String key, int level) {
|
||||
public record ItemEnchantment(ResourceId key, int level) {
|
||||
public ItemEnchantment {
|
||||
Objects.requireNonNull(key, "key");
|
||||
if (level < 1) throw new IllegalArgumentException("Enchantment level must be at least 1: " + level);
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package com.volmit.item;
|
||||
|
||||
import com.volmit.resource.ContentKey;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
/** What a module may ask the platform about items, so that its decisions follow the item they concern. Item keys are
|
||||
* written as in packs: {@code diamond_sword}, {@code minecraft:diamond_sword}, or a custom item of a provider such as
|
||||
* {@code itemsadder:ruby}. Safe for concurrent use.
|
||||
/** What a module may ask the platform about items, so that its decisions follow the item they concern. Safe for
|
||||
* concurrent use.
|
||||
*/
|
||||
public interface ItemRegistry {
|
||||
/**
|
||||
* The most damage an item of this kind takes before it breaks, 0 for an item that cannot be damaged; empty when no
|
||||
* item is known by {@code key}.
|
||||
* item is known by {@code item}.
|
||||
*/
|
||||
OptionalInt maxDurability(String key);
|
||||
OptionalInt maxDurability(ContentKey item);
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import com.volmit.config.MinNumber;
|
||||
import com.volmit.config.Ref;
|
||||
import com.volmit.config.Reference;
|
||||
import com.volmit.config.Snippet;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -37,13 +39,13 @@ public final class NoiseStyle {
|
||||
@Desc("The zoom of this style")
|
||||
private double zoom = 1;
|
||||
|
||||
@Ref(Reference.PACK_EXPRESSION)
|
||||
@Ref(kind = PackExpression.class)
|
||||
@Desc("Instead of using the style property, use a custom expression to represent this style.")
|
||||
private String expression;
|
||||
private ResourceId expression;
|
||||
|
||||
@Ref(Reference.PACK_IMAGE_MAP)
|
||||
@Ref(kind = PackImageMap.class)
|
||||
@Desc("Use an Image map instead of a generated value")
|
||||
private String imageMap;
|
||||
private ResourceId imageMap;
|
||||
|
||||
@MinNumber(0.00001)
|
||||
@Desc("The Output multiplier. Only used if parent is fracture.")
|
||||
@@ -109,13 +111,13 @@ public final class NoiseStyle {
|
||||
return zoom;
|
||||
}
|
||||
|
||||
/** The key of the pack expression that replaces the base style. */
|
||||
public Optional<String> expression() {
|
||||
/** The pack expression that replaces the base style, by the id the pack gives its key; see {@link PackResources#EXPRESSIONS}. */
|
||||
public Optional<ResourceId> expression() {
|
||||
return Optional.ofNullable(expression);
|
||||
}
|
||||
|
||||
/** The key of the pack image map that replaces the base style when there is no expression. */
|
||||
public Optional<String> imageMap() {
|
||||
/** The pack image map that replaces the base style when there is no expression; see {@link PackResources#IMAGE_MAPS}. */
|
||||
public Optional<ResourceId> imageMap() {
|
||||
return Optional.ofNullable(imageMap);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.volmit.noise;
|
||||
|
||||
import com.volmit.resource.ResourceId;
|
||||
import java.util.Objects;
|
||||
|
||||
/** An expression of the loaded pack, which a {@link NoiseStyle} can use instead of a base style. The host compiles it
|
||||
* and builds its noise ({@link NoiseFactory}); a module only names it, and can see that the pack has it through
|
||||
* {@code PackResources.find(PackResources.EXPRESSIONS, id)}.
|
||||
*/
|
||||
public record PackExpression(ResourceId id) {
|
||||
public PackExpression {
|
||||
Objects.requireNonNull(id, "id");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.volmit.noise;
|
||||
|
||||
import com.volmit.resource.ResourceId;
|
||||
import java.util.Objects;
|
||||
|
||||
/** An image map of the loaded pack, which a {@link NoiseStyle} can use instead of a base style. The host reads the
|
||||
* image and builds its noise ({@link NoiseFactory}); a module only names it, and can see that the pack has it through
|
||||
* {@code PackResources.find(PackResources.IMAGE_MAPS, id)}.
|
||||
*/
|
||||
public record PackImageMap(ResourceId id) {
|
||||
public PackImageMap {
|
||||
Objects.requireNonNull(id, "id");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.volmit.resource;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* What an item or entity a module hands the host is: a registered type by its {@link ResourceId}, or a mob or item of a
|
||||
* content provider by the provider's own name for it. Provider names are kept as written because providers tell their
|
||||
* content apart by case ({@code mythicmobs:SkeletonKing}, {@code mmoitems_SWORD:EXCALIBUR}), which no
|
||||
* {@code ResourceId} can hold.
|
||||
*/
|
||||
public sealed interface ContentKey permits ContentKey.Registered, ContentKey.Provided {
|
||||
/**
|
||||
* A type in the platform's registries, such as {@code minecraft:diamond_sword}, or one the host routes by its
|
||||
* namespace to the provider that owns it, such as {@code itemsadder:ruby}; the host decides which.
|
||||
*/
|
||||
record Registered(ResourceId id) implements ContentKey {
|
||||
public Registered {
|
||||
Objects.requireNonNull(id, "id");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return id.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A mob or item of a content provider: the provider, such as {@code mythicmobs}, and its name for the content, which
|
||||
* may hold any character, {@code :} included.
|
||||
*/
|
||||
record Provided(String provider, String name) implements ContentKey {
|
||||
public Provided {
|
||||
Objects.requireNonNull(provider, "provider");
|
||||
Objects.requireNonNull(name, "name");
|
||||
if (provider.isBlank() || name.isBlank()) {
|
||||
throw new IllegalArgumentException("A provided key needs a provider and a name: " + provider + ":" + name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return provider + ":" + name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package com.volmit.resource;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.item.ItemRegistry;
|
||||
import com.volmit.noise.NoiseFactory;
|
||||
import com.volmit.noise.PackExpression;
|
||||
import com.volmit.noise.PackImageMap;
|
||||
import com.volmit.object.GeneratedObject;
|
||||
import com.volmit.world.PackBiome;
|
||||
import com.volmit.world.PackRegion;
|
||||
@@ -14,8 +16,8 @@ import java.util.UUID;
|
||||
/** Immutable view of one loaded pack snapshot, safe for concurrent reads.
|
||||
* Reload produces a different snapshotId, even for the same pack. Resources must be immutable
|
||||
* or explicitly thread-safe. A resource is named by its kind and its id, so one id can name
|
||||
* both a biome and a region. Hosts serve the kinds {@link #BIOMES}, {@link #REGIONS} and {@link #OBJECTS}
|
||||
* and every {@link ResourceKind} the pack's modules register; an id the pack lacks for that kind returns empty,
|
||||
* both a biome and a region. Hosts serve the kinds {@link #BIOMES}, {@link #REGIONS}, {@link #OBJECTS},
|
||||
* {@link #EXPRESSIONS} and {@link #IMAGE_MAPS} and every {@link ResourceKind} the pack's modules register; an id the pack lacks for that kind returns empty,
|
||||
* and a kind the host does not serve throws IllegalArgumentException. Broken resources fail loading rather than
|
||||
* appearing absent. The host owns resolution, imports, native handles and caches; no filesystem paths escape.
|
||||
*/
|
||||
@@ -29,6 +31,12 @@ public interface PackResources {
|
||||
/** The pack's objects as geometry, as the host reads them from its own folder. */
|
||||
ResourceKind<GeneratedObject> OBJECTS = ResourceKind.of("host:object", "objects", GeneratedObject.class);
|
||||
|
||||
/** The pack's expressions, which noise styles use; the host compiles them from its own folder. */
|
||||
ResourceKind<PackExpression> EXPRESSIONS = ResourceKind.of("host:expression", "expressions", PackExpression.class);
|
||||
|
||||
/** The pack's image maps, which noise styles use; the host reads them from its own folder. */
|
||||
ResourceKind<PackImageMap> IMAGE_MAPS = ResourceKind.of("host:image-map", "image-maps", PackImageMap.class);
|
||||
|
||||
ResourceId packId();
|
||||
UUID snapshotId();
|
||||
BlockRegistry blocks();
|
||||
@@ -49,7 +57,7 @@ public interface PackResources {
|
||||
|
||||
/** The id of the resource the pack's files name by {@code key} (the file path inside the kind's folder, without
|
||||
* {@code .json}), such as {@code overworld:dungeon/chest} for {@code dungeon/chest}; see
|
||||
* {@link ResourceId#ofPackKey}. Settings that name a resource, such as a {@link com.volmit.config.ResourceRef}, or a
|
||||
* {@link ResourceId#ofPackKey}. Settings that name a resource in a {@code String}, such as a {@link com.volmit.config.Ref} option, or a
|
||||
* biome's key in a region, hold such a key. Characters an id cannot hold are replaced the way the host does for its
|
||||
* own ids, so use this and not {@code new ResourceId(packId().namespace(), key)}.
|
||||
*/
|
||||
|
||||
@@ -4,12 +4,14 @@ import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** Case-sensitive namespaced identity. Parsing never supplies an implicit namespace. */
|
||||
/** Case-sensitive namespaced identity. {@link #parse} never supplies an implicit namespace; {@link #ofPackKey} and
|
||||
* {@link #ofPlatformKey} turn the keys packs write into ids. */
|
||||
public record ResourceId(String namespace, String path) implements Comparable<ResourceId> {
|
||||
private static final Pattern NAMESPACE = Pattern.compile("[a-z0-9_.-]+");
|
||||
private static final Pattern PATH = Pattern.compile("[a-z0-9_./-]+");
|
||||
private static final Pattern NOT_PATH = Pattern.compile("[^a-z0-9_./-]");
|
||||
private static final String PATH_REPLACEMENT = "_";
|
||||
private static final String PLATFORM_NAMESPACE = "minecraft";
|
||||
|
||||
public ResourceId {
|
||||
Objects.requireNonNull(namespace, "namespace");
|
||||
@@ -42,6 +44,17 @@ public record ResourceId(String namespace, String path) implements Comparable<Re
|
||||
return new ResourceId(namespace, NOT_PATH.matcher(key.toLowerCase(Locale.ROOT)).replaceAll(PATH_REPLACEMENT));
|
||||
}
|
||||
|
||||
/**
|
||||
* The id of a platform key as packs write it, such as {@code minecraft:diamond_sword} for {@code DIAMOND_SWORD} or
|
||||
* {@code Diamond Sword}: trimmed, lower-cased, spaces as {@code _}, in the {@code minecraft} namespace when it names
|
||||
* none. Throws IllegalArgumentException when the result is still no id, such as for {@code a:b:c}.
|
||||
*/
|
||||
public static ResourceId ofPlatformKey(String key) {
|
||||
Objects.requireNonNull(key, "key");
|
||||
String normalized = key.trim().toLowerCase(Locale.ROOT).replace(' ', '_');
|
||||
return parse(normalized.indexOf(':') < 0 ? PLATFORM_NAMESPACE + ":" + normalized : normalized);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() { return namespace + ":" + path; }
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.volmit.service;
|
||||
|
||||
import com.volmit.entity.EntitySpec;
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.world.PackWorld;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -44,34 +45,46 @@ public interface AmbientEffects {
|
||||
/**
|
||||
* A sound played to the player.
|
||||
*
|
||||
* @param key the platform's sound key
|
||||
* @param key the sound, such as {@code minecraft:ambient.cave}
|
||||
* @param offsetX blocks from the player where the sound seems to come from, as the other offsets
|
||||
* @param volume the sound's volume
|
||||
* @param pitch the sound's pitch
|
||||
*/
|
||||
record Sound(String key, int offsetX, int offsetY, int offsetZ, float volume, float pitch) {
|
||||
record Sound(ResourceId key, int offsetX, int offsetY, int offsetZ, float volume, float pitch) {
|
||||
public Sound {
|
||||
Objects.requireNonNull(key, "key");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Particles shown to the player. They appear {@code forward} blocks ahead of the player, {@code sideways} blocks to
|
||||
* the right (negative for the left) and on the surface at that spot, one block up, moved by {@code jitterX} and
|
||||
* {@code jitterZ} and by {@code lift} blocks up.
|
||||
* Particles shown to the player.
|
||||
*
|
||||
* @param key the platform's particle key
|
||||
* @param count how many particles; none makes {@code altX}, {@code altY} and {@code altZ} their motion
|
||||
* @param altX the particles' offset or motion, as the other two
|
||||
* @param extra an extra value some particles take; 0 for none
|
||||
* @param key the particle, such as {@code minecraft:ash}
|
||||
* @param spot where they appear
|
||||
* @param count how many particles; none makes {@code spread} their motion
|
||||
* @param spread how far the particles spread along each axis, or their motion when {@code count} is 0
|
||||
* @param extra an extra value some particles take; 0 for none
|
||||
*/
|
||||
record Particles(String key, double forward, double sideways, double jitterX, double jitterZ, int lift, int count,
|
||||
double altX, double altY, double altZ, double extra) {
|
||||
record Particles(ResourceId key, Spot spot, int count, Spread spread, double extra) {
|
||||
public Particles {
|
||||
Objects.requireNonNull(key, "key");
|
||||
Objects.requireNonNull(spot, "spot");
|
||||
Objects.requireNonNull(spread, "spread");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Where particles appear: {@code forward} blocks ahead of the player, {@code sideways} blocks to the right (negative
|
||||
* for the left) and on the surface at that spot, one block up, moved by {@code jitterX} and {@code jitterZ} and by
|
||||
* {@code lift} blocks up.
|
||||
*/
|
||||
record Spot(double forward, double sideways, double jitterX, double jitterZ, int lift) {
|
||||
}
|
||||
|
||||
/** A distance along each axis. */
|
||||
record Spread(double x, double y, double z) {
|
||||
}
|
||||
|
||||
/**
|
||||
* A command to run where the effect plays.
|
||||
*
|
||||
@@ -88,11 +101,11 @@ public interface AmbientEffects {
|
||||
/**
|
||||
* A potion effect for the player. A player who has the same potion effect with a stronger amplifier keeps it.
|
||||
*
|
||||
* @param key the platform's potion effect key
|
||||
* @param key the potion effect, such as {@code minecraft:night_vision}
|
||||
* @param strength the amplifier
|
||||
* @param ticks how long it lasts, in server ticks
|
||||
*/
|
||||
record Potion(String key, int strength, int ticks) {
|
||||
record Potion(ResourceId key, int strength, int ticks) {
|
||||
public Potion {
|
||||
Objects.requireNonNull(key, "key");
|
||||
}
|
||||
|
||||
@@ -25,8 +25,12 @@ public interface EntitySpawns {
|
||||
/** The pack's entity {@code entity} as this module would spawn it, for tools that spawn one on request; empty for an unknown one. */
|
||||
Optional<EntitySpec> entity(PackWorld world, ResourceId entity);
|
||||
|
||||
/** What a marker in the world means for spawning; empty for a marker this module does not know. */
|
||||
Optional<MarkerRule> marker(PackWorld world, String tag);
|
||||
/**
|
||||
* What a marker in the world means for spawning; empty for a marker this module does not know. A marker's tag is a
|
||||
* key of the pack, as an object's marker block names it, and {@code tag} the id the pack gives it
|
||||
* ({@link com.volmit.resource.PackResources#idOf}).
|
||||
*/
|
||||
Optional<MarkerRule> marker(PackWorld world, ResourceId tag);
|
||||
|
||||
/** Where entities may spawn. */
|
||||
sealed interface Site permits Chunk, Marker {
|
||||
@@ -46,11 +50,11 @@ public interface EntitySpawns {
|
||||
* A spawn at a marker.
|
||||
*
|
||||
* @param position the marker's block: world X and Z, Y the height above the dimension's bottom
|
||||
* @param marker the marker's tag
|
||||
* @param marker the id of the marker's tag, as {@link EntitySpawns#marker} takes it
|
||||
* @param spawner the pack's spawner chosen among the marker's
|
||||
* @param initial whether the spawner's initial spawns are used rather than its ordinary ones
|
||||
*/
|
||||
record Marker(BlockPosition position, String marker, ResourceId spawner, boolean initial) implements Site {
|
||||
record Marker(BlockPosition position, ResourceId marker, ResourceId spawner, boolean initial) implements Site {
|
||||
public Marker {
|
||||
Objects.requireNonNull(position, "position");
|
||||
Objects.requireNonNull(marker, "marker");
|
||||
|
||||
@@ -59,9 +59,9 @@ public interface Loot {
|
||||
* A loot table of the platform, such as {@code minecraft:chests/simple_dungeon}. The host draws it with {@code seed}
|
||||
* so that the same container always gets the same items.
|
||||
*/
|
||||
record PlatformTable(String key, long seed) implements Source {
|
||||
record PlatformTable(ResourceId table, long seed) implements Source {
|
||||
public PlatformTable {
|
||||
Objects.requireNonNull(key, "key");
|
||||
Objects.requireNonNull(table, "table");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,9 +33,10 @@ public interface SaplingGrowth {
|
||||
*
|
||||
* @param at where the growth happened: world X and Z, Y the height above the dimension's bottom
|
||||
* @param center the middle of the plane of saplings that grow together, the same way
|
||||
* @param species the platform's name for the kind of tree that would grow, such as {@code TREE} or {@code JUNGLE}
|
||||
* @param species the kind of tree that would grow, as the platform names it, such as {@code minecraft:tree} or
|
||||
* {@code minecraft:jungle} (Bukkit's tree types, lower-cased)
|
||||
*/
|
||||
record Sapling(BlockPosition at, BlockPosition center, String species) {
|
||||
record Sapling(BlockPosition at, BlockPosition center, ResourceId species) {
|
||||
public Sapling {
|
||||
Objects.requireNonNull(at, "at");
|
||||
Objects.requireNonNull(center, "center");
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.volmit.config.Ref;
|
||||
import com.volmit.config.Reference;
|
||||
import com.volmit.config.MaxNumber;
|
||||
import com.volmit.config.MinNumber;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
@@ -16,8 +17,8 @@ import java.util.OptionalInt;
|
||||
*/
|
||||
@Desc("Optional overrides applied to a live vanilla, datapack, or modded jigsaw definition before Minecraft assembles it. Omitted values preserve the registered source definition.")
|
||||
public final class JigsawOverrides {
|
||||
/** Removes the definition's start connector constraint when given as {@link #startJigsawName()}. */
|
||||
public static final String NO_START_JIGSAW = "NONE";
|
||||
/** What packs write as the start connector to remove the definition's constraint. */
|
||||
private static final String NO_START_JIGSAW = "NONE";
|
||||
|
||||
/** Whether the start piece follows one of the platform's heightmaps. */
|
||||
@Desc("Controls whether a configured native jigsaw projects its start onto a Minecraft heightmap.")
|
||||
@@ -114,16 +115,23 @@ public final class JigsawOverrides {
|
||||
}
|
||||
|
||||
/** These overrides, starting from the template pool {@code pool}, such as {@code minecraft:village/plains/town_centers}. */
|
||||
public JigsawOverrides withStartPool(String pool) {
|
||||
public JigsawOverrides withStartPool(ResourceId pool) {
|
||||
JigsawOverrides overrides = new JigsawOverrides(this);
|
||||
overrides.startPool = Objects.requireNonNull(pool, "pool");
|
||||
overrides.startPool = pool.toString();
|
||||
return overrides;
|
||||
}
|
||||
|
||||
/** These overrides, starting from the connector {@code name}; {@link #NO_START_JIGSAW} removes the constraint. */
|
||||
public JigsawOverrides withStartJigsawName(String name) {
|
||||
/** These overrides, starting from the connector {@code name}. */
|
||||
public JigsawOverrides withStartJigsawName(ResourceId name) {
|
||||
JigsawOverrides overrides = new JigsawOverrides(this);
|
||||
overrides.startJigsawName = Objects.requireNonNull(name, "name");
|
||||
overrides.startJigsawName = name.toString();
|
||||
return overrides;
|
||||
}
|
||||
|
||||
/** These overrides, without the definition's start connector constraint. */
|
||||
public JigsawOverrides withoutStartJigsaw() {
|
||||
JigsawOverrides overrides = new JigsawOverrides(this);
|
||||
overrides.startJigsawName = NO_START_JIGSAW;
|
||||
return overrides;
|
||||
}
|
||||
|
||||
@@ -167,14 +175,23 @@ public final class JigsawOverrides {
|
||||
return overrides;
|
||||
}
|
||||
|
||||
/** The template pool to start from; empty keeps the definition's. */
|
||||
public String startPool() {
|
||||
return startPool == null ? "" : startPool;
|
||||
/** The template pool to start from, such as {@code minecraft:village/plains/town_centers}; empty keeps the definition's. */
|
||||
public Optional<ResourceId> startPool() {
|
||||
return platformKey(startPool);
|
||||
}
|
||||
|
||||
/** The start connector; empty keeps the definition's, {@link #NO_START_JIGSAW} removes it. */
|
||||
public String startJigsawName() {
|
||||
return startJigsawName == null ? "" : startJigsawName;
|
||||
/** The start connector; empty keeps the definition's, unless {@link #removesStartJigsaw()}. */
|
||||
public Optional<ResourceId> startJigsawName() {
|
||||
return removesStartJigsaw() ? Optional.empty() : platformKey(startJigsawName);
|
||||
}
|
||||
|
||||
/** Whether the start connector constraint is removed, which packs write as {@code NONE}. */
|
||||
public boolean removesStartJigsaw() {
|
||||
return startJigsawName != null && NO_START_JIGSAW.equalsIgnoreCase(startJigsawName.trim());
|
||||
}
|
||||
|
||||
private static Optional<ResourceId> platformKey(String key) {
|
||||
return key == null || key.isBlank() ? Optional.empty() : Optional.of(ResourceId.ofPlatformKey(key));
|
||||
}
|
||||
|
||||
public OptionalInt maxDepth() {
|
||||
@@ -217,8 +234,8 @@ public final class JigsawOverrides {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return other instanceof JigsawOverrides that && startPool().equals(that.startPool())
|
||||
&& startJigsawName().equals(that.startJigsawName()) && Objects.equals(maxDepth, that.maxDepth)
|
||||
return other instanceof JigsawOverrides that && written(startPool).equals(written(that.startPool))
|
||||
&& written(startJigsawName).equals(written(that.startJigsawName)) && Objects.equals(maxDepth, that.maxDepth)
|
||||
&& Objects.equals(maxDistanceHorizontal, that.maxDistanceHorizontal)
|
||||
&& Objects.equals(maxDistanceVertical, that.maxDistanceVertical)
|
||||
&& Objects.equals(useExpansionHack, that.useExpansionHack)
|
||||
@@ -230,12 +247,17 @@ public final class JigsawOverrides {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(startPool(), startJigsawName(), maxDepth, maxDistanceHorizontal, maxDistanceVertical,
|
||||
return Objects.hash(written(startPool), written(startJigsawName), maxDepth, maxDistanceHorizontal, maxDistanceVertical,
|
||||
useExpansionHack, projectStartToHeightmap(), dimensionPaddingBottom, dimensionPaddingTop, liquidSettings());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JigsawOverrides[pool '" + startPool() + "', depth " + maxDepth + ", " + projectStartToHeightmap() + "]";
|
||||
return "JigsawOverrides[pool '" + written(startPool) + "', depth " + maxDepth + ", " + projectStartToHeightmap() + "]";
|
||||
}
|
||||
|
||||
/** A key as the pack wrote it, without surrounding blanks; empty when it wrote none. */
|
||||
private static String written(String key) {
|
||||
return key == null ? "" : key.trim();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.volmit.world;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import java.util.Optional;
|
||||
|
||||
/** The dimension stacked above the one being generated, whose ground hangs from the top of this one's volume. It may be
|
||||
@@ -14,8 +15,8 @@ public interface UpperDimension {
|
||||
/** Whether the dimension above is this very dimension, stacked on itself. */
|
||||
boolean isThisDimension();
|
||||
|
||||
/** The key the pack knows the dimension by, such as {@code overworld}: what its noise seeds derive from. */
|
||||
String key();
|
||||
/** The id its pack gives the dimension's key, such as {@code overworld:overworld}: what its noise seeds derive from. */
|
||||
ResourceId id();
|
||||
|
||||
/** The settings of the upper dimension: its dimension, and the region and surface biome it has at the column. */
|
||||
FeatureSettings settings();
|
||||
|
||||
Reference in new issue
Block a user