πŸ”Œ CablesΒΆ

Cables are custom blocks that handle a cable system between all devices of the same network.


Place/destroy function callΒΆ

  • On place : function #itemio:calls/cables/init

  • On destroy : function #itemio:calls/cables/destroy

Cable update function eventΒΆ

This function tag is trigger when a cable connection is updated.

function #itemio:event/cable_update

Cables’ itemio.math value is a binary encoded number indicating which sides are connected, ie:

63 -> 1  1  1  1  1  1 -> all sides are active
      32 16 8  4  2  1
      E  W  S  N  U  D
This can be used to update the model of the cable.

Visual exampleΒΆ

Cables

An animation of all possible states of a cable, generated using Isometric renders fabric mod.

#itemio:event/cable_update
# @public
execute 
    if entity @s[tag=transportduct.item_cable] 
    run function transportduct:impl/item_cable/update_model:
        scoreboard players set #model transportduct.math 1430300

        scoreboard players operation #model transportduct.math += @s itemio.math
        item modify entity @s container.0 {
            "function": "minecraft:set_custom_model_data",
            "value": {
                "type": "minecraft:score",
                "target": {
                "type": "minecraft:fixed",
                "name": "#model"
                },
                "score": "transportduct.math",
                "scale": 1
            }
        }
minecraft:item/structure_void.json

The modified structure void model. All references are here

