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:
piexel committed 2026-10-24 06:06:44 +02:00
1 parent 05f621d82d
commit 6b24e6f150
31 files changed
+620 -295

No files matched your search

@@ -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");