Building bigger addons
How the pieces fit the kinds of addons people build. Each names the parts; their pages (Services, Jobs, Events, Drawing in the world) have the details.
- Movement modules change this tick’s motion in
PlayerMoveEvent(scaled fromMovement.baseSpeed()so effects still count), press keys withInputEvent, change what they collide with inCollisionShapeEvent(water walking, avoiding cactus), back off inTeleportEventand whileserver().rubberbandedWithin(ms), and change the tick rate withtickSpeed().Myriad.antiCheat().isStrict()says whether the server simulates movement (Grim) and will catch anything the vanilla client couldn’t do. - A schematic printer turns the schematic into a
Blueprint.of(...)ofTarget.state(...)and hands it tobuilding(), which works through what’s in reach: wrong blocks broken, materials borrowed into the hotbar (any slot but the one you hold, put back when it’s done, and shown as it was meanwhile), each block clicked and rotated so it comes out facing the right way, andBuild.steps()drawn as the plan. For clicks of your own,placement().place(this, hit, slot, options)places where vanilla would for that exact click (into air withwithAirPlace, onto a candle or slab with the same item) andwithSneakplaces against chests and doors;placement().use(this, hit, slot, options)right-clicks a block to use it (a lever, a repeater’s delay), turned onto it first where the server checks looks.Building.Options.forServer()rotates for everything and clicks only visible faces where the server checks, and goes fast where it doesn’t. Each placement’sresult()says whether the server kept the block,FadeMapwithRenderer3D.blockShapeshows the plan, a job (Steps.build) runs it, and it pauses whileserver().isLagging(...)or right after a rubberband. Around it,whenStuck(Why.NO_ITEM, ticks, why -> Steps.acquire(...))fetches what ran out fromMaterialSource.shulkerBoxes()andMaterialSource.container(pos), then building carries on (Essentials’ Printer does this, and walks on withSteps.walkToonce nothing in reach is left). AFileSettingpicks the schematic and aBlockPosSettingits origin. Integrations with other mods (Litematica, Baritone) belong in the addon: keep any code touching their classes in its own class, only load it afterFabricLoader.getInstance().isModLoaded("litematica"), and put mixins into them undercompat.litematica. - A storage manager finds containers per chunk with a
ChunkCache(BlockInfo.isStorage), opens them withcontainers().open(this, pos, ticks, Placement.Options.forServer())(turned onto the container first where the server checks looks), reads them inContainerEvent.Loaded/SlotUpdated(including ones the player opens by hand:view().byHand(), andopener()says which module opened the rest), moves items withview.take/put, sorts or fills one to an exact layout withview.arrange(Containers.Arrangement.of(slots, layout))(or runs click planners of its own withview.run), and runs each visit as a job (Steps.openContainer,take,closeContainer). It saves what it learns withctx.storage(), says where an item is withItemTooltipEvent, reads shulkers withItemInfo.contents, and marks chests withWorldLabel.Segment.item(...)icons. - A crystal PvP suite picks targets with
TargetSettings, finds placements withCrystals.basesand scores them withDamage.crystalagainstEntities.predictpositions (treating blocks it’s about to break as air), surrounds withHoles.surroundand akeepUpbuild, mines targets out withHoles.city, decides when to force a totem withThreats.isLethal, reacts toEntityEvent.TotemPopped, breaks crystals the tick they appear withEntityEvent.Added+Interactions.attack, checksBlockInfo.isBlastResistantandEntities.intersectsfor placements, rotates throughrotations(), swaps withinventory(), pauses withInteractions.shouldPause, and checksReachbefore every action.AttackEventlets separate modules react to the same hit, and.fakeplayergives you someone to test against in singleplayer.