Hephaestus Engine
repository·main·Indexed 42 days ago
https://github.com/unnamed/hephaestus-engineA platform-agnostic library for creating custom models, animations, and interactions in vanilla Minecraft: Java Edition. It supports integration with server environments like Paper and Minestom, provides tools for reading Blockbench .bbmodel files, and includes a ModelWriter for generating resource packs.
What's inside Hephaestus Engine
Understand the BaseModelView interface
mainTheBaseModelViewinterface provides a platform-independent way to interact with model views. It allows you to perform basic operations such as applying colors, managing movements, and controlling animations or animation ticking. WhileBaseModelViewhandles general logic, you should use platform-specific implementations (like those for Minestom or Bukkit) when you need specialized functionality.Understand cube rotation constraints in Minecraft models
mainWhen creating models using the vanilla Minecraft client, be aware of specific rotation constraints for cubes. Cube rotations are restricted to a specific set of angles:
-45º,-22.5º,0º,22.5º, or45º.Note that this restriction does not apply to bone rotations, which can use arbitrary angles.
How ModelReader and ModelDataCursor work together
mainTo create a
Modelinstance, you use aModelReader. AModelReaderuses aModelDataCursorto assign acustom_model_dataproperty to every bone within the model.Important: You should use a single
ModelDataCursorinstance for an entire resource pack. This ensures that every bone across all models maintains uniquecustom_model_dataproperties, preventing collisions.// Create a single cursor to be shared across your resource pack ModelDataCursor modelDataCursor = new ModelDataCursor(0); // Pass the shared cursor to your reader ModelReader reader = BBModelReader.blockbench(modelDataCursor);Create a Minestom model view
mainTo use
hephaestus-enginewith Minestom, you must include thehephaestus-runtime-minestomsubproject in your dependencies. You can create and track a view usingMinestomModelEngine.minestom().createViewAndTrack(...), which requires aModel, a MinestomInstance, and aPos(position).Model model = ...; ModelEntity view = MinestomModelEngine.minestom().createViewAndTrack( model, instance, // Instance position // Pos );Install hephaestus-engine using Maven
mainTo use
hephaestus-enginein a Maven project, add theunnamed-publicrepository to yourpom.xml. Then, add thehephaestus-apidependency.<repository> <id>unnamed-public</id> <url>https://repo.unnamed.team/repository/unnamed-public/</url> </repository> <dependency> <groupId>team.unnamed</groupId> <artifactId>hephaestus-api</artifactId> <version>0.1.0-SNAPSHOT</version> </dependency>Install hephaestus-engine using Gradle
mainTo use
hephaestus-enginein a Gradle project, first add theunnamed-publicrepository to yourrepositoriesblock. Then, add the required dependencies to yourdependenciesblock.Note that
hephaestus-apiis the core dependency required for all uses. Other modules like the Blockbench model reader or specific runtimes (Bukkit, Minestom) are optional depending on your project requirements.repositories { maven("https://repo.unnamed.team/repository/unnamed-public/") } dependencies { // Core API, necessary for everything implementation("team.unnamed:hephaestus-api:0.1.0-SNAPSHOT") // Blockbench model reader (optional) implementation("team.unnamed:hephaestus-reader-blockbench:0.1.0-SNAPSHOT") // Bukkit runtime projects (you might want to add :reobf classifier to adapt-v1_20_R3) implementation("team.unnamed:hephaestus-runtime-bukkit-api:0.1.0-SNAPSHOT") implementation("team.unnamed:hephaestus-runtime-bukkit-adapt-v1_20_R3:0.1.0-SNAPSHOT") // Minestom runtime implementation("team.unnamed:hephaestus-runtime-minestom:0.1.0-SNAPSHOT") }Write a resource pack to a ZIP file or directory
mainOnce you have a
ResourcePackinstance (from thecreativelibrary), useMinecraftResourcePackWriter.minecraft()to export it to the filesystem. You can either write the pack to a.zipfile or to a plain directory.ResourcePack resourcePack = ...; // write the resource-pack to a ZIP file... MinecraftResourcePackWriter.minecraft().writeToZipFile(new File("resource-pack.zip"), resourcePack); // or write it to a directory... MinecraftResourcePackWriter.minecraft().writeToDirectory(new File("resource-pack"), resourcePack);Write models to a resource pack using ModelWriter
mainHephaestus-engine uses the
creativelibrary to interact with resource pack data. You can convert a collection ofModelobjects and their bones intocreativeitem models by usingModelWriter. Specify a namespace (e.g., "mynamespace") to organize the generated assets.Collection<Model> models = ...; // creative's ResourcePack ResourcePack resourcePack = ...; // write our models to the resource-pack using the "mynamespace" namespace ModelWriter.resource("mynamespace").write(tree, models);Read a Blockbench model from a file
mainTo load a
.bbmodelfile into aModelinstance, initialize aBBModelReaderwith aModelDataCursorand call thereadmethod with aFileobject.ModelReader reader = BBModelReader.blockbench(new ModelDataCursor(0)); Model model = reader.read(new File("model.bbmodel")); // do something with 'model'Create a BBModel Reader for Blockbench models
mainThe
BBModelReaderprovides implementations for reading models in the Blockbench.bbmodelformat. You can initialize it either without a cursor (using default behavior) or with a specificModelDataCursorto manage bone data properties.// Option 1: Basic reader without a custom cursor ModelReader reader = BBModelReader.blockbench(); // Option 2: Reader with an assigned ModelDataCursor ModelDataCursor modelDataCursor = new ModelDataCursor(0); ModelReader reader = BBModelReader.blockbench(modelDataCursor);Animate model views
mainAnimations are managed via the
AnimationController.- Queue an animation: Use
view.animationPlayer().queue(animation)to add aModelAnimationto the playback queue. Animations can be retrieved from the model usingModel#animations(). - Stop animations: Use
AnimationController#clearQueue()to stop all currently queued animations.
public void animate(BaseModelView<?> view) { // walkAnimation is a ModelAnimation instance that can // be obtained from Model#animations() view.animationPlayer().queue(walkAnimation); }- Queue an animation: Use