-
Notifications
You must be signed in to change notification settings - Fork 0
Outline API
Butterfly API can render custom outlines around entities and block entities.
Outlines can be controlled from the server for synced behavior or directly on the client for local-only effects.
Create an outline style with:
import moth.butterflyapi.outline.OutlinePlacement;
import moth.butterflyapi.outline.OutlineStyle;
OutlineStyle questStyle =
OutlineStyle.builder("#FFFFFF")
.thickness(2)
.placement(
OutlinePlacement.CENTERED
)
.blackBorder(false)
.visibleThroughWalls(true)
.matchModelLayer(true)
.consistentThickness(true)
.build();See Outline Styles for the individual style settings.
Use ServerOutlines when an outline should be controlled by the logical server.
import moth.butterflyapi.outline.ServerOutlines;ServerOutlines.set(
targetEntity,
questStyle
);ServerOutlines.clear(
targetEntity
);This is suitable when the outline should be synced for viewers.
An outline can also be shown to one specific player.
ServerOutlines.setFor(
player,
targetEntity,
OutlineStyle.builder("#66CCFF")
.thickness(3)
.placement(
OutlinePlacement.OUTSIDE
)
.build()
);Clear that viewer-specific outline with:
ServerOutlines.clearFor(
player,
targetEntity
);This allows different players to see different outlines for the same entity.
Server outlines also support block entities.
ServerOutlines.set(
displayCaseBlockEntity,
OutlineStyle.of("#FFFFFF")
);Clear it with:
ServerOutlines.clear(
displayCaseBlockEntity
);For local effects that do not need server synchronization, use:
import moth.butterflyapi.client.outline.ClientOutlines;Set an outline:
ClientOutlines.set(
entity,
OutlineStyle.builder("#FFAA33")
.thickness(2)
.build()
);Clear it:
ClientOutlines.clear(entity);Clear all local outlines:
ClientOutlines.clearAll();Client outlines should be used from client-side code.
Use ServerOutlines when:
- The logical server controls the effect
- The outline should be synchronized to clients
- Different players may need different outline states
Use ClientOutlines when:
- The outline is purely local
- Only the current client needs to know about it
- No server synchronization is required
Custom client renderers can contribute their own outline masks using:
OutlineRenderers.capture(...)This is useful when a renderer cannot be represented correctly by the normal outline capture process.
A block entity whose renderer exists only to contribute to the outline mask can implement:
OutlineOnlyBlockEntityThis allows the renderer to participate in the outline system without being treated like a normal visible block entity renderer.
For custom renderers using cutout or translucent model layers, an outline style can use:
OutlineStyle.builder("#FFFFFF")
.matchModelLayer(true)
.build();This helps the outline mask follow the source renderer's model layer.