{
	"parent": "minecraft:item/handheld",
	"textures": {
		"layer0": "minecraft:item/structure_void"
	},
	"overrides":[

		{ "predicate": { "custom_model_data": 1430300 }, "model": "transportduct:block/item_cable/wire_" },
		{ "predicate": { "custom_model_data": 1430301 }, "model": "transportduct:block/item_cable/wire_d" },
		{ "predicate": { "custom_model_data": 1430302 }, "model": "transportduct:block/item_cable/wire_u" },
		{ "predicate": { "custom_model_data": 1430303 }, "model": "transportduct:block/item_cable/wire_ud" },
		{ "predicate": { "custom_model_data": 1430304 }, "model": "transportduct:block/item_cable/wire_n" },
		{ "predicate": { "custom_model_data": 1430305 }, "model": "transportduct:block/item_cable/wire_dn" },
		{ "predicate": { "custom_model_data": 1430306 }, "model": "transportduct:block/item_cable/wire_un" },
		{ "predicate": { "custom_model_data": 1430307 }, "model": "transportduct:block/item_cable/wire_udn" },
		{ "predicate": { "custom_model_data": 1430308 }, "model": "transportduct:block/item_cable/wire_s" },
		{ "predicate": { "custom_model_data": 1430309 }, "model": "transportduct:block/item_cable/wire_ds" },
		{ "predicate": { "custom_model_data": 1430310 }, "model": "transportduct:block/item_cable/wire_us" },
		{ "predicate": { "custom_model_data": 1430311 }, "model": "transportduct:block/item_cable/wire_uds" },
		{ "predicate": { "custom_model_data": 1430312 }, "model": "transportduct:block/item_cable/wire_ns" },
		{ "predicate": { "custom_model_data": 1430313 }, "model": "transportduct:block/item_cable/wire_dns" },
		{ "predicate": { "custom_model_data": 1430314 }, "model": "transportduct:block/item_cable/wire_uns" },
		{ "predicate": { "custom_model_data": 1430315 }, "model": "transportduct:block/item_cable/wire_udns" },
		{ "predicate": { "custom_model_data": 1430316 }, "model": "transportduct:block/item_cable/wire_w" },
		{ "predicate": { "custom_model_data": 1430317 }, "model": "transportduct:block/item_cable/wire_dw" },
		{ "predicate": { "custom_model_data": 1430318 }, "model": "transportduct:block/item_cable/wire_uw" },
		{ "predicate": { "custom_model_data": 1430319 }, "model": "transportduct:block/item_cable/wire_udw" },
		{ "predicate": { "custom_model_data": 1430320 }, "model": "transportduct:block/item_cable/wire_nw" },
		{ "predicate": { "custom_model_data": 1430321 }, "model": "transportduct:block/item_cable/wire_dnw" },
		{ "predicate": { "custom_model_data": 1430322 }, "model": "transportduct:block/item_cable/wire_unw" },
		{ "predicate": { "custom_model_data": 1430323 }, "model": "transportduct:block/item_cable/wire_udnw" },
		{ "predicate": { "custom_model_data": 1430324 }, "model": "transportduct:block/item_cable/wire_sw" },
		{ "predicate": { "custom_model_data": 1430325 }, "model": "transportduct:block/item_cable/wire_dsw" },
		{ "predicate": { "custom_model_data": 1430326 }, "model": "transportduct:block/item_cable/wire_usw" },
		{ "predicate": { "custom_model_data": 1430327 }, "model": "transportduct:block/item_cable/wire_udsw" },
		{ "predicate": { "custom_model_data": 1430328 }, "model": "transportduct:block/item_cable/wire_nsw" },
		{ "predicate": { "custom_model_data": 1430329 }, "model": "transportduct:block/item_cable/wire_dnsw" },
		{ "predicate": { "custom_model_data": 1430330 }, "model": "transportduct:block/item_cable/wire_unsw" },
		{ "predicate": { "custom_model_data": 1430331 }, "model": "transportduct:block/item_cable/wire_udnsw" },
		{ "predicate": { "custom_model_data": 1430332 }, "model": "transportduct:block/item_cable/wire_e" },
		{ "predicate": { "custom_model_data": 1430333 }, "model": "transportduct:block/item_cable/wire_de" },
		{ "predicate": { "custom_model_data": 1430334 }, "model": "transportduct:block/item_cable/wire_ue" },
		{ "predicate": { "custom_model_data": 1430335 }, "model": "transportduct:block/item_cable/wire_ude" },
		{ "predicate": { "custom_model_data": 1430336 }, "model": "transportduct:block/item_cable/wire_ne" },
		{ "predicate": { "custom_model_data": 1430337 }, "model": "transportduct:block/item_cable/wire_dne" },
		{ "predicate": { "custom_model_data": 1430338 }, "model": "transportduct:block/item_cable/wire_une" },
		{ "predicate": { "custom_model_data": 1430339 }, "model": "transportduct:block/item_cable/wire_udne" },
		{ "predicate": { "custom_model_data": 1430340 }, "model": "transportduct:block/item_cable/wire_se" },
		{ "predicate": { "custom_model_data": 1430341 }, "model": "transportduct:block/item_cable/wire_dse" },
		{ "predicate": { "custom_model_data": 1430342 }, "model": "transportduct:block/item_cable/wire_use" },
		{ "predicate": { "custom_model_data": 1430343 }, "model": "transportduct:block/item_cable/wire_udse" },
		{ "predicate": { "custom_model_data": 1430344 }, "model": "transportduct:block/item_cable/wire_nse" },
		{ "predicate": { "custom_model_data": 1430345 }, "model": "transportduct:block/item_cable/wire_dnse" },
		{ "predicate": { "custom_model_data": 1430346 }, "model": "transportduct:block/item_cable/wire_unse" },
		{ "predicate": { "custom_model_data": 1430347 }, "model": "transportduct:block/item_cable/wire_udnse" },
		{ "predicate": { "custom_model_data": 1430348 }, "model": "transportduct:block/item_cable/wire_ew" },
		{ "predicate": { "custom_model_data": 1430349 }, "model": "transportduct:block/item_cable/wire_dew" },
		{ "predicate": { "custom_model_data": 1430350 }, "model": "transportduct:block/item_cable/wire_uew" },
		{ "predicate": { "custom_model_data": 1430351 }, "model": "transportduct:block/item_cable/wire_udew" },
		{ "predicate": { "custom_model_data": 1430352 }, "model": "transportduct:block/item_cable/wire_new" },
		{ "predicate": { "custom_model_data": 1430353 }, "model": "transportduct:block/item_cable/wire_dnew" },
		{ "predicate": { "custom_model_data": 1430354 }, "model": "transportduct:block/item_cable/wire_unew" },
		{ "predicate": { "custom_model_data": 1430355 }, "model": "transportduct:block/item_cable/wire_udnew" },
		{ "predicate": { "custom_model_data": 1430356 }, "model": "transportduct:block/item_cable/wire_sew" },
		{ "predicate": { "custom_model_data": 1430357 }, "model": "transportduct:block/item_cable/wire_dsew" },
		{ "predicate": { "custom_model_data": 1430358 }, "model": "transportduct:block/item_cable/wire_usew" },
		{ "predicate": { "custom_model_data": 1430359 }, "model": "transportduct:block/item_cable/wire_udsew" },
		{ "predicate": { "custom_model_data": 1430360 }, "model": "transportduct:block/item_cable/wire_nsew" },
		{ "predicate": { "custom_model_data": 1430361 }, "model": "transportduct:block/item_cable/wire_dnsew" },
		{ "predicate": { "custom_model_data": 1430362 }, "model": "transportduct:block/item_cable/wire_unsew" },
		{ "predicate": { "custom_model_data": 1430363 }, "model": "transportduct:block/item_cable/wire_udnsew" }

	]}

The example datapack, that implement a simple cable system.