genesis

API Reference

API Reference

Complete API reference for the Genesis celestial system.

Table of Contents


Celestial

Package: shipwrights.genesis.space File: src/main/java/shipwrights/genesis/space/Celestial.java

The main class representing a celestial body in the Genesis system.

Constructor

public Celestial(
    CelestialTransformProvider transformProvider,
    ResourceLocation id,
    CelestialType type,
    double size,
    double gravity,
    float r,
    float g,
    float b
)

Parameters:

Methods

getID()

public ResourceLocation getID()

Returns the unique identifier for this celestial.

Returns: ResourceLocation - The celestial’s ID


getType()

public CelestialType getType()

Returns the type of this celestial.

Returns: CelestialType - The celestial’s type


size()

public double size()

Returns the size multiplier of this celestial.

Returns: double - Size multiplier (actual diameter = size × 96 blocks)


gravity()

public double gravity()

Returns the gravity strength of this celestial.

Returns: double - Gravity multiplier (1.0 = Earth gravity)


r(), g(), b()

public float r()
public float g()
public float b()

Returns the color components of this celestial.

Returns: float - Color value from 0.0 to 1.0


getPosition()

public Vector3d getPosition(long ticks, float partialTick)

Calculates the position of this celestial at a specific time.

Parameters:

Returns: Vector3d - Position vector in world space


getRotation()

public Quaterniondc getRotation(long ticks, float partialTick)

Calculates the rotation of this celestial at a specific time.

Parameters:

Returns: Quaterniondc - Rotation quaternion


getTransformProvider()

public CelestialTransformProvider getTransformProvider()

Returns the transform provider for this celestial.

Returns: CelestialTransformProvider - The transform provider


getNearestStar()

public Celestial getNearestStar(long gameTime, float partialTick)

Finds the nearest star-type celestial to this one.

Parameters:

Returns: Celestial - The nearest star, or null if none exists


getDayTime()

public long getDayTime(long gameTime)

Calculates the day time (0-24000) for this celestial based on the nearest star’s position.

Parameters:

Returns: long - Day time value (0 = noon, 12000 = midnight)


Static Fields

public static double BASE_SIZE = 96;
public static double BASE_ORBIT_DISTANCE = 15_000;
public static double BASE_ORBIT_TIME = 4_608_000;
public static double BASE_DAY_LENGTH = 24_000;

Descriptions:


CelestialType

Package: shipwrights.genesis.space.type File: src/main/java/shipwrights/genesis/space/type/CelestialType.java

Interface defining the behavioral properties and rendering of celestial types.

Methods

castsLight()

boolean castsLight()

Whether this type emits light (affects day/night cycles on other celestials).

Returns: boolean - true for stars, false for planets/moons


castsShadow()

boolean castsShadow()

Whether this type casts shadows (blocks light from other sources).

Returns: boolean - true for opaque bodies, false for stars


isVisitable()

boolean isVisitable()

Whether players can land on this type of celestial.

Returns: boolean - true for planets/moons, false for stars


getRenderer()

@NotNull CelestialRenderer getRenderer()

Returns the renderer used to draw this type of celestial.

Returns: CelestialRenderer - The renderer instance


getID()

@NotNull ResourceLocation getID()

Returns the unique identifier for this type.

Returns: ResourceLocation - The type’s ID


Static Methods

get()

static CelestialType get(ResourceLocation ID)

Retrieves a registered celestial type by its ID.

Parameters:

Returns: CelestialType - The type, or throws if not found


register()

static void register(CelestialType type)

Registers a new celestial type.

Parameters:


Built-in Types

genesis:star

genesis:body


CelestialTransformProvider

Package: shipwrights.genesis.space.transformProvider File: src/main/java/shipwrights/genesis/space/transformProvider/CelestialTransformProvider.java

Interface for providing position and rotation transformations over time.

Methods

getPosition()

Vector3d getPosition(long ticks, float subticks)

Calculates position at a specific time.

Parameters:

Returns: Vector3d - Position vector


getRotation()

Quaterniondc getRotation(long ticks, float subticks)

Calculates rotation at a specific time.

Parameters:

Returns: Quaterniondc - Rotation quaternion


getType()

ResourceLocation getType()

Returns the type identifier for this transform provider.

Returns: ResourceLocation - The provider type ID


Static Methods

register()

static void register(ResourceLocation type, Codec<? extends CelestialTransformProvider> codec)

Registers a transform provider type with its codec for JSON deserialization.

Parameters:


StaticTransformProvider

Package: shipwrights.genesis.space.transformProvider File: src/main/java/shipwrights/genesis/space/transformProvider/StaticTransformProvider.java

Transform provider for celestials with fixed positions and rotations.

Type ID: genesis:static

Constructors

Position Only

public StaticTransformProvider(double x, double y, double z)

