Repository navigation
Developer Utilities
Applies to all versions. On 1.21.1 read
ResourceLocationwhere signatures sayIdentifier.
A tour of the other helpers, by package (com.skd.commontoolkit.*). Read the Javadoc in the source for the details.
network.PayloadProvider<T> describes one custom payload: its type, stream codec, and handleClient / handleServer methods; optionally isOptional() and the handler thread. Register providers with PayloadHelper.registerPayload(provider) and let PayloadHelper handle RegisterPayloadHandlersEvent.
payloads.ButtonClickPayload sends a client-to-server "button pressed" with an integer id, handled by the open menu if it implements ButtonClickPayload.IButtonContainer (onButtonClick(int id)).
registry.DeferredHelper.create(modid) is a single entry point for deferred registration: block(...), item(...), blockItem(...), fluid(...), effect(...), sound(...), and registry(...) to create custom registries. It returns the usual DeferredBlock / DeferredItem / DeferredHolder.
tabs.TabFillingRegistry adds items to existing creative tabs without writing an event handler: registerSimple(item, tabs...), register(tab, suppliers...), or register(filler, tabs...) for items that implement ITabFiller and want to add several stacks (for example one per variant).
TickingBlockEntity lets a block entity hold its own serverTick(level, pos, state) / clientTick(...) methods; TickingBlockEntityType and TickingEntityBlock wire the tickers automatically.
-
menu.CommonToolkitContainerMenu: base menu with aQuickMoveHandlerto declare shift-click rules andaddPlayerSlots(inventory, x, y). -
menu.BlockEntityMenu+SimplerMenuProvider: menus bound to a block entity at a position. - Slots:
FilteredSlot(only accepts items matching a filter),LockedSlot(no interaction). -
SimpleDataSlots: lambda-based data slots for syncing integers to the screen. -
screen.CommonToolkitContainerScreen,ScreenUtil,TickableTextList(text that appears character by character),util.DrawsOnLeft(tooltips drawn to the left of the screen).
-
codec.CodecMap/MapBackedCodec: a registry of named codecs that is itself a codec (polymorphic data),CodecProviderfor objects that know their codec, andCommonToolkitCodecs(enum codecs and other helpers). -
json:OptionalStackCodec(item stacks that may be empty or optional),WeightedItemStack,RandomAttributeModifier(attribute modifiers with random values),ChancedEffectInstance(effects with a chance and random amplifier),JsonUtil,NBTAdapter. -
util.RandomRange,StepFunction,LinearEquation,Offset(GUI anchors),CachedObject(objects decoded once from item data and cached).
-
util.CommonToolkitTaskQueue.submitTask(id, task)/submitDelayedTask(id, delay, task): run tick-based tasks on the server; the queue is cleared when the server stops. -
events.ResourceReloadEvent: fired when client or server resources reload (one listener for both sides). -
events.AnvilLandEvent: fired when a falling anvil lands. -
util.RunnableReloader: a reload listener from a lambda.
-
datagen.DataGenBuilder: adds registry bootstraps and data providers toGatherDataEventin one place. -
datagen.LegacyRecipeProvider: recipe provider with a compact shaped/shapeless syntax. -
datagen.FieldOrderingFactory+RegisterFieldOrderingsEvent: control the order of JSON fields in generated files. -
util.data.RuntimeDatagenHelpers: write JSON files at runtime (used by/common_toolkit serialize_loot_table).
-
cap.InternalItemHandler: item handler with internal insert/extract methods that bypass the public restrictions. -
util.EnchantmentUtils,util.CommonToolkitUtil,color.GradientColor(gradient text colors).
Common Toolkit is a port of Placebo by Shadows_of_Fire (MIT) and includes code derived from Minecraft Forge (LGPL-2.1); it is distributed under the LGPL-2.1-or-later license.