⚡ simplenergy#

Support for SimplEnergy’s energy library: cables, batteries, servo mechanisms, wrench and energy balancing.

balancing#

setup_energy_balancing(can_balance: list[str]) → None[source]#

Setup energy balancing for devices.

Parameters:

can_balance – List of devices that can balance energy between them. (e.g. [“solar_panel”, “cauldron_generator”, “simple_battery”, “advanced_battery”, “elite_battery”]).

batteries#

keep_energy_for_batteries(batteries: list[str]) → None[source]#

Setup functions for keeping energy for batteries.

Parameters:

batteries – List of battery names that should keep energy when destroyed or replaced. (e.g. [“simple_battery”, “advanced_battery”, “elite_battery”, “creative_battery”])

cables#

class EnergyCableSide(
letter: str,
bit: int,
face: str,
axis: int,
u_axis: int,
edges: str,
arm_from: list[int],
arm_to: list[int],
)[source]#

Bases: object

A side an energy cable connects by, and the arm its model draws there when connected.

letter: str[source]#

Its letter in the variant names.

bit: int[source]#

Its bit in the energy.data model score.

face: str[source]#
axis: int[source]#

The model axis it points along, 0 for x.

u_axis: int[source]#

The model axis the texture’s u coordinate follows on its face.

edges: str[source]#

The letters of the sides at the top, right, bottom and left edges of its face.

arm_from: list[int][source]#
arm_to: list[int][source]#
ENERGY_CABLE_SIDES: tuple[EnergyCableSide, ...] = (EnergyCableSide(letter='u', bit=2, face='up', axis=1, u_axis=0, edges='nesw', arm_from=[4, 12, 4], arm_to=[12, 16, 12]), EnergyCableSide(letter='d', bit=1, face='down', axis=1, u_axis=0, edges='senw', arm_from=[4, -4, 4], arm_to=[12, 4, 12]), EnergyCableSide(letter='n', bit=4, face='north', axis=2, u_axis=0, edges='uwde', arm_from=[4, 4, 0], arm_to=[12, 12, 4]), EnergyCableSide(letter='s', bit=8, face='south', axis=2, u_axis=0, edges='uedw', arm_from=[4, 4, 12], arm_to=[12, 12, 16]), EnergyCableSide(letter='e', bit=32, face='east', axis=0, u_axis=2, edges='unds', arm_from=[12, 4, 4], arm_to=[16, 12, 12]), EnergyCableSide(letter='w', bit=16, face='west', axis=0, u_axis=2, edges='usdn', arm_from=[0, 4, 4], arm_to=[4, 12, 12]))[source]#

The sides of an energy cable in the order its variant names list them. The down arm reaches 4 pixels lower.

ENERGY_CABLE_TILES: dict[str, list[int]] = {'0000': [12, 12, 16, 16], '0011': [8, 8, 12, 12], '0111': [12, 8, 16, 12], '1000': [12, 1, 16, 5], '1010': [12, 1, 16, 5], '1111': [8, 12, 12, 16]}[source]#

The texture tile of a centre face, by which of its top, right, bottom and left edges meet an arm, before rotation.

ITEM_CABLE_SIDES: tuple[tuple[str, str], ...] = (('u', 'top'), ('d', 'bottom'), ('n', 'north'), ('s', 'south'), ('e', 'east'), ('w', 'west'))[source]#

Each side of an item cable, its bit in the itemio.math model score being its index, and the elements drawing it.

ITEM_CABLE_TEXTURES: tuple[tuple[str, str], ...] = (('0', 'center'), ('1', 'pillon'), ('2', 'glass'), ('particle', 'center'))[source]#

The textures of an item cable model, and the file under the cable’s folder each defaults to.

energy_cables_models(cables: list[str]) → None[source]#

Setup energy cables models and functions for SimplEnergy.

Parameters:

cables – List of cables to setup. (e.g. [“simple_cable”, “advanced_cable”, “elite_cable”])

energy_cable_elements(
i: int,
) → list[JsonDict][source]#

The model elements of an energy cable connected on the sides the bits of i set: its centre, and one arm per connection.

energy_cable_centre_face(
edges: str,
) → JsonDict[source]#

The face of the cable’s centre whose top, right, bottom and left edges meet an arm where edges holds a 1.

>>> energy_cable_centre_face("0110")
{'uv': [8, 8, 12, 12], 'rotation': 270, 'texture': '#0'}
energy_cable_variant(i: int) → str[source]#

