⚡ simplenergy#
Support for SimplEnergy’s energy library: cables, batteries, servo mechanisms, wrench and energy balancing.
balancing#
batteries#
cables#
- class EnergyCableSide(
- letter: str,
- bit: int,
- face: str,
- axis: int,
- u_axis: int,
- edges: str,
- arm_from: list[int],
- arm_to: list[int],
Bases:
objectA side an energy cable connects by, and the arm its model draws there when connected.
- 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.mathmodel 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,
The model elements of an energy cable connected on the sides the bits of
iset: its centre, and one arm per connection.
- energy_cable_centre_face(
- edges: str,
The face of the cable’s centre whose top, right, bottom and left edges meet an arm where
edgesholds 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
iset.>>> 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,
Write the function giving a cable of
familyits item model, then the variant its connections score names.
- item_cables_models(
- cables: dict[str, dict[str, str] | None],
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,
Copy
<textures_folder>/<texture_path>.pngto the resource pack’s block textures, unless missing or already there.
- model_dispatch(
- entries: list[JsonDict],
An item model choosing one of
entriesby the item’s custom model data.
- write_item_cable_variant(
- cable: str,
- textures: dict[str, str],
- i: int,
Write the item cable’s model connected on the sides the bits of
iset, 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],
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],
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],
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],
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#
gui#
- setup_gui_in_resource_packs(
- gui_translations: dict[str, GuiTranslation],
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',
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”.