Public extension API for PlayerBatch
PlayerBatch-ExtAPI is the public contract for building add-ons on top of PlayerBatch.
PlayerBatch is already a Carpet addon. This repo gives other developers a clean second layer so they can extend PlayerBatch without patching its private internals.
Without a public API, extension mods usually end up doing one of these:
- hard-depending on private classes
- copy-pasting internals
- mixin-patching random implementation details
- breaking every time the main mod changes
PlayerBatch-ExtAPI exists to stop that.
Extensions can register:
- custom summon formations
- custom summon arguments
- custom selected-bot actions
- custom post-spawn behaviors
- extra command-side integrations that plug into PlayerBatch
The main PlayerBatch mod now consumes this API at runtime.
That means external mods can already:
- register Fabric entrypoints under
playerbatch-ext - add custom formations used by
/pb summon - add custom summon argument handlers
- add custom
/pb command ...action handlers - add custom post-spawn behavior handlers
Main extension contracts:
PlayerBatchExtensionEntrypointPlayerBatchRegistrarPlayerBatchFormationPlayerBatchArgumentPlayerBatchActionPlayerBatchBehaviorPlayerBatchSummonPlanPlayerBatchBotController
Main handler contracts:
PlayerBatchFormationFactoryPlayerBatchArgumentHandlerPlayerBatchActionHandlerPlayerBatchBehaviorHandler
Your extension mod should expose a Fabric entrypoint named playerbatch-ext.
{
"entrypoints": {
"playerbatch-ext": [
"com.example.examplemod.ExampleExtension"
]
}
}import com.w4whiskers.playerbatch.extapi.PlayerBatchExtensionEntrypoint;
import com.w4whiskers.playerbatch.extapi.PlayerBatchFormation;
import com.w4whiskers.playerbatch.extapi.PlayerBatchRegistrar;
import com.w4whiskers.playerbatch.extapi.PlayerBatchSpawnPoint;
import java.util.ArrayList;
import java.util.List;
public final class ExampleExtension implements PlayerBatchExtensionEntrypoint {
@Override
public void register(PlayerBatchRegistrar registrar) {
registrar.registerFormation(
PlayerBatchFormation.builder("spiral")
.displayName("Spiral")
.description("Spawn bots in a spiral pattern.")
.factory((request, context) -> {
List<PlayerBatchSpawnPoint> points = new ArrayList<>();
for (int i = 0; i < request.count(); i++) {
double angle = i * 0.7D;
double radius = 1.5D + (i * 0.4D);
points.add(new PlayerBatchSpawnPoint(
Math.cos(angle) * radius,
0.0D,
Math.sin(angle) * radius,
0.0F,
0.0F
));
}
return points;
})
.build()
);
}
}repositories {
mavenCentral()
}
dependencies {
implementation "com.w4whiskers.playerbatch:playerbatch-extapi:0.1.0"
}Some examples of what a third-party extension could add:
spiralorarena_ringformations- argument packs like
-duel{true}or-archer{true} - action packs like
circle_strafe,anchor, orpearl_escape - behavior modules like
guard_owner,kite, ortotem_swap
| Area | Purpose |
|---|---|
PlayerBatchExtensionEntrypoint |
main extension entry |
PlayerBatchRegistrar |
register formations, actions, args, behaviors |
PlayerBatchSummonPlan |
mutable summon plan used by argument handlers |
PlayerBatchBotController |
safe runtime bot access for action/behavior hooks |
PlayerBatchFormationFactory |
custom formation spawn-point generation |