The variant model of an energy cable connected on the sides the bits of i set.

>>> energy_cable_variant(0), energy_cable_variant(1 | 2 | 32)
('variant', 'variant_ude')
write_cable_update(
cables: Iterable[str],
family: str,
score: str,
tag: str,
) → None[source]#

Write the function giving a cable of family its item model, then the variant its connections score names.

item_cables_models(
cables: dict[str, dict[str, str] | None],
) → None[source]#

Setup item cables models and functions for SimplEnergy.

Parameters:

cables – Dictionary of item cables to setup. Each key is the cable name, and the value is a dictionary mapping model textures to their paths The mapping dictionnary is optional, if not provided, it will use the default model paths. (e.g. {“item_cable”:{“0”:”item_cable/center”,”1”:”item_cable/pillon”,”2”:”item_cable/glass”}})

copy_block_texture(
textures_folder: str,
texture_path: str,
) → None[source]#

Copy <textures_folder>/<texture_path>.png to the resource pack’s block textures, unless missing or already there.

model_dispatch(
entries: list[JsonDict],
) → JsonDict[source]#

An item model choosing one of entries by the item’s custom model data.

write_item_cable_variant(
cable: str,
textures: dict[str, str],
i: int,
) → JsonDict[source]#

Write the item cable’s model connected on the sides the bits of i set, the base model losing the elements of the others.

Returns:

The entry of the cable’s item model pointing at it.

servo_mechanisms_models(
servos: dict[str, dict[str, str] | None],
) → None[source]#

Setup servo mechanisms models and functions for SimplEnergy.

Parameters:

servos – Dictionary of servo mechanisms to setup. Each key is the servo name, and the value is a dictionary mapping model textures to their paths (excluding the ‘type’ key) The mapping dictionnary is optional, if not provided, it will use the default model paths. (e.g. {“servo_extractor”: {“type”: “extract”, “default”: “servo/extract_default”, “connected”: “servo/extract_connected”}})

register_servo_models(
models_path: str,
typ: str,
textures: dict[str, str],
) → None[source]#

The block models of one servo type, default, connected and off, then its item model and the item files of the three.

register_servo_textures(
textures_folder: str,
typ: str,
textures: dict[str, str],
) → None[source]#

Copy one servo type’s textures into the resource pack, and darken a gray copy of the default one into its “off” texture.

write_servo_functions(servo: str, typ: str) → None[source]#

Tag a servo as an itemio one when placed, with its stack and retry limits, and let itemio forget it when destroyed.

servo_toggle(
servos: dict[str, dict[str, str] | None],
) → None[source]#

Setup the functions allowing players to turn servo mechanisms off and on by rotating them.

Rotating (right-clicking) a servo item frame changes its ‘ItemRotation’. A vanilla advancement listening to the ‘minecraft:player_interacted_with_entity’ trigger detects the interaction (so nothing runs every tick), then the nearby servos are checked: an odd rotation disables the rotated one (grayed out texture, item transfers stopped by removing the ‘itemio.servo.extract’ / ‘itemio.servo.insert’ tag), an even rotation enables it back to normal. As the check only acts when the parity differs, only the rotated servo toggles.

Parameters:

servos – Same servos dictionary as the one passed to ‘servo_mechanisms_models’.

energy_lib_calls#

insert_lib_calls() → None[source]#

Does nothing: the custom blocks plugin registers the blocks with energy settings.

gui#

setup_gui_in_resource_packs(
gui_translations: dict[str, GuiTranslation],
) → dict[str, str][source]#

Setup GUI item models in resource packs by creating item models and textures for each GUI.

Parameters:

gui_translations – A dictionary mapping GUI names to their translation offsets. (e.g. {‘electric_brewing_stand’: GuiTranslation.brewing_stand, ‘electric_furnace’: GuiTranslation.furnace_bottom, …})

Returns:

A dictionary mapping GUI filenames to their model paths.

(e.g. {‘gui/electric_brewing_stand.png’: ‘namespace:gui/electric_brewing_stand’})

Return type:

dict[str, str]

wrench#

setup_wrench(
blocks: list[str] | str,
tag_ns: str = 'simplenergy',
) → None[source]#

Setup rotatable tags for blocks and mechanization wrench calls.

Parameters:
  • blocks – List of block names that should be rotatable. (e.g. [“furnace_generator”, “electric_furnace”, “electric_smelter”, “pulverizer”])

  • tag_ns – Namespace for the tags. Default is “simplenergy”.