Parameters:


Position and Rotation

public StaticTransformProvider(
    double x, double y, double z,
    double xRot, double yRot, double zRot
)

Parameters:


JSON Fields

{
  "type": "genesis:static",
  "x": 0.0,
  "y": 0.0,
  "z": 0.0,
  "xRot": 0.0,
  "yRot": 0.0,
  "zRot": 0.0
}
Field Type Required Default Description
type String Yes - Must be "genesis:static"
x Number Yes - X position
y Number Yes - Y position
z Number Yes - Z position
xRot Number No 0.0 X rotation (radians)
yRot Number No 0.0 Y rotation (radians)
zRot Number No 0.0 Z rotation (radians)

OrbitingTransformProvider

Package: shipwrights.genesis.space.transformProvider File: src/main/java/shipwrights/genesis/space/transformProvider/OrbitingTransformProvider.java

Transform provider for celestials that orbit around a parent body.

Type ID: genesis:orbiting

Constructor

public OrbitingTransformProvider(
    ResourceLocation parentID,
    int seed,
    double orbitDistance,
    double orbitTime,
    double dayLength
)

Parameters:


JSON Fields

{
  "type": "genesis:orbiting",
  "parentID": "namespace:parent",
  "seed": 12345,
  "orbitDistance": 1.0,
  "orbitTime": 1.0,
  "dayLength": 1.0
}
Field Type Required Default Description
type String Yes - Must be "genesis:orbiting"
parentID String Yes - Parent celestial ID
seed Integer Yes - Random seed
orbitDistance Number Yes - Distance multiplier
orbitTime Number Yes - Period multiplier
dayLength Number No 1.0 Day length multiplier

Behavior


SpaceRegistry

Package: shipwrights.genesis.space.registry File: src/main/java/shipwrights/genesis/space/registry/SpaceRegistry.java

Central registry for all celestials in the game.

Static Methods

get()

public static Celestial get(ResourceLocation id)

Retrieves a celestial by its ID.

Parameters:

Returns: Celestial - The celestial, or null if not found


getAll()

public static List<Celestial> getAll()

Returns all registered celestials.

Returns: List<Celestial> - List of all celestials


getWhere()

public static List<Celestial> getWhere(Predicate<CelestialType> predicate)

Filters celestials by type predicate.

Parameters:

Returns: List<Celestial> - Filtered list of celestials

Example:

// Get all stars
List<Celestial> stars = SpaceRegistry.getWhere(type -> type.castsLight());

// Get all visitable bodies
List<Celestial> planets = SpaceRegistry.getWhere(type -> type.isVisitable());

RegisterCelestialsEvent

Inner Class: SpaceRegistry.RegisterCelestialsEvent

Event class used during celestial registration.

accept()

public void accept(Celestial celestial)

Registers a celestial to the registry.

Parameters:


GenesisMod

Package: shipwrights.genesis File: src/main/java/shipwrights/genesis/GenesisMod.java

Main mod class with registration hooks.

Static Methods

onRegisterCelestialsEvent()

public static void onRegisterCelestialsEvent(
    Consumer<SpaceRegistry.RegisterCelestialsEvent> callback
)

Location: src/main/java/shipwrights/genesis/GenesisMod.java:88-90

Registers a callback to be invoked during celestial registration.

Parameters:

Example:

GenesisMod.onRegisterCelestialsEvent(event -> {
    // Register celestials here
    Celestial sun = new Celestial(...);
    event.accept(sun);
});

Constants

Size Constants

Celestial.BASE_SIZE = 96  // blocks (diameter)

Usage:


Distance Constants

Celestial.BASE_ORBIT_DISTANCE = 15_000  // blocks

Usage:


Time Constants

Celestial.BASE_ORBIT_TIME = 4_608_000    // ticks (≈ 64 hours)
Celestial.BASE_DAY_LENGTH = 24_000       // ticks (20 minutes)

Usage:


JSON Schema

System Config File Format

Location: data/<namespace>/system_config/<filename>.json

{
  "celestials": [
    {
      "ID": "string",
      "type": "string",
      "size": number,
      "gravity": number,
      "r": number,
      "g": number,
      "b": number,
      "transformProvider": {
        "type": "string",
        ...
      }
    }
  ]
}

Celestial Object Schema

Field Type Required Default Description
ID String Yes - Unique identifier (format: namespace:name)
type String Yes - Celestial type ID
size Number Yes - Size multiplier
gravity Number Yes - Gravity multiplier
r Number No 0.5 Red component (0.0-1.0)
g Number No 0.5 Green component (0.0-1.0)
b Number No 0.5 Blue component (0.0-1.0)
transformProvider Object Yes - Transform configuration

Transform Provider Types

See StaticTransformProvider and OrbitingTransformProvider sections above for complete field specifications.


See Also