|
| 1 | +# Capacitor Registration |
| 2 | + |
| 3 | +This registry event extension allows you to register custom Capacitors. Capacitors are used in EnderIO machines and can modify different properties of them. |
| 4 | + |
| 5 | +> [!WARNING] NOTE |
| 6 | +> This event extension only exists since mod version 1.21.1-0.12.0, release date: 2026-02-18. |
| 7 | +
|
| 8 | +**It is a startup event and not reloadable!** |
| 9 | +Keep in mind that startup events have to be located inside the `kubejs/startup_scripts` folder. |
| 10 | + |
| 11 | +## Overview |
| 12 | + |
| 13 | +This is an extension to the built-in KubeJS item registry event. It adds convenience methods to register custom Capacitors via KubeJS. |
| 14 | + |
| 15 | +- access in a startup script via: `StartupEvents.registry` |
| 16 | +- functions: |
| 17 | + - `baseValue(float)` |
| 18 | + - description: sets the base value of the Capacitor; this is the value for all Capacitor modifiers if no custom value is set for them |
| 19 | + - required: no |
| 20 | + - default value: `1` |
| 21 | + - `modifierValue(CapacitorModifier, float)` |
| 22 | + - description: sets the value for a specific Capacitor modifier; this overrides the base value for the specified modifier |
| 23 | + - required: no |
| 24 | + - default value: same as base value |
| 25 | + - `CapacitorModifier` is an enum and can be specified by using `CapacitorModifier.<VALUE>` or by an case-insensitive string |
| 26 | + - possible values: |
| 27 | + - `ENERGY_CAPACITY` - modifies the energy capacity of the machine |
| 28 | + - `ENERGY_USE` - modifies the energy use of the machine |
| 29 | + - `FUEL_EFFICIENCY` - modifies the fuel efficiency of the machine |
| 30 | + - `BURNING_ENERGY_GENERATION` - modifies the burning energy generation of the machine; only applies to generators |
| 31 | + - `hideFromCreativeTab()` |
| 32 | + - description: hides the Capacitor from the creative tab; this is useful for Capacitors that are only used for loot as a surprise |
| 33 | + - required: no |
| 34 | + - default value: `false` |
| 35 | + - all functions of the KubeJS `ItemBuilder`, for example `displayName`, `rarity`, `tooltip`, etc. |
| 36 | + |
| 37 | +## Event Listener |
| 38 | + |
| 39 | +To access the event, the first thing you need to do is to open an event listener for the `registry` event in a startup script. |
| 40 | + |
| 41 | +```js |
| 42 | +StartupEvents.registry("item", event => { |
| 43 | + // ... |
| 44 | +}) |
| 45 | +``` |
| 46 | + |
| 47 | +After that, you can use the `CapacitorBuilder` to register a custom Capacitor. |
| 48 | + |
| 49 | +## Example |
| 50 | + |
| 51 | +```js |
| 52 | +StartupEvents.registry("item", event => { |
| 53 | + event |
| 54 | + .create( |
| 55 | + "my_modpack:my_capacitor", // id of the capacitor (will use kubejs if no namespace is specified) |
| 56 | + "enderio:capacitor" // type to register (always enderio:capacitor) |
| 57 | + ) |
| 58 | + .displayName("My Capacitor") // overrides the automatically generated display name, can still be changed with lang file |
| 59 | + .rarity("rare") // common, uncommon, rare, epic |
| 60 | + .glow(true) // enchantment overlay |
| 61 | + .baseValue(1.4) |
| 62 | + .modifierValue("energy_use", 0.2) |
| 63 | + .modifierValue("ENERGY_CAPACITY", 2) |
| 64 | + .modifierValue(CapacitorModifier.FUEL_EFFICIENCY, 2.3) |
| 65 | + .hideFromCreativeTab() |
| 66 | + .texture("minecraft:item/acacia_boat") // custom texture for the capacitor; this example uses the vanilla acacia boat texture |
| 67 | +}) |
| 68 | +``` |
0 commit comments