Textures and Emissive
PulseLib does not draw model textures directly from arbitrary files. It first collects them into a runtime atlas, then the baked model stores UVs for that atlas. This is why texture registration is a required step instead of an optional convenience.
Texture registration uses PulseLibEvents.RegisterTextureEvent.
Register textures¶
Subscribe on the mod event bus and add every texture that a PulseLib model may use:
@Mod.EventBusSubscriber(modid = ExampleMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public final class ExampleClientEvents {
@SubscribeEvent
public static void registerPulseTextures(PulseLibEvents.RegisterTextureEvent event) {
event.addTextureLocation(Identifier.fromNamespaceAndPath(
ExampleMod.MOD_ID, "entity/robot/body"));
event.addTextureLocation(Identifier.fromNamespaceAndPath(
ExampleMod.MOD_ID, "entity/robot/eyes"));
}
}
The most common mistake is to include too much of the file path. Resource locations are relative to textures and have no .png extension:
becomes:
Runtime atlas¶
The atlas is registered by PulseLib itself. Your mod only contributes texture locations.
Runtime atlas classes:
PulseLib registers the atlas at:
Renderers normally pass PTextureCache.ATLAS_LOCATION to PRenderTypes, so you rarely need to access the atlas manually.
Emissive textures¶
Emissive textures are useful for eyes, screens, lamps, energy parts, and other pieces that should ignore normal light. PulseLib reads this flag from texture metadata through PLibSpriteMetadata.
To mark a texture as emissive, add a .png.mcmeta file next to it:
assets/examplemod/textures/entity/robot/eyes.png
assets/examplemod/textures/entity/robot/eyes.png.mcmeta
When PModelCache bakes the model, each mesh stores whether its sprite is emissive. The default renderers automatically switch to an emissive variant through:
You can also choose an emissive render type directly in custom rendering code:
PRenderTypes.RenderTypeProvider::trianglesEmissiveCutout
PRenderTypes.RenderTypeProvider::trianglesEmissiveTranslucent
PRenderTypes.RenderTypeProvider::trianglesInstantEmissiveCutout
PRenderTypes.RenderTypeProvider::trianglesInstantEmissiveTranslucent
Classes used: